diff --git a/SyntaxTree/tree/Tree.cs b/SyntaxTree/tree/Tree.cs
index eddba80b2..c2cb28d1f 100644
--- a/SyntaxTree/tree/Tree.cs
+++ b/SyntaxTree/tree/Tree.cs
@@ -1,54749 +1,54749 @@
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-
-namespace PascalABCCompiler.SyntaxTree
-{
- ///
- ///Выражение
- ///
- [Serializable]
- public partial class expression : declaration
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public expression()
- {
-
- }
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- expression copy = new expression();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new expression TypedClone()
- {
- return Clone() as expression;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Базовый класс для всех классов синтаксического дерева
- ///
- [Serializable]
- public partial class syntax_tree_node
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public syntax_tree_node()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public syntax_tree_node(SourceContext _source_context)
- {
- this._source_context=_source_context;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public syntax_tree_node(SourceContext _source_context,SourceContext sc)
- {
- this._source_context=_source_context;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected SourceContext _source_context;
-
- ///
- ///Позиция в тексте (строка-столбец начала - строка-столбец конца)
- ///
- public SourceContext source_context
- {
- get
- {
- return _source_context;
- }
- set
- {
- _source_context=value;
- }
- }
-
-
- /// Создает копию узла
- public virtual syntax_tree_node Clone()
- {
- syntax_tree_node copy = new syntax_tree_node();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public virtual syntax_tree_node TypedClone()
- {
- return Clone() as syntax_tree_node;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public virtual void FillParentsInDirectChilds()
- {
- }
-
- /// Заполняет поля Parent во всем поддереве
- public virtual void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public virtual Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public virtual Int32 subnodes_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public virtual syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public virtual void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Оператор
- ///
- [Serializable]
- public partial class statement : declaration
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public statement()
- {
-
- }
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- statement copy = new statement();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new statement TypedClone()
- {
- return Clone() as statement;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Блок операторов
- ///
- [Serializable]
- public partial class statement_list : statement
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public statement_list()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public statement_list(List _subnodes,token_info _left_logical_bracket,token_info _right_logical_bracket,bool _expr_lambda_body)
- {
- this._subnodes=_subnodes;
- this._left_logical_bracket=_left_logical_bracket;
- this._right_logical_bracket=_right_logical_bracket;
- this._expr_lambda_body=_expr_lambda_body;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public statement_list(List _subnodes,token_info _left_logical_bracket,token_info _right_logical_bracket,bool _expr_lambda_body,SourceContext sc)
- {
- this._subnodes=_subnodes;
- this._left_logical_bracket=_left_logical_bracket;
- this._right_logical_bracket=_right_logical_bracket;
- this._expr_lambda_body=_expr_lambda_body;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- public statement_list(statement elem, SourceContext sc = null)
- {
- Add(elem, sc);
- FillParentsInDirectChilds();
- }
-
- protected List _subnodes=new List();
- protected token_info _left_logical_bracket;
- protected token_info _right_logical_bracket;
- protected bool _expr_lambda_body=new bool();
-
- ///
- ///Список операторов
- ///
- public List subnodes
- {
- get
- {
- return _subnodes;
- }
- set
- {
- _subnodes=value;
- }
- }
-
- ///
- ///Левая операторная скобка
- ///
- public token_info left_logical_bracket
- {
- get
- {
- return _left_logical_bracket;
- }
- set
- {
- _left_logical_bracket=value;
- if (_left_logical_bracket != null)
- _left_logical_bracket.Parent = this;
- }
- }
-
- ///
- ///Правая операторная скобка
- ///
- public token_info right_logical_bracket
- {
- get
- {
- return _right_logical_bracket;
- }
- set
- {
- _right_logical_bracket=value;
- if (_right_logical_bracket != null)
- _right_logical_bracket.Parent = this;
- }
- }
-
- ///
- ///Поле, показывающее, что это - тело лямбда-выражения из одного выражения (созданное вызовом NewLambdaBody)
- ///
- public bool expr_lambda_body
- {
- get
- {
- return _expr_lambda_body;
- }
- set
- {
- _expr_lambda_body=value;
- }
- }
-
-
- public statement_list Add(statement elem, SourceContext sc = null)
- {
- subnodes.Add(elem);
- if (elem != null)
- elem.Parent = this;
- if (sc != null)
- source_context = sc;
- return this;
- }
-
- public void AddFirst(statement el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- subnodes.Insert(0, el);
- FillParentsInDirectChilds();
- }
-
- public void AddFirst(IEnumerable els)
- {
- if (els == null)
- throw new ArgumentNullException(nameof(els));
- subnodes.InsertRange(0, els);
- foreach (var el in els)
- if (el != null)
- el.Parent = this;
- }
-
- public void AddMany(params statement[] els)
- {
- if (els == null)
- throw new ArgumentNullException(nameof(els));
- subnodes.AddRange(els);
- foreach (var el in els)
- if (el != null)
- el.Parent = this;
- }
-
- private int FindIndexInList(statement el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- var ind = subnodes.FindIndex(x => x == el);
- if (ind == -1)
- throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el));
- return ind;
- }
-
- public void InsertAfter(statement el, statement newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- subnodes.Insert(FindIndexInList(el) + 1, newel);
- newel.Parent = this;
- }
-
- public void InsertAfter(statement el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- subnodes.InsertRange(FindIndexInList(el) + 1, newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public void InsertBefore(statement el, statement newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- subnodes.Insert(FindIndexInList(el), newel);
- newel.Parent = this;
- }
-
- public void InsertBefore(statement el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- subnodes.InsertRange(FindIndexInList(el), newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public bool Remove(statement el)
- {
- return subnodes.Remove(el);
- }
-
- public void ReplaceInList(statement el, statement newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- subnodes[FindIndexInList(el)] = newel;
- newel.Parent = this;
- }
-
- public void ReplaceInList(statement el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- var ind = FindIndexInList(el);
- subnodes.RemoveAt(ind);
- subnodes.InsertRange(ind, newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public int RemoveAll(Predicate match)
- {
- return subnodes.RemoveAll(match);
- }
-
- public statement Last()
- {
- if (subnodes.Count > 0)
- return subnodes[subnodes.Count - 1];
- throw new InvalidOperationException("Список пуст");
- }
-
- public int Count
- {
- get { return subnodes.Count; }
- }
-
- public void Insert(int pos, statement el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- subnodes.Insert(pos,el);
- if (el != null)
- el.Parent = this;
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- statement_list copy = new statement_list();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (subnodes != null)
- {
- foreach (statement elem in subnodes)
- {
- if (elem != null)
- {
- copy.Add((statement)elem.Clone());
- copy.Last().Parent = copy;
- }
- else
- copy.Add(null);
- }
- }
- if (left_logical_bracket != null)
- {
- copy.left_logical_bracket = (token_info)left_logical_bracket.Clone();
- copy.left_logical_bracket.Parent = copy;
- }
- if (right_logical_bracket != null)
- {
- copy.right_logical_bracket = (token_info)right_logical_bracket.Clone();
- copy.right_logical_bracket.Parent = copy;
- }
- copy.expr_lambda_body = expr_lambda_body;
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new statement_list TypedClone()
- {
- return Clone() as statement_list;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (subnodes != null)
- {
- foreach (var child in subnodes)
- if (child != null)
- child.Parent = this;
- }
- if (left_logical_bracket != null)
- left_logical_bracket.Parent = this;
- if (right_logical_bracket != null)
- right_logical_bracket.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- if (subnodes != null)
- {
- foreach (var child in subnodes)
- child?.FillParentsInAllChilds();
- }
- left_logical_bracket?.FillParentsInAllChilds();
- right_logical_bracket?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 2;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 2 + (subnodes == null ? 0 : subnodes.Count);
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return left_logical_bracket;
- case 1:
- return right_logical_bracket;
- }
- Int32 index_counter=ind - 2;
- if(subnodes != null)
- {
- if(index_counter < subnodes.Count)
- {
- return subnodes[index_counter];
- }
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- left_logical_bracket = (token_info)value;
- break;
- case 1:
- right_logical_bracket = (token_info)value;
- break;
- }
- Int32 index_counter=ind - 2;
- if(subnodes != null)
- {
- if(index_counter < subnodes.Count)
- {
- subnodes[index_counter]= (statement)value;
- return;
- }
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Идентификатор
- ///
- [Serializable]
- public partial class ident : addressed_value_funcname
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public ident()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public ident(string _name)
- {
- this._name=_name;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public ident(string _name,SourceContext sc)
- {
- this._name=_name;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected string _name;
-
- ///
- ///Строка, представляющая идентификатор
- ///
- public string name
- {
- get
- {
- return _name;
- }
- set
- {
- _name=value;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- ident copy = new ident();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- copy.name = name;
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new ident TypedClone()
- {
- return Clone() as ident;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Оператор присваивания
- ///
- [Serializable]
- public partial class assign : statement
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public assign()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public assign(addressed_value _to,expression _from,Operators _operator_type)
- {
- this._to=_to;
- this._from=_from;
- this._operator_type=_operator_type;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public assign(addressed_value _to,expression _from,Operators _operator_type,SourceContext sc)
- {
- this._to=_to;
- this._from=_from;
- this._operator_type=_operator_type;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected addressed_value _to;
- protected expression _from;
- protected Operators _operator_type;
-
- ///
- ///Левый операнд оператора присваивания (чему присваивать).
- ///
- public addressed_value to
- {
- get
- {
- return _to;
- }
- set
- {
- _to=value;
- if (_to != null)
- _to.Parent = this;
- }
- }
-
- ///
- ///Выражение в правой части
- ///
- public expression from
- {
- get
- {
- return _from;
- }
- set
- {
- _from=value;
- if (_from != null)
- _from.Parent = this;
- }
- }
-
- ///
- ///Тип оператора присваивания
- ///
- public Operators operator_type
- {
- get
- {
- return _operator_type;
- }
- set
- {
- _operator_type=value;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- assign copy = new assign();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (to != null)
- {
- copy.to = (addressed_value)to.Clone();
- copy.to.Parent = copy;
- }
- if (from != null)
- {
- copy.from = (expression)from.Clone();
- copy.from.Parent = copy;
- }
- copy.operator_type = operator_type;
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new assign TypedClone()
- {
- return Clone() as assign;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (to != null)
- to.Parent = this;
- if (from != null)
- from.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- to?.FillParentsInAllChilds();
- from?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 2;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 2;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return to;
- case 1:
- return from;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- to = (addressed_value)value;
- break;
- case 1:
- from = (expression)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Бинарное выражение
- ///
- [Serializable]
- public partial class bin_expr : addressed_value
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public bin_expr()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public bin_expr(expression _left,expression _right,Operators _operation_type)
- {
- this._left=_left;
- this._right=_right;
- this._operation_type=_operation_type;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public bin_expr(expression _left,expression _right,Operators _operation_type,SourceContext sc)
- {
- this._left=_left;
- this._right=_right;
- this._operation_type=_operation_type;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected expression _left;
- protected expression _right;
- protected Operators _operation_type;
-
- ///
- ///
- ///
- public expression left
- {
- get
- {
- return _left;
- }
- set
- {
- _left=value;
- if (_left != null)
- _left.Parent = this;
- }
- }
-
- ///
- ///
- ///
- public expression right
- {
- get
- {
- return _right;
- }
- set
- {
- _right=value;
- if (_right != null)
- _right.Parent = this;
- }
- }
-
- ///
- ///
- ///
- public Operators operation_type
- {
- get
- {
- return _operation_type;
- }
- set
- {
- _operation_type=value;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- bin_expr copy = new bin_expr();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (left != null)
- {
- copy.left = (expression)left.Clone();
- copy.left.Parent = copy;
- }
- if (right != null)
- {
- copy.right = (expression)right.Clone();
- copy.right.Parent = copy;
- }
- copy.operation_type = operation_type;
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new bin_expr TypedClone()
- {
- return Clone() as bin_expr;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (left != null)
- left.Parent = this;
- if (right != null)
- right.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- left?.FillParentsInAllChilds();
- right?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 2;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 2;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return left;
- case 1:
- return right;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- left = (expression)value;
- break;
- case 1:
- right = (expression)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Унарное выражение
- ///
- [Serializable]
- public partial class un_expr : addressed_value
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public un_expr()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public un_expr(expression _subnode,Operators _operation_type)
- {
- this._subnode=_subnode;
- this._operation_type=_operation_type;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public un_expr(expression _subnode,Operators _operation_type,SourceContext sc)
- {
- this._subnode=_subnode;
- this._operation_type=_operation_type;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected expression _subnode;
- protected Operators _operation_type;
-
- ///
- ///
- ///
- public expression subnode
- {
- get
- {
- return _subnode;
- }
- set
- {
- _subnode=value;
- if (_subnode != null)
- _subnode.Parent = this;
- }
- }
-
- ///
- ///
- ///
- public Operators operation_type
- {
- get
- {
- return _operation_type;
- }
- set
- {
- _operation_type=value;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- un_expr copy = new un_expr();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (subnode != null)
- {
- copy.subnode = (expression)subnode.Clone();
- copy.subnode.Parent = copy;
- }
- copy.operation_type = operation_type;
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new un_expr TypedClone()
- {
- return Clone() as un_expr;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (subnode != null)
- subnode.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- subnode?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 1;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 1;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return subnode;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- subnode = (expression)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Константа
- ///
- [Serializable]
- public partial class const_node : addressed_value
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public const_node()
- {
-
- }
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- const_node copy = new const_node();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new const_node TypedClone()
- {
- return Clone() as const_node;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Логическая константа
- ///
- [Serializable]
- public partial class bool_const : const_node
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public bool_const()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public bool_const(bool _val)
- {
- this._val=_val;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public bool_const(bool _val,SourceContext sc)
- {
- this._val=_val;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected bool _val;
-
- ///
- ///Значение логической константы
- ///
- public bool val
- {
- get
- {
- return _val;
- }
- set
- {
- _val=value;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- bool_const copy = new bool_const();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- copy.val = val;
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new bool_const TypedClone()
- {
- return Clone() as bool_const;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Целая константа
- ///
- [Serializable]
- public partial class int32_const : const_node
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public int32_const()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public int32_const(Int32 _val)
- {
- this._val=_val;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public int32_const(Int32 _val,SourceContext sc)
- {
- this._val=_val;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected Int32 _val;
-
- ///
- ///Значение
- ///
- public Int32 val
- {
- get
- {
- return _val;
- }
- set
- {
- _val=value;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- int32_const copy = new int32_const();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- copy.val = val;
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new int32_const TypedClone()
- {
- return Clone() as int32_const;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Вещественная константа
- ///
- [Serializable]
- public partial class double_const : const_node
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public double_const()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public double_const(double _val)
- {
- this._val=_val;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public double_const(double _val,SourceContext sc)
- {
- this._val=_val;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected double _val;
-
- ///
- ///Значение вещественной константы
- ///
- public double val
- {
- get
- {
- return _val;
- }
- set
- {
- _val=value;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- double_const copy = new double_const();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- copy.val = val;
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new double_const TypedClone()
- {
- return Clone() as double_const;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Тело подпрограммы
- ///
- [Serializable]
- public partial class subprogram_body : syntax_tree_node
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public subprogram_body()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public subprogram_body(statement_list _subprogram_code,declarations _subprogram_defs)
- {
- this._subprogram_code=_subprogram_code;
- this._subprogram_defs=_subprogram_defs;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public subprogram_body(statement_list _subprogram_code,declarations _subprogram_defs,SourceContext sc)
- {
- this._subprogram_code=_subprogram_code;
- this._subprogram_defs=_subprogram_defs;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected statement_list _subprogram_code;
- protected declarations _subprogram_defs;
-
- ///
- ///Блок операторов подпрограммы
- ///
- public statement_list subprogram_code
- {
- get
- {
- return _subprogram_code;
- }
- set
- {
- _subprogram_code=value;
- if (_subprogram_code != null)
- _subprogram_code.Parent = this;
- }
- }
-
- ///
- ///Описания подпрограммы
- ///
- public declarations subprogram_defs
- {
- get
- {
- return _subprogram_defs;
- }
- set
- {
- _subprogram_defs=value;
- if (_subprogram_defs != null)
- _subprogram_defs.Parent = this;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- subprogram_body copy = new subprogram_body();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (subprogram_code != null)
- {
- copy.subprogram_code = (statement_list)subprogram_code.Clone();
- copy.subprogram_code.Parent = copy;
- }
- if (subprogram_defs != null)
- {
- copy.subprogram_defs = (declarations)subprogram_defs.Clone();
- copy.subprogram_defs.Parent = copy;
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new subprogram_body TypedClone()
- {
- return Clone() as subprogram_body;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (subprogram_code != null)
- subprogram_code.Parent = this;
- if (subprogram_defs != null)
- subprogram_defs.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- subprogram_code?.FillParentsInAllChilds();
- subprogram_defs?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 2;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 2;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return subprogram_code;
- case 1:
- return subprogram_defs;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- subprogram_code = (statement_list)value;
- break;
- case 1:
- subprogram_defs = (declarations)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Значение, имеющее адрес
- ///
- [Serializable]
- public partial class addressed_value : expression
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public addressed_value()
- {
-
- }
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- addressed_value copy = new addressed_value();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new addressed_value TypedClone()
- {
- return Clone() as addressed_value;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Определение типа
- ///
- [Serializable]
- public partial class type_definition : declaration
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public type_definition()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public type_definition(type_definition_attr_list _attr_list)
- {
- this._attr_list=_attr_list;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public type_definition(type_definition_attr_list _attr_list,SourceContext sc)
- {
- this._attr_list=_attr_list;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected type_definition_attr_list _attr_list;
-
- ///
- ///
- ///
- public type_definition_attr_list attr_list
- {
- get
- {
- return _attr_list;
- }
- set
- {
- _attr_list=value;
- if (_attr_list != null)
- _attr_list.Parent = this;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- type_definition copy = new type_definition();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (attr_list != null)
- {
- copy.attr_list = (type_definition_attr_list)attr_list.Clone();
- copy.attr_list.Parent = copy;
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new type_definition TypedClone()
- {
- return Clone() as type_definition;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (attr_list != null)
- attr_list.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- attr_list?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 1;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 1;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return attr_list;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- attr_list = (type_definition_attr_list)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///
- ///
- [Serializable]
- public partial class roof_dereference : dereference
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public roof_dereference()
- {
-
- }
-
-
- ///
- ///Конструктор с параметрами.
- ///
- public roof_dereference(addressed_value _dereferencing_value)
- {
- this._dereferencing_value=_dereferencing_value;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public roof_dereference(addressed_value _dereferencing_value,SourceContext sc)
- {
- this._dereferencing_value=_dereferencing_value;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- roof_dereference copy = new roof_dereference();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (dereferencing_value != null)
- {
- copy.dereferencing_value = (addressed_value)dereferencing_value.Clone();
- copy.dereferencing_value.Parent = copy;
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new roof_dereference TypedClone()
- {
- return Clone() as roof_dereference;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (dereferencing_value != null)
- dereferencing_value.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- dereferencing_value?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 1;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 1;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return dereferencing_value;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- dereferencing_value = (addressed_value)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Именованное определение типа
- ///
- [Serializable]
- public partial class named_type_reference : type_definition
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public named_type_reference()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public named_type_reference(List _names)
- {
- this._names=_names;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public named_type_reference(List _names,SourceContext sc)
- {
- this._names=_names;
- source_context = sc;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public named_type_reference(type_definition_attr_list _attr_list,List _names)
- {
- this._attr_list=_attr_list;
- this._names=_names;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public named_type_reference(type_definition_attr_list _attr_list,List _names,SourceContext sc)
- {
- this._attr_list=_attr_list;
- this._names=_names;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- public named_type_reference(ident elem, SourceContext sc = null)
- {
- Add(elem, sc);
- FillParentsInDirectChilds();
- }
-
- protected List _names=new List();
-
- ///
- ///Список имен типа
- ///
- public List names
- {
- get
- {
- return _names;
- }
- set
- {
- _names=value;
- }
- }
-
-
- public named_type_reference Add(ident elem, SourceContext sc = null)
- {
- names.Add(elem);
- if (elem != null)
- elem.Parent = this;
- if (sc != null)
- source_context = sc;
- return this;
- }
-
- public void AddFirst(ident el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- names.Insert(0, el);
- FillParentsInDirectChilds();
- }
-
- public void AddFirst(IEnumerable els)
- {
- if (els == null)
- throw new ArgumentNullException(nameof(els));
- names.InsertRange(0, els);
- foreach (var el in els)
- if (el != null)
- el.Parent = this;
- }
-
- public void AddMany(params ident[] els)
- {
- if (els == null)
- throw new ArgumentNullException(nameof(els));
- names.AddRange(els);
- foreach (var el in els)
- if (el != null)
- el.Parent = this;
- }
-
- private int FindIndexInList(ident el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- var ind = names.FindIndex(x => x == el);
- if (ind == -1)
- throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el));
- return ind;
- }
-
- public void InsertAfter(ident el, ident newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- names.Insert(FindIndexInList(el) + 1, newel);
- newel.Parent = this;
- }
-
- public void InsertAfter(ident el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- names.InsertRange(FindIndexInList(el) + 1, newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public void InsertBefore(ident el, ident newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- names.Insert(FindIndexInList(el), newel);
- newel.Parent = this;
- }
-
- public void InsertBefore(ident el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- names.InsertRange(FindIndexInList(el), newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public bool Remove(ident el)
- {
- return names.Remove(el);
- }
-
- public void ReplaceInList(ident el, ident newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- names[FindIndexInList(el)] = newel;
- newel.Parent = this;
- }
-
- public void ReplaceInList(ident el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- var ind = FindIndexInList(el);
- names.RemoveAt(ind);
- names.InsertRange(ind, newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public int RemoveAll(Predicate match)
- {
- return names.RemoveAll(match);
- }
-
- public ident Last()
- {
- if (names.Count > 0)
- return names[names.Count - 1];
- throw new InvalidOperationException("Список пуст");
- }
-
- public int Count
- {
- get { return names.Count; }
- }
-
- public void Insert(int pos, ident el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- names.Insert(pos,el);
- if (el != null)
- el.Parent = this;
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- named_type_reference copy = new named_type_reference();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (attr_list != null)
- {
- copy.attr_list = (type_definition_attr_list)attr_list.Clone();
- copy.attr_list.Parent = copy;
- }
- if (names != null)
- {
- foreach (ident elem in names)
- {
- if (elem != null)
- {
- copy.Add((ident)elem.Clone());
- copy.Last().Parent = copy;
- }
- else
- copy.Add(null);
- }
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new named_type_reference TypedClone()
- {
- return Clone() as named_type_reference;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (attr_list != null)
- attr_list.Parent = this;
- if (names != null)
- {
- foreach (var child in names)
- if (child != null)
- child.Parent = this;
- }
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- attr_list?.FillParentsInAllChilds();
- if (names != null)
- {
- foreach (var child in names)
- child?.FillParentsInAllChilds();
- }
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 1;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 1 + (names == null ? 0 : names.Count);
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return attr_list;
- }
- Int32 index_counter=ind - 1;
- if(names != null)
- {
- if(index_counter < names.Count)
- {
- return names[index_counter];
- }
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- attr_list = (type_definition_attr_list)value;
- break;
- }
- Int32 index_counter=ind - 1;
- if(names != null)
- {
- if(index_counter < names.Count)
- {
- names[index_counter]= (ident)value;
- return;
- }
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Секция описания переменных (до beginа). Состоит из var_def_statement. Не путать с var_statement - однострочным описанием переменной внутри begin-end
- ///
- [Serializable]
- public partial class variable_definitions : declaration
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public variable_definitions()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public variable_definitions(List _var_definitions)
- {
- this._var_definitions=_var_definitions;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public variable_definitions(List _var_definitions,SourceContext sc)
- {
- this._var_definitions=_var_definitions;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- public variable_definitions(var_def_statement elem, SourceContext sc = null)
- {
- Add(elem, sc);
- FillParentsInDirectChilds();
- }
-
- protected List _var_definitions=new List();
-
- ///
- ///Список описаний переменных
- ///
- public List var_definitions
- {
- get
- {
- return _var_definitions;
- }
- set
- {
- _var_definitions=value;
- }
- }
-
-
- public variable_definitions Add(var_def_statement elem, SourceContext sc = null)
- {
- var_definitions.Add(elem);
- if (elem != null)
- elem.Parent = this;
- if (sc != null)
- source_context = sc;
- return this;
- }
-
- public void AddFirst(var_def_statement el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- var_definitions.Insert(0, el);
- FillParentsInDirectChilds();
- }
-
- public void AddFirst(IEnumerable els)
- {
- if (els == null)
- throw new ArgumentNullException(nameof(els));
- var_definitions.InsertRange(0, els);
- foreach (var el in els)
- if (el != null)
- el.Parent = this;
- }
-
- public void AddMany(params var_def_statement[] els)
- {
- if (els == null)
- throw new ArgumentNullException(nameof(els));
- var_definitions.AddRange(els);
- foreach (var el in els)
- if (el != null)
- el.Parent = this;
- }
-
- private int FindIndexInList(var_def_statement el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- var ind = var_definitions.FindIndex(x => x == el);
- if (ind == -1)
- throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el));
- return ind;
- }
-
- public void InsertAfter(var_def_statement el, var_def_statement newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- var_definitions.Insert(FindIndexInList(el) + 1, newel);
- newel.Parent = this;
- }
-
- public void InsertAfter(var_def_statement el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- var_definitions.InsertRange(FindIndexInList(el) + 1, newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public void InsertBefore(var_def_statement el, var_def_statement newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- var_definitions.Insert(FindIndexInList(el), newel);
- newel.Parent = this;
- }
-
- public void InsertBefore(var_def_statement el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- var_definitions.InsertRange(FindIndexInList(el), newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public bool Remove(var_def_statement el)
- {
- return var_definitions.Remove(el);
- }
-
- public void ReplaceInList(var_def_statement el, var_def_statement newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- var_definitions[FindIndexInList(el)] = newel;
- newel.Parent = this;
- }
-
- public void ReplaceInList(var_def_statement el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- var ind = FindIndexInList(el);
- var_definitions.RemoveAt(ind);
- var_definitions.InsertRange(ind, newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public int RemoveAll(Predicate match)
- {
- return var_definitions.RemoveAll(match);
- }
-
- public var_def_statement Last()
- {
- if (var_definitions.Count > 0)
- return var_definitions[var_definitions.Count - 1];
- throw new InvalidOperationException("Список пуст");
- }
-
- public int Count
- {
- get { return var_definitions.Count; }
- }
-
- public void Insert(int pos, var_def_statement el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- var_definitions.Insert(pos,el);
- if (el != null)
- el.Parent = this;
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- variable_definitions copy = new variable_definitions();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (var_definitions != null)
- {
- foreach (var_def_statement elem in var_definitions)
- {
- if (elem != null)
- {
- copy.Add((var_def_statement)elem.Clone());
- copy.Last().Parent = copy;
- }
- else
- copy.Add(null);
- }
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new variable_definitions TypedClone()
- {
- return Clone() as variable_definitions;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (var_definitions != null)
- {
- foreach (var child in var_definitions)
- if (child != null)
- child.Parent = this;
- }
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- if (var_definitions != null)
- {
- foreach (var child in var_definitions)
- child?.FillParentsInAllChilds();
- }
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 0 + (var_definitions == null ? 0 : var_definitions.Count);
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- Int32 index_counter=ind - 0;
- if(var_definitions != null)
- {
- if(index_counter < var_definitions.Count)
- {
- return var_definitions[index_counter];
- }
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- Int32 index_counter=ind - 0;
- if(var_definitions != null)
- {
- if(index_counter < var_definitions.Count)
- {
- var_definitions[index_counter]= (var_def_statement)value;
- return;
- }
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Список идентификаторов
- ///
- [Serializable]
- public partial class ident_list : syntax_tree_node
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public ident_list()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public ident_list(List _idents)
- {
- this._idents=_idents;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public ident_list(List _idents,SourceContext sc)
- {
- this._idents=_idents;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- public ident_list(ident elem, SourceContext sc = null)
- {
- Add(elem, sc);
- FillParentsInDirectChilds();
- }
-
- protected List _idents=new List();
-
- ///
- ///Список идентификаторов
- ///
- public List idents
- {
- get
- {
- return _idents;
- }
- set
- {
- _idents=value;
- }
- }
-
-
- public ident_list Add(ident elem, SourceContext sc = null)
- {
- idents.Add(elem);
- if (elem != null)
- elem.Parent = this;
- if (sc != null)
- source_context = sc;
- return this;
- }
-
- public void AddFirst(ident el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- idents.Insert(0, el);
- FillParentsInDirectChilds();
- }
-
- public void AddFirst(IEnumerable els)
- {
- if (els == null)
- throw new ArgumentNullException(nameof(els));
- idents.InsertRange(0, els);
- foreach (var el in els)
- if (el != null)
- el.Parent = this;
- }
-
- public void AddMany(params ident[] els)
- {
- if (els == null)
- throw new ArgumentNullException(nameof(els));
- idents.AddRange(els);
- foreach (var el in els)
- if (el != null)
- el.Parent = this;
- }
-
- private int FindIndexInList(ident el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- var ind = idents.FindIndex(x => x == el);
- if (ind == -1)
- throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el));
- return ind;
- }
-
- public void InsertAfter(ident el, ident newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- idents.Insert(FindIndexInList(el) + 1, newel);
- newel.Parent = this;
- }
-
- public void InsertAfter(ident el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- idents.InsertRange(FindIndexInList(el) + 1, newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public void InsertBefore(ident el, ident newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- idents.Insert(FindIndexInList(el), newel);
- newel.Parent = this;
- }
-
- public void InsertBefore(ident el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- idents.InsertRange(FindIndexInList(el), newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public bool Remove(ident el)
- {
- return idents.Remove(el);
- }
-
- public void ReplaceInList(ident el, ident newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- idents[FindIndexInList(el)] = newel;
- newel.Parent = this;
- }
-
- public void ReplaceInList(ident el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- var ind = FindIndexInList(el);
- idents.RemoveAt(ind);
- idents.InsertRange(ind, newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public int RemoveAll(Predicate match)
- {
- return idents.RemoveAll(match);
- }
-
- public ident Last()
- {
- if (idents.Count > 0)
- return idents[idents.Count - 1];
- throw new InvalidOperationException("Список пуст");
- }
-
- public int Count
- {
- get { return idents.Count; }
- }
-
- public void Insert(int pos, ident el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- idents.Insert(pos,el);
- if (el != null)
- el.Parent = this;
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- ident_list copy = new ident_list();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (idents != null)
- {
- foreach (ident elem in idents)
- {
- if (elem != null)
- {
- copy.Add((ident)elem.Clone());
- copy.Last().Parent = copy;
- }
- else
- copy.Add(null);
- }
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new ident_list TypedClone()
- {
- return Clone() as ident_list;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (idents != null)
- {
- foreach (var child in idents)
- if (child != null)
- child.Parent = this;
- }
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- if (idents != null)
- {
- foreach (var child in idents)
- child?.FillParentsInAllChilds();
- }
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 0 + (idents == null ? 0 : idents.Count);
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- Int32 index_counter=ind - 0;
- if(idents != null)
- {
- if(index_counter < idents.Count)
- {
- return idents[index_counter];
- }
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- Int32 index_counter=ind - 0;
- if(idents != null)
- {
- if(index_counter < idents.Count)
- {
- idents[index_counter]= (ident)value;
- return;
- }
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Описание переменных одной строкой. Не содержит var, т.к. встречается исключительно внутри другой конструкции. Может встречаться как до beginа (внутри variable_definitions), так и как внутриблочное описание (внутри var_statement).
-
- ///
- [Serializable]
- public partial class var_def_statement : declaration
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public var_def_statement()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public var_def_statement(ident_list _vars,type_definition _vars_type,expression _inital_value,definition_attribute _var_attr,bool _is_event)
- {
- this._vars=_vars;
- this._vars_type=_vars_type;
- this._inital_value=_inital_value;
- this._var_attr=_var_attr;
- this._is_event=_is_event;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public var_def_statement(ident_list _vars,type_definition _vars_type,expression _inital_value,definition_attribute _var_attr,bool _is_event,SourceContext sc)
- {
- this._vars=_vars;
- this._vars_type=_vars_type;
- this._inital_value=_inital_value;
- this._var_attr=_var_attr;
- this._is_event=_is_event;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected ident_list _vars;
- protected type_definition _vars_type;
- protected expression _inital_value;
- protected definition_attribute _var_attr;
- protected bool _is_event;
-
- ///
- ///Список имен переменных
- ///
- public ident_list vars
- {
- get
- {
- return _vars;
- }
- set
- {
- _vars=value;
- if (_vars != null)
- _vars.Parent = this;
- }
- }
-
- ///
- ///Тип переменных
- ///
- public type_definition vars_type
- {
- get
- {
- return _vars_type;
- }
- set
- {
- _vars_type=value;
- if (_vars_type != null)
- _vars_type.Parent = this;
- }
- }
-
- ///
- ///Начальное значение переменных
- ///
- public expression inital_value
- {
- get
- {
- return _inital_value;
- }
- set
- {
- _inital_value=value;
- if (_inital_value != null)
- _inital_value.Parent = this;
- }
- }
-
- ///
- ///
- ///
- public definition_attribute var_attr
- {
- get
- {
- return _var_attr;
- }
- set
- {
- _var_attr=value;
- }
- }
-
- ///
- ///Являются ли переменные событиями
- ///
- public bool is_event
- {
- get
- {
- return _is_event;
- }
- set
- {
- _is_event=value;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- var_def_statement copy = new var_def_statement();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (vars != null)
- {
- copy.vars = (ident_list)vars.Clone();
- copy.vars.Parent = copy;
- }
- if (vars_type != null)
- {
- copy.vars_type = (type_definition)vars_type.Clone();
- copy.vars_type.Parent = copy;
- }
- if (inital_value != null)
- {
- copy.inital_value = (expression)inital_value.Clone();
- copy.inital_value.Parent = copy;
- }
- copy.var_attr = var_attr;
- copy.is_event = is_event;
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new var_def_statement TypedClone()
- {
- return Clone() as var_def_statement;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (vars != null)
- vars.Parent = this;
- if (vars_type != null)
- vars_type.Parent = this;
- if (inital_value != null)
- inital_value.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- vars?.FillParentsInAllChilds();
- vars_type?.FillParentsInAllChilds();
- inital_value?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 3;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 3;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return vars;
- case 1:
- return vars_type;
- case 2:
- return inital_value;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- vars = (ident_list)value;
- break;
- case 1:
- vars_type = (type_definition)value;
- break;
- case 2:
- inital_value = (expression)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Описание
- ///
- [Serializable]
- public partial class declaration : syntax_tree_node
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public declaration()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public declaration(attribute_list _attributes)
- {
- this._attributes=_attributes;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public declaration(attribute_list _attributes,SourceContext sc)
- {
- this._attributes=_attributes;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected attribute_list _attributes;
-
- ///
- ///Список атрибутов описания
- ///
- public attribute_list attributes
- {
- get
- {
- return _attributes;
- }
- set
- {
- _attributes=value;
- if (_attributes != null)
- _attributes.Parent = this;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- declaration copy = new declaration();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new declaration TypedClone()
- {
- return Clone() as declaration;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 1;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 1;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return attributes;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- attributes = (attribute_list)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Список описаний
- ///
- [Serializable]
- public partial class declarations : syntax_tree_node
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public declarations()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public declarations(List _defs)
- {
- this._defs=_defs;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public declarations(List _defs,SourceContext sc)
- {
- this._defs=_defs;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- public declarations(declaration elem, SourceContext sc = null)
- {
- Add(elem, sc);
- FillParentsInDirectChilds();
- }
-
- protected List _defs=new List();
-
- ///
- ///Список описаний
- ///
- public List defs
- {
- get
- {
- return _defs;
- }
- set
- {
- _defs=value;
- }
- }
-
-
- public declarations Add(declaration elem, SourceContext sc = null)
- {
- defs.Add(elem);
- if (elem != null)
- elem.Parent = this;
- if (sc != null)
- source_context = sc;
- return this;
- }
-
- public void AddFirst(declaration el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- defs.Insert(0, el);
- FillParentsInDirectChilds();
- }
-
- public void AddFirst(IEnumerable els)
- {
- if (els == null)
- throw new ArgumentNullException(nameof(els));
- defs.InsertRange(0, els);
- foreach (var el in els)
- if (el != null)
- el.Parent = this;
- }
-
- public void AddMany(params declaration[] els)
- {
- if (els == null)
- throw new ArgumentNullException(nameof(els));
- defs.AddRange(els);
- foreach (var el in els)
- if (el != null)
- el.Parent = this;
- }
-
- private int FindIndexInList(declaration el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- var ind = defs.FindIndex(x => x == el);
- if (ind == -1)
- throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el));
- return ind;
- }
-
- public void InsertAfter(declaration el, declaration newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- defs.Insert(FindIndexInList(el) + 1, newel);
- newel.Parent = this;
- }
-
- public void InsertAfter(declaration el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- defs.InsertRange(FindIndexInList(el) + 1, newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public void InsertBefore(declaration el, declaration newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- defs.Insert(FindIndexInList(el), newel);
- newel.Parent = this;
- }
-
- public void InsertBefore(declaration el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- defs.InsertRange(FindIndexInList(el), newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public bool Remove(declaration el)
- {
- return defs.Remove(el);
- }
-
- public void ReplaceInList(declaration el, declaration newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- defs[FindIndexInList(el)] = newel;
- newel.Parent = this;
- }
-
- public void ReplaceInList(declaration el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- var ind = FindIndexInList(el);
- defs.RemoveAt(ind);
- defs.InsertRange(ind, newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public int RemoveAll(Predicate match)
- {
- return defs.RemoveAll(match);
- }
-
- public declaration Last()
- {
- if (defs.Count > 0)
- return defs[defs.Count - 1];
- throw new InvalidOperationException("Список пуст");
- }
-
- public int Count
- {
- get { return defs.Count; }
- }
-
- public void Insert(int pos, declaration el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- defs.Insert(pos,el);
- if (el != null)
- el.Parent = this;
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- declarations copy = new declarations();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (defs != null)
- {
- foreach (declaration elem in defs)
- {
- if (elem != null)
- {
- copy.Add((declaration)elem.Clone());
- copy.Last().Parent = copy;
- }
- else
- copy.Add(null);
- }
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new declarations TypedClone()
- {
- return Clone() as declarations;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (defs != null)
- {
- foreach (var child in defs)
- if (child != null)
- child.Parent = this;
- }
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- if (defs != null)
- {
- foreach (var child in defs)
- child?.FillParentsInAllChilds();
- }
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 0 + (defs == null ? 0 : defs.Count);
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- Int32 index_counter=ind - 0;
- if(defs != null)
- {
- if(index_counter < defs.Count)
- {
- return defs[index_counter];
- }
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- Int32 index_counter=ind - 0;
- if(defs != null)
- {
- if(index_counter < defs.Count)
- {
- defs[index_counter]= (declaration)value;
- return;
- }
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///
- ///
- [Serializable]
- public partial class program_tree : syntax_tree_node
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public program_tree()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public program_tree(List _compilation_units)
- {
- this._compilation_units=_compilation_units;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public program_tree(List _compilation_units,SourceContext sc)
- {
- this._compilation_units=_compilation_units;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- public program_tree(compilation_unit elem, SourceContext sc = null)
- {
- Add(elem, sc);
- FillParentsInDirectChilds();
- }
-
- protected List _compilation_units=new List();
-
- ///
- ///Список подключенных модулей
- ///
- public List compilation_units
- {
- get
- {
- return _compilation_units;
- }
- set
- {
- _compilation_units=value;
- }
- }
-
-
- public program_tree Add(compilation_unit elem, SourceContext sc = null)
- {
- compilation_units.Add(elem);
- if (elem != null)
- elem.Parent = this;
- if (sc != null)
- source_context = sc;
- return this;
- }
-
- public void AddFirst(compilation_unit el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- compilation_units.Insert(0, el);
- FillParentsInDirectChilds();
- }
-
- public void AddFirst(IEnumerable els)
- {
- if (els == null)
- throw new ArgumentNullException(nameof(els));
- compilation_units.InsertRange(0, els);
- foreach (var el in els)
- if (el != null)
- el.Parent = this;
- }
-
- public void AddMany(params compilation_unit[] els)
- {
- if (els == null)
- throw new ArgumentNullException(nameof(els));
- compilation_units.AddRange(els);
- foreach (var el in els)
- if (el != null)
- el.Parent = this;
- }
-
- private int FindIndexInList(compilation_unit el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- var ind = compilation_units.FindIndex(x => x == el);
- if (ind == -1)
- throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el));
- return ind;
- }
-
- public void InsertAfter(compilation_unit el, compilation_unit newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- compilation_units.Insert(FindIndexInList(el) + 1, newel);
- newel.Parent = this;
- }
-
- public void InsertAfter(compilation_unit el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- compilation_units.InsertRange(FindIndexInList(el) + 1, newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public void InsertBefore(compilation_unit el, compilation_unit newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- compilation_units.Insert(FindIndexInList(el), newel);
- newel.Parent = this;
- }
-
- public void InsertBefore(compilation_unit el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- compilation_units.InsertRange(FindIndexInList(el), newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public bool Remove(compilation_unit el)
- {
- return compilation_units.Remove(el);
- }
-
- public void ReplaceInList(compilation_unit el, compilation_unit newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- compilation_units[FindIndexInList(el)] = newel;
- newel.Parent = this;
- }
-
- public void ReplaceInList(compilation_unit el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- var ind = FindIndexInList(el);
- compilation_units.RemoveAt(ind);
- compilation_units.InsertRange(ind, newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public int RemoveAll(Predicate match)
- {
- return compilation_units.RemoveAll(match);
- }
-
- public compilation_unit Last()
- {
- if (compilation_units.Count > 0)
- return compilation_units[compilation_units.Count - 1];
- throw new InvalidOperationException("Список пуст");
- }
-
- public int Count
- {
- get { return compilation_units.Count; }
- }
-
- public void Insert(int pos, compilation_unit el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- compilation_units.Insert(pos,el);
- if (el != null)
- el.Parent = this;
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- program_tree copy = new program_tree();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (compilation_units != null)
- {
- foreach (compilation_unit elem in compilation_units)
- {
- if (elem != null)
- {
- copy.Add((compilation_unit)elem.Clone());
- copy.Last().Parent = copy;
- }
- else
- copy.Add(null);
- }
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new program_tree TypedClone()
- {
- return Clone() as program_tree;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (compilation_units != null)
- {
- foreach (var child in compilation_units)
- if (child != null)
- child.Parent = this;
- }
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- if (compilation_units != null)
- {
- foreach (var child in compilation_units)
- child?.FillParentsInAllChilds();
- }
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 0 + (compilation_units == null ? 0 : compilation_units.Count);
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- Int32 index_counter=ind - 0;
- if(compilation_units != null)
- {
- if(index_counter < compilation_units.Count)
- {
- return compilation_units[index_counter];
- }
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- Int32 index_counter=ind - 0;
- if(compilation_units != null)
- {
- if(index_counter < compilation_units.Count)
- {
- compilation_units[index_counter]= (compilation_unit)value;
- return;
- }
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Имя программы
- ///
- [Serializable]
- public partial class program_name : syntax_tree_node
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public program_name()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public program_name(ident _prog_name)
- {
- this._prog_name=_prog_name;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public program_name(ident _prog_name,SourceContext sc)
- {
- this._prog_name=_prog_name;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected ident _prog_name;
-
- ///
- ///Идентификатор - имя программы
- ///
- public ident prog_name
- {
- get
- {
- return _prog_name;
- }
- set
- {
- _prog_name=value;
- if (_prog_name != null)
- _prog_name.Parent = this;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- program_name copy = new program_name();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (prog_name != null)
- {
- copy.prog_name = (ident)prog_name.Clone();
- copy.prog_name.Parent = copy;
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new program_name TypedClone()
- {
- return Clone() as program_name;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (prog_name != null)
- prog_name.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- prog_name?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 1;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 1;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return prog_name;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- prog_name = (ident)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Строковая константа
- ///
- [Serializable]
- public partial class string_const : literal
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public string_const()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public string_const(string _Value)
- {
- this._Value=_Value;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public string_const(string _Value,SourceContext sc)
- {
- this._Value=_Value;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected string _Value;
-
- ///
- ///Значенеи строковой константы
- ///
- public string Value
- {
- get
- {
- return _Value;
- }
- set
- {
- _Value=value;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- string_const copy = new string_const();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- copy.Value = Value;
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new string_const TypedClone()
- {
- return Clone() as string_const;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Список выражений
- ///
- [Serializable]
- public partial class expression_list : syntax_tree_node
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public expression_list()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public expression_list(List _expressions)
- {
- this._expressions=_expressions;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public expression_list(List _expressions,SourceContext sc)
- {
- this._expressions=_expressions;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- public expression_list(expression elem, SourceContext sc = null)
- {
- Add(elem, sc);
- FillParentsInDirectChilds();
- }
-
- protected List _expressions=new List();
-
- ///
- ///Список выражений
- ///
- public List expressions
- {
- get
- {
- return _expressions;
- }
- set
- {
- _expressions=value;
- }
- }
-
-
- public expression_list Add(expression elem, SourceContext sc = null)
- {
- expressions.Add(elem);
- if (elem != null)
- elem.Parent = this;
- if (sc != null)
- source_context = sc;
- return this;
- }
-
- public void AddFirst(expression el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- expressions.Insert(0, el);
- FillParentsInDirectChilds();
- }
-
- public void AddFirst(IEnumerable els)
- {
- if (els == null)
- throw new ArgumentNullException(nameof(els));
- expressions.InsertRange(0, els);
- foreach (var el in els)
- if (el != null)
- el.Parent = this;
- }
-
- public void AddMany(params expression[] els)
- {
- if (els == null)
- throw new ArgumentNullException(nameof(els));
- expressions.AddRange(els);
- foreach (var el in els)
- if (el != null)
- el.Parent = this;
- }
-
- private int FindIndexInList(expression el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- var ind = expressions.FindIndex(x => x == el);
- if (ind == -1)
- throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el));
- return ind;
- }
-
- public void InsertAfter(expression el, expression newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- expressions.Insert(FindIndexInList(el) + 1, newel);
- newel.Parent = this;
- }
-
- public void InsertAfter(expression el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- expressions.InsertRange(FindIndexInList(el) + 1, newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public void InsertBefore(expression el, expression newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- expressions.Insert(FindIndexInList(el), newel);
- newel.Parent = this;
- }
-
- public void InsertBefore(expression el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- expressions.InsertRange(FindIndexInList(el), newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public bool Remove(expression el)
- {
- return expressions.Remove(el);
- }
-
- public void ReplaceInList(expression el, expression newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- expressions[FindIndexInList(el)] = newel;
- newel.Parent = this;
- }
-
- public void ReplaceInList(expression el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- var ind = FindIndexInList(el);
- expressions.RemoveAt(ind);
- expressions.InsertRange(ind, newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public int RemoveAll(Predicate match)
- {
- return expressions.RemoveAll(match);
- }
-
- public expression Last()
- {
- if (expressions.Count > 0)
- return expressions[expressions.Count - 1];
- throw new InvalidOperationException("Список пуст");
- }
-
- public int Count
- {
- get { return expressions.Count; }
- }
-
- public void Insert(int pos, expression el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- expressions.Insert(pos,el);
- if (el != null)
- el.Parent = this;
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- expression_list copy = new expression_list();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (expressions != null)
- {
- foreach (expression elem in expressions)
- {
- if (elem != null)
- {
- copy.Add((expression)elem.Clone());
- copy.Last().Parent = copy;
- }
- else
- copy.Add(null);
- }
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new expression_list TypedClone()
- {
- return Clone() as expression_list;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (expressions != null)
- {
- foreach (var child in expressions)
- if (child != null)
- child.Parent = this;
- }
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- if (expressions != null)
- {
- foreach (var child in expressions)
- child?.FillParentsInAllChilds();
- }
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 0 + (expressions == null ? 0 : expressions.Count);
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- Int32 index_counter=ind - 0;
- if(expressions != null)
- {
- if(index_counter < expressions.Count)
- {
- return expressions[index_counter];
- }
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- Int32 index_counter=ind - 0;
- if(expressions != null)
- {
- if(index_counter < expressions.Count)
- {
- expressions[index_counter]= (expression)value;
- return;
- }
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///
- ///
- [Serializable]
- public partial class dereference : addressed_value_funcname
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public dereference()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public dereference(addressed_value _dereferencing_value)
- {
- this._dereferencing_value=_dereferencing_value;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public dereference(addressed_value _dereferencing_value,SourceContext sc)
- {
- this._dereferencing_value=_dereferencing_value;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected addressed_value _dereferencing_value;
-
- ///
- ///
- ///
- public addressed_value dereferencing_value
- {
- get
- {
- return _dereferencing_value;
- }
- set
- {
- _dereferencing_value=value;
- if (_dereferencing_value != null)
- _dereferencing_value.Parent = this;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- dereference copy = new dereference();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (dereferencing_value != null)
- {
- copy.dereferencing_value = (addressed_value)dereferencing_value.Clone();
- copy.dereferencing_value.Parent = copy;
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new dereference TypedClone()
- {
- return Clone() as dereference;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (dereferencing_value != null)
- dereferencing_value.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- dereferencing_value?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 1;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 1;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return dereferencing_value;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- dereferencing_value = (addressed_value)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Индекс или индексы
- ///
- [Serializable]
- public partial class indexer : dereference
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public indexer()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public indexer(expression_list _indexes)
- {
- this._indexes=_indexes;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public indexer(expression_list _indexes,SourceContext sc)
- {
- this._indexes=_indexes;
- source_context = sc;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public indexer(addressed_value _dereferencing_value,expression_list _indexes)
- {
- this._dereferencing_value=_dereferencing_value;
- this._indexes=_indexes;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public indexer(addressed_value _dereferencing_value,expression_list _indexes,SourceContext sc)
- {
- this._dereferencing_value=_dereferencing_value;
- this._indexes=_indexes;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected expression_list _indexes;
-
- ///
- ///Список индексов
- ///
- public expression_list indexes
- {
- get
- {
- return _indexes;
- }
- set
- {
- _indexes=value;
- if (_indexes != null)
- _indexes.Parent = this;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- indexer copy = new indexer();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (dereferencing_value != null)
- {
- copy.dereferencing_value = (addressed_value)dereferencing_value.Clone();
- copy.dereferencing_value.Parent = copy;
- }
- if (indexes != null)
- {
- copy.indexes = (expression_list)indexes.Clone();
- copy.indexes.Parent = copy;
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new indexer TypedClone()
- {
- return Clone() as indexer;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (dereferencing_value != null)
- dereferencing_value.Parent = this;
- if (indexes != null)
- indexes.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- dereferencing_value?.FillParentsInAllChilds();
- indexes?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 2;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 2;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return dereferencing_value;
- case 1:
- return indexes;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- dereferencing_value = (addressed_value)value;
- break;
- case 1:
- indexes = (expression_list)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Цикл for
- ///
- [Serializable]
- public partial class for_node : statement
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public for_node()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public for_node(ident _loop_variable,expression _initial_value,expression _finish_value,statement _statements,for_cycle_type _cycle_type,expression _increment_value,type_definition _type_name,bool _create_loop_variable)
- {
- this._loop_variable=_loop_variable;
- this._initial_value=_initial_value;
- this._finish_value=_finish_value;
- this._statements=_statements;
- this._cycle_type=_cycle_type;
- this._increment_value=_increment_value;
- this._type_name=_type_name;
- this._create_loop_variable=_create_loop_variable;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public for_node(ident _loop_variable,expression _initial_value,expression _finish_value,statement _statements,for_cycle_type _cycle_type,expression _increment_value,type_definition _type_name,bool _create_loop_variable,SourceContext sc)
- {
- this._loop_variable=_loop_variable;
- this._initial_value=_initial_value;
- this._finish_value=_finish_value;
- this._statements=_statements;
- this._cycle_type=_cycle_type;
- this._increment_value=_increment_value;
- this._type_name=_type_name;
- this._create_loop_variable=_create_loop_variable;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected ident _loop_variable;
- protected expression _initial_value;
- protected expression _finish_value;
- protected statement _statements;
- protected for_cycle_type _cycle_type;
- protected expression _increment_value;
- protected type_definition _type_name;
- protected bool _create_loop_variable;
-
- ///
- ///Переменная цикла for
- ///
- public ident loop_variable
- {
- get
- {
- return _loop_variable;
- }
- set
- {
- _loop_variable=value;
- if (_loop_variable != null)
- _loop_variable.Parent = this;
- }
- }
-
- ///
- ///Начальное значение переменной цикла
- ///
- public expression initial_value
- {
- get
- {
- return _initial_value;
- }
- set
- {
- _initial_value=value;
- if (_initial_value != null)
- _initial_value.Parent = this;
- }
- }
-
- ///
- ///Конечное значение переменной цикла
- ///
- public expression finish_value
- {
- get
- {
- return _finish_value;
- }
- set
- {
- _finish_value=value;
- if (_finish_value != null)
- _finish_value.Parent = this;
- }
- }
-
- ///
- ///Тело цикла
- ///
- public statement statements
- {
- get
- {
- return _statements;
- }
- set
- {
- _statements=value;
- if (_statements != null)
- _statements.Parent = this;
- }
- }
-
- ///
- ///
- ///
- public for_cycle_type cycle_type
- {
- get
- {
- return _cycle_type;
- }
- set
- {
- _cycle_type=value;
- }
- }
-
- ///
- ///Шаг переменной цикла
- ///
- public expression increment_value
- {
- get
- {
- return _increment_value;
- }
- set
- {
- _increment_value=value;
- if (_increment_value != null)
- _increment_value.Parent = this;
- }
- }
-
- ///
- ///
- ///
- public type_definition type_name
- {
- get
- {
- return _type_name;
- }
- set
- {
- _type_name=value;
- if (_type_name != null)
- _type_name.Parent = this;
- }
- }
-
- ///
- ///
- ///
- public bool create_loop_variable
- {
- get
- {
- return _create_loop_variable;
- }
- set
- {
- _create_loop_variable=value;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- for_node copy = new for_node();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (loop_variable != null)
- {
- copy.loop_variable = (ident)loop_variable.Clone();
- copy.loop_variable.Parent = copy;
- }
- if (initial_value != null)
- {
- copy.initial_value = (expression)initial_value.Clone();
- copy.initial_value.Parent = copy;
- }
- if (finish_value != null)
- {
- copy.finish_value = (expression)finish_value.Clone();
- copy.finish_value.Parent = copy;
- }
- if (statements != null)
- {
- copy.statements = (statement)statements.Clone();
- copy.statements.Parent = copy;
- }
- copy.cycle_type = cycle_type;
- if (increment_value != null)
- {
- copy.increment_value = (expression)increment_value.Clone();
- copy.increment_value.Parent = copy;
- }
- if (type_name != null)
- {
- copy.type_name = (type_definition)type_name.Clone();
- copy.type_name.Parent = copy;
- }
- copy.create_loop_variable = create_loop_variable;
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new for_node TypedClone()
- {
- return Clone() as for_node;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (loop_variable != null)
- loop_variable.Parent = this;
- if (initial_value != null)
- initial_value.Parent = this;
- if (finish_value != null)
- finish_value.Parent = this;
- if (statements != null)
- statements.Parent = this;
- if (increment_value != null)
- increment_value.Parent = this;
- if (type_name != null)
- type_name.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- loop_variable?.FillParentsInAllChilds();
- initial_value?.FillParentsInAllChilds();
- finish_value?.FillParentsInAllChilds();
- statements?.FillParentsInAllChilds();
- increment_value?.FillParentsInAllChilds();
- type_name?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 6;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 6;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return loop_variable;
- case 1:
- return initial_value;
- case 2:
- return finish_value;
- case 3:
- return statements;
- case 4:
- return increment_value;
- case 5:
- return type_name;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- loop_variable = (ident)value;
- break;
- case 1:
- initial_value = (expression)value;
- break;
- case 2:
- finish_value = (expression)value;
- break;
- case 3:
- statements = (statement)value;
- break;
- case 4:
- increment_value = (expression)value;
- break;
- case 5:
- type_name = (type_definition)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Цикл с постусловием (repeat)
- ///
- [Serializable]
- public partial class repeat_node : statement
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public repeat_node()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public repeat_node(statement _statements,expression _expr)
- {
- this._statements=_statements;
- this._expr=_expr;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public repeat_node(statement _statements,expression _expr,SourceContext sc)
- {
- this._statements=_statements;
- this._expr=_expr;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected statement _statements;
- protected expression _expr;
-
- ///
- ///Тело цикла
- ///
- public statement statements
- {
- get
- {
- return _statements;
- }
- set
- {
- _statements=value;
- if (_statements != null)
- _statements.Parent = this;
- }
- }
-
- ///
- ///Условие завершения цикла
- ///
- public expression expr
- {
- get
- {
- return _expr;
- }
- set
- {
- _expr=value;
- if (_expr != null)
- _expr.Parent = this;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- repeat_node copy = new repeat_node();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (statements != null)
- {
- copy.statements = (statement)statements.Clone();
- copy.statements.Parent = copy;
- }
- if (expr != null)
- {
- copy.expr = (expression)expr.Clone();
- copy.expr.Parent = copy;
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new repeat_node TypedClone()
- {
- return Clone() as repeat_node;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (statements != null)
- statements.Parent = this;
- if (expr != null)
- expr.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- statements?.FillParentsInAllChilds();
- expr?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 2;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 2;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return statements;
- case 1:
- return expr;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- statements = (statement)value;
- break;
- case 1:
- expr = (expression)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Цикл ПОКА
- ///
- [Serializable]
- public partial class while_node : statement
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public while_node()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public while_node(expression _expr,statement _statements,WhileCycleType _CycleType)
- {
- this._expr=_expr;
- this._statements=_statements;
- this._CycleType=_CycleType;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public while_node(expression _expr,statement _statements,WhileCycleType _CycleType,SourceContext sc)
- {
- this._expr=_expr;
- this._statements=_statements;
- this._CycleType=_CycleType;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected expression _expr;
- protected statement _statements;
- protected WhileCycleType _CycleType;
-
- ///
- ///Условие цикла
- ///
- public expression expr
- {
- get
- {
- return _expr;
- }
- set
- {
- _expr=value;
- if (_expr != null)
- _expr.Parent = this;
- }
- }
-
- ///
- ///Тело цикла
- ///
- public statement statements
- {
- get
- {
- return _statements;
- }
- set
- {
- _statements=value;
- if (_statements != null)
- _statements.Parent = this;
- }
- }
-
- ///
- ///Тип цикла ПОКА
- ///
- public WhileCycleType CycleType
- {
- get
- {
- return _CycleType;
- }
- set
- {
- _CycleType=value;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- while_node copy = new while_node();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (expr != null)
- {
- copy.expr = (expression)expr.Clone();
- copy.expr.Parent = copy;
- }
- if (statements != null)
- {
- copy.statements = (statement)statements.Clone();
- copy.statements.Parent = copy;
- }
- copy.CycleType = CycleType;
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new while_node TypedClone()
- {
- return Clone() as while_node;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (expr != null)
- expr.Parent = this;
- if (statements != null)
- statements.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- expr?.FillParentsInAllChilds();
- statements?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 2;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 2;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return expr;
- case 1:
- return statements;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- expr = (expression)value;
- break;
- case 1:
- statements = (statement)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Условный оператор
- ///
- [Serializable]
- public partial class if_node : statement
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public if_node()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public if_node(expression _condition,statement _then_body,statement _else_body)
- {
- this._condition=_condition;
- this._then_body=_then_body;
- this._else_body=_else_body;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public if_node(expression _condition,statement _then_body,statement _else_body,SourceContext sc)
- {
- this._condition=_condition;
- this._then_body=_then_body;
- this._else_body=_else_body;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected expression _condition;
- protected statement _then_body;
- protected statement _else_body;
-
- ///
- ///Условие
- ///
- public expression condition
- {
- get
- {
- return _condition;
- }
- set
- {
- _condition=value;
- if (_condition != null)
- _condition.Parent = this;
- }
- }
-
- ///
- ///Оператор по ветви then
- ///
- public statement then_body
- {
- get
- {
- return _then_body;
- }
- set
- {
- _then_body=value;
- if (_then_body != null)
- _then_body.Parent = this;
- }
- }
-
- ///
- ///Оператор по ветви else
- ///
- public statement else_body
- {
- get
- {
- return _else_body;
- }
- set
- {
- _else_body=value;
- if (_else_body != null)
- _else_body.Parent = this;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- if_node copy = new if_node();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (condition != null)
- {
- copy.condition = (expression)condition.Clone();
- copy.condition.Parent = copy;
- }
- if (then_body != null)
- {
- copy.then_body = (statement)then_body.Clone();
- copy.then_body.Parent = copy;
- }
- if (else_body != null)
- {
- copy.else_body = (statement)else_body.Clone();
- copy.else_body.Parent = copy;
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new if_node TypedClone()
- {
- return Clone() as if_node;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (condition != null)
- condition.Parent = this;
- if (then_body != null)
- then_body.Parent = this;
- if (else_body != null)
- else_body.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- condition?.FillParentsInAllChilds();
- then_body?.FillParentsInAllChilds();
- else_body?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 3;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 3;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return condition;
- case 1:
- return then_body;
- case 2:
- return else_body;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- condition = (expression)value;
- break;
- case 1:
- then_body = (statement)value;
- break;
- case 2:
- else_body = (statement)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///
- ///
- [Serializable]
- public partial class ref_type : type_definition
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public ref_type()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public ref_type(type_definition _pointed_to)
- {
- this._pointed_to=_pointed_to;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public ref_type(type_definition _pointed_to,SourceContext sc)
- {
- this._pointed_to=_pointed_to;
- source_context = sc;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public ref_type(type_definition_attr_list _attr_list,type_definition _pointed_to)
- {
- this._attr_list=_attr_list;
- this._pointed_to=_pointed_to;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public ref_type(type_definition_attr_list _attr_list,type_definition _pointed_to,SourceContext sc)
- {
- this._attr_list=_attr_list;
- this._pointed_to=_pointed_to;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected type_definition _pointed_to;
-
- ///
- ///
- ///
- public type_definition pointed_to
- {
- get
- {
- return _pointed_to;
- }
- set
- {
- _pointed_to=value;
- if (_pointed_to != null)
- _pointed_to.Parent = this;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- ref_type copy = new ref_type();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (attr_list != null)
- {
- copy.attr_list = (type_definition_attr_list)attr_list.Clone();
- copy.attr_list.Parent = copy;
- }
- if (pointed_to != null)
- {
- copy.pointed_to = (type_definition)pointed_to.Clone();
- copy.pointed_to.Parent = copy;
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new ref_type TypedClone()
- {
- return Clone() as ref_type;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (attr_list != null)
- attr_list.Parent = this;
- if (pointed_to != null)
- pointed_to.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- attr_list?.FillParentsInAllChilds();
- pointed_to?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 2;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 2;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return attr_list;
- case 1:
- return pointed_to;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- attr_list = (type_definition_attr_list)value;
- break;
- case 1:
- pointed_to = (type_definition)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Диапазон
- ///
- [Serializable]
- public partial class diapason : type_definition
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public diapason()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public diapason(expression _left,expression _right)
- {
- this._left=_left;
- this._right=_right;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public diapason(expression _left,expression _right,SourceContext sc)
- {
- this._left=_left;
- this._right=_right;
- source_context = sc;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public diapason(type_definition_attr_list _attr_list,expression _left,expression _right)
- {
- this._attr_list=_attr_list;
- this._left=_left;
- this._right=_right;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public diapason(type_definition_attr_list _attr_list,expression _left,expression _right,SourceContext sc)
- {
- this._attr_list=_attr_list;
- this._left=_left;
- this._right=_right;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected expression _left;
- protected expression _right;
-
- ///
- ///Нижняя граница диапазона
- ///
- public expression left
- {
- get
- {
- return _left;
- }
- set
- {
- _left=value;
- if (_left != null)
- _left.Parent = this;
- }
- }
-
- ///
- ///Верхняя граница диапазона
- ///
- public expression right
- {
- get
- {
- return _right;
- }
- set
- {
- _right=value;
- if (_right != null)
- _right.Parent = this;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- diapason copy = new diapason();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (attr_list != null)
- {
- copy.attr_list = (type_definition_attr_list)attr_list.Clone();
- copy.attr_list.Parent = copy;
- }
- if (left != null)
- {
- copy.left = (expression)left.Clone();
- copy.left.Parent = copy;
- }
- if (right != null)
- {
- copy.right = (expression)right.Clone();
- copy.right.Parent = copy;
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new diapason TypedClone()
- {
- return Clone() as diapason;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (attr_list != null)
- attr_list.Parent = this;
- if (left != null)
- left.Parent = this;
- if (right != null)
- right.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- attr_list?.FillParentsInAllChilds();
- left?.FillParentsInAllChilds();
- right?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 3;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 3;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return attr_list;
- case 1:
- return left;
- case 2:
- return right;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- attr_list = (type_definition_attr_list)value;
- break;
- case 1:
- left = (expression)value;
- break;
- case 2:
- right = (expression)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Типы индексов
- ///
- [Serializable]
- public partial class indexers_types : type_definition
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public indexers_types()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public indexers_types(List _indexers)
- {
- this._indexers=_indexers;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public indexers_types(List _indexers,SourceContext sc)
- {
- this._indexers=_indexers;
- source_context = sc;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public indexers_types(type_definition_attr_list _attr_list,List _indexers)
- {
- this._attr_list=_attr_list;
- this._indexers=_indexers;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public indexers_types(type_definition_attr_list _attr_list,List _indexers,SourceContext sc)
- {
- this._attr_list=_attr_list;
- this._indexers=_indexers;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- public indexers_types(type_definition elem, SourceContext sc = null)
- {
- Add(elem, sc);
- FillParentsInDirectChilds();
- }
-
- protected List _indexers=new List();
-
- ///
- ///Список типов индексов
- ///
- public List indexers
- {
- get
- {
- return _indexers;
- }
- set
- {
- _indexers=value;
- }
- }
-
-
- public indexers_types Add(type_definition elem, SourceContext sc = null)
- {
- indexers.Add(elem);
- if (elem != null)
- elem.Parent = this;
- if (sc != null)
- source_context = sc;
- return this;
- }
-
- public void AddFirst(type_definition el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- indexers.Insert(0, el);
- FillParentsInDirectChilds();
- }
-
- public void AddFirst(IEnumerable els)
- {
- if (els == null)
- throw new ArgumentNullException(nameof(els));
- indexers.InsertRange(0, els);
- foreach (var el in els)
- if (el != null)
- el.Parent = this;
- }
-
- public void AddMany(params type_definition[] els)
- {
- if (els == null)
- throw new ArgumentNullException(nameof(els));
- indexers.AddRange(els);
- foreach (var el in els)
- if (el != null)
- el.Parent = this;
- }
-
- private int FindIndexInList(type_definition el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- var ind = indexers.FindIndex(x => x == el);
- if (ind == -1)
- throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el));
- return ind;
- }
-
- public void InsertAfter(type_definition el, type_definition newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- indexers.Insert(FindIndexInList(el) + 1, newel);
- newel.Parent = this;
- }
-
- public void InsertAfter(type_definition el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- indexers.InsertRange(FindIndexInList(el) + 1, newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public void InsertBefore(type_definition el, type_definition newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- indexers.Insert(FindIndexInList(el), newel);
- newel.Parent = this;
- }
-
- public void InsertBefore(type_definition el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- indexers.InsertRange(FindIndexInList(el), newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public bool Remove(type_definition el)
- {
- return indexers.Remove(el);
- }
-
- public void ReplaceInList(type_definition el, type_definition newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- indexers[FindIndexInList(el)] = newel;
- newel.Parent = this;
- }
-
- public void ReplaceInList(type_definition el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- var ind = FindIndexInList(el);
- indexers.RemoveAt(ind);
- indexers.InsertRange(ind, newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public int RemoveAll(Predicate match)
- {
- return indexers.RemoveAll(match);
- }
-
- public type_definition Last()
- {
- if (indexers.Count > 0)
- return indexers[indexers.Count - 1];
- throw new InvalidOperationException("Список пуст");
- }
-
- public int Count
- {
- get { return indexers.Count; }
- }
-
- public void Insert(int pos, type_definition el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- indexers.Insert(pos,el);
- if (el != null)
- el.Parent = this;
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- indexers_types copy = new indexers_types();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (attr_list != null)
- {
- copy.attr_list = (type_definition_attr_list)attr_list.Clone();
- copy.attr_list.Parent = copy;
- }
- if (indexers != null)
- {
- foreach (type_definition elem in indexers)
- {
- if (elem != null)
- {
- copy.Add((type_definition)elem.Clone());
- copy.Last().Parent = copy;
- }
- else
- copy.Add(null);
- }
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new indexers_types TypedClone()
- {
- return Clone() as indexers_types;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (attr_list != null)
- attr_list.Parent = this;
- if (indexers != null)
- {
- foreach (var child in indexers)
- if (child != null)
- child.Parent = this;
- }
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- attr_list?.FillParentsInAllChilds();
- if (indexers != null)
- {
- foreach (var child in indexers)
- child?.FillParentsInAllChilds();
- }
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 1;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 1 + (indexers == null ? 0 : indexers.Count);
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return attr_list;
- }
- Int32 index_counter=ind - 1;
- if(indexers != null)
- {
- if(index_counter < indexers.Count)
- {
- return indexers[index_counter];
- }
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- attr_list = (type_definition_attr_list)value;
- break;
- }
- Int32 index_counter=ind - 1;
- if(indexers != null)
- {
- if(index_counter < indexers.Count)
- {
- indexers[index_counter]= (type_definition)value;
- return;
- }
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Тип массива
- ///
- [Serializable]
- public partial class array_type : type_definition
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public array_type()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public array_type(indexers_types _indexers,type_definition _elements_type)
- {
- this._indexers=_indexers;
- this._elements_type=_elements_type;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public array_type(indexers_types _indexers,type_definition _elements_type,SourceContext sc)
- {
- this._indexers=_indexers;
- this._elements_type=_elements_type;
- source_context = sc;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public array_type(type_definition_attr_list _attr_list,indexers_types _indexers,type_definition _elements_type)
- {
- this._attr_list=_attr_list;
- this._indexers=_indexers;
- this._elements_type=_elements_type;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public array_type(type_definition_attr_list _attr_list,indexers_types _indexers,type_definition _elements_type,SourceContext sc)
- {
- this._attr_list=_attr_list;
- this._indexers=_indexers;
- this._elements_type=_elements_type;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected indexers_types _indexers;
- protected type_definition _elements_type;
-
- ///
- ///Типы индексов массива
- ///
- public indexers_types indexers
- {
- get
- {
- return _indexers;
- }
- set
- {
- _indexers=value;
- if (_indexers != null)
- _indexers.Parent = this;
- }
- }
-
- ///
- ///Тип элементов массива
- ///
- public type_definition elements_type
- {
- get
- {
- return _elements_type;
- }
- set
- {
- _elements_type=value;
- if (_elements_type != null)
- _elements_type.Parent = this;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- array_type copy = new array_type();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (attr_list != null)
- {
- copy.attr_list = (type_definition_attr_list)attr_list.Clone();
- copy.attr_list.Parent = copy;
- }
- if (indexers != null)
- {
- copy.indexers = (indexers_types)indexers.Clone();
- copy.indexers.Parent = copy;
- }
- if (elements_type != null)
- {
- copy.elements_type = (type_definition)elements_type.Clone();
- copy.elements_type.Parent = copy;
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new array_type TypedClone()
- {
- return Clone() as array_type;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (attr_list != null)
- attr_list.Parent = this;
- if (indexers != null)
- indexers.Parent = this;
- if (elements_type != null)
- elements_type.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- attr_list?.FillParentsInAllChilds();
- indexers?.FillParentsInAllChilds();
- elements_type?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 3;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 3;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return attr_list;
- case 1:
- return indexers;
- case 2:
- return elements_type;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- attr_list = (type_definition_attr_list)value;
- break;
- case 1:
- indexers = (indexers_types)value;
- break;
- case 2:
- elements_type = (type_definition)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Описание меток
- ///
- [Serializable]
- public partial class label_definitions : declaration
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public label_definitions()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public label_definitions(ident_list _labels)
- {
- this._labels=_labels;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public label_definitions(ident_list _labels,SourceContext sc)
- {
- this._labels=_labels;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected ident_list _labels;
-
- ///
- ///Список меток
- ///
- public ident_list labels
- {
- get
- {
- return _labels;
- }
- set
- {
- _labels=value;
- if (_labels != null)
- _labels.Parent = this;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- label_definitions copy = new label_definitions();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (labels != null)
- {
- copy.labels = (ident_list)labels.Clone();
- copy.labels.Parent = copy;
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new label_definitions TypedClone()
- {
- return Clone() as label_definitions;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (labels != null)
- labels.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- labels?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 1;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 1;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return labels;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- labels = (ident_list)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///
- ///
- [Serializable]
- public partial class procedure_attribute : ident
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public procedure_attribute()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public procedure_attribute(proc_attribute _attribute_type)
- {
- this._attribute_type=_attribute_type;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public procedure_attribute(proc_attribute _attribute_type,SourceContext sc)
- {
- this._attribute_type=_attribute_type;
- source_context = sc;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public procedure_attribute(string _name,proc_attribute _attribute_type)
- {
- this._name=_name;
- this._attribute_type=_attribute_type;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public procedure_attribute(string _name,proc_attribute _attribute_type,SourceContext sc)
- {
- this._name=_name;
- this._attribute_type=_attribute_type;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected proc_attribute _attribute_type;
-
- ///
- ///
- ///
- public proc_attribute attribute_type
- {
- get
- {
- return _attribute_type;
- }
- set
- {
- _attribute_type=value;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- procedure_attribute copy = new procedure_attribute();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- copy.name = name;
- copy.attribute_type = attribute_type;
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new procedure_attribute TypedClone()
- {
- return Clone() as procedure_attribute;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///
- ///
- [Serializable]
- public partial class typed_parameters : declaration
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public typed_parameters()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public typed_parameters(ident_list _idents,type_definition _vars_type,parametr_kind _param_kind,expression _inital_value)
- {
- this._idents=_idents;
- this._vars_type=_vars_type;
- this._param_kind=_param_kind;
- this._inital_value=_inital_value;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public typed_parameters(ident_list _idents,type_definition _vars_type,parametr_kind _param_kind,expression _inital_value,SourceContext sc)
- {
- this._idents=_idents;
- this._vars_type=_vars_type;
- this._param_kind=_param_kind;
- this._inital_value=_inital_value;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected ident_list _idents;
- protected type_definition _vars_type;
- protected parametr_kind _param_kind;
- protected expression _inital_value;
-
- ///
- ///
- ///
- public ident_list idents
- {
- get
- {
- return _idents;
- }
- set
- {
- _idents=value;
- if (_idents != null)
- _idents.Parent = this;
- }
- }
-
- ///
- ///
- ///
- public type_definition vars_type
- {
- get
- {
- return _vars_type;
- }
- set
- {
- _vars_type=value;
- if (_vars_type != null)
- _vars_type.Parent = this;
- }
- }
-
- ///
- ///
- ///
- public parametr_kind param_kind
- {
- get
- {
- return _param_kind;
- }
- set
- {
- _param_kind=value;
- }
- }
-
- ///
- ///
- ///
- public expression inital_value
- {
- get
- {
- return _inital_value;
- }
- set
- {
- _inital_value=value;
- if (_inital_value != null)
- _inital_value.Parent = this;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- typed_parameters copy = new typed_parameters();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (idents != null)
- {
- copy.idents = (ident_list)idents.Clone();
- copy.idents.Parent = copy;
- }
- if (vars_type != null)
- {
- copy.vars_type = (type_definition)vars_type.Clone();
- copy.vars_type.Parent = copy;
- }
- copy.param_kind = param_kind;
- if (inital_value != null)
- {
- copy.inital_value = (expression)inital_value.Clone();
- copy.inital_value.Parent = copy;
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new typed_parameters TypedClone()
- {
- return Clone() as typed_parameters;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (idents != null)
- idents.Parent = this;
- if (vars_type != null)
- vars_type.Parent = this;
- if (inital_value != null)
- inital_value.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- idents?.FillParentsInAllChilds();
- vars_type?.FillParentsInAllChilds();
- inital_value?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 3;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 3;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return idents;
- case 1:
- return vars_type;
- case 2:
- return inital_value;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- idents = (ident_list)value;
- break;
- case 1:
- vars_type = (type_definition)value;
- break;
- case 2:
- inital_value = (expression)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///
- ///
- [Serializable]
- public partial class formal_parameters : syntax_tree_node
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public formal_parameters()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public formal_parameters(List _params_list)
- {
- this._params_list=_params_list;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public formal_parameters(List _params_list,SourceContext sc)
- {
- this._params_list=_params_list;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- public formal_parameters(typed_parameters elem, SourceContext sc = null)
- {
- Add(elem, sc);
- FillParentsInDirectChilds();
- }
-
- protected List _params_list=new List();
-
- ///
- ///
- ///
- public List params_list
- {
- get
- {
- return _params_list;
- }
- set
- {
- _params_list=value;
- }
- }
-
-
- public formal_parameters Add(typed_parameters elem, SourceContext sc = null)
- {
- params_list.Add(elem);
- if (elem != null)
- elem.Parent = this;
- if (sc != null)
- source_context = sc;
- return this;
- }
-
- public void AddFirst(typed_parameters el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- params_list.Insert(0, el);
- FillParentsInDirectChilds();
- }
-
- public void AddFirst(IEnumerable els)
- {
- if (els == null)
- throw new ArgumentNullException(nameof(els));
- params_list.InsertRange(0, els);
- foreach (var el in els)
- if (el != null)
- el.Parent = this;
- }
-
- public void AddMany(params typed_parameters[] els)
- {
- if (els == null)
- throw new ArgumentNullException(nameof(els));
- params_list.AddRange(els);
- foreach (var el in els)
- if (el != null)
- el.Parent = this;
- }
-
- private int FindIndexInList(typed_parameters el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- var ind = params_list.FindIndex(x => x == el);
- if (ind == -1)
- throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el));
- return ind;
- }
-
- public void InsertAfter(typed_parameters el, typed_parameters newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- params_list.Insert(FindIndexInList(el) + 1, newel);
- newel.Parent = this;
- }
-
- public void InsertAfter(typed_parameters el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- params_list.InsertRange(FindIndexInList(el) + 1, newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public void InsertBefore(typed_parameters el, typed_parameters newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- params_list.Insert(FindIndexInList(el), newel);
- newel.Parent = this;
- }
-
- public void InsertBefore(typed_parameters el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- params_list.InsertRange(FindIndexInList(el), newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public bool Remove(typed_parameters el)
- {
- return params_list.Remove(el);
- }
-
- public void ReplaceInList(typed_parameters el, typed_parameters newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- params_list[FindIndexInList(el)] = newel;
- newel.Parent = this;
- }
-
- public void ReplaceInList(typed_parameters el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- var ind = FindIndexInList(el);
- params_list.RemoveAt(ind);
- params_list.InsertRange(ind, newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public int RemoveAll(Predicate match)
- {
- return params_list.RemoveAll(match);
- }
-
- public typed_parameters Last()
- {
- if (params_list.Count > 0)
- return params_list[params_list.Count - 1];
- throw new InvalidOperationException("Список пуст");
- }
-
- public int Count
- {
- get { return params_list.Count; }
- }
-
- public void Insert(int pos, typed_parameters el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- params_list.Insert(pos,el);
- if (el != null)
- el.Parent = this;
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- formal_parameters copy = new formal_parameters();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (params_list != null)
- {
- foreach (typed_parameters elem in params_list)
- {
- if (elem != null)
- {
- copy.Add((typed_parameters)elem.Clone());
- copy.Last().Parent = copy;
- }
- else
- copy.Add(null);
- }
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new formal_parameters TypedClone()
- {
- return Clone() as formal_parameters;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (params_list != null)
- {
- foreach (var child in params_list)
- if (child != null)
- child.Parent = this;
- }
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- if (params_list != null)
- {
- foreach (var child in params_list)
- child?.FillParentsInAllChilds();
- }
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 0 + (params_list == null ? 0 : params_list.Count);
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- Int32 index_counter=ind - 0;
- if(params_list != null)
- {
- if(index_counter < params_list.Count)
- {
- return params_list[index_counter];
- }
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- Int32 index_counter=ind - 0;
- if(params_list != null)
- {
- if(index_counter < params_list.Count)
- {
- params_list[index_counter]= (typed_parameters)value;
- return;
- }
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///
- ///
- [Serializable]
- public partial class procedure_attributes_list : syntax_tree_node
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public procedure_attributes_list()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public procedure_attributes_list(List _proc_attributes)
- {
- this._proc_attributes=_proc_attributes;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public procedure_attributes_list(List _proc_attributes,SourceContext sc)
- {
- this._proc_attributes=_proc_attributes;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- public procedure_attributes_list(procedure_attribute elem, SourceContext sc = null)
- {
- Add(elem, sc);
- FillParentsInDirectChilds();
- }
-
- protected List _proc_attributes=new List();
-
- ///
- ///
- ///
- public List proc_attributes
- {
- get
- {
- return _proc_attributes;
- }
- set
- {
- _proc_attributes=value;
- }
- }
-
-
- public procedure_attributes_list Add(procedure_attribute elem, SourceContext sc = null)
- {
- proc_attributes.Add(elem);
- if (elem != null)
- elem.Parent = this;
- if (sc != null)
- source_context = sc;
- return this;
- }
-
- public void AddFirst(procedure_attribute el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- proc_attributes.Insert(0, el);
- FillParentsInDirectChilds();
- }
-
- public void AddFirst(IEnumerable els)
- {
- if (els == null)
- throw new ArgumentNullException(nameof(els));
- proc_attributes.InsertRange(0, els);
- foreach (var el in els)
- if (el != null)
- el.Parent = this;
- }
-
- public void AddMany(params procedure_attribute[] els)
- {
- if (els == null)
- throw new ArgumentNullException(nameof(els));
- proc_attributes.AddRange(els);
- foreach (var el in els)
- if (el != null)
- el.Parent = this;
- }
-
- private int FindIndexInList(procedure_attribute el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- var ind = proc_attributes.FindIndex(x => x == el);
- if (ind == -1)
- throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el));
- return ind;
- }
-
- public void InsertAfter(procedure_attribute el, procedure_attribute newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- proc_attributes.Insert(FindIndexInList(el) + 1, newel);
- newel.Parent = this;
- }
-
- public void InsertAfter(procedure_attribute el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- proc_attributes.InsertRange(FindIndexInList(el) + 1, newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public void InsertBefore(procedure_attribute el, procedure_attribute newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- proc_attributes.Insert(FindIndexInList(el), newel);
- newel.Parent = this;
- }
-
- public void InsertBefore(procedure_attribute el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- proc_attributes.InsertRange(FindIndexInList(el), newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public bool Remove(procedure_attribute el)
- {
- return proc_attributes.Remove(el);
- }
-
- public void ReplaceInList(procedure_attribute el, procedure_attribute newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- proc_attributes[FindIndexInList(el)] = newel;
- newel.Parent = this;
- }
-
- public void ReplaceInList(procedure_attribute el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- var ind = FindIndexInList(el);
- proc_attributes.RemoveAt(ind);
- proc_attributes.InsertRange(ind, newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public int RemoveAll(Predicate match)
- {
- return proc_attributes.RemoveAll(match);
- }
-
- public procedure_attribute Last()
- {
- if (proc_attributes.Count > 0)
- return proc_attributes[proc_attributes.Count - 1];
- throw new InvalidOperationException("Список пуст");
- }
-
- public int Count
- {
- get { return proc_attributes.Count; }
- }
-
- public void Insert(int pos, procedure_attribute el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- proc_attributes.Insert(pos,el);
- if (el != null)
- el.Parent = this;
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- procedure_attributes_list copy = new procedure_attributes_list();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (proc_attributes != null)
- {
- foreach (procedure_attribute elem in proc_attributes)
- {
- if (elem != null)
- {
- copy.Add((procedure_attribute)elem.Clone());
- copy.Last().Parent = copy;
- }
- else
- copy.Add(null);
- }
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new procedure_attributes_list TypedClone()
- {
- return Clone() as procedure_attributes_list;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (proc_attributes != null)
- {
- foreach (var child in proc_attributes)
- if (child != null)
- child.Parent = this;
- }
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- if (proc_attributes != null)
- {
- foreach (var child in proc_attributes)
- child?.FillParentsInAllChilds();
- }
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 0 + (proc_attributes == null ? 0 : proc_attributes.Count);
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- Int32 index_counter=ind - 0;
- if(proc_attributes != null)
- {
- if(index_counter < proc_attributes.Count)
- {
- return proc_attributes[index_counter];
- }
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- Int32 index_counter=ind - 0;
- if(proc_attributes != null)
- {
- if(index_counter < proc_attributes.Count)
- {
- proc_attributes[index_counter]= (procedure_attribute)value;
- return;
- }
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///
- ///
- [Serializable]
- public partial class procedure_header : type_definition
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public procedure_header()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public procedure_header(formal_parameters _parameters,procedure_attributes_list _proc_attributes,method_name _name,bool _of_object,bool _class_keyword,ident_list _template_args,where_definition_list _where_defs)
- {
- this._parameters=_parameters;
- this._proc_attributes=_proc_attributes;
- this._name=_name;
- this._of_object=_of_object;
- this._class_keyword=_class_keyword;
- this._template_args=_template_args;
- this._where_defs=_where_defs;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public procedure_header(formal_parameters _parameters,procedure_attributes_list _proc_attributes,method_name _name,bool _of_object,bool _class_keyword,ident_list _template_args,where_definition_list _where_defs,SourceContext sc)
- {
- this._parameters=_parameters;
- this._proc_attributes=_proc_attributes;
- this._name=_name;
- this._of_object=_of_object;
- this._class_keyword=_class_keyword;
- this._template_args=_template_args;
- this._where_defs=_where_defs;
- source_context = sc;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public procedure_header(type_definition_attr_list _attr_list,formal_parameters _parameters,procedure_attributes_list _proc_attributes,method_name _name,bool _of_object,bool _class_keyword,ident_list _template_args,where_definition_list _where_defs)
- {
- this._attr_list=_attr_list;
- this._parameters=_parameters;
- this._proc_attributes=_proc_attributes;
- this._name=_name;
- this._of_object=_of_object;
- this._class_keyword=_class_keyword;
- this._template_args=_template_args;
- this._where_defs=_where_defs;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public procedure_header(type_definition_attr_list _attr_list,formal_parameters _parameters,procedure_attributes_list _proc_attributes,method_name _name,bool _of_object,bool _class_keyword,ident_list _template_args,where_definition_list _where_defs,SourceContext sc)
- {
- this._attr_list=_attr_list;
- this._parameters=_parameters;
- this._proc_attributes=_proc_attributes;
- this._name=_name;
- this._of_object=_of_object;
- this._class_keyword=_class_keyword;
- this._template_args=_template_args;
- this._where_defs=_where_defs;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected formal_parameters _parameters;
- protected procedure_attributes_list _proc_attributes;
- protected method_name _name;
- protected bool _of_object;
- protected bool _class_keyword;
- protected ident_list _template_args;
- protected where_definition_list _where_defs;
-
- ///
- ///
- ///
- public formal_parameters parameters
- {
- get
- {
- return _parameters;
- }
- set
- {
- _parameters=value;
- if (_parameters != null)
- _parameters.Parent = this;
- }
- }
-
- ///
- ///
- ///
- public procedure_attributes_list proc_attributes
- {
- get
- {
- return _proc_attributes;
- }
- set
- {
- _proc_attributes=value;
- if (_proc_attributes != null)
- _proc_attributes.Parent = this;
- }
- }
-
- ///
- ///
- ///
- public method_name name
- {
- get
- {
- return _name;
- }
- set
- {
- _name=value;
- if (_name != null)
- _name.Parent = this;
- }
- }
-
- ///
- ///
- ///
- public bool of_object
- {
- get
- {
- return _of_object;
- }
- set
- {
- _of_object=value;
- }
- }
-
- ///
- ///class procedure...
- ///
- public bool class_keyword
- {
- get
- {
- return _class_keyword;
- }
- set
- {
- _class_keyword=value;
- }
- }
-
- ///
- ///
- ///
- public ident_list template_args
- {
- get
- {
- return _template_args;
- }
- set
- {
- _template_args=value;
- if (_template_args != null)
- _template_args.Parent = this;
- }
- }
-
- ///
- ///
- ///
- public where_definition_list where_defs
- {
- get
- {
- return _where_defs;
- }
- set
- {
- _where_defs=value;
- if (_where_defs != null)
- _where_defs.Parent = this;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- procedure_header copy = new procedure_header();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (attr_list != null)
- {
- copy.attr_list = (type_definition_attr_list)attr_list.Clone();
- copy.attr_list.Parent = copy;
- }
- if (parameters != null)
- {
- copy.parameters = (formal_parameters)parameters.Clone();
- copy.parameters.Parent = copy;
- }
- if (proc_attributes != null)
- {
- copy.proc_attributes = (procedure_attributes_list)proc_attributes.Clone();
- copy.proc_attributes.Parent = copy;
- }
- if (name != null)
- {
- copy.name = (method_name)name.Clone();
- copy.name.Parent = copy;
- }
- copy.of_object = of_object;
- copy.class_keyword = class_keyword;
- if (template_args != null)
- {
- copy.template_args = (ident_list)template_args.Clone();
- copy.template_args.Parent = copy;
- }
- if (where_defs != null)
- {
- copy.where_defs = (where_definition_list)where_defs.Clone();
- copy.where_defs.Parent = copy;
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new procedure_header TypedClone()
- {
- return Clone() as procedure_header;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (attr_list != null)
- attr_list.Parent = this;
- if (parameters != null)
- parameters.Parent = this;
- if (proc_attributes != null)
- proc_attributes.Parent = this;
- if (name != null)
- name.Parent = this;
- if (template_args != null)
- template_args.Parent = this;
- if (where_defs != null)
- where_defs.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- attr_list?.FillParentsInAllChilds();
- parameters?.FillParentsInAllChilds();
- proc_attributes?.FillParentsInAllChilds();
- name?.FillParentsInAllChilds();
- template_args?.FillParentsInAllChilds();
- where_defs?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 6;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 6;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return attr_list;
- case 1:
- return parameters;
- case 2:
- return proc_attributes;
- case 3:
- return name;
- case 4:
- return template_args;
- case 5:
- return where_defs;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- attr_list = (type_definition_attr_list)value;
- break;
- case 1:
- parameters = (formal_parameters)value;
- break;
- case 2:
- proc_attributes = (procedure_attributes_list)value;
- break;
- case 3:
- name = (method_name)value;
- break;
- case 4:
- template_args = (ident_list)value;
- break;
- case 5:
- where_defs = (where_definition_list)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///
- ///
- [Serializable]
- public partial class function_header : procedure_header
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public function_header()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public function_header(type_definition _return_type)
- {
- this._return_type=_return_type;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public function_header(type_definition _return_type,SourceContext sc)
- {
- this._return_type=_return_type;
- source_context = sc;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public function_header(type_definition_attr_list _attr_list,formal_parameters _parameters,procedure_attributes_list _proc_attributes,method_name _name,bool _of_object,bool _class_keyword,ident_list _template_args,where_definition_list _where_defs,type_definition _return_type)
- {
- this._attr_list=_attr_list;
- this._parameters=_parameters;
- this._proc_attributes=_proc_attributes;
- this._name=_name;
- this._of_object=_of_object;
- this._class_keyword=_class_keyword;
- this._template_args=_template_args;
- this._where_defs=_where_defs;
- this._return_type=_return_type;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public function_header(type_definition_attr_list _attr_list,formal_parameters _parameters,procedure_attributes_list _proc_attributes,method_name _name,bool _of_object,bool _class_keyword,ident_list _template_args,where_definition_list _where_defs,type_definition _return_type,SourceContext sc)
- {
- this._attr_list=_attr_list;
- this._parameters=_parameters;
- this._proc_attributes=_proc_attributes;
- this._name=_name;
- this._of_object=_of_object;
- this._class_keyword=_class_keyword;
- this._template_args=_template_args;
- this._where_defs=_where_defs;
- this._return_type=_return_type;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected type_definition _return_type;
-
- ///
- ///
- ///
- public type_definition return_type
- {
- get
- {
- return _return_type;
- }
- set
- {
- _return_type=value;
- if (_return_type != null)
- _return_type.Parent = this;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- function_header copy = new function_header();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (attr_list != null)
- {
- copy.attr_list = (type_definition_attr_list)attr_list.Clone();
- copy.attr_list.Parent = copy;
- }
- if (parameters != null)
- {
- copy.parameters = (formal_parameters)parameters.Clone();
- copy.parameters.Parent = copy;
- }
- if (proc_attributes != null)
- {
- copy.proc_attributes = (procedure_attributes_list)proc_attributes.Clone();
- copy.proc_attributes.Parent = copy;
- }
- if (name != null)
- {
- copy.name = (method_name)name.Clone();
- copy.name.Parent = copy;
- }
- copy.of_object = of_object;
- copy.class_keyword = class_keyword;
- if (template_args != null)
- {
- copy.template_args = (ident_list)template_args.Clone();
- copy.template_args.Parent = copy;
- }
- if (where_defs != null)
- {
- copy.where_defs = (where_definition_list)where_defs.Clone();
- copy.where_defs.Parent = copy;
- }
- if (return_type != null)
- {
- copy.return_type = (type_definition)return_type.Clone();
- copy.return_type.Parent = copy;
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new function_header TypedClone()
- {
- return Clone() as function_header;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (attr_list != null)
- attr_list.Parent = this;
- if (parameters != null)
- parameters.Parent = this;
- if (proc_attributes != null)
- proc_attributes.Parent = this;
- if (name != null)
- name.Parent = this;
- if (template_args != null)
- template_args.Parent = this;
- if (where_defs != null)
- where_defs.Parent = this;
- if (return_type != null)
- return_type.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- attr_list?.FillParentsInAllChilds();
- parameters?.FillParentsInAllChilds();
- proc_attributes?.FillParentsInAllChilds();
- name?.FillParentsInAllChilds();
- template_args?.FillParentsInAllChilds();
- where_defs?.FillParentsInAllChilds();
- return_type?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 7;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 7;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return attr_list;
- case 1:
- return parameters;
- case 2:
- return proc_attributes;
- case 3:
- return name;
- case 4:
- return template_args;
- case 5:
- return where_defs;
- case 6:
- return return_type;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- attr_list = (type_definition_attr_list)value;
- break;
- case 1:
- parameters = (formal_parameters)value;
- break;
- case 2:
- proc_attributes = (procedure_attributes_list)value;
- break;
- case 3:
- name = (method_name)value;
- break;
- case 4:
- template_args = (ident_list)value;
- break;
- case 5:
- where_defs = (where_definition_list)value;
- break;
- case 6:
- return_type = (type_definition)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///
- ///
- [Serializable]
- public partial class procedure_definition : declaration
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public procedure_definition()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public procedure_definition(procedure_header _proc_header,proc_block _proc_body,bool _is_short_definition)
- {
- this._proc_header=_proc_header;
- this._proc_body=_proc_body;
- this._is_short_definition=_is_short_definition;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public procedure_definition(procedure_header _proc_header,proc_block _proc_body,bool _is_short_definition,SourceContext sc)
- {
- this._proc_header=_proc_header;
- this._proc_body=_proc_body;
- this._is_short_definition=_is_short_definition;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected procedure_header _proc_header;
- protected proc_block _proc_body;
- protected bool _is_short_definition;
-
- ///
- ///
- ///
- public procedure_header proc_header
- {
- get
- {
- return _proc_header;
- }
- set
- {
- _proc_header=value;
- if (_proc_header != null)
- _proc_header.Parent = this;
- }
- }
-
- ///
- ///
- ///
- public proc_block proc_body
- {
- get
- {
- return _proc_body;
- }
- set
- {
- _proc_body=value;
- if (_proc_body != null)
- _proc_body.Parent = this;
- }
- }
-
- ///
- ///
- ///
- public bool is_short_definition
- {
- get
- {
- return _is_short_definition;
- }
- set
- {
- _is_short_definition=value;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- procedure_definition copy = new procedure_definition();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (proc_header != null)
- {
- copy.proc_header = (procedure_header)proc_header.Clone();
- copy.proc_header.Parent = copy;
- }
- if (proc_body != null)
- {
- copy.proc_body = (proc_block)proc_body.Clone();
- copy.proc_body.Parent = copy;
- }
- copy.is_short_definition = is_short_definition;
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new procedure_definition TypedClone()
- {
- return Clone() as procedure_definition;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (proc_header != null)
- proc_header.Parent = this;
- if (proc_body != null)
- proc_body.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- proc_header?.FillParentsInAllChilds();
- proc_body?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 2;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 2;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return proc_header;
- case 1:
- return proc_body;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- proc_header = (procedure_header)value;
- break;
- case 1:
- proc_body = (proc_block)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///
- ///
- [Serializable]
- public partial class type_declaration : declaration
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public type_declaration()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public type_declaration(ident _type_name,type_definition _type_def)
- {
- this._type_name=_type_name;
- this._type_def=_type_def;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public type_declaration(ident _type_name,type_definition _type_def,SourceContext sc)
- {
- this._type_name=_type_name;
- this._type_def=_type_def;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected ident _type_name;
- protected type_definition _type_def;
-
- ///
- ///
- ///
- public ident type_name
- {
- get
- {
- return _type_name;
- }
- set
- {
- _type_name=value;
- if (_type_name != null)
- _type_name.Parent = this;
- }
- }
-
- ///
- ///
- ///
- public type_definition type_def
- {
- get
- {
- return _type_def;
- }
- set
- {
- _type_def=value;
- if (_type_def != null)
- _type_def.Parent = this;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- type_declaration copy = new type_declaration();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (type_name != null)
- {
- copy.type_name = (ident)type_name.Clone();
- copy.type_name.Parent = copy;
- }
- if (type_def != null)
- {
- copy.type_def = (type_definition)type_def.Clone();
- copy.type_def.Parent = copy;
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new type_declaration TypedClone()
- {
- return Clone() as type_declaration;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (type_name != null)
- type_name.Parent = this;
- if (type_def != null)
- type_def.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- type_name?.FillParentsInAllChilds();
- type_def?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 2;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 2;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return type_name;
- case 1:
- return type_def;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- type_name = (ident)value;
- break;
- case 1:
- type_def = (type_definition)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///Список определений типов
- ///
- [Serializable]
- public partial class type_declarations : declaration
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public type_declarations()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public type_declarations(List _types_decl)
- {
- this._types_decl=_types_decl;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public type_declarations(List _types_decl,SourceContext sc)
- {
- this._types_decl=_types_decl;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- public type_declarations(type_declaration elem, SourceContext sc = null)
- {
- Add(elem, sc);
- FillParentsInDirectChilds();
- }
-
- protected List _types_decl=new List();
-
- ///
- ///
- ///
- public List types_decl
- {
- get
- {
- return _types_decl;
- }
- set
- {
- _types_decl=value;
- }
- }
-
-
- public type_declarations Add(type_declaration elem, SourceContext sc = null)
- {
- types_decl.Add(elem);
- if (elem != null)
- elem.Parent = this;
- if (sc != null)
- source_context = sc;
- return this;
- }
-
- public void AddFirst(type_declaration el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- types_decl.Insert(0, el);
- FillParentsInDirectChilds();
- }
-
- public void AddFirst(IEnumerable els)
- {
- if (els == null)
- throw new ArgumentNullException(nameof(els));
- types_decl.InsertRange(0, els);
- foreach (var el in els)
- if (el != null)
- el.Parent = this;
- }
-
- public void AddMany(params type_declaration[] els)
- {
- if (els == null)
- throw new ArgumentNullException(nameof(els));
- types_decl.AddRange(els);
- foreach (var el in els)
- if (el != null)
- el.Parent = this;
- }
-
- private int FindIndexInList(type_declaration el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- var ind = types_decl.FindIndex(x => x == el);
- if (ind == -1)
- throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el));
- return ind;
- }
-
- public void InsertAfter(type_declaration el, type_declaration newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- types_decl.Insert(FindIndexInList(el) + 1, newel);
- newel.Parent = this;
- }
-
- public void InsertAfter(type_declaration el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- types_decl.InsertRange(FindIndexInList(el) + 1, newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public void InsertBefore(type_declaration el, type_declaration newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- types_decl.Insert(FindIndexInList(el), newel);
- newel.Parent = this;
- }
-
- public void InsertBefore(type_declaration el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- types_decl.InsertRange(FindIndexInList(el), newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public bool Remove(type_declaration el)
- {
- return types_decl.Remove(el);
- }
-
- public void ReplaceInList(type_declaration el, type_declaration newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- types_decl[FindIndexInList(el)] = newel;
- newel.Parent = this;
- }
-
- public void ReplaceInList(type_declaration el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- var ind = FindIndexInList(el);
- types_decl.RemoveAt(ind);
- types_decl.InsertRange(ind, newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public int RemoveAll(Predicate match)
- {
- return types_decl.RemoveAll(match);
- }
-
- public type_declaration Last()
- {
- if (types_decl.Count > 0)
- return types_decl[types_decl.Count - 1];
- throw new InvalidOperationException("Список пуст");
- }
-
- public int Count
- {
- get { return types_decl.Count; }
- }
-
- public void Insert(int pos, type_declaration el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- types_decl.Insert(pos,el);
- if (el != null)
- el.Parent = this;
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- type_declarations copy = new type_declarations();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (types_decl != null)
- {
- foreach (type_declaration elem in types_decl)
- {
- if (elem != null)
- {
- copy.Add((type_declaration)elem.Clone());
- copy.Last().Parent = copy;
- }
- else
- copy.Add(null);
- }
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new type_declarations TypedClone()
- {
- return Clone() as type_declarations;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (types_decl != null)
- {
- foreach (var child in types_decl)
- if (child != null)
- child.Parent = this;
- }
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- if (types_decl != null)
- {
- foreach (var child in types_decl)
- child?.FillParentsInAllChilds();
- }
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 0 + (types_decl == null ? 0 : types_decl.Count);
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- Int32 index_counter=ind - 0;
- if(types_decl != null)
- {
- if(index_counter < types_decl.Count)
- {
- return types_decl[index_counter];
- }
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- Int32 index_counter=ind - 0;
- if(types_decl != null)
- {
- if(index_counter < types_decl.Count)
- {
- types_decl[index_counter]= (type_declaration)value;
- return;
- }
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///
- ///
- [Serializable]
- public partial class simple_const_definition : const_definition
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public simple_const_definition()
- {
-
- }
-
-
- ///
- ///Конструктор с параметрами.
- ///
- public simple_const_definition(ident _const_name,expression _const_value)
- {
- this._const_name=_const_name;
- this._const_value=_const_value;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public simple_const_definition(ident _const_name,expression _const_value,SourceContext sc)
- {
- this._const_name=_const_name;
- this._const_value=_const_value;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- simple_const_definition copy = new simple_const_definition();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (const_name != null)
- {
- copy.const_name = (ident)const_name.Clone();
- copy.const_name.Parent = copy;
- }
- if (const_value != null)
- {
- copy.const_value = (expression)const_value.Clone();
- copy.const_value.Parent = copy;
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new simple_const_definition TypedClone()
- {
- return Clone() as simple_const_definition;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (const_name != null)
- const_name.Parent = this;
- if (const_value != null)
- const_value.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- const_name?.FillParentsInAllChilds();
- const_value?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 2;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 2;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return const_name;
- case 1:
- return const_value;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- const_name = (ident)value;
- break;
- case 1:
- const_value = (expression)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///
- ///
- [Serializable]
- public partial class typed_const_definition : const_definition
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public typed_const_definition()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public typed_const_definition(type_definition _const_type)
- {
- this._const_type=_const_type;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public typed_const_definition(type_definition _const_type,SourceContext sc)
- {
- this._const_type=_const_type;
- source_context = sc;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public typed_const_definition(ident _const_name,expression _const_value,type_definition _const_type)
- {
- this._const_name=_const_name;
- this._const_value=_const_value;
- this._const_type=_const_type;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public typed_const_definition(ident _const_name,expression _const_value,type_definition _const_type,SourceContext sc)
- {
- this._const_name=_const_name;
- this._const_value=_const_value;
- this._const_type=_const_type;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected type_definition _const_type;
-
- ///
- ///
- ///
- public type_definition const_type
- {
- get
- {
- return _const_type;
- }
- set
- {
- _const_type=value;
- if (_const_type != null)
- _const_type.Parent = this;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- typed_const_definition copy = new typed_const_definition();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (const_name != null)
- {
- copy.const_name = (ident)const_name.Clone();
- copy.const_name.Parent = copy;
- }
- if (const_value != null)
- {
- copy.const_value = (expression)const_value.Clone();
- copy.const_value.Parent = copy;
- }
- if (const_type != null)
- {
- copy.const_type = (type_definition)const_type.Clone();
- copy.const_type.Parent = copy;
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new typed_const_definition TypedClone()
- {
- return Clone() as typed_const_definition;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (const_name != null)
- const_name.Parent = this;
- if (const_value != null)
- const_value.Parent = this;
- if (const_type != null)
- const_type.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- const_name?.FillParentsInAllChilds();
- const_value?.FillParentsInAllChilds();
- const_type?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 3;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 3;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return const_name;
- case 1:
- return const_value;
- case 2:
- return const_type;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- const_name = (ident)value;
- break;
- case 1:
- const_value = (expression)value;
- break;
- case 2:
- const_type = (type_definition)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///
- ///
- [Serializable]
- public partial class const_definition : declaration
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public const_definition()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public const_definition(ident _const_name,expression _const_value)
- {
- this._const_name=_const_name;
- this._const_value=_const_value;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public const_definition(ident _const_name,expression _const_value,SourceContext sc)
- {
- this._const_name=_const_name;
- this._const_value=_const_value;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected ident _const_name;
- protected expression _const_value;
-
- ///
- ///
- ///
- public ident const_name
- {
- get
- {
- return _const_name;
- }
- set
- {
- _const_name=value;
- if (_const_name != null)
- _const_name.Parent = this;
- }
- }
-
- ///
- ///
- ///
- public expression const_value
- {
- get
- {
- return _const_value;
- }
- set
- {
- _const_value=value;
- if (_const_value != null)
- _const_value.Parent = this;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- const_definition copy = new const_definition();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (const_name != null)
- {
- copy.const_name = (ident)const_name.Clone();
- copy.const_name.Parent = copy;
- }
- if (const_value != null)
- {
- copy.const_value = (expression)const_value.Clone();
- copy.const_value.Parent = copy;
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new const_definition TypedClone()
- {
- return Clone() as const_definition;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (const_name != null)
- const_name.Parent = this;
- if (const_value != null)
- const_value.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- const_name?.FillParentsInAllChilds();
- const_value?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 2;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 2;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return const_name;
- case 1:
- return const_value;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- const_name = (ident)value;
- break;
- case 1:
- const_value = (expression)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///
- ///
- [Serializable]
- public partial class consts_definitions_list : declaration
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public consts_definitions_list()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public consts_definitions_list(List _const_defs)
- {
- this._const_defs=_const_defs;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public consts_definitions_list(List _const_defs,SourceContext sc)
- {
- this._const_defs=_const_defs;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- public consts_definitions_list(const_definition elem, SourceContext sc = null)
- {
- Add(elem, sc);
- FillParentsInDirectChilds();
- }
-
- protected List _const_defs=new List();
-
- ///
- ///
- ///
- public List const_defs
- {
- get
- {
- return _const_defs;
- }
- set
- {
- _const_defs=value;
- }
- }
-
-
- public consts_definitions_list Add(const_definition elem, SourceContext sc = null)
- {
- const_defs.Add(elem);
- if (elem != null)
- elem.Parent = this;
- if (sc != null)
- source_context = sc;
- return this;
- }
-
- public void AddFirst(const_definition el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- const_defs.Insert(0, el);
- FillParentsInDirectChilds();
- }
-
- public void AddFirst(IEnumerable els)
- {
- if (els == null)
- throw new ArgumentNullException(nameof(els));
- const_defs.InsertRange(0, els);
- foreach (var el in els)
- if (el != null)
- el.Parent = this;
- }
-
- public void AddMany(params const_definition[] els)
- {
- if (els == null)
- throw new ArgumentNullException(nameof(els));
- const_defs.AddRange(els);
- foreach (var el in els)
- if (el != null)
- el.Parent = this;
- }
-
- private int FindIndexInList(const_definition el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- var ind = const_defs.FindIndex(x => x == el);
- if (ind == -1)
- throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el));
- return ind;
- }
-
- public void InsertAfter(const_definition el, const_definition newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- const_defs.Insert(FindIndexInList(el) + 1, newel);
- newel.Parent = this;
- }
-
- public void InsertAfter(const_definition el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- const_defs.InsertRange(FindIndexInList(el) + 1, newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public void InsertBefore(const_definition el, const_definition newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- const_defs.Insert(FindIndexInList(el), newel);
- newel.Parent = this;
- }
-
- public void InsertBefore(const_definition el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- const_defs.InsertRange(FindIndexInList(el), newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public bool Remove(const_definition el)
- {
- return const_defs.Remove(el);
- }
-
- public void ReplaceInList(const_definition el, const_definition newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- const_defs[FindIndexInList(el)] = newel;
- newel.Parent = this;
- }
-
- public void ReplaceInList(const_definition el, IEnumerable newels)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newels == null)
- throw new ArgumentNullException(nameof(newels));
- var ind = FindIndexInList(el);
- const_defs.RemoveAt(ind);
- const_defs.InsertRange(ind, newels);
- foreach (var newel in newels)
- if (newel != null)
- newel.Parent = this;
- }
-
- public int RemoveAll(Predicate match)
- {
- return const_defs.RemoveAll(match);
- }
-
- public const_definition Last()
- {
- if (const_defs.Count > 0)
- return const_defs[const_defs.Count - 1];
- throw new InvalidOperationException("Список пуст");
- }
-
- public int Count
- {
- get { return const_defs.Count; }
- }
-
- public void Insert(int pos, const_definition el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- const_defs.Insert(pos,el);
- if (el != null)
- el.Parent = this;
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- consts_definitions_list copy = new consts_definitions_list();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (attributes != null)
- {
- copy.attributes = (attribute_list)attributes.Clone();
- copy.attributes.Parent = copy;
- }
- if (const_defs != null)
- {
- foreach (const_definition elem in const_defs)
- {
- if (elem != null)
- {
- copy.Add((const_definition)elem.Clone());
- copy.Last().Parent = copy;
- }
- else
- copy.Add(null);
- }
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new consts_definitions_list TypedClone()
- {
- return Clone() as consts_definitions_list;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (attributes != null)
- attributes.Parent = this;
- if (const_defs != null)
- {
- foreach (var child in const_defs)
- if (child != null)
- child.Parent = this;
- }
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- attributes?.FillParentsInAllChilds();
- if (const_defs != null)
- {
- foreach (var child in const_defs)
- child?.FillParentsInAllChilds();
- }
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 0;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 0 + (const_defs == null ? 0 : const_defs.Count);
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- Int32 index_counter=ind - 0;
- if(const_defs != null)
- {
- if(index_counter < const_defs.Count)
- {
- return const_defs[index_counter];
- }
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- Int32 index_counter=ind - 0;
- if(const_defs != null)
- {
- if(index_counter < const_defs.Count)
- {
- const_defs[index_counter]= (const_definition)value;
- return;
- }
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///
- ///
- [Serializable]
- public partial class unit_name : syntax_tree_node
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public unit_name()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public unit_name(ident _idunit_name,UnitHeaderKeyword _HeaderKeyword)
- {
- this._idunit_name=_idunit_name;
- this._HeaderKeyword=_HeaderKeyword;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public unit_name(ident _idunit_name,UnitHeaderKeyword _HeaderKeyword,SourceContext sc)
- {
- this._idunit_name=_idunit_name;
- this._HeaderKeyword=_HeaderKeyword;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected ident _idunit_name;
- protected UnitHeaderKeyword _HeaderKeyword;
-
- ///
- ///
- ///
- public ident idunit_name
- {
- get
- {
- return _idunit_name;
- }
- set
- {
- _idunit_name=value;
- if (_idunit_name != null)
- _idunit_name.Parent = this;
- }
- }
-
- ///
- ///
- ///
- public UnitHeaderKeyword HeaderKeyword
- {
- get
- {
- return _HeaderKeyword;
- }
- set
- {
- _HeaderKeyword=value;
- }
- }
-
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- unit_name copy = new unit_name();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (idunit_name != null)
- {
- copy.idunit_name = (ident)idunit_name.Clone();
- copy.idunit_name.Parent = copy;
- }
- copy.HeaderKeyword = HeaderKeyword;
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new unit_name TypedClone()
- {
- return Clone() as unit_name;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (idunit_name != null)
- idunit_name.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- idunit_name?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 1;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 1;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return idunit_name;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- idunit_name = (ident)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///
- ///
- [Serializable]
- public partial class unit_or_namespace : syntax_tree_node
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public unit_or_namespace()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public unit_or_namespace(ident_list _name)
- {
- this._name=_name;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public unit_or_namespace(ident_list _name,SourceContext sc)
- {
- this._name=_name;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected ident_list _name;
-
- ///
- ///
- ///
- public ident_list name
- {
- get
- {
- return _name;
- }
- set
- {
- _name=value;
- if (_name != null)
- _name.Parent = this;
- }
- }
-
- // имя модуля в случае обычного uses
- // или путь к модулю в случае uses-in
- public virtual string UsesPath() => name.idents[0].name;
-
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- unit_or_namespace copy = new unit_or_namespace();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (name != null)
- {
- copy.name = (ident_list)name.Clone();
- copy.name.Parent = copy;
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new unit_or_namespace TypedClone()
- {
- return Clone() as unit_or_namespace;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (name != null)
- name.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- name?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 1;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 1;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return name;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- name = (ident_list)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///
- ///
- [Serializable]
- public partial class uses_unit_in : unit_or_namespace
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public uses_unit_in()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public uses_unit_in(string_const _in_file)
- {
- this._in_file=_in_file;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public uses_unit_in(string_const _in_file,SourceContext sc)
- {
- this._in_file=_in_file;
- source_context = sc;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public uses_unit_in(ident_list _name,string_const _in_file)
- {
- this._name=_name;
- this._in_file=_in_file;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public uses_unit_in(ident_list _name,string_const _in_file,SourceContext sc)
- {
- this._name=_name;
- this._in_file=_in_file;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- protected string_const _in_file;
-
- ///
- ///
- ///
- public string_const in_file
- {
- get
- {
- return _in_file;
- }
- set
- {
- _in_file=value;
- if (_in_file != null)
- _in_file.Parent = this;
- }
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace PascalABCCompiler.SyntaxTree
+{
+ ///
+ ///Выражение
+ ///
+ [Serializable]
+ public partial class expression : declaration
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public expression()
+ {
+
+ }
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ expression copy = new expression();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new expression TypedClone()
+ {
+ return Clone() as expression;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Базовый класс для всех классов синтаксического дерева
+ ///
+ [Serializable]
+ public partial class syntax_tree_node
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public syntax_tree_node()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public syntax_tree_node(SourceContext _source_context)
+ {
+ this._source_context=_source_context;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public syntax_tree_node(SourceContext _source_context,SourceContext sc)
+ {
+ this._source_context=_source_context;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected SourceContext _source_context;
+
+ ///
+ ///Позиция в тексте (строка-столбец начала - строка-столбец конца)
+ ///
+ public SourceContext source_context
+ {
+ get
+ {
+ return _source_context;
+ }
+ set
+ {
+ _source_context=value;
+ }
+ }
+
+
+ /// Создает копию узла
+ public virtual syntax_tree_node Clone()
+ {
+ syntax_tree_node copy = new syntax_tree_node();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public virtual syntax_tree_node TypedClone()
+ {
+ return Clone() as syntax_tree_node;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public virtual void FillParentsInDirectChilds()
+ {
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public virtual void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public virtual Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public virtual Int32 subnodes_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public virtual syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public virtual void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Оператор
+ ///
+ [Serializable]
+ public partial class statement : declaration
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public statement()
+ {
+
+ }
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ statement copy = new statement();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new statement TypedClone()
+ {
+ return Clone() as statement;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Блок операторов
+ ///
+ [Serializable]
+ public partial class statement_list : statement
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public statement_list()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public statement_list(List _subnodes,token_info _left_logical_bracket,token_info _right_logical_bracket,bool _expr_lambda_body)
+ {
+ this._subnodes=_subnodes;
+ this._left_logical_bracket=_left_logical_bracket;
+ this._right_logical_bracket=_right_logical_bracket;
+ this._expr_lambda_body=_expr_lambda_body;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public statement_list(List _subnodes,token_info _left_logical_bracket,token_info _right_logical_bracket,bool _expr_lambda_body,SourceContext sc)
+ {
+ this._subnodes=_subnodes;
+ this._left_logical_bracket=_left_logical_bracket;
+ this._right_logical_bracket=_right_logical_bracket;
+ this._expr_lambda_body=_expr_lambda_body;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ public statement_list(statement elem, SourceContext sc = null)
+ {
+ Add(elem, sc);
+ FillParentsInDirectChilds();
+ }
+
+ protected List _subnodes=new List();
+ protected token_info _left_logical_bracket;
+ protected token_info _right_logical_bracket;
+ protected bool _expr_lambda_body=new bool();
+
+ ///
+ ///Список операторов
+ ///
+ public List subnodes
+ {
+ get
+ {
+ return _subnodes;
+ }
+ set
+ {
+ _subnodes=value;
+ }
+ }
+
+ ///
+ ///Левая операторная скобка
+ ///
+ public token_info left_logical_bracket
+ {
+ get
+ {
+ return _left_logical_bracket;
+ }
+ set
+ {
+ _left_logical_bracket=value;
+ if (_left_logical_bracket != null)
+ _left_logical_bracket.Parent = this;
+ }
+ }
+
+ ///
+ ///Правая операторная скобка
+ ///
+ public token_info right_logical_bracket
+ {
+ get
+ {
+ return _right_logical_bracket;
+ }
+ set
+ {
+ _right_logical_bracket=value;
+ if (_right_logical_bracket != null)
+ _right_logical_bracket.Parent = this;
+ }
+ }
+
+ ///
+ ///Поле, показывающее, что это - тело лямбда-выражения из одного выражения (созданное вызовом NewLambdaBody)
+ ///
+ public bool expr_lambda_body
+ {
+ get
+ {
+ return _expr_lambda_body;
+ }
+ set
+ {
+ _expr_lambda_body=value;
+ }
+ }
+
+
+ public statement_list Add(statement elem, SourceContext sc = null)
+ {
+ subnodes.Add(elem);
+ if (elem != null)
+ elem.Parent = this;
+ if (sc != null)
+ source_context = sc;
+ return this;
+ }
+
+ public void AddFirst(statement el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ subnodes.Insert(0, el);
+ FillParentsInDirectChilds();
+ }
+
+ public void AddFirst(IEnumerable els)
+ {
+ if (els == null)
+ throw new ArgumentNullException(nameof(els));
+ subnodes.InsertRange(0, els);
+ foreach (var el in els)
+ if (el != null)
+ el.Parent = this;
+ }
+
+ public void AddMany(params statement[] els)
+ {
+ if (els == null)
+ throw new ArgumentNullException(nameof(els));
+ subnodes.AddRange(els);
+ foreach (var el in els)
+ if (el != null)
+ el.Parent = this;
+ }
+
+ private int FindIndexInList(statement el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ var ind = subnodes.FindIndex(x => x == el);
+ if (ind == -1)
+ throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el));
+ return ind;
+ }
+
+ public void InsertAfter(statement el, statement newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ subnodes.Insert(FindIndexInList(el) + 1, newel);
+ newel.Parent = this;
+ }
+
+ public void InsertAfter(statement el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ subnodes.InsertRange(FindIndexInList(el) + 1, newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public void InsertBefore(statement el, statement newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ subnodes.Insert(FindIndexInList(el), newel);
+ newel.Parent = this;
+ }
+
+ public void InsertBefore(statement el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ subnodes.InsertRange(FindIndexInList(el), newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public bool Remove(statement el)
+ {
+ return subnodes.Remove(el);
+ }
+
+ public void ReplaceInList(statement el, statement newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ subnodes[FindIndexInList(el)] = newel;
+ newel.Parent = this;
+ }
+
+ public void ReplaceInList(statement el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ var ind = FindIndexInList(el);
+ subnodes.RemoveAt(ind);
+ subnodes.InsertRange(ind, newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public int RemoveAll(Predicate match)
+ {
+ return subnodes.RemoveAll(match);
+ }
+
+ public statement Last()
+ {
+ if (subnodes.Count > 0)
+ return subnodes[subnodes.Count - 1];
+ throw new InvalidOperationException("Список пуст");
+ }
+
+ public int Count
+ {
+ get { return subnodes.Count; }
+ }
+
+ public void Insert(int pos, statement el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ subnodes.Insert(pos,el);
+ if (el != null)
+ el.Parent = this;
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ statement_list copy = new statement_list();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (subnodes != null)
+ {
+ foreach (statement elem in subnodes)
+ {
+ if (elem != null)
+ {
+ copy.Add((statement)elem.Clone());
+ copy.Last().Parent = copy;
+ }
+ else
+ copy.Add(null);
+ }
+ }
+ if (left_logical_bracket != null)
+ {
+ copy.left_logical_bracket = (token_info)left_logical_bracket.Clone();
+ copy.left_logical_bracket.Parent = copy;
+ }
+ if (right_logical_bracket != null)
+ {
+ copy.right_logical_bracket = (token_info)right_logical_bracket.Clone();
+ copy.right_logical_bracket.Parent = copy;
+ }
+ copy.expr_lambda_body = expr_lambda_body;
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new statement_list TypedClone()
+ {
+ return Clone() as statement_list;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (subnodes != null)
+ {
+ foreach (var child in subnodes)
+ if (child != null)
+ child.Parent = this;
+ }
+ if (left_logical_bracket != null)
+ left_logical_bracket.Parent = this;
+ if (right_logical_bracket != null)
+ right_logical_bracket.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ if (subnodes != null)
+ {
+ foreach (var child in subnodes)
+ child?.FillParentsInAllChilds();
+ }
+ left_logical_bracket?.FillParentsInAllChilds();
+ right_logical_bracket?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 2;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 2 + (subnodes == null ? 0 : subnodes.Count);
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return left_logical_bracket;
+ case 1:
+ return right_logical_bracket;
+ }
+ Int32 index_counter=ind - 2;
+ if(subnodes != null)
+ {
+ if(index_counter < subnodes.Count)
+ {
+ return subnodes[index_counter];
+ }
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ left_logical_bracket = (token_info)value;
+ break;
+ case 1:
+ right_logical_bracket = (token_info)value;
+ break;
+ }
+ Int32 index_counter=ind - 2;
+ if(subnodes != null)
+ {
+ if(index_counter < subnodes.Count)
+ {
+ subnodes[index_counter]= (statement)value;
+ return;
+ }
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Идентификатор
+ ///
+ [Serializable]
+ public partial class ident : addressed_value_funcname
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public ident()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public ident(string _name)
+ {
+ this._name=_name;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public ident(string _name,SourceContext sc)
+ {
+ this._name=_name;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected string _name;
+
+ ///
+ ///Строка, представляющая идентификатор
+ ///
+ public string name
+ {
+ get
+ {
+ return _name;
+ }
+ set
+ {
+ _name=value;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ ident copy = new ident();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ copy.name = name;
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new ident TypedClone()
+ {
+ return Clone() as ident;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Оператор присваивания
+ ///
+ [Serializable]
+ public partial class assign : statement
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public assign()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public assign(addressed_value _to,expression _from,Operators _operator_type)
+ {
+ this._to=_to;
+ this._from=_from;
+ this._operator_type=_operator_type;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public assign(addressed_value _to,expression _from,Operators _operator_type,SourceContext sc)
+ {
+ this._to=_to;
+ this._from=_from;
+ this._operator_type=_operator_type;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected addressed_value _to;
+ protected expression _from;
+ protected Operators _operator_type;
+
+ ///
+ ///Левый операнд оператора присваивания (чему присваивать).
+ ///
+ public addressed_value to
+ {
+ get
+ {
+ return _to;
+ }
+ set
+ {
+ _to=value;
+ if (_to != null)
+ _to.Parent = this;
+ }
+ }
+
+ ///
+ ///Выражение в правой части
+ ///
+ public expression from
+ {
+ get
+ {
+ return _from;
+ }
+ set
+ {
+ _from=value;
+ if (_from != null)
+ _from.Parent = this;
+ }
+ }
+
+ ///
+ ///Тип оператора присваивания
+ ///
+ public Operators operator_type
+ {
+ get
+ {
+ return _operator_type;
+ }
+ set
+ {
+ _operator_type=value;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ assign copy = new assign();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (to != null)
+ {
+ copy.to = (addressed_value)to.Clone();
+ copy.to.Parent = copy;
+ }
+ if (from != null)
+ {
+ copy.from = (expression)from.Clone();
+ copy.from.Parent = copy;
+ }
+ copy.operator_type = operator_type;
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new assign TypedClone()
+ {
+ return Clone() as assign;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (to != null)
+ to.Parent = this;
+ if (from != null)
+ from.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ to?.FillParentsInAllChilds();
+ from?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 2;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 2;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return to;
+ case 1:
+ return from;
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ to = (addressed_value)value;
+ break;
+ case 1:
+ from = (expression)value;
+ break;
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Бинарное выражение
+ ///
+ [Serializable]
+ public partial class bin_expr : addressed_value
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public bin_expr()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public bin_expr(expression _left,expression _right,Operators _operation_type)
+ {
+ this._left=_left;
+ this._right=_right;
+ this._operation_type=_operation_type;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public bin_expr(expression _left,expression _right,Operators _operation_type,SourceContext sc)
+ {
+ this._left=_left;
+ this._right=_right;
+ this._operation_type=_operation_type;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected expression _left;
+ protected expression _right;
+ protected Operators _operation_type;
+
+ ///
+ ///
+ ///
+ public expression left
+ {
+ get
+ {
+ return _left;
+ }
+ set
+ {
+ _left=value;
+ if (_left != null)
+ _left.Parent = this;
+ }
+ }
+
+ ///
+ ///
+ ///
+ public expression right
+ {
+ get
+ {
+ return _right;
+ }
+ set
+ {
+ _right=value;
+ if (_right != null)
+ _right.Parent = this;
+ }
+ }
+
+ ///
+ ///
+ ///
+ public Operators operation_type
+ {
+ get
+ {
+ return _operation_type;
+ }
+ set
+ {
+ _operation_type=value;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ bin_expr copy = new bin_expr();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (left != null)
+ {
+ copy.left = (expression)left.Clone();
+ copy.left.Parent = copy;
+ }
+ if (right != null)
+ {
+ copy.right = (expression)right.Clone();
+ copy.right.Parent = copy;
+ }
+ copy.operation_type = operation_type;
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new bin_expr TypedClone()
+ {
+ return Clone() as bin_expr;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (left != null)
+ left.Parent = this;
+ if (right != null)
+ right.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ left?.FillParentsInAllChilds();
+ right?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 2;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 2;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return left;
+ case 1:
+ return right;
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ left = (expression)value;
+ break;
+ case 1:
+ right = (expression)value;
+ break;
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Унарное выражение
+ ///
+ [Serializable]
+ public partial class un_expr : addressed_value
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public un_expr()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public un_expr(expression _subnode,Operators _operation_type)
+ {
+ this._subnode=_subnode;
+ this._operation_type=_operation_type;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public un_expr(expression _subnode,Operators _operation_type,SourceContext sc)
+ {
+ this._subnode=_subnode;
+ this._operation_type=_operation_type;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected expression _subnode;
+ protected Operators _operation_type;
+
+ ///
+ ///
+ ///
+ public expression subnode
+ {
+ get
+ {
+ return _subnode;
+ }
+ set
+ {
+ _subnode=value;
+ if (_subnode != null)
+ _subnode.Parent = this;
+ }
+ }
+
+ ///
+ ///
+ ///
+ public Operators operation_type
+ {
+ get
+ {
+ return _operation_type;
+ }
+ set
+ {
+ _operation_type=value;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ un_expr copy = new un_expr();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (subnode != null)
+ {
+ copy.subnode = (expression)subnode.Clone();
+ copy.subnode.Parent = copy;
+ }
+ copy.operation_type = operation_type;
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new un_expr TypedClone()
+ {
+ return Clone() as un_expr;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (subnode != null)
+ subnode.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ subnode?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 1;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 1;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return subnode;
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ subnode = (expression)value;
+ break;
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Константа
+ ///
+ [Serializable]
+ public partial class const_node : addressed_value
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public const_node()
+ {
+
+ }
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ const_node copy = new const_node();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new const_node TypedClone()
+ {
+ return Clone() as const_node;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Логическая константа
+ ///
+ [Serializable]
+ public partial class bool_const : const_node
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public bool_const()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public bool_const(bool _val)
+ {
+ this._val=_val;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public bool_const(bool _val,SourceContext sc)
+ {
+ this._val=_val;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected bool _val;
+
+ ///
+ ///Значение логической константы
+ ///
+ public bool val
+ {
+ get
+ {
+ return _val;
+ }
+ set
+ {
+ _val=value;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ bool_const copy = new bool_const();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ copy.val = val;
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new bool_const TypedClone()
+ {
+ return Clone() as bool_const;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Целая константа
+ ///
+ [Serializable]
+ public partial class int32_const : const_node
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public int32_const()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public int32_const(Int32 _val)
+ {
+ this._val=_val;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public int32_const(Int32 _val,SourceContext sc)
+ {
+ this._val=_val;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected Int32 _val;
+
+ ///
+ ///Значение
+ ///
+ public Int32 val
+ {
+ get
+ {
+ return _val;
+ }
+ set
+ {
+ _val=value;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ int32_const copy = new int32_const();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ copy.val = val;
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new int32_const TypedClone()
+ {
+ return Clone() as int32_const;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Вещественная константа
+ ///
+ [Serializable]
+ public partial class double_const : const_node
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public double_const()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public double_const(double _val)
+ {
+ this._val=_val;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public double_const(double _val,SourceContext sc)
+ {
+ this._val=_val;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected double _val;
+
+ ///
+ ///Значение вещественной константы
+ ///
+ public double val
+ {
+ get
+ {
+ return _val;
+ }
+ set
+ {
+ _val=value;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ double_const copy = new double_const();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ copy.val = val;
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new double_const TypedClone()
+ {
+ return Clone() as double_const;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Тело подпрограммы
+ ///
+ [Serializable]
+ public partial class subprogram_body : syntax_tree_node
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public subprogram_body()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public subprogram_body(statement_list _subprogram_code,declarations _subprogram_defs)
+ {
+ this._subprogram_code=_subprogram_code;
+ this._subprogram_defs=_subprogram_defs;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public subprogram_body(statement_list _subprogram_code,declarations _subprogram_defs,SourceContext sc)
+ {
+ this._subprogram_code=_subprogram_code;
+ this._subprogram_defs=_subprogram_defs;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected statement_list _subprogram_code;
+ protected declarations _subprogram_defs;
+
+ ///
+ ///Блок операторов подпрограммы
+ ///
+ public statement_list subprogram_code
+ {
+ get
+ {
+ return _subprogram_code;
+ }
+ set
+ {
+ _subprogram_code=value;
+ if (_subprogram_code != null)
+ _subprogram_code.Parent = this;
+ }
+ }
+
+ ///
+ ///Описания подпрограммы
+ ///
+ public declarations subprogram_defs
+ {
+ get
+ {
+ return _subprogram_defs;
+ }
+ set
+ {
+ _subprogram_defs=value;
+ if (_subprogram_defs != null)
+ _subprogram_defs.Parent = this;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ subprogram_body copy = new subprogram_body();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (subprogram_code != null)
+ {
+ copy.subprogram_code = (statement_list)subprogram_code.Clone();
+ copy.subprogram_code.Parent = copy;
+ }
+ if (subprogram_defs != null)
+ {
+ copy.subprogram_defs = (declarations)subprogram_defs.Clone();
+ copy.subprogram_defs.Parent = copy;
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new subprogram_body TypedClone()
+ {
+ return Clone() as subprogram_body;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (subprogram_code != null)
+ subprogram_code.Parent = this;
+ if (subprogram_defs != null)
+ subprogram_defs.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ subprogram_code?.FillParentsInAllChilds();
+ subprogram_defs?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 2;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 2;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return subprogram_code;
+ case 1:
+ return subprogram_defs;
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ subprogram_code = (statement_list)value;
+ break;
+ case 1:
+ subprogram_defs = (declarations)value;
+ break;
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Значение, имеющее адрес
+ ///
+ [Serializable]
+ public partial class addressed_value : expression
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public addressed_value()
+ {
+
+ }
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ addressed_value copy = new addressed_value();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new addressed_value TypedClone()
+ {
+ return Clone() as addressed_value;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Определение типа
+ ///
+ [Serializable]
+ public partial class type_definition : declaration
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public type_definition()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public type_definition(type_definition_attr_list _attr_list)
+ {
+ this._attr_list=_attr_list;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public type_definition(type_definition_attr_list _attr_list,SourceContext sc)
+ {
+ this._attr_list=_attr_list;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected type_definition_attr_list _attr_list;
+
+ ///
+ ///
+ ///
+ public type_definition_attr_list attr_list
+ {
+ get
+ {
+ return _attr_list;
+ }
+ set
+ {
+ _attr_list=value;
+ if (_attr_list != null)
+ _attr_list.Parent = this;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ type_definition copy = new type_definition();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (attr_list != null)
+ {
+ copy.attr_list = (type_definition_attr_list)attr_list.Clone();
+ copy.attr_list.Parent = copy;
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new type_definition TypedClone()
+ {
+ return Clone() as type_definition;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (attr_list != null)
+ attr_list.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ attr_list?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 1;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 1;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return attr_list;
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ attr_list = (type_definition_attr_list)value;
+ break;
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///
+ ///
+ [Serializable]
+ public partial class roof_dereference : dereference
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public roof_dereference()
+ {
+
+ }
+
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public roof_dereference(addressed_value _dereferencing_value)
+ {
+ this._dereferencing_value=_dereferencing_value;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public roof_dereference(addressed_value _dereferencing_value,SourceContext sc)
+ {
+ this._dereferencing_value=_dereferencing_value;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ roof_dereference copy = new roof_dereference();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (dereferencing_value != null)
+ {
+ copy.dereferencing_value = (addressed_value)dereferencing_value.Clone();
+ copy.dereferencing_value.Parent = copy;
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new roof_dereference TypedClone()
+ {
+ return Clone() as roof_dereference;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (dereferencing_value != null)
+ dereferencing_value.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ dereferencing_value?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 1;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 1;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return dereferencing_value;
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ dereferencing_value = (addressed_value)value;
+ break;
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Именованное определение типа
+ ///
+ [Serializable]
+ public partial class named_type_reference : type_definition
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public named_type_reference()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public named_type_reference(List _names)
+ {
+ this._names=_names;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public named_type_reference(List _names,SourceContext sc)
+ {
+ this._names=_names;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public named_type_reference(type_definition_attr_list _attr_list,List _names)
+ {
+ this._attr_list=_attr_list;
+ this._names=_names;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public named_type_reference(type_definition_attr_list _attr_list,List _names,SourceContext sc)
+ {
+ this._attr_list=_attr_list;
+ this._names=_names;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ public named_type_reference(ident elem, SourceContext sc = null)
+ {
+ Add(elem, sc);
+ FillParentsInDirectChilds();
+ }
+
+ protected List _names=new List();
+
+ ///
+ ///Список имен типа
+ ///
+ public List names
+ {
+ get
+ {
+ return _names;
+ }
+ set
+ {
+ _names=value;
+ }
+ }
+
+
+ public named_type_reference Add(ident elem, SourceContext sc = null)
+ {
+ names.Add(elem);
+ if (elem != null)
+ elem.Parent = this;
+ if (sc != null)
+ source_context = sc;
+ return this;
+ }
+
+ public void AddFirst(ident el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ names.Insert(0, el);
+ FillParentsInDirectChilds();
+ }
+
+ public void AddFirst(IEnumerable els)
+ {
+ if (els == null)
+ throw new ArgumentNullException(nameof(els));
+ names.InsertRange(0, els);
+ foreach (var el in els)
+ if (el != null)
+ el.Parent = this;
+ }
+
+ public void AddMany(params ident[] els)
+ {
+ if (els == null)
+ throw new ArgumentNullException(nameof(els));
+ names.AddRange(els);
+ foreach (var el in els)
+ if (el != null)
+ el.Parent = this;
+ }
+
+ private int FindIndexInList(ident el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ var ind = names.FindIndex(x => x == el);
+ if (ind == -1)
+ throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el));
+ return ind;
+ }
+
+ public void InsertAfter(ident el, ident newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ names.Insert(FindIndexInList(el) + 1, newel);
+ newel.Parent = this;
+ }
+
+ public void InsertAfter(ident el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ names.InsertRange(FindIndexInList(el) + 1, newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public void InsertBefore(ident el, ident newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ names.Insert(FindIndexInList(el), newel);
+ newel.Parent = this;
+ }
+
+ public void InsertBefore(ident el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ names.InsertRange(FindIndexInList(el), newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public bool Remove(ident el)
+ {
+ return names.Remove(el);
+ }
+
+ public void ReplaceInList(ident el, ident newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ names[FindIndexInList(el)] = newel;
+ newel.Parent = this;
+ }
+
+ public void ReplaceInList(ident el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ var ind = FindIndexInList(el);
+ names.RemoveAt(ind);
+ names.InsertRange(ind, newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public int RemoveAll(Predicate match)
+ {
+ return names.RemoveAll(match);
+ }
+
+ public ident Last()
+ {
+ if (names.Count > 0)
+ return names[names.Count - 1];
+ throw new InvalidOperationException("Список пуст");
+ }
+
+ public int Count
+ {
+ get { return names.Count; }
+ }
+
+ public void Insert(int pos, ident el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ names.Insert(pos,el);
+ if (el != null)
+ el.Parent = this;
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ named_type_reference copy = new named_type_reference();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (attr_list != null)
+ {
+ copy.attr_list = (type_definition_attr_list)attr_list.Clone();
+ copy.attr_list.Parent = copy;
+ }
+ if (names != null)
+ {
+ foreach (ident elem in names)
+ {
+ if (elem != null)
+ {
+ copy.Add((ident)elem.Clone());
+ copy.Last().Parent = copy;
+ }
+ else
+ copy.Add(null);
+ }
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new named_type_reference TypedClone()
+ {
+ return Clone() as named_type_reference;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (attr_list != null)
+ attr_list.Parent = this;
+ if (names != null)
+ {
+ foreach (var child in names)
+ if (child != null)
+ child.Parent = this;
+ }
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ attr_list?.FillParentsInAllChilds();
+ if (names != null)
+ {
+ foreach (var child in names)
+ child?.FillParentsInAllChilds();
+ }
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 1;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 1 + (names == null ? 0 : names.Count);
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return attr_list;
+ }
+ Int32 index_counter=ind - 1;
+ if(names != null)
+ {
+ if(index_counter < names.Count)
+ {
+ return names[index_counter];
+ }
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ attr_list = (type_definition_attr_list)value;
+ break;
+ }
+ Int32 index_counter=ind - 1;
+ if(names != null)
+ {
+ if(index_counter < names.Count)
+ {
+ names[index_counter]= (ident)value;
+ return;
+ }
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Секция описания переменных (до beginа). Состоит из var_def_statement. Не путать с var_statement - однострочным описанием переменной внутри begin-end
+ ///
+ [Serializable]
+ public partial class variable_definitions : declaration
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public variable_definitions()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public variable_definitions(List _var_definitions)
+ {
+ this._var_definitions=_var_definitions;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public variable_definitions(List _var_definitions,SourceContext sc)
+ {
+ this._var_definitions=_var_definitions;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ public variable_definitions(var_def_statement elem, SourceContext sc = null)
+ {
+ Add(elem, sc);
+ FillParentsInDirectChilds();
+ }
+
+ protected List _var_definitions=new List();
+
+ ///
+ ///Список описаний переменных
+ ///
+ public List var_definitions
+ {
+ get
+ {
+ return _var_definitions;
+ }
+ set
+ {
+ _var_definitions=value;
+ }
+ }
+
+
+ public variable_definitions Add(var_def_statement elem, SourceContext sc = null)
+ {
+ var_definitions.Add(elem);
+ if (elem != null)
+ elem.Parent = this;
+ if (sc != null)
+ source_context = sc;
+ return this;
+ }
+
+ public void AddFirst(var_def_statement el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ var_definitions.Insert(0, el);
+ FillParentsInDirectChilds();
+ }
+
+ public void AddFirst(IEnumerable els)
+ {
+ if (els == null)
+ throw new ArgumentNullException(nameof(els));
+ var_definitions.InsertRange(0, els);
+ foreach (var el in els)
+ if (el != null)
+ el.Parent = this;
+ }
+
+ public void AddMany(params var_def_statement[] els)
+ {
+ if (els == null)
+ throw new ArgumentNullException(nameof(els));
+ var_definitions.AddRange(els);
+ foreach (var el in els)
+ if (el != null)
+ el.Parent = this;
+ }
+
+ private int FindIndexInList(var_def_statement el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ var ind = var_definitions.FindIndex(x => x == el);
+ if (ind == -1)
+ throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el));
+ return ind;
+ }
+
+ public void InsertAfter(var_def_statement el, var_def_statement newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ var_definitions.Insert(FindIndexInList(el) + 1, newel);
+ newel.Parent = this;
+ }
+
+ public void InsertAfter(var_def_statement el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ var_definitions.InsertRange(FindIndexInList(el) + 1, newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public void InsertBefore(var_def_statement el, var_def_statement newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ var_definitions.Insert(FindIndexInList(el), newel);
+ newel.Parent = this;
+ }
+
+ public void InsertBefore(var_def_statement el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ var_definitions.InsertRange(FindIndexInList(el), newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public bool Remove(var_def_statement el)
+ {
+ return var_definitions.Remove(el);
+ }
+
+ public void ReplaceInList(var_def_statement el, var_def_statement newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ var_definitions[FindIndexInList(el)] = newel;
+ newel.Parent = this;
+ }
+
+ public void ReplaceInList(var_def_statement el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ var ind = FindIndexInList(el);
+ var_definitions.RemoveAt(ind);
+ var_definitions.InsertRange(ind, newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public int RemoveAll(Predicate match)
+ {
+ return var_definitions.RemoveAll(match);
+ }
+
+ public var_def_statement Last()
+ {
+ if (var_definitions.Count > 0)
+ return var_definitions[var_definitions.Count - 1];
+ throw new InvalidOperationException("Список пуст");
+ }
+
+ public int Count
+ {
+ get { return var_definitions.Count; }
+ }
+
+ public void Insert(int pos, var_def_statement el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ var_definitions.Insert(pos,el);
+ if (el != null)
+ el.Parent = this;
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ variable_definitions copy = new variable_definitions();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (var_definitions != null)
+ {
+ foreach (var_def_statement elem in var_definitions)
+ {
+ if (elem != null)
+ {
+ copy.Add((var_def_statement)elem.Clone());
+ copy.Last().Parent = copy;
+ }
+ else
+ copy.Add(null);
+ }
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new variable_definitions TypedClone()
+ {
+ return Clone() as variable_definitions;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (var_definitions != null)
+ {
+ foreach (var child in var_definitions)
+ if (child != null)
+ child.Parent = this;
+ }
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ if (var_definitions != null)
+ {
+ foreach (var child in var_definitions)
+ child?.FillParentsInAllChilds();
+ }
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 0 + (var_definitions == null ? 0 : var_definitions.Count);
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ Int32 index_counter=ind - 0;
+ if(var_definitions != null)
+ {
+ if(index_counter < var_definitions.Count)
+ {
+ return var_definitions[index_counter];
+ }
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ Int32 index_counter=ind - 0;
+ if(var_definitions != null)
+ {
+ if(index_counter < var_definitions.Count)
+ {
+ var_definitions[index_counter]= (var_def_statement)value;
+ return;
+ }
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Список идентификаторов
+ ///
+ [Serializable]
+ public partial class ident_list : syntax_tree_node
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public ident_list()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public ident_list(List _idents)
+ {
+ this._idents=_idents;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public ident_list(List _idents,SourceContext sc)
+ {
+ this._idents=_idents;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ public ident_list(ident elem, SourceContext sc = null)
+ {
+ Add(elem, sc);
+ FillParentsInDirectChilds();
+ }
+
+ protected List _idents=new List();
+
+ ///
+ ///Список идентификаторов
+ ///
+ public List idents
+ {
+ get
+ {
+ return _idents;
+ }
+ set
+ {
+ _idents=value;
+ }
+ }
+
+
+ public ident_list Add(ident elem, SourceContext sc = null)
+ {
+ idents.Add(elem);
+ if (elem != null)
+ elem.Parent = this;
+ if (sc != null)
+ source_context = sc;
+ return this;
+ }
+
+ public void AddFirst(ident el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ idents.Insert(0, el);
+ FillParentsInDirectChilds();
+ }
+
+ public void AddFirst(IEnumerable els)
+ {
+ if (els == null)
+ throw new ArgumentNullException(nameof(els));
+ idents.InsertRange(0, els);
+ foreach (var el in els)
+ if (el != null)
+ el.Parent = this;
+ }
+
+ public void AddMany(params ident[] els)
+ {
+ if (els == null)
+ throw new ArgumentNullException(nameof(els));
+ idents.AddRange(els);
+ foreach (var el in els)
+ if (el != null)
+ el.Parent = this;
+ }
+
+ private int FindIndexInList(ident el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ var ind = idents.FindIndex(x => x == el);
+ if (ind == -1)
+ throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el));
+ return ind;
+ }
+
+ public void InsertAfter(ident el, ident newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ idents.Insert(FindIndexInList(el) + 1, newel);
+ newel.Parent = this;
+ }
+
+ public void InsertAfter(ident el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ idents.InsertRange(FindIndexInList(el) + 1, newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public void InsertBefore(ident el, ident newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ idents.Insert(FindIndexInList(el), newel);
+ newel.Parent = this;
+ }
+
+ public void InsertBefore(ident el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ idents.InsertRange(FindIndexInList(el), newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public bool Remove(ident el)
+ {
+ return idents.Remove(el);
+ }
+
+ public void ReplaceInList(ident el, ident newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ idents[FindIndexInList(el)] = newel;
+ newel.Parent = this;
+ }
+
+ public void ReplaceInList(ident el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ var ind = FindIndexInList(el);
+ idents.RemoveAt(ind);
+ idents.InsertRange(ind, newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public int RemoveAll(Predicate match)
+ {
+ return idents.RemoveAll(match);
+ }
+
+ public ident Last()
+ {
+ if (idents.Count > 0)
+ return idents[idents.Count - 1];
+ throw new InvalidOperationException("Список пуст");
+ }
+
+ public int Count
+ {
+ get { return idents.Count; }
+ }
+
+ public void Insert(int pos, ident el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ idents.Insert(pos,el);
+ if (el != null)
+ el.Parent = this;
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ ident_list copy = new ident_list();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (idents != null)
+ {
+ foreach (ident elem in idents)
+ {
+ if (elem != null)
+ {
+ copy.Add((ident)elem.Clone());
+ copy.Last().Parent = copy;
+ }
+ else
+ copy.Add(null);
+ }
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new ident_list TypedClone()
+ {
+ return Clone() as ident_list;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (idents != null)
+ {
+ foreach (var child in idents)
+ if (child != null)
+ child.Parent = this;
+ }
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ if (idents != null)
+ {
+ foreach (var child in idents)
+ child?.FillParentsInAllChilds();
+ }
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 0 + (idents == null ? 0 : idents.Count);
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ Int32 index_counter=ind - 0;
+ if(idents != null)
+ {
+ if(index_counter < idents.Count)
+ {
+ return idents[index_counter];
+ }
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ Int32 index_counter=ind - 0;
+ if(idents != null)
+ {
+ if(index_counter < idents.Count)
+ {
+ idents[index_counter]= (ident)value;
+ return;
+ }
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Описание переменных одной строкой. Не содержит var, т.к. встречается исключительно внутри другой конструкции. Может встречаться как до beginа (внутри variable_definitions), так и как внутриблочное описание (внутри var_statement).
+
+ ///
+ [Serializable]
+ public partial class var_def_statement : declaration
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public var_def_statement()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public var_def_statement(ident_list _vars,type_definition _vars_type,expression _inital_value,definition_attribute _var_attr,bool _is_event)
+ {
+ this._vars=_vars;
+ this._vars_type=_vars_type;
+ this._inital_value=_inital_value;
+ this._var_attr=_var_attr;
+ this._is_event=_is_event;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public var_def_statement(ident_list _vars,type_definition _vars_type,expression _inital_value,definition_attribute _var_attr,bool _is_event,SourceContext sc)
+ {
+ this._vars=_vars;
+ this._vars_type=_vars_type;
+ this._inital_value=_inital_value;
+ this._var_attr=_var_attr;
+ this._is_event=_is_event;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected ident_list _vars;
+ protected type_definition _vars_type;
+ protected expression _inital_value;
+ protected definition_attribute _var_attr;
+ protected bool _is_event;
+
+ ///
+ ///Список имен переменных
+ ///
+ public ident_list vars
+ {
+ get
+ {
+ return _vars;
+ }
+ set
+ {
+ _vars=value;
+ if (_vars != null)
+ _vars.Parent = this;
+ }
+ }
+
+ ///
+ ///Тип переменных
+ ///
+ public type_definition vars_type
+ {
+ get
+ {
+ return _vars_type;
+ }
+ set
+ {
+ _vars_type=value;
+ if (_vars_type != null)
+ _vars_type.Parent = this;
+ }
+ }
+
+ ///
+ ///Начальное значение переменных
+ ///
+ public expression inital_value
+ {
+ get
+ {
+ return _inital_value;
+ }
+ set
+ {
+ _inital_value=value;
+ if (_inital_value != null)
+ _inital_value.Parent = this;
+ }
+ }
+
+ ///
+ ///
+ ///
+ public definition_attribute var_attr
+ {
+ get
+ {
+ return _var_attr;
+ }
+ set
+ {
+ _var_attr=value;
+ }
+ }
+
+ ///
+ ///Являются ли переменные событиями
+ ///
+ public bool is_event
+ {
+ get
+ {
+ return _is_event;
+ }
+ set
+ {
+ _is_event=value;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ var_def_statement copy = new var_def_statement();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (vars != null)
+ {
+ copy.vars = (ident_list)vars.Clone();
+ copy.vars.Parent = copy;
+ }
+ if (vars_type != null)
+ {
+ copy.vars_type = (type_definition)vars_type.Clone();
+ copy.vars_type.Parent = copy;
+ }
+ if (inital_value != null)
+ {
+ copy.inital_value = (expression)inital_value.Clone();
+ copy.inital_value.Parent = copy;
+ }
+ copy.var_attr = var_attr;
+ copy.is_event = is_event;
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new var_def_statement TypedClone()
+ {
+ return Clone() as var_def_statement;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (vars != null)
+ vars.Parent = this;
+ if (vars_type != null)
+ vars_type.Parent = this;
+ if (inital_value != null)
+ inital_value.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ vars?.FillParentsInAllChilds();
+ vars_type?.FillParentsInAllChilds();
+ inital_value?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 3;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 3;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return vars;
+ case 1:
+ return vars_type;
+ case 2:
+ return inital_value;
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ vars = (ident_list)value;
+ break;
+ case 1:
+ vars_type = (type_definition)value;
+ break;
+ case 2:
+ inital_value = (expression)value;
+ break;
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Описание
+ ///
+ [Serializable]
+ public partial class declaration : syntax_tree_node
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public declaration()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public declaration(attribute_list _attributes)
+ {
+ this._attributes=_attributes;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public declaration(attribute_list _attributes,SourceContext sc)
+ {
+ this._attributes=_attributes;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected attribute_list _attributes;
+
+ ///
+ ///Список атрибутов описания
+ ///
+ public attribute_list attributes
+ {
+ get
+ {
+ return _attributes;
+ }
+ set
+ {
+ _attributes=value;
+ if (_attributes != null)
+ _attributes.Parent = this;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ declaration copy = new declaration();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new declaration TypedClone()
+ {
+ return Clone() as declaration;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 1;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 1;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return attributes;
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ attributes = (attribute_list)value;
+ break;
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Список описаний
+ ///
+ [Serializable]
+ public partial class declarations : syntax_tree_node
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public declarations()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public declarations(List _defs)
+ {
+ this._defs=_defs;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public declarations(List _defs,SourceContext sc)
+ {
+ this._defs=_defs;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ public declarations(declaration elem, SourceContext sc = null)
+ {
+ Add(elem, sc);
+ FillParentsInDirectChilds();
+ }
+
+ protected List _defs=new List();
+
+ ///
+ ///Список описаний
+ ///
+ public List defs
+ {
+ get
+ {
+ return _defs;
+ }
+ set
+ {
+ _defs=value;
+ }
+ }
+
+
+ public declarations Add(declaration elem, SourceContext sc = null)
+ {
+ defs.Add(elem);
+ if (elem != null)
+ elem.Parent = this;
+ if (sc != null)
+ source_context = sc;
+ return this;
+ }
+
+ public void AddFirst(declaration el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ defs.Insert(0, el);
+ FillParentsInDirectChilds();
+ }
+
+ public void AddFirst(IEnumerable els)
+ {
+ if (els == null)
+ throw new ArgumentNullException(nameof(els));
+ defs.InsertRange(0, els);
+ foreach (var el in els)
+ if (el != null)
+ el.Parent = this;
+ }
+
+ public void AddMany(params declaration[] els)
+ {
+ if (els == null)
+ throw new ArgumentNullException(nameof(els));
+ defs.AddRange(els);
+ foreach (var el in els)
+ if (el != null)
+ el.Parent = this;
+ }
+
+ private int FindIndexInList(declaration el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ var ind = defs.FindIndex(x => x == el);
+ if (ind == -1)
+ throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el));
+ return ind;
+ }
+
+ public void InsertAfter(declaration el, declaration newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ defs.Insert(FindIndexInList(el) + 1, newel);
+ newel.Parent = this;
+ }
+
+ public void InsertAfter(declaration el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ defs.InsertRange(FindIndexInList(el) + 1, newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public void InsertBefore(declaration el, declaration newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ defs.Insert(FindIndexInList(el), newel);
+ newel.Parent = this;
+ }
+
+ public void InsertBefore(declaration el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ defs.InsertRange(FindIndexInList(el), newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public bool Remove(declaration el)
+ {
+ return defs.Remove(el);
+ }
+
+ public void ReplaceInList(declaration el, declaration newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ defs[FindIndexInList(el)] = newel;
+ newel.Parent = this;
+ }
+
+ public void ReplaceInList(declaration el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ var ind = FindIndexInList(el);
+ defs.RemoveAt(ind);
+ defs.InsertRange(ind, newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public int RemoveAll(Predicate match)
+ {
+ return defs.RemoveAll(match);
+ }
+
+ public declaration Last()
+ {
+ if (defs.Count > 0)
+ return defs[defs.Count - 1];
+ throw new InvalidOperationException("Список пуст");
+ }
+
+ public int Count
+ {
+ get { return defs.Count; }
+ }
+
+ public void Insert(int pos, declaration el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ defs.Insert(pos,el);
+ if (el != null)
+ el.Parent = this;
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ declarations copy = new declarations();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (defs != null)
+ {
+ foreach (declaration elem in defs)
+ {
+ if (elem != null)
+ {
+ copy.Add((declaration)elem.Clone());
+ copy.Last().Parent = copy;
+ }
+ else
+ copy.Add(null);
+ }
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new declarations TypedClone()
+ {
+ return Clone() as declarations;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (defs != null)
+ {
+ foreach (var child in defs)
+ if (child != null)
+ child.Parent = this;
+ }
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ if (defs != null)
+ {
+ foreach (var child in defs)
+ child?.FillParentsInAllChilds();
+ }
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 0 + (defs == null ? 0 : defs.Count);
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ Int32 index_counter=ind - 0;
+ if(defs != null)
+ {
+ if(index_counter < defs.Count)
+ {
+ return defs[index_counter];
+ }
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ Int32 index_counter=ind - 0;
+ if(defs != null)
+ {
+ if(index_counter < defs.Count)
+ {
+ defs[index_counter]= (declaration)value;
+ return;
+ }
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///
+ ///
+ [Serializable]
+ public partial class program_tree : syntax_tree_node
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public program_tree()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public program_tree(List _compilation_units)
+ {
+ this._compilation_units=_compilation_units;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public program_tree(List _compilation_units,SourceContext sc)
+ {
+ this._compilation_units=_compilation_units;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ public program_tree(compilation_unit elem, SourceContext sc = null)
+ {
+ Add(elem, sc);
+ FillParentsInDirectChilds();
+ }
+
+ protected List _compilation_units=new List();
+
+ ///
+ ///Список подключенных модулей
+ ///
+ public List compilation_units
+ {
+ get
+ {
+ return _compilation_units;
+ }
+ set
+ {
+ _compilation_units=value;
+ }
+ }
+
+
+ public program_tree Add(compilation_unit elem, SourceContext sc = null)
+ {
+ compilation_units.Add(elem);
+ if (elem != null)
+ elem.Parent = this;
+ if (sc != null)
+ source_context = sc;
+ return this;
+ }
+
+ public void AddFirst(compilation_unit el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ compilation_units.Insert(0, el);
+ FillParentsInDirectChilds();
+ }
+
+ public void AddFirst(IEnumerable els)
+ {
+ if (els == null)
+ throw new ArgumentNullException(nameof(els));
+ compilation_units.InsertRange(0, els);
+ foreach (var el in els)
+ if (el != null)
+ el.Parent = this;
+ }
+
+ public void AddMany(params compilation_unit[] els)
+ {
+ if (els == null)
+ throw new ArgumentNullException(nameof(els));
+ compilation_units.AddRange(els);
+ foreach (var el in els)
+ if (el != null)
+ el.Parent = this;
+ }
+
+ private int FindIndexInList(compilation_unit el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ var ind = compilation_units.FindIndex(x => x == el);
+ if (ind == -1)
+ throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el));
+ return ind;
+ }
+
+ public void InsertAfter(compilation_unit el, compilation_unit newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ compilation_units.Insert(FindIndexInList(el) + 1, newel);
+ newel.Parent = this;
+ }
+
+ public void InsertAfter(compilation_unit el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ compilation_units.InsertRange(FindIndexInList(el) + 1, newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public void InsertBefore(compilation_unit el, compilation_unit newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ compilation_units.Insert(FindIndexInList(el), newel);
+ newel.Parent = this;
+ }
+
+ public void InsertBefore(compilation_unit el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ compilation_units.InsertRange(FindIndexInList(el), newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public bool Remove(compilation_unit el)
+ {
+ return compilation_units.Remove(el);
+ }
+
+ public void ReplaceInList(compilation_unit el, compilation_unit newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ compilation_units[FindIndexInList(el)] = newel;
+ newel.Parent = this;
+ }
+
+ public void ReplaceInList(compilation_unit el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ var ind = FindIndexInList(el);
+ compilation_units.RemoveAt(ind);
+ compilation_units.InsertRange(ind, newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public int RemoveAll(Predicate match)
+ {
+ return compilation_units.RemoveAll(match);
+ }
+
+ public compilation_unit Last()
+ {
+ if (compilation_units.Count > 0)
+ return compilation_units[compilation_units.Count - 1];
+ throw new InvalidOperationException("Список пуст");
+ }
+
+ public int Count
+ {
+ get { return compilation_units.Count; }
+ }
+
+ public void Insert(int pos, compilation_unit el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ compilation_units.Insert(pos,el);
+ if (el != null)
+ el.Parent = this;
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ program_tree copy = new program_tree();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (compilation_units != null)
+ {
+ foreach (compilation_unit elem in compilation_units)
+ {
+ if (elem != null)
+ {
+ copy.Add((compilation_unit)elem.Clone());
+ copy.Last().Parent = copy;
+ }
+ else
+ copy.Add(null);
+ }
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new program_tree TypedClone()
+ {
+ return Clone() as program_tree;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (compilation_units != null)
+ {
+ foreach (var child in compilation_units)
+ if (child != null)
+ child.Parent = this;
+ }
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ if (compilation_units != null)
+ {
+ foreach (var child in compilation_units)
+ child?.FillParentsInAllChilds();
+ }
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 0 + (compilation_units == null ? 0 : compilation_units.Count);
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ Int32 index_counter=ind - 0;
+ if(compilation_units != null)
+ {
+ if(index_counter < compilation_units.Count)
+ {
+ return compilation_units[index_counter];
+ }
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ Int32 index_counter=ind - 0;
+ if(compilation_units != null)
+ {
+ if(index_counter < compilation_units.Count)
+ {
+ compilation_units[index_counter]= (compilation_unit)value;
+ return;
+ }
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Имя программы
+ ///
+ [Serializable]
+ public partial class program_name : syntax_tree_node
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public program_name()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public program_name(ident _prog_name)
+ {
+ this._prog_name=_prog_name;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public program_name(ident _prog_name,SourceContext sc)
+ {
+ this._prog_name=_prog_name;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected ident _prog_name;
+
+ ///
+ ///Идентификатор - имя программы
+ ///
+ public ident prog_name
+ {
+ get
+ {
+ return _prog_name;
+ }
+ set
+ {
+ _prog_name=value;
+ if (_prog_name != null)
+ _prog_name.Parent = this;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ program_name copy = new program_name();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (prog_name != null)
+ {
+ copy.prog_name = (ident)prog_name.Clone();
+ copy.prog_name.Parent = copy;
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new program_name TypedClone()
+ {
+ return Clone() as program_name;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (prog_name != null)
+ prog_name.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ prog_name?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 1;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 1;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return prog_name;
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ prog_name = (ident)value;
+ break;
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Строковая константа
+ ///
+ [Serializable]
+ public partial class string_const : literal
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public string_const()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public string_const(string _Value)
+ {
+ this._Value=_Value;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public string_const(string _Value,SourceContext sc)
+ {
+ this._Value=_Value;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected string _Value;
+
+ ///
+ ///Значенеи строковой константы
+ ///
+ public string Value
+ {
+ get
+ {
+ return _Value;
+ }
+ set
+ {
+ _Value=value;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ string_const copy = new string_const();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ copy.Value = Value;
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new string_const TypedClone()
+ {
+ return Clone() as string_const;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Список выражений
+ ///
+ [Serializable]
+ public partial class expression_list : syntax_tree_node
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public expression_list()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public expression_list(List _expressions)
+ {
+ this._expressions=_expressions;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public expression_list(List _expressions,SourceContext sc)
+ {
+ this._expressions=_expressions;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ public expression_list(expression elem, SourceContext sc = null)
+ {
+ Add(elem, sc);
+ FillParentsInDirectChilds();
+ }
+
+ protected List _expressions=new List();
+
+ ///
+ ///Список выражений
+ ///
+ public List expressions
+ {
+ get
+ {
+ return _expressions;
+ }
+ set
+ {
+ _expressions=value;
+ }
+ }
+
+
+ public expression_list Add(expression elem, SourceContext sc = null)
+ {
+ expressions.Add(elem);
+ if (elem != null)
+ elem.Parent = this;
+ if (sc != null)
+ source_context = sc;
+ return this;
+ }
+
+ public void AddFirst(expression el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ expressions.Insert(0, el);
+ FillParentsInDirectChilds();
+ }
+
+ public void AddFirst(IEnumerable els)
+ {
+ if (els == null)
+ throw new ArgumentNullException(nameof(els));
+ expressions.InsertRange(0, els);
+ foreach (var el in els)
+ if (el != null)
+ el.Parent = this;
+ }
+
+ public void AddMany(params expression[] els)
+ {
+ if (els == null)
+ throw new ArgumentNullException(nameof(els));
+ expressions.AddRange(els);
+ foreach (var el in els)
+ if (el != null)
+ el.Parent = this;
+ }
+
+ private int FindIndexInList(expression el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ var ind = expressions.FindIndex(x => x == el);
+ if (ind == -1)
+ throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el));
+ return ind;
+ }
+
+ public void InsertAfter(expression el, expression newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ expressions.Insert(FindIndexInList(el) + 1, newel);
+ newel.Parent = this;
+ }
+
+ public void InsertAfter(expression el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ expressions.InsertRange(FindIndexInList(el) + 1, newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public void InsertBefore(expression el, expression newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ expressions.Insert(FindIndexInList(el), newel);
+ newel.Parent = this;
+ }
+
+ public void InsertBefore(expression el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ expressions.InsertRange(FindIndexInList(el), newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public bool Remove(expression el)
+ {
+ return expressions.Remove(el);
+ }
+
+ public void ReplaceInList(expression el, expression newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ expressions[FindIndexInList(el)] = newel;
+ newel.Parent = this;
+ }
+
+ public void ReplaceInList(expression el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ var ind = FindIndexInList(el);
+ expressions.RemoveAt(ind);
+ expressions.InsertRange(ind, newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public int RemoveAll(Predicate match)
+ {
+ return expressions.RemoveAll(match);
+ }
+
+ public expression Last()
+ {
+ if (expressions.Count > 0)
+ return expressions[expressions.Count - 1];
+ throw new InvalidOperationException("Список пуст");
+ }
+
+ public int Count
+ {
+ get { return expressions.Count; }
+ }
+
+ public void Insert(int pos, expression el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ expressions.Insert(pos,el);
+ if (el != null)
+ el.Parent = this;
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ expression_list copy = new expression_list();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (expressions != null)
+ {
+ foreach (expression elem in expressions)
+ {
+ if (elem != null)
+ {
+ copy.Add((expression)elem.Clone());
+ copy.Last().Parent = copy;
+ }
+ else
+ copy.Add(null);
+ }
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new expression_list TypedClone()
+ {
+ return Clone() as expression_list;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (expressions != null)
+ {
+ foreach (var child in expressions)
+ if (child != null)
+ child.Parent = this;
+ }
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ if (expressions != null)
+ {
+ foreach (var child in expressions)
+ child?.FillParentsInAllChilds();
+ }
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 0 + (expressions == null ? 0 : expressions.Count);
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ Int32 index_counter=ind - 0;
+ if(expressions != null)
+ {
+ if(index_counter < expressions.Count)
+ {
+ return expressions[index_counter];
+ }
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ Int32 index_counter=ind - 0;
+ if(expressions != null)
+ {
+ if(index_counter < expressions.Count)
+ {
+ expressions[index_counter]= (expression)value;
+ return;
+ }
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///
+ ///
+ [Serializable]
+ public partial class dereference : addressed_value_funcname
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public dereference()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public dereference(addressed_value _dereferencing_value)
+ {
+ this._dereferencing_value=_dereferencing_value;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public dereference(addressed_value _dereferencing_value,SourceContext sc)
+ {
+ this._dereferencing_value=_dereferencing_value;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected addressed_value _dereferencing_value;
+
+ ///
+ ///
+ ///
+ public addressed_value dereferencing_value
+ {
+ get
+ {
+ return _dereferencing_value;
+ }
+ set
+ {
+ _dereferencing_value=value;
+ if (_dereferencing_value != null)
+ _dereferencing_value.Parent = this;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ dereference copy = new dereference();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (dereferencing_value != null)
+ {
+ copy.dereferencing_value = (addressed_value)dereferencing_value.Clone();
+ copy.dereferencing_value.Parent = copy;
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new dereference TypedClone()
+ {
+ return Clone() as dereference;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (dereferencing_value != null)
+ dereferencing_value.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ dereferencing_value?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 1;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 1;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return dereferencing_value;
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ dereferencing_value = (addressed_value)value;
+ break;
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Индекс или индексы
+ ///
+ [Serializable]
+ public partial class indexer : dereference
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public indexer()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public indexer(expression_list _indexes)
+ {
+ this._indexes=_indexes;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public indexer(expression_list _indexes,SourceContext sc)
+ {
+ this._indexes=_indexes;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public indexer(addressed_value _dereferencing_value,expression_list _indexes)
+ {
+ this._dereferencing_value=_dereferencing_value;
+ this._indexes=_indexes;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public indexer(addressed_value _dereferencing_value,expression_list _indexes,SourceContext sc)
+ {
+ this._dereferencing_value=_dereferencing_value;
+ this._indexes=_indexes;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected expression_list _indexes;
+
+ ///
+ ///Список индексов
+ ///
+ public expression_list indexes
+ {
+ get
+ {
+ return _indexes;
+ }
+ set
+ {
+ _indexes=value;
+ if (_indexes != null)
+ _indexes.Parent = this;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ indexer copy = new indexer();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (dereferencing_value != null)
+ {
+ copy.dereferencing_value = (addressed_value)dereferencing_value.Clone();
+ copy.dereferencing_value.Parent = copy;
+ }
+ if (indexes != null)
+ {
+ copy.indexes = (expression_list)indexes.Clone();
+ copy.indexes.Parent = copy;
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new indexer TypedClone()
+ {
+ return Clone() as indexer;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (dereferencing_value != null)
+ dereferencing_value.Parent = this;
+ if (indexes != null)
+ indexes.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ dereferencing_value?.FillParentsInAllChilds();
+ indexes?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 2;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 2;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return dereferencing_value;
+ case 1:
+ return indexes;
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ dereferencing_value = (addressed_value)value;
+ break;
+ case 1:
+ indexes = (expression_list)value;
+ break;
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Цикл for
+ ///
+ [Serializable]
+ public partial class for_node : statement
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public for_node()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public for_node(ident _loop_variable,expression _initial_value,expression _finish_value,statement _statements,for_cycle_type _cycle_type,expression _increment_value,type_definition _type_name,bool _create_loop_variable)
+ {
+ this._loop_variable=_loop_variable;
+ this._initial_value=_initial_value;
+ this._finish_value=_finish_value;
+ this._statements=_statements;
+ this._cycle_type=_cycle_type;
+ this._increment_value=_increment_value;
+ this._type_name=_type_name;
+ this._create_loop_variable=_create_loop_variable;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public for_node(ident _loop_variable,expression _initial_value,expression _finish_value,statement _statements,for_cycle_type _cycle_type,expression _increment_value,type_definition _type_name,bool _create_loop_variable,SourceContext sc)
+ {
+ this._loop_variable=_loop_variable;
+ this._initial_value=_initial_value;
+ this._finish_value=_finish_value;
+ this._statements=_statements;
+ this._cycle_type=_cycle_type;
+ this._increment_value=_increment_value;
+ this._type_name=_type_name;
+ this._create_loop_variable=_create_loop_variable;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected ident _loop_variable;
+ protected expression _initial_value;
+ protected expression _finish_value;
+ protected statement _statements;
+ protected for_cycle_type _cycle_type;
+ protected expression _increment_value;
+ protected type_definition _type_name;
+ protected bool _create_loop_variable;
+
+ ///
+ ///Переменная цикла for
+ ///
+ public ident loop_variable
+ {
+ get
+ {
+ return _loop_variable;
+ }
+ set
+ {
+ _loop_variable=value;
+ if (_loop_variable != null)
+ _loop_variable.Parent = this;
+ }
+ }
+
+ ///
+ ///Начальное значение переменной цикла
+ ///
+ public expression initial_value
+ {
+ get
+ {
+ return _initial_value;
+ }
+ set
+ {
+ _initial_value=value;
+ if (_initial_value != null)
+ _initial_value.Parent = this;
+ }
+ }
+
+ ///
+ ///Конечное значение переменной цикла
+ ///
+ public expression finish_value
+ {
+ get
+ {
+ return _finish_value;
+ }
+ set
+ {
+ _finish_value=value;
+ if (_finish_value != null)
+ _finish_value.Parent = this;
+ }
+ }
+
+ ///
+ ///Тело цикла
+ ///
+ public statement statements
+ {
+ get
+ {
+ return _statements;
+ }
+ set
+ {
+ _statements=value;
+ if (_statements != null)
+ _statements.Parent = this;
+ }
+ }
+
+ ///
+ ///
+ ///
+ public for_cycle_type cycle_type
+ {
+ get
+ {
+ return _cycle_type;
+ }
+ set
+ {
+ _cycle_type=value;
+ }
+ }
+
+ ///
+ ///Шаг переменной цикла
+ ///
+ public expression increment_value
+ {
+ get
+ {
+ return _increment_value;
+ }
+ set
+ {
+ _increment_value=value;
+ if (_increment_value != null)
+ _increment_value.Parent = this;
+ }
+ }
+
+ ///
+ ///
+ ///
+ public type_definition type_name
+ {
+ get
+ {
+ return _type_name;
+ }
+ set
+ {
+ _type_name=value;
+ if (_type_name != null)
+ _type_name.Parent = this;
+ }
+ }
+
+ ///
+ ///
+ ///
+ public bool create_loop_variable
+ {
+ get
+ {
+ return _create_loop_variable;
+ }
+ set
+ {
+ _create_loop_variable=value;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ for_node copy = new for_node();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (loop_variable != null)
+ {
+ copy.loop_variable = (ident)loop_variable.Clone();
+ copy.loop_variable.Parent = copy;
+ }
+ if (initial_value != null)
+ {
+ copy.initial_value = (expression)initial_value.Clone();
+ copy.initial_value.Parent = copy;
+ }
+ if (finish_value != null)
+ {
+ copy.finish_value = (expression)finish_value.Clone();
+ copy.finish_value.Parent = copy;
+ }
+ if (statements != null)
+ {
+ copy.statements = (statement)statements.Clone();
+ copy.statements.Parent = copy;
+ }
+ copy.cycle_type = cycle_type;
+ if (increment_value != null)
+ {
+ copy.increment_value = (expression)increment_value.Clone();
+ copy.increment_value.Parent = copy;
+ }
+ if (type_name != null)
+ {
+ copy.type_name = (type_definition)type_name.Clone();
+ copy.type_name.Parent = copy;
+ }
+ copy.create_loop_variable = create_loop_variable;
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new for_node TypedClone()
+ {
+ return Clone() as for_node;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (loop_variable != null)
+ loop_variable.Parent = this;
+ if (initial_value != null)
+ initial_value.Parent = this;
+ if (finish_value != null)
+ finish_value.Parent = this;
+ if (statements != null)
+ statements.Parent = this;
+ if (increment_value != null)
+ increment_value.Parent = this;
+ if (type_name != null)
+ type_name.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ loop_variable?.FillParentsInAllChilds();
+ initial_value?.FillParentsInAllChilds();
+ finish_value?.FillParentsInAllChilds();
+ statements?.FillParentsInAllChilds();
+ increment_value?.FillParentsInAllChilds();
+ type_name?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 6;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 6;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return loop_variable;
+ case 1:
+ return initial_value;
+ case 2:
+ return finish_value;
+ case 3:
+ return statements;
+ case 4:
+ return increment_value;
+ case 5:
+ return type_name;
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ loop_variable = (ident)value;
+ break;
+ case 1:
+ initial_value = (expression)value;
+ break;
+ case 2:
+ finish_value = (expression)value;
+ break;
+ case 3:
+ statements = (statement)value;
+ break;
+ case 4:
+ increment_value = (expression)value;
+ break;
+ case 5:
+ type_name = (type_definition)value;
+ break;
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Цикл с постусловием (repeat)
+ ///
+ [Serializable]
+ public partial class repeat_node : statement
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public repeat_node()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public repeat_node(statement _statements,expression _expr)
+ {
+ this._statements=_statements;
+ this._expr=_expr;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public repeat_node(statement _statements,expression _expr,SourceContext sc)
+ {
+ this._statements=_statements;
+ this._expr=_expr;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected statement _statements;
+ protected expression _expr;
+
+ ///
+ ///Тело цикла
+ ///
+ public statement statements
+ {
+ get
+ {
+ return _statements;
+ }
+ set
+ {
+ _statements=value;
+ if (_statements != null)
+ _statements.Parent = this;
+ }
+ }
+
+ ///
+ ///Условие завершения цикла
+ ///
+ public expression expr
+ {
+ get
+ {
+ return _expr;
+ }
+ set
+ {
+ _expr=value;
+ if (_expr != null)
+ _expr.Parent = this;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ repeat_node copy = new repeat_node();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (statements != null)
+ {
+ copy.statements = (statement)statements.Clone();
+ copy.statements.Parent = copy;
+ }
+ if (expr != null)
+ {
+ copy.expr = (expression)expr.Clone();
+ copy.expr.Parent = copy;
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new repeat_node TypedClone()
+ {
+ return Clone() as repeat_node;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (statements != null)
+ statements.Parent = this;
+ if (expr != null)
+ expr.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ statements?.FillParentsInAllChilds();
+ expr?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 2;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 2;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return statements;
+ case 1:
+ return expr;
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ statements = (statement)value;
+ break;
+ case 1:
+ expr = (expression)value;
+ break;
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Цикл ПОКА
+ ///
+ [Serializable]
+ public partial class while_node : statement
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public while_node()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public while_node(expression _expr,statement _statements,WhileCycleType _CycleType)
+ {
+ this._expr=_expr;
+ this._statements=_statements;
+ this._CycleType=_CycleType;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public while_node(expression _expr,statement _statements,WhileCycleType _CycleType,SourceContext sc)
+ {
+ this._expr=_expr;
+ this._statements=_statements;
+ this._CycleType=_CycleType;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected expression _expr;
+ protected statement _statements;
+ protected WhileCycleType _CycleType;
+
+ ///
+ ///Условие цикла
+ ///
+ public expression expr
+ {
+ get
+ {
+ return _expr;
+ }
+ set
+ {
+ _expr=value;
+ if (_expr != null)
+ _expr.Parent = this;
+ }
+ }
+
+ ///
+ ///Тело цикла
+ ///
+ public statement statements
+ {
+ get
+ {
+ return _statements;
+ }
+ set
+ {
+ _statements=value;
+ if (_statements != null)
+ _statements.Parent = this;
+ }
+ }
+
+ ///
+ ///Тип цикла ПОКА
+ ///
+ public WhileCycleType CycleType
+ {
+ get
+ {
+ return _CycleType;
+ }
+ set
+ {
+ _CycleType=value;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ while_node copy = new while_node();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (expr != null)
+ {
+ copy.expr = (expression)expr.Clone();
+ copy.expr.Parent = copy;
+ }
+ if (statements != null)
+ {
+ copy.statements = (statement)statements.Clone();
+ copy.statements.Parent = copy;
+ }
+ copy.CycleType = CycleType;
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new while_node TypedClone()
+ {
+ return Clone() as while_node;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (expr != null)
+ expr.Parent = this;
+ if (statements != null)
+ statements.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ expr?.FillParentsInAllChilds();
+ statements?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 2;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 2;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return expr;
+ case 1:
+ return statements;
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ expr = (expression)value;
+ break;
+ case 1:
+ statements = (statement)value;
+ break;
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Условный оператор
+ ///
+ [Serializable]
+ public partial class if_node : statement
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public if_node()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public if_node(expression _condition,statement _then_body,statement _else_body)
+ {
+ this._condition=_condition;
+ this._then_body=_then_body;
+ this._else_body=_else_body;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public if_node(expression _condition,statement _then_body,statement _else_body,SourceContext sc)
+ {
+ this._condition=_condition;
+ this._then_body=_then_body;
+ this._else_body=_else_body;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected expression _condition;
+ protected statement _then_body;
+ protected statement _else_body;
+
+ ///
+ ///Условие
+ ///
+ public expression condition
+ {
+ get
+ {
+ return _condition;
+ }
+ set
+ {
+ _condition=value;
+ if (_condition != null)
+ _condition.Parent = this;
+ }
+ }
+
+ ///
+ ///Оператор по ветви then
+ ///
+ public statement then_body
+ {
+ get
+ {
+ return _then_body;
+ }
+ set
+ {
+ _then_body=value;
+ if (_then_body != null)
+ _then_body.Parent = this;
+ }
+ }
+
+ ///
+ ///Оператор по ветви else
+ ///
+ public statement else_body
+ {
+ get
+ {
+ return _else_body;
+ }
+ set
+ {
+ _else_body=value;
+ if (_else_body != null)
+ _else_body.Parent = this;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ if_node copy = new if_node();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (condition != null)
+ {
+ copy.condition = (expression)condition.Clone();
+ copy.condition.Parent = copy;
+ }
+ if (then_body != null)
+ {
+ copy.then_body = (statement)then_body.Clone();
+ copy.then_body.Parent = copy;
+ }
+ if (else_body != null)
+ {
+ copy.else_body = (statement)else_body.Clone();
+ copy.else_body.Parent = copy;
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new if_node TypedClone()
+ {
+ return Clone() as if_node;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (condition != null)
+ condition.Parent = this;
+ if (then_body != null)
+ then_body.Parent = this;
+ if (else_body != null)
+ else_body.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ condition?.FillParentsInAllChilds();
+ then_body?.FillParentsInAllChilds();
+ else_body?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 3;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 3;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return condition;
+ case 1:
+ return then_body;
+ case 2:
+ return else_body;
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ condition = (expression)value;
+ break;
+ case 1:
+ then_body = (statement)value;
+ break;
+ case 2:
+ else_body = (statement)value;
+ break;
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///
+ ///
+ [Serializable]
+ public partial class ref_type : type_definition
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public ref_type()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public ref_type(type_definition _pointed_to)
+ {
+ this._pointed_to=_pointed_to;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public ref_type(type_definition _pointed_to,SourceContext sc)
+ {
+ this._pointed_to=_pointed_to;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public ref_type(type_definition_attr_list _attr_list,type_definition _pointed_to)
+ {
+ this._attr_list=_attr_list;
+ this._pointed_to=_pointed_to;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public ref_type(type_definition_attr_list _attr_list,type_definition _pointed_to,SourceContext sc)
+ {
+ this._attr_list=_attr_list;
+ this._pointed_to=_pointed_to;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected type_definition _pointed_to;
+
+ ///
+ ///
+ ///
+ public type_definition pointed_to
+ {
+ get
+ {
+ return _pointed_to;
+ }
+ set
+ {
+ _pointed_to=value;
+ if (_pointed_to != null)
+ _pointed_to.Parent = this;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ ref_type copy = new ref_type();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (attr_list != null)
+ {
+ copy.attr_list = (type_definition_attr_list)attr_list.Clone();
+ copy.attr_list.Parent = copy;
+ }
+ if (pointed_to != null)
+ {
+ copy.pointed_to = (type_definition)pointed_to.Clone();
+ copy.pointed_to.Parent = copy;
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new ref_type TypedClone()
+ {
+ return Clone() as ref_type;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (attr_list != null)
+ attr_list.Parent = this;
+ if (pointed_to != null)
+ pointed_to.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ attr_list?.FillParentsInAllChilds();
+ pointed_to?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 2;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 2;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return attr_list;
+ case 1:
+ return pointed_to;
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ attr_list = (type_definition_attr_list)value;
+ break;
+ case 1:
+ pointed_to = (type_definition)value;
+ break;
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Диапазон
+ ///
+ [Serializable]
+ public partial class diapason : type_definition
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public diapason()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public diapason(expression _left,expression _right)
+ {
+ this._left=_left;
+ this._right=_right;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public diapason(expression _left,expression _right,SourceContext sc)
+ {
+ this._left=_left;
+ this._right=_right;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public diapason(type_definition_attr_list _attr_list,expression _left,expression _right)
+ {
+ this._attr_list=_attr_list;
+ this._left=_left;
+ this._right=_right;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public diapason(type_definition_attr_list _attr_list,expression _left,expression _right,SourceContext sc)
+ {
+ this._attr_list=_attr_list;
+ this._left=_left;
+ this._right=_right;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected expression _left;
+ protected expression _right;
+
+ ///
+ ///Нижняя граница диапазона
+ ///
+ public expression left
+ {
+ get
+ {
+ return _left;
+ }
+ set
+ {
+ _left=value;
+ if (_left != null)
+ _left.Parent = this;
+ }
+ }
+
+ ///
+ ///Верхняя граница диапазона
+ ///
+ public expression right
+ {
+ get
+ {
+ return _right;
+ }
+ set
+ {
+ _right=value;
+ if (_right != null)
+ _right.Parent = this;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ diapason copy = new diapason();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (attr_list != null)
+ {
+ copy.attr_list = (type_definition_attr_list)attr_list.Clone();
+ copy.attr_list.Parent = copy;
+ }
+ if (left != null)
+ {
+ copy.left = (expression)left.Clone();
+ copy.left.Parent = copy;
+ }
+ if (right != null)
+ {
+ copy.right = (expression)right.Clone();
+ copy.right.Parent = copy;
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new diapason TypedClone()
+ {
+ return Clone() as diapason;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (attr_list != null)
+ attr_list.Parent = this;
+ if (left != null)
+ left.Parent = this;
+ if (right != null)
+ right.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ attr_list?.FillParentsInAllChilds();
+ left?.FillParentsInAllChilds();
+ right?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 3;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 3;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return attr_list;
+ case 1:
+ return left;
+ case 2:
+ return right;
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ attr_list = (type_definition_attr_list)value;
+ break;
+ case 1:
+ left = (expression)value;
+ break;
+ case 2:
+ right = (expression)value;
+ break;
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Типы индексов
+ ///
+ [Serializable]
+ public partial class indexers_types : type_definition
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public indexers_types()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public indexers_types(List _indexers)
+ {
+ this._indexers=_indexers;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public indexers_types(List _indexers,SourceContext sc)
+ {
+ this._indexers=_indexers;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public indexers_types(type_definition_attr_list _attr_list,List _indexers)
+ {
+ this._attr_list=_attr_list;
+ this._indexers=_indexers;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public indexers_types(type_definition_attr_list _attr_list,List _indexers,SourceContext sc)
+ {
+ this._attr_list=_attr_list;
+ this._indexers=_indexers;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ public indexers_types(type_definition elem, SourceContext sc = null)
+ {
+ Add(elem, sc);
+ FillParentsInDirectChilds();
+ }
+
+ protected List _indexers=new List();
+
+ ///
+ ///Список типов индексов
+ ///
+ public List indexers
+ {
+ get
+ {
+ return _indexers;
+ }
+ set
+ {
+ _indexers=value;
+ }
+ }
+
+
+ public indexers_types Add(type_definition elem, SourceContext sc = null)
+ {
+ indexers.Add(elem);
+ if (elem != null)
+ elem.Parent = this;
+ if (sc != null)
+ source_context = sc;
+ return this;
+ }
+
+ public void AddFirst(type_definition el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ indexers.Insert(0, el);
+ FillParentsInDirectChilds();
+ }
+
+ public void AddFirst(IEnumerable els)
+ {
+ if (els == null)
+ throw new ArgumentNullException(nameof(els));
+ indexers.InsertRange(0, els);
+ foreach (var el in els)
+ if (el != null)
+ el.Parent = this;
+ }
+
+ public void AddMany(params type_definition[] els)
+ {
+ if (els == null)
+ throw new ArgumentNullException(nameof(els));
+ indexers.AddRange(els);
+ foreach (var el in els)
+ if (el != null)
+ el.Parent = this;
+ }
+
+ private int FindIndexInList(type_definition el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ var ind = indexers.FindIndex(x => x == el);
+ if (ind == -1)
+ throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el));
+ return ind;
+ }
+
+ public void InsertAfter(type_definition el, type_definition newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ indexers.Insert(FindIndexInList(el) + 1, newel);
+ newel.Parent = this;
+ }
+
+ public void InsertAfter(type_definition el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ indexers.InsertRange(FindIndexInList(el) + 1, newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public void InsertBefore(type_definition el, type_definition newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ indexers.Insert(FindIndexInList(el), newel);
+ newel.Parent = this;
+ }
+
+ public void InsertBefore(type_definition el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ indexers.InsertRange(FindIndexInList(el), newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public bool Remove(type_definition el)
+ {
+ return indexers.Remove(el);
+ }
+
+ public void ReplaceInList(type_definition el, type_definition newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ indexers[FindIndexInList(el)] = newel;
+ newel.Parent = this;
+ }
+
+ public void ReplaceInList(type_definition el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ var ind = FindIndexInList(el);
+ indexers.RemoveAt(ind);
+ indexers.InsertRange(ind, newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public int RemoveAll(Predicate match)
+ {
+ return indexers.RemoveAll(match);
+ }
+
+ public type_definition Last()
+ {
+ if (indexers.Count > 0)
+ return indexers[indexers.Count - 1];
+ throw new InvalidOperationException("Список пуст");
+ }
+
+ public int Count
+ {
+ get { return indexers.Count; }
+ }
+
+ public void Insert(int pos, type_definition el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ indexers.Insert(pos,el);
+ if (el != null)
+ el.Parent = this;
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ indexers_types copy = new indexers_types();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (attr_list != null)
+ {
+ copy.attr_list = (type_definition_attr_list)attr_list.Clone();
+ copy.attr_list.Parent = copy;
+ }
+ if (indexers != null)
+ {
+ foreach (type_definition elem in indexers)
+ {
+ if (elem != null)
+ {
+ copy.Add((type_definition)elem.Clone());
+ copy.Last().Parent = copy;
+ }
+ else
+ copy.Add(null);
+ }
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new indexers_types TypedClone()
+ {
+ return Clone() as indexers_types;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (attr_list != null)
+ attr_list.Parent = this;
+ if (indexers != null)
+ {
+ foreach (var child in indexers)
+ if (child != null)
+ child.Parent = this;
+ }
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ attr_list?.FillParentsInAllChilds();
+ if (indexers != null)
+ {
+ foreach (var child in indexers)
+ child?.FillParentsInAllChilds();
+ }
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 1;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 1 + (indexers == null ? 0 : indexers.Count);
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return attr_list;
+ }
+ Int32 index_counter=ind - 1;
+ if(indexers != null)
+ {
+ if(index_counter < indexers.Count)
+ {
+ return indexers[index_counter];
+ }
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ attr_list = (type_definition_attr_list)value;
+ break;
+ }
+ Int32 index_counter=ind - 1;
+ if(indexers != null)
+ {
+ if(index_counter < indexers.Count)
+ {
+ indexers[index_counter]= (type_definition)value;
+ return;
+ }
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Тип массива
+ ///
+ [Serializable]
+ public partial class array_type : type_definition
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public array_type()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public array_type(indexers_types _indexers,type_definition _elements_type)
+ {
+ this._indexers=_indexers;
+ this._elements_type=_elements_type;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public array_type(indexers_types _indexers,type_definition _elements_type,SourceContext sc)
+ {
+ this._indexers=_indexers;
+ this._elements_type=_elements_type;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public array_type(type_definition_attr_list _attr_list,indexers_types _indexers,type_definition _elements_type)
+ {
+ this._attr_list=_attr_list;
+ this._indexers=_indexers;
+ this._elements_type=_elements_type;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public array_type(type_definition_attr_list _attr_list,indexers_types _indexers,type_definition _elements_type,SourceContext sc)
+ {
+ this._attr_list=_attr_list;
+ this._indexers=_indexers;
+ this._elements_type=_elements_type;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected indexers_types _indexers;
+ protected type_definition _elements_type;
+
+ ///
+ ///Типы индексов массива
+ ///
+ public indexers_types indexers
+ {
+ get
+ {
+ return _indexers;
+ }
+ set
+ {
+ _indexers=value;
+ if (_indexers != null)
+ _indexers.Parent = this;
+ }
+ }
+
+ ///
+ ///Тип элементов массива
+ ///
+ public type_definition elements_type
+ {
+ get
+ {
+ return _elements_type;
+ }
+ set
+ {
+ _elements_type=value;
+ if (_elements_type != null)
+ _elements_type.Parent = this;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ array_type copy = new array_type();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (attr_list != null)
+ {
+ copy.attr_list = (type_definition_attr_list)attr_list.Clone();
+ copy.attr_list.Parent = copy;
+ }
+ if (indexers != null)
+ {
+ copy.indexers = (indexers_types)indexers.Clone();
+ copy.indexers.Parent = copy;
+ }
+ if (elements_type != null)
+ {
+ copy.elements_type = (type_definition)elements_type.Clone();
+ copy.elements_type.Parent = copy;
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new array_type TypedClone()
+ {
+ return Clone() as array_type;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (attr_list != null)
+ attr_list.Parent = this;
+ if (indexers != null)
+ indexers.Parent = this;
+ if (elements_type != null)
+ elements_type.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ attr_list?.FillParentsInAllChilds();
+ indexers?.FillParentsInAllChilds();
+ elements_type?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 3;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 3;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return attr_list;
+ case 1:
+ return indexers;
+ case 2:
+ return elements_type;
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ attr_list = (type_definition_attr_list)value;
+ break;
+ case 1:
+ indexers = (indexers_types)value;
+ break;
+ case 2:
+ elements_type = (type_definition)value;
+ break;
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Описание меток
+ ///
+ [Serializable]
+ public partial class label_definitions : declaration
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public label_definitions()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public label_definitions(ident_list _labels)
+ {
+ this._labels=_labels;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public label_definitions(ident_list _labels,SourceContext sc)
+ {
+ this._labels=_labels;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected ident_list _labels;
+
+ ///
+ ///Список меток
+ ///
+ public ident_list labels
+ {
+ get
+ {
+ return _labels;
+ }
+ set
+ {
+ _labels=value;
+ if (_labels != null)
+ _labels.Parent = this;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ label_definitions copy = new label_definitions();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (labels != null)
+ {
+ copy.labels = (ident_list)labels.Clone();
+ copy.labels.Parent = copy;
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new label_definitions TypedClone()
+ {
+ return Clone() as label_definitions;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (labels != null)
+ labels.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ labels?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 1;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 1;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return labels;
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ labels = (ident_list)value;
+ break;
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///
+ ///
+ [Serializable]
+ public partial class procedure_attribute : ident
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public procedure_attribute()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public procedure_attribute(proc_attribute _attribute_type)
+ {
+ this._attribute_type=_attribute_type;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public procedure_attribute(proc_attribute _attribute_type,SourceContext sc)
+ {
+ this._attribute_type=_attribute_type;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public procedure_attribute(string _name,proc_attribute _attribute_type)
+ {
+ this._name=_name;
+ this._attribute_type=_attribute_type;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public procedure_attribute(string _name,proc_attribute _attribute_type,SourceContext sc)
+ {
+ this._name=_name;
+ this._attribute_type=_attribute_type;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected proc_attribute _attribute_type;
+
+ ///
+ ///
+ ///
+ public proc_attribute attribute_type
+ {
+ get
+ {
+ return _attribute_type;
+ }
+ set
+ {
+ _attribute_type=value;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ procedure_attribute copy = new procedure_attribute();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ copy.name = name;
+ copy.attribute_type = attribute_type;
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new procedure_attribute TypedClone()
+ {
+ return Clone() as procedure_attribute;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///
+ ///
+ [Serializable]
+ public partial class typed_parameters : declaration
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public typed_parameters()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public typed_parameters(ident_list _idents,type_definition _vars_type,parametr_kind _param_kind,expression _inital_value)
+ {
+ this._idents=_idents;
+ this._vars_type=_vars_type;
+ this._param_kind=_param_kind;
+ this._inital_value=_inital_value;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public typed_parameters(ident_list _idents,type_definition _vars_type,parametr_kind _param_kind,expression _inital_value,SourceContext sc)
+ {
+ this._idents=_idents;
+ this._vars_type=_vars_type;
+ this._param_kind=_param_kind;
+ this._inital_value=_inital_value;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected ident_list _idents;
+ protected type_definition _vars_type;
+ protected parametr_kind _param_kind;
+ protected expression _inital_value;
+
+ ///
+ ///
+ ///
+ public ident_list idents
+ {
+ get
+ {
+ return _idents;
+ }
+ set
+ {
+ _idents=value;
+ if (_idents != null)
+ _idents.Parent = this;
+ }
+ }
+
+ ///
+ ///
+ ///
+ public type_definition vars_type
+ {
+ get
+ {
+ return _vars_type;
+ }
+ set
+ {
+ _vars_type=value;
+ if (_vars_type != null)
+ _vars_type.Parent = this;
+ }
+ }
+
+ ///
+ ///
+ ///
+ public parametr_kind param_kind
+ {
+ get
+ {
+ return _param_kind;
+ }
+ set
+ {
+ _param_kind=value;
+ }
+ }
+
+ ///
+ ///
+ ///
+ public expression inital_value
+ {
+ get
+ {
+ return _inital_value;
+ }
+ set
+ {
+ _inital_value=value;
+ if (_inital_value != null)
+ _inital_value.Parent = this;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ typed_parameters copy = new typed_parameters();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (idents != null)
+ {
+ copy.idents = (ident_list)idents.Clone();
+ copy.idents.Parent = copy;
+ }
+ if (vars_type != null)
+ {
+ copy.vars_type = (type_definition)vars_type.Clone();
+ copy.vars_type.Parent = copy;
+ }
+ copy.param_kind = param_kind;
+ if (inital_value != null)
+ {
+ copy.inital_value = (expression)inital_value.Clone();
+ copy.inital_value.Parent = copy;
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new typed_parameters TypedClone()
+ {
+ return Clone() as typed_parameters;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (idents != null)
+ idents.Parent = this;
+ if (vars_type != null)
+ vars_type.Parent = this;
+ if (inital_value != null)
+ inital_value.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ idents?.FillParentsInAllChilds();
+ vars_type?.FillParentsInAllChilds();
+ inital_value?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 3;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 3;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return idents;
+ case 1:
+ return vars_type;
+ case 2:
+ return inital_value;
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ idents = (ident_list)value;
+ break;
+ case 1:
+ vars_type = (type_definition)value;
+ break;
+ case 2:
+ inital_value = (expression)value;
+ break;
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///
+ ///
+ [Serializable]
+ public partial class formal_parameters : syntax_tree_node
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public formal_parameters()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public formal_parameters(List _params_list)
+ {
+ this._params_list=_params_list;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public formal_parameters(List _params_list,SourceContext sc)
+ {
+ this._params_list=_params_list;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ public formal_parameters(typed_parameters elem, SourceContext sc = null)
+ {
+ Add(elem, sc);
+ FillParentsInDirectChilds();
+ }
+
+ protected List _params_list=new List();
+
+ ///
+ ///
+ ///
+ public List params_list
+ {
+ get
+ {
+ return _params_list;
+ }
+ set
+ {
+ _params_list=value;
+ }
+ }
+
+
+ public formal_parameters Add(typed_parameters elem, SourceContext sc = null)
+ {
+ params_list.Add(elem);
+ if (elem != null)
+ elem.Parent = this;
+ if (sc != null)
+ source_context = sc;
+ return this;
+ }
+
+ public void AddFirst(typed_parameters el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ params_list.Insert(0, el);
+ FillParentsInDirectChilds();
+ }
+
+ public void AddFirst(IEnumerable els)
+ {
+ if (els == null)
+ throw new ArgumentNullException(nameof(els));
+ params_list.InsertRange(0, els);
+ foreach (var el in els)
+ if (el != null)
+ el.Parent = this;
+ }
+
+ public void AddMany(params typed_parameters[] els)
+ {
+ if (els == null)
+ throw new ArgumentNullException(nameof(els));
+ params_list.AddRange(els);
+ foreach (var el in els)
+ if (el != null)
+ el.Parent = this;
+ }
+
+ private int FindIndexInList(typed_parameters el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ var ind = params_list.FindIndex(x => x == el);
+ if (ind == -1)
+ throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el));
+ return ind;
+ }
+
+ public void InsertAfter(typed_parameters el, typed_parameters newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ params_list.Insert(FindIndexInList(el) + 1, newel);
+ newel.Parent = this;
+ }
+
+ public void InsertAfter(typed_parameters el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ params_list.InsertRange(FindIndexInList(el) + 1, newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public void InsertBefore(typed_parameters el, typed_parameters newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ params_list.Insert(FindIndexInList(el), newel);
+ newel.Parent = this;
+ }
+
+ public void InsertBefore(typed_parameters el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ params_list.InsertRange(FindIndexInList(el), newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public bool Remove(typed_parameters el)
+ {
+ return params_list.Remove(el);
+ }
+
+ public void ReplaceInList(typed_parameters el, typed_parameters newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ params_list[FindIndexInList(el)] = newel;
+ newel.Parent = this;
+ }
+
+ public void ReplaceInList(typed_parameters el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ var ind = FindIndexInList(el);
+ params_list.RemoveAt(ind);
+ params_list.InsertRange(ind, newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public int RemoveAll(Predicate match)
+ {
+ return params_list.RemoveAll(match);
+ }
+
+ public typed_parameters Last()
+ {
+ if (params_list.Count > 0)
+ return params_list[params_list.Count - 1];
+ throw new InvalidOperationException("Список пуст");
+ }
+
+ public int Count
+ {
+ get { return params_list.Count; }
+ }
+
+ public void Insert(int pos, typed_parameters el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ params_list.Insert(pos,el);
+ if (el != null)
+ el.Parent = this;
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ formal_parameters copy = new formal_parameters();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (params_list != null)
+ {
+ foreach (typed_parameters elem in params_list)
+ {
+ if (elem != null)
+ {
+ copy.Add((typed_parameters)elem.Clone());
+ copy.Last().Parent = copy;
+ }
+ else
+ copy.Add(null);
+ }
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new formal_parameters TypedClone()
+ {
+ return Clone() as formal_parameters;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (params_list != null)
+ {
+ foreach (var child in params_list)
+ if (child != null)
+ child.Parent = this;
+ }
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ if (params_list != null)
+ {
+ foreach (var child in params_list)
+ child?.FillParentsInAllChilds();
+ }
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 0 + (params_list == null ? 0 : params_list.Count);
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ Int32 index_counter=ind - 0;
+ if(params_list != null)
+ {
+ if(index_counter < params_list.Count)
+ {
+ return params_list[index_counter];
+ }
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ Int32 index_counter=ind - 0;
+ if(params_list != null)
+ {
+ if(index_counter < params_list.Count)
+ {
+ params_list[index_counter]= (typed_parameters)value;
+ return;
+ }
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///
+ ///
+ [Serializable]
+ public partial class procedure_attributes_list : syntax_tree_node
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public procedure_attributes_list()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public procedure_attributes_list(List _proc_attributes)
+ {
+ this._proc_attributes=_proc_attributes;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public procedure_attributes_list(List _proc_attributes,SourceContext sc)
+ {
+ this._proc_attributes=_proc_attributes;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ public procedure_attributes_list(procedure_attribute elem, SourceContext sc = null)
+ {
+ Add(elem, sc);
+ FillParentsInDirectChilds();
+ }
+
+ protected List _proc_attributes=new List();
+
+ ///
+ ///
+ ///
+ public List proc_attributes
+ {
+ get
+ {
+ return _proc_attributes;
+ }
+ set
+ {
+ _proc_attributes=value;
+ }
+ }
+
+
+ public procedure_attributes_list Add(procedure_attribute elem, SourceContext sc = null)
+ {
+ proc_attributes.Add(elem);
+ if (elem != null)
+ elem.Parent = this;
+ if (sc != null)
+ source_context = sc;
+ return this;
+ }
+
+ public void AddFirst(procedure_attribute el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ proc_attributes.Insert(0, el);
+ FillParentsInDirectChilds();
+ }
+
+ public void AddFirst(IEnumerable els)
+ {
+ if (els == null)
+ throw new ArgumentNullException(nameof(els));
+ proc_attributes.InsertRange(0, els);
+ foreach (var el in els)
+ if (el != null)
+ el.Parent = this;
+ }
+
+ public void AddMany(params procedure_attribute[] els)
+ {
+ if (els == null)
+ throw new ArgumentNullException(nameof(els));
+ proc_attributes.AddRange(els);
+ foreach (var el in els)
+ if (el != null)
+ el.Parent = this;
+ }
+
+ private int FindIndexInList(procedure_attribute el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ var ind = proc_attributes.FindIndex(x => x == el);
+ if (ind == -1)
+ throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el));
+ return ind;
+ }
+
+ public void InsertAfter(procedure_attribute el, procedure_attribute newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ proc_attributes.Insert(FindIndexInList(el) + 1, newel);
+ newel.Parent = this;
+ }
+
+ public void InsertAfter(procedure_attribute el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ proc_attributes.InsertRange(FindIndexInList(el) + 1, newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public void InsertBefore(procedure_attribute el, procedure_attribute newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ proc_attributes.Insert(FindIndexInList(el), newel);
+ newel.Parent = this;
+ }
+
+ public void InsertBefore(procedure_attribute el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ proc_attributes.InsertRange(FindIndexInList(el), newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public bool Remove(procedure_attribute el)
+ {
+ return proc_attributes.Remove(el);
+ }
+
+ public void ReplaceInList(procedure_attribute el, procedure_attribute newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ proc_attributes[FindIndexInList(el)] = newel;
+ newel.Parent = this;
+ }
+
+ public void ReplaceInList(procedure_attribute el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ var ind = FindIndexInList(el);
+ proc_attributes.RemoveAt(ind);
+ proc_attributes.InsertRange(ind, newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public int RemoveAll(Predicate match)
+ {
+ return proc_attributes.RemoveAll(match);
+ }
+
+ public procedure_attribute Last()
+ {
+ if (proc_attributes.Count > 0)
+ return proc_attributes[proc_attributes.Count - 1];
+ throw new InvalidOperationException("Список пуст");
+ }
+
+ public int Count
+ {
+ get { return proc_attributes.Count; }
+ }
+
+ public void Insert(int pos, procedure_attribute el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ proc_attributes.Insert(pos,el);
+ if (el != null)
+ el.Parent = this;
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ procedure_attributes_list copy = new procedure_attributes_list();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (proc_attributes != null)
+ {
+ foreach (procedure_attribute elem in proc_attributes)
+ {
+ if (elem != null)
+ {
+ copy.Add((procedure_attribute)elem.Clone());
+ copy.Last().Parent = copy;
+ }
+ else
+ copy.Add(null);
+ }
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new procedure_attributes_list TypedClone()
+ {
+ return Clone() as procedure_attributes_list;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (proc_attributes != null)
+ {
+ foreach (var child in proc_attributes)
+ if (child != null)
+ child.Parent = this;
+ }
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ if (proc_attributes != null)
+ {
+ foreach (var child in proc_attributes)
+ child?.FillParentsInAllChilds();
+ }
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 0 + (proc_attributes == null ? 0 : proc_attributes.Count);
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ Int32 index_counter=ind - 0;
+ if(proc_attributes != null)
+ {
+ if(index_counter < proc_attributes.Count)
+ {
+ return proc_attributes[index_counter];
+ }
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ Int32 index_counter=ind - 0;
+ if(proc_attributes != null)
+ {
+ if(index_counter < proc_attributes.Count)
+ {
+ proc_attributes[index_counter]= (procedure_attribute)value;
+ return;
+ }
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///
+ ///
+ [Serializable]
+ public partial class procedure_header : type_definition
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public procedure_header()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public procedure_header(formal_parameters _parameters,procedure_attributes_list _proc_attributes,method_name _name,bool _of_object,bool _class_keyword,ident_list _template_args,where_definition_list _where_defs)
+ {
+ this._parameters=_parameters;
+ this._proc_attributes=_proc_attributes;
+ this._name=_name;
+ this._of_object=_of_object;
+ this._class_keyword=_class_keyword;
+ this._template_args=_template_args;
+ this._where_defs=_where_defs;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public procedure_header(formal_parameters _parameters,procedure_attributes_list _proc_attributes,method_name _name,bool _of_object,bool _class_keyword,ident_list _template_args,where_definition_list _where_defs,SourceContext sc)
+ {
+ this._parameters=_parameters;
+ this._proc_attributes=_proc_attributes;
+ this._name=_name;
+ this._of_object=_of_object;
+ this._class_keyword=_class_keyword;
+ this._template_args=_template_args;
+ this._where_defs=_where_defs;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public procedure_header(type_definition_attr_list _attr_list,formal_parameters _parameters,procedure_attributes_list _proc_attributes,method_name _name,bool _of_object,bool _class_keyword,ident_list _template_args,where_definition_list _where_defs)
+ {
+ this._attr_list=_attr_list;
+ this._parameters=_parameters;
+ this._proc_attributes=_proc_attributes;
+ this._name=_name;
+ this._of_object=_of_object;
+ this._class_keyword=_class_keyword;
+ this._template_args=_template_args;
+ this._where_defs=_where_defs;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public procedure_header(type_definition_attr_list _attr_list,formal_parameters _parameters,procedure_attributes_list _proc_attributes,method_name _name,bool _of_object,bool _class_keyword,ident_list _template_args,where_definition_list _where_defs,SourceContext sc)
+ {
+ this._attr_list=_attr_list;
+ this._parameters=_parameters;
+ this._proc_attributes=_proc_attributes;
+ this._name=_name;
+ this._of_object=_of_object;
+ this._class_keyword=_class_keyword;
+ this._template_args=_template_args;
+ this._where_defs=_where_defs;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected formal_parameters _parameters;
+ protected procedure_attributes_list _proc_attributes;
+ protected method_name _name;
+ protected bool _of_object;
+ protected bool _class_keyword;
+ protected ident_list _template_args;
+ protected where_definition_list _where_defs;
+
+ ///
+ ///
+ ///
+ public formal_parameters parameters
+ {
+ get
+ {
+ return _parameters;
+ }
+ set
+ {
+ _parameters=value;
+ if (_parameters != null)
+ _parameters.Parent = this;
+ }
+ }
+
+ ///
+ ///
+ ///
+ public procedure_attributes_list proc_attributes
+ {
+ get
+ {
+ return _proc_attributes;
+ }
+ set
+ {
+ _proc_attributes=value;
+ if (_proc_attributes != null)
+ _proc_attributes.Parent = this;
+ }
+ }
+
+ ///
+ ///
+ ///
+ public method_name name
+ {
+ get
+ {
+ return _name;
+ }
+ set
+ {
+ _name=value;
+ if (_name != null)
+ _name.Parent = this;
+ }
+ }
+
+ ///
+ ///
+ ///
+ public bool of_object
+ {
+ get
+ {
+ return _of_object;
+ }
+ set
+ {
+ _of_object=value;
+ }
+ }
+
+ ///
+ ///class procedure...
+ ///
+ public bool class_keyword
+ {
+ get
+ {
+ return _class_keyword;
+ }
+ set
+ {
+ _class_keyword=value;
+ }
+ }
+
+ ///
+ ///
+ ///
+ public ident_list template_args
+ {
+ get
+ {
+ return _template_args;
+ }
+ set
+ {
+ _template_args=value;
+ if (_template_args != null)
+ _template_args.Parent = this;
+ }
+ }
+
+ ///
+ ///
+ ///
+ public where_definition_list where_defs
+ {
+ get
+ {
+ return _where_defs;
+ }
+ set
+ {
+ _where_defs=value;
+ if (_where_defs != null)
+ _where_defs.Parent = this;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ procedure_header copy = new procedure_header();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (attr_list != null)
+ {
+ copy.attr_list = (type_definition_attr_list)attr_list.Clone();
+ copy.attr_list.Parent = copy;
+ }
+ if (parameters != null)
+ {
+ copy.parameters = (formal_parameters)parameters.Clone();
+ copy.parameters.Parent = copy;
+ }
+ if (proc_attributes != null)
+ {
+ copy.proc_attributes = (procedure_attributes_list)proc_attributes.Clone();
+ copy.proc_attributes.Parent = copy;
+ }
+ if (name != null)
+ {
+ copy.name = (method_name)name.Clone();
+ copy.name.Parent = copy;
+ }
+ copy.of_object = of_object;
+ copy.class_keyword = class_keyword;
+ if (template_args != null)
+ {
+ copy.template_args = (ident_list)template_args.Clone();
+ copy.template_args.Parent = copy;
+ }
+ if (where_defs != null)
+ {
+ copy.where_defs = (where_definition_list)where_defs.Clone();
+ copy.where_defs.Parent = copy;
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new procedure_header TypedClone()
+ {
+ return Clone() as procedure_header;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (attr_list != null)
+ attr_list.Parent = this;
+ if (parameters != null)
+ parameters.Parent = this;
+ if (proc_attributes != null)
+ proc_attributes.Parent = this;
+ if (name != null)
+ name.Parent = this;
+ if (template_args != null)
+ template_args.Parent = this;
+ if (where_defs != null)
+ where_defs.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ attr_list?.FillParentsInAllChilds();
+ parameters?.FillParentsInAllChilds();
+ proc_attributes?.FillParentsInAllChilds();
+ name?.FillParentsInAllChilds();
+ template_args?.FillParentsInAllChilds();
+ where_defs?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 6;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 6;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return attr_list;
+ case 1:
+ return parameters;
+ case 2:
+ return proc_attributes;
+ case 3:
+ return name;
+ case 4:
+ return template_args;
+ case 5:
+ return where_defs;
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ attr_list = (type_definition_attr_list)value;
+ break;
+ case 1:
+ parameters = (formal_parameters)value;
+ break;
+ case 2:
+ proc_attributes = (procedure_attributes_list)value;
+ break;
+ case 3:
+ name = (method_name)value;
+ break;
+ case 4:
+ template_args = (ident_list)value;
+ break;
+ case 5:
+ where_defs = (where_definition_list)value;
+ break;
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///
+ ///
+ [Serializable]
+ public partial class function_header : procedure_header
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public function_header()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public function_header(type_definition _return_type)
+ {
+ this._return_type=_return_type;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public function_header(type_definition _return_type,SourceContext sc)
+ {
+ this._return_type=_return_type;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public function_header(type_definition_attr_list _attr_list,formal_parameters _parameters,procedure_attributes_list _proc_attributes,method_name _name,bool _of_object,bool _class_keyword,ident_list _template_args,where_definition_list _where_defs,type_definition _return_type)
+ {
+ this._attr_list=_attr_list;
+ this._parameters=_parameters;
+ this._proc_attributes=_proc_attributes;
+ this._name=_name;
+ this._of_object=_of_object;
+ this._class_keyword=_class_keyword;
+ this._template_args=_template_args;
+ this._where_defs=_where_defs;
+ this._return_type=_return_type;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public function_header(type_definition_attr_list _attr_list,formal_parameters _parameters,procedure_attributes_list _proc_attributes,method_name _name,bool _of_object,bool _class_keyword,ident_list _template_args,where_definition_list _where_defs,type_definition _return_type,SourceContext sc)
+ {
+ this._attr_list=_attr_list;
+ this._parameters=_parameters;
+ this._proc_attributes=_proc_attributes;
+ this._name=_name;
+ this._of_object=_of_object;
+ this._class_keyword=_class_keyword;
+ this._template_args=_template_args;
+ this._where_defs=_where_defs;
+ this._return_type=_return_type;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected type_definition _return_type;
+
+ ///
+ ///
+ ///
+ public type_definition return_type
+ {
+ get
+ {
+ return _return_type;
+ }
+ set
+ {
+ _return_type=value;
+ if (_return_type != null)
+ _return_type.Parent = this;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ function_header copy = new function_header();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (attr_list != null)
+ {
+ copy.attr_list = (type_definition_attr_list)attr_list.Clone();
+ copy.attr_list.Parent = copy;
+ }
+ if (parameters != null)
+ {
+ copy.parameters = (formal_parameters)parameters.Clone();
+ copy.parameters.Parent = copy;
+ }
+ if (proc_attributes != null)
+ {
+ copy.proc_attributes = (procedure_attributes_list)proc_attributes.Clone();
+ copy.proc_attributes.Parent = copy;
+ }
+ if (name != null)
+ {
+ copy.name = (method_name)name.Clone();
+ copy.name.Parent = copy;
+ }
+ copy.of_object = of_object;
+ copy.class_keyword = class_keyword;
+ if (template_args != null)
+ {
+ copy.template_args = (ident_list)template_args.Clone();
+ copy.template_args.Parent = copy;
+ }
+ if (where_defs != null)
+ {
+ copy.where_defs = (where_definition_list)where_defs.Clone();
+ copy.where_defs.Parent = copy;
+ }
+ if (return_type != null)
+ {
+ copy.return_type = (type_definition)return_type.Clone();
+ copy.return_type.Parent = copy;
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new function_header TypedClone()
+ {
+ return Clone() as function_header;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (attr_list != null)
+ attr_list.Parent = this;
+ if (parameters != null)
+ parameters.Parent = this;
+ if (proc_attributes != null)
+ proc_attributes.Parent = this;
+ if (name != null)
+ name.Parent = this;
+ if (template_args != null)
+ template_args.Parent = this;
+ if (where_defs != null)
+ where_defs.Parent = this;
+ if (return_type != null)
+ return_type.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ attr_list?.FillParentsInAllChilds();
+ parameters?.FillParentsInAllChilds();
+ proc_attributes?.FillParentsInAllChilds();
+ name?.FillParentsInAllChilds();
+ template_args?.FillParentsInAllChilds();
+ where_defs?.FillParentsInAllChilds();
+ return_type?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 7;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 7;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return attr_list;
+ case 1:
+ return parameters;
+ case 2:
+ return proc_attributes;
+ case 3:
+ return name;
+ case 4:
+ return template_args;
+ case 5:
+ return where_defs;
+ case 6:
+ return return_type;
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ attr_list = (type_definition_attr_list)value;
+ break;
+ case 1:
+ parameters = (formal_parameters)value;
+ break;
+ case 2:
+ proc_attributes = (procedure_attributes_list)value;
+ break;
+ case 3:
+ name = (method_name)value;
+ break;
+ case 4:
+ template_args = (ident_list)value;
+ break;
+ case 5:
+ where_defs = (where_definition_list)value;
+ break;
+ case 6:
+ return_type = (type_definition)value;
+ break;
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///
+ ///
+ [Serializable]
+ public partial class procedure_definition : declaration
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public procedure_definition()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public procedure_definition(procedure_header _proc_header,proc_block _proc_body,bool _is_short_definition)
+ {
+ this._proc_header=_proc_header;
+ this._proc_body=_proc_body;
+ this._is_short_definition=_is_short_definition;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public procedure_definition(procedure_header _proc_header,proc_block _proc_body,bool _is_short_definition,SourceContext sc)
+ {
+ this._proc_header=_proc_header;
+ this._proc_body=_proc_body;
+ this._is_short_definition=_is_short_definition;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected procedure_header _proc_header;
+ protected proc_block _proc_body;
+ protected bool _is_short_definition;
+
+ ///
+ ///
+ ///
+ public procedure_header proc_header
+ {
+ get
+ {
+ return _proc_header;
+ }
+ set
+ {
+ _proc_header=value;
+ if (_proc_header != null)
+ _proc_header.Parent = this;
+ }
+ }
+
+ ///
+ ///
+ ///
+ public proc_block proc_body
+ {
+ get
+ {
+ return _proc_body;
+ }
+ set
+ {
+ _proc_body=value;
+ if (_proc_body != null)
+ _proc_body.Parent = this;
+ }
+ }
+
+ ///
+ ///
+ ///
+ public bool is_short_definition
+ {
+ get
+ {
+ return _is_short_definition;
+ }
+ set
+ {
+ _is_short_definition=value;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ procedure_definition copy = new procedure_definition();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (proc_header != null)
+ {
+ copy.proc_header = (procedure_header)proc_header.Clone();
+ copy.proc_header.Parent = copy;
+ }
+ if (proc_body != null)
+ {
+ copy.proc_body = (proc_block)proc_body.Clone();
+ copy.proc_body.Parent = copy;
+ }
+ copy.is_short_definition = is_short_definition;
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new procedure_definition TypedClone()
+ {
+ return Clone() as procedure_definition;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (proc_header != null)
+ proc_header.Parent = this;
+ if (proc_body != null)
+ proc_body.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ proc_header?.FillParentsInAllChilds();
+ proc_body?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 2;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 2;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return proc_header;
+ case 1:
+ return proc_body;
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ proc_header = (procedure_header)value;
+ break;
+ case 1:
+ proc_body = (proc_block)value;
+ break;
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///
+ ///
+ [Serializable]
+ public partial class type_declaration : declaration
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public type_declaration()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public type_declaration(ident _type_name,type_definition _type_def)
+ {
+ this._type_name=_type_name;
+ this._type_def=_type_def;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public type_declaration(ident _type_name,type_definition _type_def,SourceContext sc)
+ {
+ this._type_name=_type_name;
+ this._type_def=_type_def;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected ident _type_name;
+ protected type_definition _type_def;
+
+ ///
+ ///
+ ///
+ public ident type_name
+ {
+ get
+ {
+ return _type_name;
+ }
+ set
+ {
+ _type_name=value;
+ if (_type_name != null)
+ _type_name.Parent = this;
+ }
+ }
+
+ ///
+ ///
+ ///
+ public type_definition type_def
+ {
+ get
+ {
+ return _type_def;
+ }
+ set
+ {
+ _type_def=value;
+ if (_type_def != null)
+ _type_def.Parent = this;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ type_declaration copy = new type_declaration();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (type_name != null)
+ {
+ copy.type_name = (ident)type_name.Clone();
+ copy.type_name.Parent = copy;
+ }
+ if (type_def != null)
+ {
+ copy.type_def = (type_definition)type_def.Clone();
+ copy.type_def.Parent = copy;
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new type_declaration TypedClone()
+ {
+ return Clone() as type_declaration;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (type_name != null)
+ type_name.Parent = this;
+ if (type_def != null)
+ type_def.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ type_name?.FillParentsInAllChilds();
+ type_def?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 2;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 2;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return type_name;
+ case 1:
+ return type_def;
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ type_name = (ident)value;
+ break;
+ case 1:
+ type_def = (type_definition)value;
+ break;
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///Список определений типов
+ ///
+ [Serializable]
+ public partial class type_declarations : declaration
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public type_declarations()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public type_declarations(List _types_decl)
+ {
+ this._types_decl=_types_decl;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public type_declarations(List _types_decl,SourceContext sc)
+ {
+ this._types_decl=_types_decl;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ public type_declarations(type_declaration elem, SourceContext sc = null)
+ {
+ Add(elem, sc);
+ FillParentsInDirectChilds();
+ }
+
+ protected List _types_decl=new List();
+
+ ///
+ ///
+ ///
+ public List types_decl
+ {
+ get
+ {
+ return _types_decl;
+ }
+ set
+ {
+ _types_decl=value;
+ }
+ }
+
+
+ public type_declarations Add(type_declaration elem, SourceContext sc = null)
+ {
+ types_decl.Add(elem);
+ if (elem != null)
+ elem.Parent = this;
+ if (sc != null)
+ source_context = sc;
+ return this;
+ }
+
+ public void AddFirst(type_declaration el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ types_decl.Insert(0, el);
+ FillParentsInDirectChilds();
+ }
+
+ public void AddFirst(IEnumerable els)
+ {
+ if (els == null)
+ throw new ArgumentNullException(nameof(els));
+ types_decl.InsertRange(0, els);
+ foreach (var el in els)
+ if (el != null)
+ el.Parent = this;
+ }
+
+ public void AddMany(params type_declaration[] els)
+ {
+ if (els == null)
+ throw new ArgumentNullException(nameof(els));
+ types_decl.AddRange(els);
+ foreach (var el in els)
+ if (el != null)
+ el.Parent = this;
+ }
+
+ private int FindIndexInList(type_declaration el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ var ind = types_decl.FindIndex(x => x == el);
+ if (ind == -1)
+ throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el));
+ return ind;
+ }
+
+ public void InsertAfter(type_declaration el, type_declaration newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ types_decl.Insert(FindIndexInList(el) + 1, newel);
+ newel.Parent = this;
+ }
+
+ public void InsertAfter(type_declaration el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ types_decl.InsertRange(FindIndexInList(el) + 1, newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public void InsertBefore(type_declaration el, type_declaration newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ types_decl.Insert(FindIndexInList(el), newel);
+ newel.Parent = this;
+ }
+
+ public void InsertBefore(type_declaration el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ types_decl.InsertRange(FindIndexInList(el), newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public bool Remove(type_declaration el)
+ {
+ return types_decl.Remove(el);
+ }
+
+ public void ReplaceInList(type_declaration el, type_declaration newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ types_decl[FindIndexInList(el)] = newel;
+ newel.Parent = this;
+ }
+
+ public void ReplaceInList(type_declaration el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ var ind = FindIndexInList(el);
+ types_decl.RemoveAt(ind);
+ types_decl.InsertRange(ind, newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public int RemoveAll(Predicate match)
+ {
+ return types_decl.RemoveAll(match);
+ }
+
+ public type_declaration Last()
+ {
+ if (types_decl.Count > 0)
+ return types_decl[types_decl.Count - 1];
+ throw new InvalidOperationException("Список пуст");
+ }
+
+ public int Count
+ {
+ get { return types_decl.Count; }
+ }
+
+ public void Insert(int pos, type_declaration el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ types_decl.Insert(pos,el);
+ if (el != null)
+ el.Parent = this;
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ type_declarations copy = new type_declarations();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (types_decl != null)
+ {
+ foreach (type_declaration elem in types_decl)
+ {
+ if (elem != null)
+ {
+ copy.Add((type_declaration)elem.Clone());
+ copy.Last().Parent = copy;
+ }
+ else
+ copy.Add(null);
+ }
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new type_declarations TypedClone()
+ {
+ return Clone() as type_declarations;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (types_decl != null)
+ {
+ foreach (var child in types_decl)
+ if (child != null)
+ child.Parent = this;
+ }
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ if (types_decl != null)
+ {
+ foreach (var child in types_decl)
+ child?.FillParentsInAllChilds();
+ }
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 0 + (types_decl == null ? 0 : types_decl.Count);
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ Int32 index_counter=ind - 0;
+ if(types_decl != null)
+ {
+ if(index_counter < types_decl.Count)
+ {
+ return types_decl[index_counter];
+ }
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ Int32 index_counter=ind - 0;
+ if(types_decl != null)
+ {
+ if(index_counter < types_decl.Count)
+ {
+ types_decl[index_counter]= (type_declaration)value;
+ return;
+ }
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///
+ ///
+ [Serializable]
+ public partial class simple_const_definition : const_definition
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public simple_const_definition()
+ {
+
+ }
+
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public simple_const_definition(ident _const_name,expression _const_value)
+ {
+ this._const_name=_const_name;
+ this._const_value=_const_value;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public simple_const_definition(ident _const_name,expression _const_value,SourceContext sc)
+ {
+ this._const_name=_const_name;
+ this._const_value=_const_value;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ simple_const_definition copy = new simple_const_definition();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (const_name != null)
+ {
+ copy.const_name = (ident)const_name.Clone();
+ copy.const_name.Parent = copy;
+ }
+ if (const_value != null)
+ {
+ copy.const_value = (expression)const_value.Clone();
+ copy.const_value.Parent = copy;
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new simple_const_definition TypedClone()
+ {
+ return Clone() as simple_const_definition;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (const_name != null)
+ const_name.Parent = this;
+ if (const_value != null)
+ const_value.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ const_name?.FillParentsInAllChilds();
+ const_value?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 2;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 2;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return const_name;
+ case 1:
+ return const_value;
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ const_name = (ident)value;
+ break;
+ case 1:
+ const_value = (expression)value;
+ break;
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///
+ ///
+ [Serializable]
+ public partial class typed_const_definition : const_definition
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public typed_const_definition()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public typed_const_definition(type_definition _const_type)
+ {
+ this._const_type=_const_type;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public typed_const_definition(type_definition _const_type,SourceContext sc)
+ {
+ this._const_type=_const_type;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public typed_const_definition(ident _const_name,expression _const_value,type_definition _const_type)
+ {
+ this._const_name=_const_name;
+ this._const_value=_const_value;
+ this._const_type=_const_type;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public typed_const_definition(ident _const_name,expression _const_value,type_definition _const_type,SourceContext sc)
+ {
+ this._const_name=_const_name;
+ this._const_value=_const_value;
+ this._const_type=_const_type;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected type_definition _const_type;
+
+ ///
+ ///
+ ///
+ public type_definition const_type
+ {
+ get
+ {
+ return _const_type;
+ }
+ set
+ {
+ _const_type=value;
+ if (_const_type != null)
+ _const_type.Parent = this;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ typed_const_definition copy = new typed_const_definition();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (const_name != null)
+ {
+ copy.const_name = (ident)const_name.Clone();
+ copy.const_name.Parent = copy;
+ }
+ if (const_value != null)
+ {
+ copy.const_value = (expression)const_value.Clone();
+ copy.const_value.Parent = copy;
+ }
+ if (const_type != null)
+ {
+ copy.const_type = (type_definition)const_type.Clone();
+ copy.const_type.Parent = copy;
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new typed_const_definition TypedClone()
+ {
+ return Clone() as typed_const_definition;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (const_name != null)
+ const_name.Parent = this;
+ if (const_value != null)
+ const_value.Parent = this;
+ if (const_type != null)
+ const_type.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ const_name?.FillParentsInAllChilds();
+ const_value?.FillParentsInAllChilds();
+ const_type?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 3;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 3;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return const_name;
+ case 1:
+ return const_value;
+ case 2:
+ return const_type;
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ const_name = (ident)value;
+ break;
+ case 1:
+ const_value = (expression)value;
+ break;
+ case 2:
+ const_type = (type_definition)value;
+ break;
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///
+ ///
+ [Serializable]
+ public partial class const_definition : declaration
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public const_definition()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public const_definition(ident _const_name,expression _const_value)
+ {
+ this._const_name=_const_name;
+ this._const_value=_const_value;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public const_definition(ident _const_name,expression _const_value,SourceContext sc)
+ {
+ this._const_name=_const_name;
+ this._const_value=_const_value;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected ident _const_name;
+ protected expression _const_value;
+
+ ///
+ ///
+ ///
+ public ident const_name
+ {
+ get
+ {
+ return _const_name;
+ }
+ set
+ {
+ _const_name=value;
+ if (_const_name != null)
+ _const_name.Parent = this;
+ }
+ }
+
+ ///
+ ///
+ ///
+ public expression const_value
+ {
+ get
+ {
+ return _const_value;
+ }
+ set
+ {
+ _const_value=value;
+ if (_const_value != null)
+ _const_value.Parent = this;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ const_definition copy = new const_definition();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (const_name != null)
+ {
+ copy.const_name = (ident)const_name.Clone();
+ copy.const_name.Parent = copy;
+ }
+ if (const_value != null)
+ {
+ copy.const_value = (expression)const_value.Clone();
+ copy.const_value.Parent = copy;
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new const_definition TypedClone()
+ {
+ return Clone() as const_definition;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (const_name != null)
+ const_name.Parent = this;
+ if (const_value != null)
+ const_value.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ const_name?.FillParentsInAllChilds();
+ const_value?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 2;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 2;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return const_name;
+ case 1:
+ return const_value;
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ const_name = (ident)value;
+ break;
+ case 1:
+ const_value = (expression)value;
+ break;
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///
+ ///
+ [Serializable]
+ public partial class consts_definitions_list : declaration
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public consts_definitions_list()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public consts_definitions_list(List _const_defs)
+ {
+ this._const_defs=_const_defs;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public consts_definitions_list(List _const_defs,SourceContext sc)
+ {
+ this._const_defs=_const_defs;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ public consts_definitions_list(const_definition elem, SourceContext sc = null)
+ {
+ Add(elem, sc);
+ FillParentsInDirectChilds();
+ }
+
+ protected List _const_defs=new List();
+
+ ///
+ ///
+ ///
+ public List const_defs
+ {
+ get
+ {
+ return _const_defs;
+ }
+ set
+ {
+ _const_defs=value;
+ }
+ }
+
+
+ public consts_definitions_list Add(const_definition elem, SourceContext sc = null)
+ {
+ const_defs.Add(elem);
+ if (elem != null)
+ elem.Parent = this;
+ if (sc != null)
+ source_context = sc;
+ return this;
+ }
+
+ public void AddFirst(const_definition el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ const_defs.Insert(0, el);
+ FillParentsInDirectChilds();
+ }
+
+ public void AddFirst(IEnumerable els)
+ {
+ if (els == null)
+ throw new ArgumentNullException(nameof(els));
+ const_defs.InsertRange(0, els);
+ foreach (var el in els)
+ if (el != null)
+ el.Parent = this;
+ }
+
+ public void AddMany(params const_definition[] els)
+ {
+ if (els == null)
+ throw new ArgumentNullException(nameof(els));
+ const_defs.AddRange(els);
+ foreach (var el in els)
+ if (el != null)
+ el.Parent = this;
+ }
+
+ private int FindIndexInList(const_definition el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ var ind = const_defs.FindIndex(x => x == el);
+ if (ind == -1)
+ throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el));
+ return ind;
+ }
+
+ public void InsertAfter(const_definition el, const_definition newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ const_defs.Insert(FindIndexInList(el) + 1, newel);
+ newel.Parent = this;
+ }
+
+ public void InsertAfter(const_definition el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ const_defs.InsertRange(FindIndexInList(el) + 1, newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public void InsertBefore(const_definition el, const_definition newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ const_defs.Insert(FindIndexInList(el), newel);
+ newel.Parent = this;
+ }
+
+ public void InsertBefore(const_definition el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ const_defs.InsertRange(FindIndexInList(el), newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public bool Remove(const_definition el)
+ {
+ return const_defs.Remove(el);
+ }
+
+ public void ReplaceInList(const_definition el, const_definition newel)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newel == null)
+ throw new ArgumentNullException(nameof(newel));
+ const_defs[FindIndexInList(el)] = newel;
+ newel.Parent = this;
+ }
+
+ public void ReplaceInList(const_definition el, IEnumerable newels)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ if (newels == null)
+ throw new ArgumentNullException(nameof(newels));
+ var ind = FindIndexInList(el);
+ const_defs.RemoveAt(ind);
+ const_defs.InsertRange(ind, newels);
+ foreach (var newel in newels)
+ if (newel != null)
+ newel.Parent = this;
+ }
+
+ public int RemoveAll(Predicate match)
+ {
+ return const_defs.RemoveAll(match);
+ }
+
+ public const_definition Last()
+ {
+ if (const_defs.Count > 0)
+ return const_defs[const_defs.Count - 1];
+ throw new InvalidOperationException("Список пуст");
+ }
+
+ public int Count
+ {
+ get { return const_defs.Count; }
+ }
+
+ public void Insert(int pos, const_definition el)
+ {
+ if (el == null)
+ throw new ArgumentNullException(nameof(el));
+ const_defs.Insert(pos,el);
+ if (el != null)
+ el.Parent = this;
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ consts_definitions_list copy = new consts_definitions_list();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (attributes != null)
+ {
+ copy.attributes = (attribute_list)attributes.Clone();
+ copy.attributes.Parent = copy;
+ }
+ if (const_defs != null)
+ {
+ foreach (const_definition elem in const_defs)
+ {
+ if (elem != null)
+ {
+ copy.Add((const_definition)elem.Clone());
+ copy.Last().Parent = copy;
+ }
+ else
+ copy.Add(null);
+ }
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new consts_definitions_list TypedClone()
+ {
+ return Clone() as consts_definitions_list;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (attributes != null)
+ attributes.Parent = this;
+ if (const_defs != null)
+ {
+ foreach (var child in const_defs)
+ if (child != null)
+ child.Parent = this;
+ }
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ attributes?.FillParentsInAllChilds();
+ if (const_defs != null)
+ {
+ foreach (var child in const_defs)
+ child?.FillParentsInAllChilds();
+ }
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 0;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 0 + (const_defs == null ? 0 : const_defs.Count);
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ Int32 index_counter=ind - 0;
+ if(const_defs != null)
+ {
+ if(index_counter < const_defs.Count)
+ {
+ return const_defs[index_counter];
+ }
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ Int32 index_counter=ind - 0;
+ if(const_defs != null)
+ {
+ if(index_counter < const_defs.Count)
+ {
+ const_defs[index_counter]= (const_definition)value;
+ return;
+ }
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///
+ ///
+ [Serializable]
+ public partial class unit_name : syntax_tree_node
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public unit_name()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public unit_name(ident _idunit_name,UnitHeaderKeyword _HeaderKeyword)
+ {
+ this._idunit_name=_idunit_name;
+ this._HeaderKeyword=_HeaderKeyword;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public unit_name(ident _idunit_name,UnitHeaderKeyword _HeaderKeyword,SourceContext sc)
+ {
+ this._idunit_name=_idunit_name;
+ this._HeaderKeyword=_HeaderKeyword;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected ident _idunit_name;
+ protected UnitHeaderKeyword _HeaderKeyword;
+
+ ///
+ ///
+ ///
+ public ident idunit_name
+ {
+ get
+ {
+ return _idunit_name;
+ }
+ set
+ {
+ _idunit_name=value;
+ if (_idunit_name != null)
+ _idunit_name.Parent = this;
+ }
+ }
+
+ ///
+ ///
+ ///
+ public UnitHeaderKeyword HeaderKeyword
+ {
+ get
+ {
+ return _HeaderKeyword;
+ }
+ set
+ {
+ _HeaderKeyword=value;
+ }
+ }
+
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ unit_name copy = new unit_name();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (idunit_name != null)
+ {
+ copy.idunit_name = (ident)idunit_name.Clone();
+ copy.idunit_name.Parent = copy;
+ }
+ copy.HeaderKeyword = HeaderKeyword;
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new unit_name TypedClone()
+ {
+ return Clone() as unit_name;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (idunit_name != null)
+ idunit_name.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ idunit_name?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 1;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 1;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return idunit_name;
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ idunit_name = (ident)value;
+ break;
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///
+ ///
+ [Serializable]
+ public partial class unit_or_namespace : syntax_tree_node
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public unit_or_namespace()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public unit_or_namespace(ident_list _name)
+ {
+ this._name=_name;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public unit_or_namespace(ident_list _name,SourceContext sc)
+ {
+ this._name=_name;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected ident_list _name;
+
+ ///
+ ///
+ ///
+ public ident_list name
+ {
+ get
+ {
+ return _name;
+ }
+ set
+ {
+ _name=value;
+ if (_name != null)
+ _name.Parent = this;
+ }
+ }
+
+ // имя модуля в случае обычного uses
+ // или путь к модулю в случае uses-in
+ public virtual string UsesPath() => name.idents[0].name;
+
+ /// Создает копию узла
+ public override syntax_tree_node Clone()
+ {
+ unit_or_namespace copy = new unit_or_namespace();
+ copy.Parent = this.Parent;
+ if (source_context != null)
+ copy.source_context = new SourceContext(source_context);
+ if (name != null)
+ {
+ copy.name = (ident_list)name.Clone();
+ copy.name.Parent = copy;
+ }
+ return copy;
+ }
+
+ /// Получает копию данного узла корректного типа
+ public new unit_or_namespace TypedClone()
+ {
+ return Clone() as unit_or_namespace;
+ }
+
+ /// Заполняет поля Parent в непосредственных дочерних узлах
+ public override void FillParentsInDirectChilds()
+ {
+ if (name != null)
+ name.Parent = this;
+ }
+
+ /// Заполняет поля Parent во всем поддереве
+ public override void FillParentsInAllChilds()
+ {
+ FillParentsInDirectChilds();
+ name?.FillParentsInAllChilds();
+ }
+
+ ///
+ ///Свойство для получения количества всех подузлов без элементов поля типа List
+ ///
+ public override Int32 subnodes_without_list_elements_count
+ {
+ get
+ {
+ return 1;
+ }
+ }
+ ///
+ ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
+ ///
+ public override Int32 subnodes_count
+ {
+ get
+ {
+ return 1;
+ }
+ }
+ ///
+ ///Индексатор для получения всех подузлов
+ ///
+ public override syntax_tree_node this[Int32 ind]
+ {
+ get
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ return name;
+ }
+ return null;
+ }
+ set
+ {
+ if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
+ throw new IndexOutOfRangeException();
+ switch(ind)
+ {
+ case 0:
+ name = (ident_list)value;
+ break;
+ }
+ }
+ }
+ ///
+ ///Метод для обхода дерева посетителем
+ ///
+ ///Объект-посетитель.
+ ///Return value is void
+ public override void visit(IVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ }
+
+
+ ///
+ ///
+ ///
+ [Serializable]
+ public partial class uses_unit_in : unit_or_namespace
+ {
+
+ ///
+ ///Конструктор без параметров.
+ ///
+ public uses_unit_in()
+ {
+
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public uses_unit_in(string_const _in_file)
+ {
+ this._in_file=_in_file;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public uses_unit_in(string_const _in_file,SourceContext sc)
+ {
+ this._in_file=_in_file;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public uses_unit_in(ident_list _name,string_const _in_file)
+ {
+ this._name=_name;
+ this._in_file=_in_file;
+ FillParentsInDirectChilds();
+ }
+
+ ///
+ ///Конструктор с параметрами.
+ ///
+ public uses_unit_in(ident_list _name,string_const _in_file,SourceContext sc)
+ {
+ this._name=_name;
+ this._in_file=_in_file;
+ source_context = sc;
+ FillParentsInDirectChilds();
+ }
+ protected string_const _in_file;
+
+ ///
+ ///
+ ///
+ public string_const in_file
+ {
+ get
+ {
+ return _in_file;
+ }
+ set
+ {
+ _in_file=value;
+ if (_in_file != null)
+ _in_file.Parent = this;
+ }
}
public override string UsesPath() => in_file.Value;
- /// Создает копию узла
- public override syntax_tree_node Clone()
- {
- uses_unit_in copy = new uses_unit_in();
- copy.Parent = this.Parent;
- if (source_context != null)
- copy.source_context = new SourceContext(source_context);
- if (name != null)
- {
- copy.name = (ident_list)name.Clone();
- copy.name.Parent = copy;
- }
- if (in_file != null)
- {
- copy.in_file = (string_const)in_file.Clone();
- copy.in_file.Parent = copy;
- }
- return copy;
- }
-
- /// Получает копию данного узла корректного типа
- public new uses_unit_in TypedClone()
- {
- return Clone() as uses_unit_in;
- }
-
- /// Заполняет поля Parent в непосредственных дочерних узлах
- public override void FillParentsInDirectChilds()
- {
- if (name != null)
- name.Parent = this;
- if (in_file != null)
- in_file.Parent = this;
- }
-
- /// Заполняет поля Parent во всем поддереве
- public override void FillParentsInAllChilds()
- {
- FillParentsInDirectChilds();
- name?.FillParentsInAllChilds();
- in_file?.FillParentsInAllChilds();
- }
-
- ///
- ///Свойство для получения количества всех подузлов без элементов поля типа List
- ///
- public override Int32 subnodes_without_list_elements_count
- {
- get
- {
- return 2;
- }
- }
- ///
- ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
- ///
- public override Int32 subnodes_count
- {
- get
- {
- return 2;
- }
- }
- ///
- ///Индексатор для получения всех подузлов
- ///
- public override syntax_tree_node this[Int32 ind]
- {
- get
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- return name;
- case 1:
- return in_file;
- }
- return null;
- }
- set
- {
- if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
- throw new IndexOutOfRangeException();
- switch(ind)
- {
- case 0:
- name = (ident_list)value;
- break;
- case 1:
- in_file = (string_const)value;
- break;
- }
- }
- }
- ///
- ///Метод для обхода дерева посетителем
- ///
- ///Объект-посетитель.
- ///Return value is void
- public override void visit(IVisitor visitor)
- {
- visitor.visit(this);
- }
-
- }
-
-
- ///
- ///
- ///
- [Serializable]
- public partial class uses_list : syntax_tree_node
- {
-
- ///
- ///Конструктор без параметров.
- ///
- public uses_list()
- {
-
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public uses_list(List _units)
- {
- this._units=_units;
- FillParentsInDirectChilds();
- }
-
- ///
- ///Конструктор с параметрами.
- ///
- public uses_list(List _units,SourceContext sc)
- {
- this._units=_units;
- source_context = sc;
- FillParentsInDirectChilds();
- }
- public uses_list(unit_or_namespace elem, SourceContext sc = null)
- {
- Add(elem, sc);
- FillParentsInDirectChilds();
- }
-
- protected List _units=new List();
-
- ///
- ///
- ///
- public List units
- {
- get
- {
- return _units;
- }
- set
- {
- _units=value;
- }
- }
-
-
- public uses_list Add(unit_or_namespace elem, SourceContext sc = null)
- {
- units.Add(elem);
- if (elem != null)
- elem.Parent = this;
- if (sc != null)
- source_context = sc;
- return this;
- }
-
- public void AddFirst(unit_or_namespace el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- units.Insert(0, el);
- FillParentsInDirectChilds();
- }
-
- public void AddFirst(IEnumerable els)
- {
- if (els == null)
- throw new ArgumentNullException(nameof(els));
- units.InsertRange(0, els);
- foreach (var el in els)
- if (el != null)
- el.Parent = this;
- }
-
- public void AddMany(params unit_or_namespace[] els)
- {
- if (els == null)
- throw new ArgumentNullException(nameof(els));
- units.AddRange(els);
- foreach (var el in els)
- if (el != null)
- el.Parent = this;
- }
-
- private int FindIndexInList(unit_or_namespace el)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- var ind = units.FindIndex(x => x == el);
- if (ind == -1)
- throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el));
- return ind;
- }
-
- public void InsertAfter(unit_or_namespace el, unit_or_namespace newel)
- {
- if (el == null)
- throw new ArgumentNullException(nameof(el));
- if (newel == null)
- throw new ArgumentNullException(nameof(newel));
- units.Insert(FindIndexInList(el) + 1, newel);
- newel.Parent = this;
- }
-
- public void InsertAfter(unit_or_namespace el, IEnumerable