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; } } /// Создает копию узла 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 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 newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); units.InsertRange(FindIndexInList(el) + 1, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public void InsertBefore(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), newel); newel.Parent = this; } public void InsertBefore(unit_or_namespace el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); units.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(unit_or_namespace el) { return units.Remove(el); } public void ReplaceInList(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[FindIndexInList(el)] = newel; newel.Parent = this; } public void ReplaceInList(unit_or_namespace el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); var ind = FindIndexInList(el); units.RemoveAt(ind); units.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return units.RemoveAll(match); } public unit_or_namespace Last() { if (units.Count > 0) return units[units.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return units.Count; } } public void Insert(int pos, unit_or_namespace el) { if (el == null) throw new ArgumentNullException(nameof(el)); units.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { uses_list copy = new uses_list(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (units != null) { foreach (unit_or_namespace elem in units) { if (elem != null) { copy.Add((unit_or_namespace)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new uses_list TypedClone() { return Clone() as uses_list; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (units != null) { foreach (var child in units) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (units != null) { foreach (var child in units) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (units == null ? 0 : 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(units != null) { if(index_counter < units.Count) { return 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(units != null) { if(index_counter < units.Count) { units[index_counter]= (unit_or_namespace)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class program_body : syntax_tree_node { /// ///Конструктор без параметров. /// public program_body() { } /// ///Конструктор с параметрами. /// public program_body(uses_list _used_units,declarations _program_definitions,statement_list _program_code,using_list _using_list) { this._used_units=_used_units; this._program_definitions=_program_definitions; this._program_code=_program_code; this._using_list=_using_list; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public program_body(uses_list _used_units,declarations _program_definitions,statement_list _program_code,using_list _using_list,SourceContext sc) { this._used_units=_used_units; this._program_definitions=_program_definitions; this._program_code=_program_code; this._using_list=_using_list; source_context = sc; FillParentsInDirectChilds(); } protected uses_list _used_units; protected declarations _program_definitions; protected statement_list _program_code; protected using_list _using_list; /// /// /// public uses_list used_units { get { return _used_units; } set { _used_units=value; if (_used_units != null) _used_units.Parent = this; } } /// /// /// public declarations program_definitions { get { return _program_definitions; } set { _program_definitions=value; if (_program_definitions != null) _program_definitions.Parent = this; } } /// /// /// public statement_list program_code { get { return _program_code; } set { _program_code=value; if (_program_code != null) _program_code.Parent = this; } } /// /// /// public using_list using_list { get { return _using_list; } set { _using_list=value; if (_using_list != null) _using_list.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { program_body copy = new program_body(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (used_units != null) { copy.used_units = (uses_list)used_units.Clone(); copy.used_units.Parent = copy; } if (program_definitions != null) { copy.program_definitions = (declarations)program_definitions.Clone(); copy.program_definitions.Parent = copy; } if (program_code != null) { copy.program_code = (statement_list)program_code.Clone(); copy.program_code.Parent = copy; } if (using_list != null) { copy.using_list = (using_list)using_list.Clone(); copy.using_list.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new program_body TypedClone() { return Clone() as program_body; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (used_units != null) used_units.Parent = this; if (program_definitions != null) program_definitions.Parent = this; if (program_code != null) program_code.Parent = this; if (using_list != null) using_list.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); used_units?.FillParentsInAllChilds(); program_definitions?.FillParentsInAllChilds(); program_code?.FillParentsInAllChilds(); using_list?.FillParentsInAllChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 4; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 4; } } /// ///Индексатор для получения всех подузлов /// 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 used_units; case 1: return program_definitions; case 2: return program_code; case 3: return using_list; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: used_units = (uses_list)value; break; case 1: program_definitions = (declarations)value; break; case 2: program_code = (statement_list)value; break; case 3: using_list = (using_list)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class compilation_unit : syntax_tree_node { /// ///Конструктор без параметров. /// public compilation_unit() { } /// ///Конструктор с параметрами. /// public compilation_unit(string _file_name,List _compiler_directives,LanguageId _Language) { this._file_name=_file_name; this._compiler_directives=_compiler_directives; this._Language=_Language; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public compilation_unit(string _file_name,List _compiler_directives,LanguageId _Language,SourceContext sc) { this._file_name=_file_name; this._compiler_directives=_compiler_directives; this._Language=_Language; source_context = sc; FillParentsInDirectChilds(); } public compilation_unit(compiler_directive elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected string _file_name; protected List _compiler_directives=new List(); protected LanguageId _Language; /// /// /// public string file_name { get { return _file_name; } set { _file_name=value; } } /// /// /// public List compiler_directives { get { return _compiler_directives; } set { _compiler_directives=value; } } /// /// /// public LanguageId Language { get { return _Language; } set { _Language=value; } } public compilation_unit Add(compiler_directive elem, SourceContext sc = null) { compiler_directives.Add(elem); if (elem != null) elem.Parent = this; if (sc != null) source_context = sc; return this; } public void AddFirst(compiler_directive el) { if (el == null) throw new ArgumentNullException(nameof(el)); compiler_directives.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); compiler_directives.InsertRange(0, els); foreach (var el in els) if (el != null) el.Parent = this; } public void AddMany(params compiler_directive[] els) { if (els == null) throw new ArgumentNullException(nameof(els)); compiler_directives.AddRange(els); foreach (var el in els) if (el != null) el.Parent = this; } private int FindIndexInList(compiler_directive el) { if (el == null) throw new ArgumentNullException(nameof(el)); var ind = compiler_directives.FindIndex(x => x == el); if (ind == -1) throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el)); return ind; } public void InsertAfter(compiler_directive el, compiler_directive newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); compiler_directives.Insert(FindIndexInList(el) + 1, newel); newel.Parent = this; } public void InsertAfter(compiler_directive el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); compiler_directives.InsertRange(FindIndexInList(el) + 1, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public void InsertBefore(compiler_directive el, compiler_directive newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); compiler_directives.Insert(FindIndexInList(el), newel); newel.Parent = this; } public void InsertBefore(compiler_directive el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); compiler_directives.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(compiler_directive el) { return compiler_directives.Remove(el); } public void ReplaceInList(compiler_directive el, compiler_directive newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); compiler_directives[FindIndexInList(el)] = newel; newel.Parent = this; } public void ReplaceInList(compiler_directive el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); var ind = FindIndexInList(el); compiler_directives.RemoveAt(ind); compiler_directives.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return compiler_directives.RemoveAll(match); } public compiler_directive Last() { if (compiler_directives.Count > 0) return compiler_directives[compiler_directives.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return compiler_directives.Count; } } public void Insert(int pos, compiler_directive el) { if (el == null) throw new ArgumentNullException(nameof(el)); compiler_directives.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { compilation_unit copy = new compilation_unit(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); copy.file_name = file_name; if (compiler_directives != null) { foreach (compiler_directive elem in compiler_directives) { if (elem != null) { copy.Add((compiler_directive)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } copy.Language = Language; return copy; } /// Получает копию данного узла корректного типа public new compilation_unit TypedClone() { return Clone() as compilation_unit; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (compiler_directives != null) { foreach (var child in compiler_directives) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (compiler_directives != null) { foreach (var child in compiler_directives) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (compiler_directives == null ? 0 : compiler_directives.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(compiler_directives != null) { if(index_counter < compiler_directives.Count) { return compiler_directives[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); Int32 index_counter=ind - 0; if(compiler_directives != null) { if(index_counter < compiler_directives.Count) { compiler_directives[index_counter]= (compiler_directive)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class unit_module : compilation_unit { /// ///Конструктор без параметров. /// public unit_module() { } /// ///Конструктор с параметрами. /// public unit_module(unit_name _unit_name,interface_node _interface_part,implementation_node _implementation_part,statement_list _initialization_part,statement_list _finalization_part,attribute_list _attributes) { this._unit_name=_unit_name; this._interface_part=_interface_part; this._implementation_part=_implementation_part; this._initialization_part=_initialization_part; this._finalization_part=_finalization_part; this._attributes=_attributes; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public unit_module(unit_name _unit_name,interface_node _interface_part,implementation_node _implementation_part,statement_list _initialization_part,statement_list _finalization_part,attribute_list _attributes,SourceContext sc) { this._unit_name=_unit_name; this._interface_part=_interface_part; this._implementation_part=_implementation_part; this._initialization_part=_initialization_part; this._finalization_part=_finalization_part; this._attributes=_attributes; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public unit_module(string _file_name,List _compiler_directives,LanguageId _Language,unit_name _unit_name,interface_node _interface_part,implementation_node _implementation_part,statement_list _initialization_part,statement_list _finalization_part,attribute_list _attributes) { this._file_name=_file_name; this._compiler_directives=_compiler_directives; this._Language=_Language; this._unit_name=_unit_name; this._interface_part=_interface_part; this._implementation_part=_implementation_part; this._initialization_part=_initialization_part; this._finalization_part=_finalization_part; this._attributes=_attributes; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public unit_module(string _file_name,List _compiler_directives,LanguageId _Language,unit_name _unit_name,interface_node _interface_part,implementation_node _implementation_part,statement_list _initialization_part,statement_list _finalization_part,attribute_list _attributes,SourceContext sc) { this._file_name=_file_name; this._compiler_directives=_compiler_directives; this._Language=_Language; this._unit_name=_unit_name; this._interface_part=_interface_part; this._implementation_part=_implementation_part; this._initialization_part=_initialization_part; this._finalization_part=_finalization_part; this._attributes=_attributes; source_context = sc; FillParentsInDirectChilds(); } protected unit_name _unit_name; protected interface_node _interface_part; protected implementation_node _implementation_part; protected statement_list _initialization_part; protected statement_list _finalization_part; protected attribute_list _attributes; /// /// /// public unit_name unit_name { get { return _unit_name; } set { _unit_name=value; if (_unit_name != null) _unit_name.Parent = this; } } /// /// /// public interface_node interface_part { get { return _interface_part; } set { _interface_part=value; if (_interface_part != null) _interface_part.Parent = this; } } /// /// /// public implementation_node implementation_part { get { return _implementation_part; } set { _implementation_part=value; if (_implementation_part != null) _implementation_part.Parent = this; } } /// /// /// public statement_list initialization_part { get { return _initialization_part; } set { _initialization_part=value; if (_initialization_part != null) _initialization_part.Parent = this; } } /// /// /// public statement_list finalization_part { get { return _finalization_part; } set { _finalization_part=value; if (_finalization_part != null) _finalization_part.Parent = this; } } /// /// /// public attribute_list attributes { get { return _attributes; } set { _attributes=value; if (_attributes != null) _attributes.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { unit_module copy = new unit_module(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); copy.file_name = file_name; if (compiler_directives != null) { foreach (compiler_directive elem in compiler_directives) { if (elem != null) { copy.Add((compiler_directive)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } copy.Language = Language; if (unit_name != null) { copy.unit_name = (unit_name)unit_name.Clone(); copy.unit_name.Parent = copy; } if (interface_part != null) { copy.interface_part = (interface_node)interface_part.Clone(); copy.interface_part.Parent = copy; } if (implementation_part != null) { copy.implementation_part = (implementation_node)implementation_part.Clone(); copy.implementation_part.Parent = copy; } if (initialization_part != null) { copy.initialization_part = (statement_list)initialization_part.Clone(); copy.initialization_part.Parent = copy; } if (finalization_part != null) { copy.finalization_part = (statement_list)finalization_part.Clone(); copy.finalization_part.Parent = copy; } if (attributes != null) { copy.attributes = (attribute_list)attributes.Clone(); copy.attributes.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new unit_module TypedClone() { return Clone() as unit_module; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (compiler_directives != null) { foreach (var child in compiler_directives) if (child != null) child.Parent = this; } if (unit_name != null) unit_name.Parent = this; if (interface_part != null) interface_part.Parent = this; if (implementation_part != null) implementation_part.Parent = this; if (initialization_part != null) initialization_part.Parent = this; if (finalization_part != null) finalization_part.Parent = this; if (attributes != null) attributes.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (compiler_directives != null) { foreach (var child in compiler_directives) child?.FillParentsInAllChilds(); } unit_name?.FillParentsInAllChilds(); interface_part?.FillParentsInAllChilds(); implementation_part?.FillParentsInAllChilds(); initialization_part?.FillParentsInAllChilds(); finalization_part?.FillParentsInAllChilds(); attributes?.FillParentsInAllChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 6; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 6 + (compiler_directives == null ? 0 : compiler_directives.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 unit_name; case 1: return interface_part; case 2: return implementation_part; case 3: return initialization_part; case 4: return finalization_part; case 5: return attributes; } Int32 index_counter=ind - 6; if(compiler_directives != null) { if(index_counter < compiler_directives.Count) { return compiler_directives[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: unit_name = (unit_name)value; break; case 1: interface_part = (interface_node)value; break; case 2: implementation_part = (implementation_node)value; break; case 3: initialization_part = (statement_list)value; break; case 4: finalization_part = (statement_list)value; break; case 5: attributes = (attribute_list)value; break; } Int32 index_counter=ind - 6; if(compiler_directives != null) { if(index_counter < compiler_directives.Count) { compiler_directives[index_counter]= (compiler_directive)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class program_module : compilation_unit { /// ///Конструктор без параметров. /// public program_module() { } /// ///Конструктор с параметрами. /// public program_module(program_name _program_name,uses_list _used_units,block _program_block,using_list _using_namespaces) { this._program_name=_program_name; this._used_units=_used_units; this._program_block=_program_block; this._using_namespaces=_using_namespaces; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public program_module(program_name _program_name,uses_list _used_units,block _program_block,using_list _using_namespaces,SourceContext sc) { this._program_name=_program_name; this._used_units=_used_units; this._program_block=_program_block; this._using_namespaces=_using_namespaces; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public program_module(string _file_name,List _compiler_directives,LanguageId _Language,program_name _program_name,uses_list _used_units,block _program_block,using_list _using_namespaces) { this._file_name=_file_name; this._compiler_directives=_compiler_directives; this._Language=_Language; this._program_name=_program_name; this._used_units=_used_units; this._program_block=_program_block; this._using_namespaces=_using_namespaces; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public program_module(string _file_name,List _compiler_directives,LanguageId _Language,program_name _program_name,uses_list _used_units,block _program_block,using_list _using_namespaces,SourceContext sc) { this._file_name=_file_name; this._compiler_directives=_compiler_directives; this._Language=_Language; this._program_name=_program_name; this._used_units=_used_units; this._program_block=_program_block; this._using_namespaces=_using_namespaces; source_context = sc; FillParentsInDirectChilds(); } protected program_name _program_name; protected uses_list _used_units; protected block _program_block; protected using_list _using_namespaces; /// /// /// public program_name program_name { get { return _program_name; } set { _program_name=value; if (_program_name != null) _program_name.Parent = this; } } /// /// /// public uses_list used_units { get { return _used_units; } set { _used_units=value; if (_used_units != null) _used_units.Parent = this; } } /// /// /// public block program_block { get { return _program_block; } set { _program_block=value; if (_program_block != null) _program_block.Parent = this; } } /// /// /// public using_list using_namespaces { get { return _using_namespaces; } set { _using_namespaces=value; if (_using_namespaces != null) _using_namespaces.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { program_module copy = new program_module(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); copy.file_name = file_name; if (compiler_directives != null) { foreach (compiler_directive elem in compiler_directives) { if (elem != null) { copy.Add((compiler_directive)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } copy.Language = Language; if (program_name != null) { copy.program_name = (program_name)program_name.Clone(); copy.program_name.Parent = copy; } if (used_units != null) { copy.used_units = (uses_list)used_units.Clone(); copy.used_units.Parent = copy; } if (program_block != null) { copy.program_block = (block)program_block.Clone(); copy.program_block.Parent = copy; } if (using_namespaces != null) { copy.using_namespaces = (using_list)using_namespaces.Clone(); copy.using_namespaces.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new program_module TypedClone() { return Clone() as program_module; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (compiler_directives != null) { foreach (var child in compiler_directives) if (child != null) child.Parent = this; } if (program_name != null) program_name.Parent = this; if (used_units != null) used_units.Parent = this; if (program_block != null) program_block.Parent = this; if (using_namespaces != null) using_namespaces.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (compiler_directives != null) { foreach (var child in compiler_directives) child?.FillParentsInAllChilds(); } program_name?.FillParentsInAllChilds(); used_units?.FillParentsInAllChilds(); program_block?.FillParentsInAllChilds(); using_namespaces?.FillParentsInAllChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 4; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 4 + (compiler_directives == null ? 0 : compiler_directives.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 program_name; case 1: return used_units; case 2: return program_block; case 3: return using_namespaces; } Int32 index_counter=ind - 4; if(compiler_directives != null) { if(index_counter < compiler_directives.Count) { return compiler_directives[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: program_name = (program_name)value; break; case 1: used_units = (uses_list)value; break; case 2: program_block = (block)value; break; case 3: using_namespaces = (using_list)value; break; } Int32 index_counter=ind - 4; if(compiler_directives != null) { if(index_counter < compiler_directives.Count) { compiler_directives[index_counter]= (compiler_directive)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class hex_constant : int64_const { /// ///Конструктор без параметров. /// public hex_constant() { } /// ///Конструктор с параметрами. /// public hex_constant(Int64 _val) { this._val=_val; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public hex_constant(Int64 _val,SourceContext sc) { this._val=_val; source_context = sc; FillParentsInDirectChilds(); } /// Создает копию узла public override syntax_tree_node Clone() { hex_constant copy = new hex_constant(); 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 hex_constant TypedClone() { return Clone() as hex_constant; } /// Заполняет поля 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 get_address : addressed_value_funcname { /// ///Конструктор без параметров. /// public get_address() { } /// ///Конструктор с параметрами. /// public get_address(addressed_value _address_of) { this._address_of=_address_of; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public get_address(addressed_value _address_of,SourceContext sc) { this._address_of=_address_of; source_context = sc; FillParentsInDirectChilds(); } protected addressed_value _address_of; /// /// /// public addressed_value address_of { get { return _address_of; } set { _address_of=value; if (_address_of != null) _address_of.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { get_address copy = new get_address(); 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 (address_of != null) { copy.address_of = (addressed_value)address_of.Clone(); copy.address_of.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new get_address TypedClone() { return Clone() as get_address; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (address_of != null) address_of.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); address_of?.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 address_of; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: address_of = (addressed_value)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class case_variant : statement { /// ///Конструктор без параметров. /// public case_variant() { } /// ///Конструктор с параметрами. /// public case_variant(expression_list _conditions,statement _exec_if_true) { this._conditions=_conditions; this._exec_if_true=_exec_if_true; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public case_variant(expression_list _conditions,statement _exec_if_true,SourceContext sc) { this._conditions=_conditions; this._exec_if_true=_exec_if_true; source_context = sc; FillParentsInDirectChilds(); } protected expression_list _conditions; protected statement _exec_if_true; /// /// /// public expression_list conditions { get { return _conditions; } set { _conditions=value; if (_conditions != null) _conditions.Parent = this; } } /// /// /// public statement exec_if_true { get { return _exec_if_true; } set { _exec_if_true=value; if (_exec_if_true != null) _exec_if_true.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { case_variant copy = new case_variant(); 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 (conditions != null) { copy.conditions = (expression_list)conditions.Clone(); copy.conditions.Parent = copy; } if (exec_if_true != null) { copy.exec_if_true = (statement)exec_if_true.Clone(); copy.exec_if_true.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new case_variant TypedClone() { return Clone() as case_variant; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (conditions != null) conditions.Parent = this; if (exec_if_true != null) exec_if_true.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); conditions?.FillParentsInAllChilds(); exec_if_true?.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 conditions; case 1: return exec_if_true; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: conditions = (expression_list)value; break; case 1: exec_if_true = (statement)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class case_node : statement { /// ///Конструктор без параметров. /// public case_node() { } /// ///Конструктор с параметрами. /// public case_node(expression _param,case_variants _conditions,statement _else_statement) { this._param=_param; this._conditions=_conditions; this._else_statement=_else_statement; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public case_node(expression _param,case_variants _conditions,statement _else_statement,SourceContext sc) { this._param=_param; this._conditions=_conditions; this._else_statement=_else_statement; source_context = sc; FillParentsInDirectChilds(); } protected expression _param; protected case_variants _conditions; protected statement _else_statement; /// /// /// public expression param { get { return _param; } set { _param=value; if (_param != null) _param.Parent = this; } } /// /// /// public case_variants conditions { get { return _conditions; } set { _conditions=value; if (_conditions != null) _conditions.Parent = this; } } /// /// /// public statement else_statement { get { return _else_statement; } set { _else_statement=value; if (_else_statement != null) _else_statement.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { case_node copy = new case_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 (param != null) { copy.param = (expression)param.Clone(); copy.param.Parent = copy; } if (conditions != null) { copy.conditions = (case_variants)conditions.Clone(); copy.conditions.Parent = copy; } if (else_statement != null) { copy.else_statement = (statement)else_statement.Clone(); copy.else_statement.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new case_node TypedClone() { return Clone() as case_node; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (param != null) param.Parent = this; if (conditions != null) conditions.Parent = this; if (else_statement != null) else_statement.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); param?.FillParentsInAllChilds(); conditions?.FillParentsInAllChilds(); else_statement?.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 param; case 1: return conditions; case 2: return else_statement; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: param = (expression)value; break; case 1: conditions = (case_variants)value; break; case 2: else_statement = (statement)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class method_name : syntax_tree_node { /// ///Конструктор без параметров. /// public method_name() { } /// ///Конструктор с параметрами. /// public method_name(List _ln,ident _class_name,ident _meth_name,ident _explicit_interface_name) { this._ln=_ln; this._class_name=_class_name; this._meth_name=_meth_name; this._explicit_interface_name=_explicit_interface_name; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public method_name(List _ln,ident _class_name,ident _meth_name,ident _explicit_interface_name,SourceContext sc) { this._ln=_ln; this._class_name=_class_name; this._meth_name=_meth_name; this._explicit_interface_name=_explicit_interface_name; source_context = sc; FillParentsInDirectChilds(); } public method_name(ident elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected List _ln=new List(); protected ident _class_name; protected ident _meth_name; protected ident _explicit_interface_name; /// /// /// public List ln { get { return _ln; } set { _ln=value; } } /// /// /// public ident class_name { get { return _class_name; } set { _class_name=value; if (_class_name != null) _class_name.Parent = this; } } /// /// /// public ident meth_name { get { return _meth_name; } set { _meth_name=value; if (_meth_name != null) _meth_name.Parent = this; } } /// /// /// public ident explicit_interface_name { get { return _explicit_interface_name; } set { _explicit_interface_name=value; if (_explicit_interface_name != null) _explicit_interface_name.Parent = this; } } public method_name Add(ident elem, SourceContext sc = null) { ln.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)); ln.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); ln.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)); ln.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 = ln.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)); ln.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)); ln.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)); ln.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)); ln.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(ident el) { return ln.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)); ln[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); ln.RemoveAt(ind); ln.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return ln.RemoveAll(match); } public ident Last() { if (ln.Count > 0) return ln[ln.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return ln.Count; } } public void Insert(int pos, ident el) { if (el == null) throw new ArgumentNullException(nameof(el)); ln.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { method_name copy = new method_name(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (ln != null) { foreach (ident elem in ln) { if (elem != null) { copy.Add((ident)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } if (class_name != null) { copy.class_name = (ident)class_name.Clone(); copy.class_name.Parent = copy; } if (meth_name != null) { copy.meth_name = (ident)meth_name.Clone(); copy.meth_name.Parent = copy; } if (explicit_interface_name != null) { copy.explicit_interface_name = (ident)explicit_interface_name.Clone(); copy.explicit_interface_name.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new method_name TypedClone() { return Clone() as method_name; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (ln != null) { foreach (var child in ln) if (child != null) child.Parent = this; } if (class_name != null) class_name.Parent = this; if (meth_name != null) meth_name.Parent = this; if (explicit_interface_name != null) explicit_interface_name.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (ln != null) { foreach (var child in ln) child?.FillParentsInAllChilds(); } class_name?.FillParentsInAllChilds(); meth_name?.FillParentsInAllChilds(); explicit_interface_name?.FillParentsInAllChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 3; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 3 + (ln == null ? 0 : ln.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 class_name; case 1: return meth_name; case 2: return explicit_interface_name; } Int32 index_counter=ind - 3; if(ln != null) { if(index_counter < ln.Count) { return ln[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: class_name = (ident)value; break; case 1: meth_name = (ident)value; break; case 2: explicit_interface_name = (ident)value; break; } Int32 index_counter=ind - 3; if(ln != null) { if(index_counter < ln.Count) { ln[index_counter]= (ident)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class dot_node : addressed_value_funcname { /// ///Конструктор без параметров. /// public dot_node() { } /// ///Конструктор с параметрами. /// public dot_node(addressed_value _left,addressed_value _right) { this._left=_left; this._right=_right; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public dot_node(addressed_value _left,addressed_value _right,SourceContext sc) { this._left=_left; this._right=_right; source_context = sc; FillParentsInDirectChilds(); } protected addressed_value _left; protected addressed_value _right; /// /// /// public addressed_value left { get { return _left; } set { _left=value; if (_left != null) _left.Parent = this; } } /// /// /// public addressed_value right { get { return _right; } set { _right=value; if (_right != null) _right.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { dot_node copy = new dot_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 (left != null) { copy.left = (addressed_value)left.Clone(); copy.left.Parent = copy; } if (right != null) { copy.right = (addressed_value)right.Clone(); copy.right.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new dot_node TypedClone() { return Clone() as dot_node; } /// Заполняет поля 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 = (addressed_value)value; break; case 1: right = (addressed_value)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class empty_statement : statement { /// ///Конструктор без параметров. /// public empty_statement() { } /// Создает копию узла public override syntax_tree_node Clone() { empty_statement copy = new empty_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 empty_statement TypedClone() { return Clone() as empty_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 goto_statement : statement { /// ///Конструктор без параметров. /// public goto_statement() { } /// ///Конструктор с параметрами. /// public goto_statement(ident _label) { this._label=_label; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public goto_statement(ident _label,SourceContext sc) { this._label=_label; source_context = sc; FillParentsInDirectChilds(); } protected ident _label; /// /// /// public ident label { get { return _label; } set { _label=value; if (_label != null) _label.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { goto_statement copy = new goto_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 (label != null) { copy.label = (ident)label.Clone(); copy.label.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new goto_statement TypedClone() { return Clone() as goto_statement; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (label != null) label.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); label?.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 label; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: label = (ident)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class labeled_statement : statement { /// ///Конструктор без параметров. /// public labeled_statement() { } /// ///Конструктор с параметрами. /// public labeled_statement(ident _label_name,statement _to_statement) { this._label_name=_label_name; this._to_statement=_to_statement; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public labeled_statement(ident _label_name,statement _to_statement,SourceContext sc) { this._label_name=_label_name; this._to_statement=_to_statement; source_context = sc; FillParentsInDirectChilds(); } protected ident _label_name; protected statement _to_statement; /// /// /// public ident label_name { get { return _label_name; } set { _label_name=value; if (_label_name != null) _label_name.Parent = this; } } /// /// /// public statement to_statement { get { return _to_statement; } set { _to_statement=value; if (_to_statement != null) _to_statement.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { labeled_statement copy = new labeled_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 (label_name != null) { copy.label_name = (ident)label_name.Clone(); copy.label_name.Parent = copy; } if (to_statement != null) { copy.to_statement = (statement)to_statement.Clone(); copy.to_statement.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new labeled_statement TypedClone() { return Clone() as labeled_statement; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (label_name != null) label_name.Parent = this; if (to_statement != null) to_statement.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); label_name?.FillParentsInAllChilds(); to_statement?.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 label_name; case 1: return to_statement; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: label_name = (ident)value; break; case 1: to_statement = (statement)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// ///Представление оператора with в синтаксическом дереве. /// [Serializable] public partial class with_statement : statement { /// ///Конструктор без параметров. /// public with_statement() { } /// ///Конструктор с параметрами. /// public with_statement(statement _what_do,expression_list _do_with) { this._what_do=_what_do; this._do_with=_do_with; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public with_statement(statement _what_do,expression_list _do_with,SourceContext sc) { this._what_do=_what_do; this._do_with=_do_with; source_context = sc; FillParentsInDirectChilds(); } protected statement _what_do; protected expression_list _do_with; /// ///Что делать. /// public statement what_do { get { return _what_do; } set { _what_do=value; if (_what_do != null) _what_do.Parent = this; } } /// ///Список объектов, с которыми производить действия. /// public expression_list do_with { get { return _do_with; } set { _do_with=value; if (_do_with != null) _do_with.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { with_statement copy = new with_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 (what_do != null) { copy.what_do = (statement)what_do.Clone(); copy.what_do.Parent = copy; } if (do_with != null) { copy.do_with = (expression_list)do_with.Clone(); copy.do_with.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new with_statement TypedClone() { return Clone() as with_statement; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (what_do != null) what_do.Parent = this; if (do_with != null) do_with.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); what_do?.FillParentsInAllChilds(); do_with?.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 what_do; case 1: return do_with; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: what_do = (statement)value; break; case 1: do_with = (expression_list)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class method_call : dereference { /// ///Конструктор без параметров. /// public method_call() { } /// ///Конструктор с параметрами. /// public method_call(expression_list _parameters) { this._parameters=_parameters; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public method_call(expression_list _parameters,SourceContext sc) { this._parameters=_parameters; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public method_call(addressed_value _dereferencing_value,expression_list _parameters) { this._dereferencing_value=_dereferencing_value; this._parameters=_parameters; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public method_call(addressed_value _dereferencing_value,expression_list _parameters,SourceContext sc) { this._dereferencing_value=_dereferencing_value; this._parameters=_parameters; source_context = sc; FillParentsInDirectChilds(); } protected expression_list _parameters; /// /// /// public expression_list parameters { get { return _parameters; } set { _parameters=value; if (_parameters != null) _parameters.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { method_call copy = new method_call(); 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 (parameters != null) { copy.parameters = (expression_list)parameters.Clone(); copy.parameters.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new method_call TypedClone() { return Clone() as method_call; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (dereferencing_value != null) dereferencing_value.Parent = this; if (parameters != null) parameters.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); dereferencing_value?.FillParentsInAllChilds(); parameters?.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 parameters; } 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: parameters = (expression_list)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// ///Выражение-константа множество /// [Serializable] public partial class pascal_set_constant : addressed_value { /// ///Конструктор без параметров. /// public pascal_set_constant() { } /// ///Конструктор с параметрами. /// public pascal_set_constant(expression_list _values) { this._values=_values; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public pascal_set_constant(expression_list _values,SourceContext sc) { this._values=_values; source_context = sc; FillParentsInDirectChilds(); } protected expression_list _values; /// /// /// public expression_list values { get { return _values; } set { _values=value; if (_values != null) _values.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { pascal_set_constant copy = new pascal_set_constant(); 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 (values != null) { copy.values = (expression_list)values.Clone(); copy.values.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new pascal_set_constant TypedClone() { return Clone() as pascal_set_constant; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (values != null) values.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); values?.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 values; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: values = (expression_list)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class array_const : expression { /// ///Конструктор без параметров. /// public array_const() { } /// ///Конструктор с параметрами. /// public array_const(expression_list _elements) { this._elements=_elements; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public array_const(expression_list _elements,SourceContext sc) { this._elements=_elements; source_context = sc; FillParentsInDirectChilds(); } protected expression_list _elements; /// /// /// public expression_list elements { get { return _elements; } set { _elements=value; if (_elements != null) _elements.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { array_const copy = new array_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; } if (elements != null) { copy.elements = (expression_list)elements.Clone(); copy.elements.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new array_const TypedClone() { return Clone() as array_const; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (elements != null) elements.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); elements?.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 elements; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: elements = (expression_list)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// ///procedure_definition pr != null если метод сгенерирован по выражению. //pr сделано object чтобы не обходилось лишний раз /// [Serializable] public partial class write_accessor_name : syntax_tree_node { /// ///Конструктор без параметров. /// public write_accessor_name() { } /// ///Конструктор с параметрами. /// public write_accessor_name(ident _accessor_name,procedure_definition _pr,statement _statment_for_formatting) { this._accessor_name=_accessor_name; this._pr=_pr; this._statment_for_formatting=_statment_for_formatting; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public write_accessor_name(ident _accessor_name,procedure_definition _pr,statement _statment_for_formatting,SourceContext sc) { this._accessor_name=_accessor_name; this._pr=_pr; this._statment_for_formatting=_statment_for_formatting; source_context = sc; FillParentsInDirectChilds(); } protected ident _accessor_name; protected procedure_definition _pr; protected statement _statment_for_formatting; /// /// /// public ident accessor_name { get { return _accessor_name; } set { _accessor_name=value; if (_accessor_name != null) _accessor_name.Parent = this; } } /// /// /// public procedure_definition pr { get { return _pr; } set { _pr=value; if (_pr != null) _pr.Parent = this; } } /// /// /// public statement statment_for_formatting { get { return _statment_for_formatting; } set { _statment_for_formatting=value; if (_statment_for_formatting != null) _statment_for_formatting.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { write_accessor_name copy = new write_accessor_name(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (accessor_name != null) { copy.accessor_name = (ident)accessor_name.Clone(); copy.accessor_name.Parent = copy; } if (pr != null) { copy.pr = (procedure_definition)pr.Clone(); copy.pr.Parent = copy; } if (statment_for_formatting != null) { copy.statment_for_formatting = (statement)statment_for_formatting.Clone(); copy.statment_for_formatting.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new write_accessor_name TypedClone() { return Clone() as write_accessor_name; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (accessor_name != null) accessor_name.Parent = this; if (pr != null) pr.Parent = this; if (statment_for_formatting != null) statment_for_formatting.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); accessor_name?.FillParentsInAllChilds(); pr?.FillParentsInAllChilds(); statment_for_formatting?.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 accessor_name; case 1: return pr; case 2: return statment_for_formatting; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: accessor_name = (ident)value; break; case 1: pr = (procedure_definition)value; break; case 2: statment_for_formatting = (statement)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// ///procedure_definition pr != null если метод сгенерирован по выражению. //pr сделано object чтобы не обходилось лишний раз /// [Serializable] public partial class read_accessor_name : syntax_tree_node { /// ///Конструктор без параметров. /// public read_accessor_name() { } /// ///Конструктор с параметрами. /// public read_accessor_name(ident _accessor_name,procedure_definition _pr,expression _expression_for_formatting) { this._accessor_name=_accessor_name; this._pr=_pr; this._expression_for_formatting=_expression_for_formatting; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public read_accessor_name(ident _accessor_name,procedure_definition _pr,expression _expression_for_formatting,SourceContext sc) { this._accessor_name=_accessor_name; this._pr=_pr; this._expression_for_formatting=_expression_for_formatting; source_context = sc; FillParentsInDirectChilds(); } protected ident _accessor_name; protected procedure_definition _pr; protected expression _expression_for_formatting; /// /// /// public ident accessor_name { get { return _accessor_name; } set { _accessor_name=value; if (_accessor_name != null) _accessor_name.Parent = this; } } /// /// /// public procedure_definition pr { get { return _pr; } set { _pr=value; if (_pr != null) _pr.Parent = this; } } /// /// /// public expression expression_for_formatting { get { return _expression_for_formatting; } set { _expression_for_formatting=value; if (_expression_for_formatting != null) _expression_for_formatting.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { read_accessor_name copy = new read_accessor_name(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (accessor_name != null) { copy.accessor_name = (ident)accessor_name.Clone(); copy.accessor_name.Parent = copy; } if (pr != null) { copy.pr = (procedure_definition)pr.Clone(); copy.pr.Parent = copy; } if (expression_for_formatting != null) { copy.expression_for_formatting = (expression)expression_for_formatting.Clone(); copy.expression_for_formatting.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new read_accessor_name TypedClone() { return Clone() as read_accessor_name; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (accessor_name != null) accessor_name.Parent = this; if (pr != null) pr.Parent = this; if (expression_for_formatting != null) expression_for_formatting.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); accessor_name?.FillParentsInAllChilds(); pr?.FillParentsInAllChilds(); expression_for_formatting?.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 accessor_name; case 1: return pr; case 2: return expression_for_formatting; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: accessor_name = (ident)value; break; case 1: pr = (procedure_definition)value; break; case 2: expression_for_formatting = (expression)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class property_accessors : syntax_tree_node { /// ///Конструктор без параметров. /// public property_accessors() { } /// ///Конструктор с параметрами. /// public property_accessors(read_accessor_name _read_accessor,write_accessor_name _write_accessor) { this._read_accessor=_read_accessor; this._write_accessor=_write_accessor; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public property_accessors(read_accessor_name _read_accessor,write_accessor_name _write_accessor,SourceContext sc) { this._read_accessor=_read_accessor; this._write_accessor=_write_accessor; source_context = sc; FillParentsInDirectChilds(); } protected read_accessor_name _read_accessor; protected write_accessor_name _write_accessor; /// /// /// public read_accessor_name read_accessor { get { return _read_accessor; } set { _read_accessor=value; if (_read_accessor != null) _read_accessor.Parent = this; } } /// /// /// public write_accessor_name write_accessor { get { return _write_accessor; } set { _write_accessor=value; if (_write_accessor != null) _write_accessor.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { property_accessors copy = new property_accessors(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (read_accessor != null) { copy.read_accessor = (read_accessor_name)read_accessor.Clone(); copy.read_accessor.Parent = copy; } if (write_accessor != null) { copy.write_accessor = (write_accessor_name)write_accessor.Clone(); copy.write_accessor.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new property_accessors TypedClone() { return Clone() as property_accessors; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (read_accessor != null) read_accessor.Parent = this; if (write_accessor != null) write_accessor.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); read_accessor?.FillParentsInAllChilds(); write_accessor?.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 read_accessor; case 1: return write_accessor; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: read_accessor = (read_accessor_name)value; break; case 1: write_accessor = (write_accessor_name)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// ///property property_name[parameter_list]:property_type index index_expression accessors; [virtual;] array_default; /// [Serializable] public partial class simple_property : declaration { /// ///Конструктор без параметров. /// public simple_property() { } /// ///Конструктор с параметрами. /// public simple_property(ident _property_name,type_definition _property_type,expression _index_expression,property_accessors _accessors,property_array_default _array_default,property_parameter_list _parameter_list,definition_attribute _attr,proc_attribute _virt_over_none_attr,bool _is_auto,expression _initial_value) { this._property_name=_property_name; this._property_type=_property_type; this._index_expression=_index_expression; this._accessors=_accessors; this._array_default=_array_default; this._parameter_list=_parameter_list; this._attr=_attr; this._virt_over_none_attr=_virt_over_none_attr; this._is_auto=_is_auto; this._initial_value=_initial_value; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public simple_property(ident _property_name,type_definition _property_type,expression _index_expression,property_accessors _accessors,property_array_default _array_default,property_parameter_list _parameter_list,definition_attribute _attr,proc_attribute _virt_over_none_attr,bool _is_auto,expression _initial_value,SourceContext sc) { this._property_name=_property_name; this._property_type=_property_type; this._index_expression=_index_expression; this._accessors=_accessors; this._array_default=_array_default; this._parameter_list=_parameter_list; this._attr=_attr; this._virt_over_none_attr=_virt_over_none_attr; this._is_auto=_is_auto; this._initial_value=_initial_value; source_context = sc; FillParentsInDirectChilds(); } protected ident _property_name; protected type_definition _property_type; protected expression _index_expression; protected property_accessors _accessors; protected property_array_default _array_default; protected property_parameter_list _parameter_list; protected definition_attribute _attr; protected proc_attribute _virt_over_none_attr; protected bool _is_auto; protected expression _initial_value; /// /// /// public ident property_name { get { return _property_name; } set { _property_name=value; if (_property_name != null) _property_name.Parent = this; } } /// /// /// public type_definition property_type { get { return _property_type; } set { _property_type=value; if (_property_type != null) _property_type.Parent = this; } } /// /// /// public expression index_expression { get { return _index_expression; } set { _index_expression=value; if (_index_expression != null) _index_expression.Parent = this; } } /// /// /// public property_accessors accessors { get { return _accessors; } set { _accessors=value; if (_accessors != null) _accessors.Parent = this; } } /// /// /// public property_array_default array_default { get { return _array_default; } set { _array_default=value; if (_array_default != null) _array_default.Parent = this; } } /// /// /// public property_parameter_list parameter_list { get { return _parameter_list; } set { _parameter_list=value; if (_parameter_list != null) _parameter_list.Parent = this; } } /// /// /// public definition_attribute attr { get { return _attr; } set { _attr=value; } } /// /// /// public proc_attribute virt_over_none_attr { get { return _virt_over_none_attr; } set { _virt_over_none_attr=value; } } /// /// /// public bool is_auto { get { return _is_auto; } set { _is_auto=value; } } /// /// /// public expression initial_value { get { return _initial_value; } set { _initial_value=value; if (_initial_value != null) _initial_value.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { simple_property copy = new simple_property(); 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 (property_name != null) { copy.property_name = (ident)property_name.Clone(); copy.property_name.Parent = copy; } if (property_type != null) { copy.property_type = (type_definition)property_type.Clone(); copy.property_type.Parent = copy; } if (index_expression != null) { copy.index_expression = (expression)index_expression.Clone(); copy.index_expression.Parent = copy; } if (accessors != null) { copy.accessors = (property_accessors)accessors.Clone(); copy.accessors.Parent = copy; } if (array_default != null) { copy.array_default = (property_array_default)array_default.Clone(); copy.array_default.Parent = copy; } if (parameter_list != null) { copy.parameter_list = (property_parameter_list)parameter_list.Clone(); copy.parameter_list.Parent = copy; } copy.attr = attr; copy.virt_over_none_attr = virt_over_none_attr; copy.is_auto = is_auto; if (initial_value != null) { copy.initial_value = (expression)initial_value.Clone(); copy.initial_value.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new simple_property TypedClone() { return Clone() as simple_property; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (property_name != null) property_name.Parent = this; if (property_type != null) property_type.Parent = this; if (index_expression != null) index_expression.Parent = this; if (accessors != null) accessors.Parent = this; if (array_default != null) array_default.Parent = this; if (parameter_list != null) parameter_list.Parent = this; if (initial_value != null) initial_value.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); property_name?.FillParentsInAllChilds(); property_type?.FillParentsInAllChilds(); index_expression?.FillParentsInAllChilds(); accessors?.FillParentsInAllChilds(); array_default?.FillParentsInAllChilds(); parameter_list?.FillParentsInAllChilds(); initial_value?.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 property_name; case 1: return property_type; case 2: return index_expression; case 3: return accessors; case 4: return array_default; case 5: return parameter_list; case 6: return initial_value; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: property_name = (ident)value; break; case 1: property_type = (type_definition)value; break; case 2: index_expression = (expression)value; break; case 3: accessors = (property_accessors)value; break; case 4: array_default = (property_array_default)value; break; case 5: parameter_list = (property_parameter_list)value; break; case 6: initial_value = (expression)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class index_property : simple_property { /// ///Конструктор без параметров. /// public index_property() { } /// ///Конструктор с параметрами. /// public index_property(formal_parameters _property_parametres,default_indexer_property_node _is_default) { this._property_parametres=_property_parametres; this._is_default=_is_default; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public index_property(formal_parameters _property_parametres,default_indexer_property_node _is_default,SourceContext sc) { this._property_parametres=_property_parametres; this._is_default=_is_default; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public index_property(ident _property_name,type_definition _property_type,expression _index_expression,property_accessors _accessors,property_array_default _array_default,property_parameter_list _parameter_list,definition_attribute _attr,proc_attribute _virt_over_none_attr,bool _is_auto,expression _initial_value,formal_parameters _property_parametres,default_indexer_property_node _is_default) { this._property_name=_property_name; this._property_type=_property_type; this._index_expression=_index_expression; this._accessors=_accessors; this._array_default=_array_default; this._parameter_list=_parameter_list; this._attr=_attr; this._virt_over_none_attr=_virt_over_none_attr; this._is_auto=_is_auto; this._initial_value=_initial_value; this._property_parametres=_property_parametres; this._is_default=_is_default; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public index_property(ident _property_name,type_definition _property_type,expression _index_expression,property_accessors _accessors,property_array_default _array_default,property_parameter_list _parameter_list,definition_attribute _attr,proc_attribute _virt_over_none_attr,bool _is_auto,expression _initial_value,formal_parameters _property_parametres,default_indexer_property_node _is_default,SourceContext sc) { this._property_name=_property_name; this._property_type=_property_type; this._index_expression=_index_expression; this._accessors=_accessors; this._array_default=_array_default; this._parameter_list=_parameter_list; this._attr=_attr; this._virt_over_none_attr=_virt_over_none_attr; this._is_auto=_is_auto; this._initial_value=_initial_value; this._property_parametres=_property_parametres; this._is_default=_is_default; source_context = sc; FillParentsInDirectChilds(); } protected formal_parameters _property_parametres; protected default_indexer_property_node _is_default; /// /// /// public formal_parameters property_parametres { get { return _property_parametres; } set { _property_parametres=value; if (_property_parametres != null) _property_parametres.Parent = this; } } /// /// /// public default_indexer_property_node is_default { get { return _is_default; } set { _is_default=value; if (_is_default != null) _is_default.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { index_property copy = new index_property(); 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 (property_name != null) { copy.property_name = (ident)property_name.Clone(); copy.property_name.Parent = copy; } if (property_type != null) { copy.property_type = (type_definition)property_type.Clone(); copy.property_type.Parent = copy; } if (index_expression != null) { copy.index_expression = (expression)index_expression.Clone(); copy.index_expression.Parent = copy; } if (accessors != null) { copy.accessors = (property_accessors)accessors.Clone(); copy.accessors.Parent = copy; } if (array_default != null) { copy.array_default = (property_array_default)array_default.Clone(); copy.array_default.Parent = copy; } if (parameter_list != null) { copy.parameter_list = (property_parameter_list)parameter_list.Clone(); copy.parameter_list.Parent = copy; } copy.attr = attr; copy.virt_over_none_attr = virt_over_none_attr; copy.is_auto = is_auto; if (initial_value != null) { copy.initial_value = (expression)initial_value.Clone(); copy.initial_value.Parent = copy; } if (property_parametres != null) { copy.property_parametres = (formal_parameters)property_parametres.Clone(); copy.property_parametres.Parent = copy; } if (is_default != null) { copy.is_default = (default_indexer_property_node)is_default.Clone(); copy.is_default.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new index_property TypedClone() { return Clone() as index_property; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (property_name != null) property_name.Parent = this; if (property_type != null) property_type.Parent = this; if (index_expression != null) index_expression.Parent = this; if (accessors != null) accessors.Parent = this; if (array_default != null) array_default.Parent = this; if (parameter_list != null) parameter_list.Parent = this; if (initial_value != null) initial_value.Parent = this; if (property_parametres != null) property_parametres.Parent = this; if (is_default != null) is_default.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); property_name?.FillParentsInAllChilds(); property_type?.FillParentsInAllChilds(); index_expression?.FillParentsInAllChilds(); accessors?.FillParentsInAllChilds(); array_default?.FillParentsInAllChilds(); parameter_list?.FillParentsInAllChilds(); initial_value?.FillParentsInAllChilds(); property_parametres?.FillParentsInAllChilds(); is_default?.FillParentsInAllChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 9; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 9; } } /// ///Индексатор для получения всех подузлов /// 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 property_name; case 1: return property_type; case 2: return index_expression; case 3: return accessors; case 4: return array_default; case 5: return parameter_list; case 6: return initial_value; case 7: return property_parametres; case 8: return is_default; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: property_name = (ident)value; break; case 1: property_type = (type_definition)value; break; case 2: index_expression = (expression)value; break; case 3: accessors = (property_accessors)value; break; case 4: array_default = (property_array_default)value; break; case 5: parameter_list = (property_parameter_list)value; break; case 6: initial_value = (expression)value; break; case 7: property_parametres = (formal_parameters)value; break; case 8: is_default = (default_indexer_property_node)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class class_members : syntax_tree_node { /// ///Конструктор без параметров. /// public class_members() { } /// ///Конструктор с параметрами. /// public class_members(List _members,access_modifer_node _access_mod) { this._members=_members; this._access_mod=_access_mod; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public class_members(List _members,access_modifer_node _access_mod,SourceContext sc) { this._members=_members; this._access_mod=_access_mod; source_context = sc; FillParentsInDirectChilds(); } public class_members(declaration elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected List _members=new List(); protected access_modifer_node _access_mod; /// /// /// public List members { get { return _members; } set { _members=value; } } /// /// /// public access_modifer_node access_mod { get { return _access_mod; } set { _access_mod=value; if (_access_mod != null) _access_mod.Parent = this; } } public class_members Add(declaration elem, SourceContext sc = null) { members.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)); members.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); members.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)); members.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 = members.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)); members.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)); members.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)); members.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)); members.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(declaration el) { return members.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)); members[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); members.RemoveAt(ind); members.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return members.RemoveAll(match); } public declaration Last() { if (members.Count > 0) return members[members.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return members.Count; } } public void Insert(int pos, declaration el) { if (el == null) throw new ArgumentNullException(nameof(el)); members.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { class_members copy = new class_members(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (members != null) { foreach (declaration elem in members) { if (elem != null) { copy.Add((declaration)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } if (access_mod != null) { copy.access_mod = (access_modifer_node)access_mod.Clone(); copy.access_mod.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new class_members TypedClone() { return Clone() as class_members; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (members != null) { foreach (var child in members) if (child != null) child.Parent = this; } if (access_mod != null) access_mod.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (members != null) { foreach (var child in members) child?.FillParentsInAllChilds(); } access_mod?.FillParentsInAllChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 1; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 1 + (members == null ? 0 : members.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 access_mod; } Int32 index_counter=ind - 1; if(members != null) { if(index_counter < members.Count) { return members[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: access_mod = (access_modifer_node)value; break; } Int32 index_counter=ind - 1; if(members != null) { if(index_counter < members.Count) { members[index_counter]= (declaration)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class access_modifer_node : syntax_tree_node { /// ///Конструктор без параметров. /// public access_modifer_node() { } /// ///Конструктор с параметрами. /// public access_modifer_node(access_modifer _access_level) { this._access_level=_access_level; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public access_modifer_node(access_modifer _access_level,SourceContext sc) { this._access_level=_access_level; source_context = sc; FillParentsInDirectChilds(); } protected access_modifer _access_level; /// /// /// public access_modifer access_level { get { return _access_level; } set { _access_level=value; } } /// Создает копию узла public override syntax_tree_node Clone() { access_modifer_node copy = new access_modifer_node(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); copy.access_level = access_level; return copy; } /// Получает копию данного узла корректного типа public new access_modifer_node TypedClone() { return Clone() as access_modifer_node; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа 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 class_body_list : syntax_tree_node { /// ///Конструктор без параметров. /// public class_body_list() { } /// ///Конструктор с параметрами. /// public class_body_list(List _class_def_blocks) { this._class_def_blocks=_class_def_blocks; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public class_body_list(List _class_def_blocks,SourceContext sc) { this._class_def_blocks=_class_def_blocks; source_context = sc; FillParentsInDirectChilds(); } public class_body_list(class_members elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected List _class_def_blocks=new List(); /// /// /// public List class_def_blocks { get { return _class_def_blocks; } set { _class_def_blocks=value; } } public class_body_list Add(class_members elem, SourceContext sc = null) { class_def_blocks.Add(elem); if (elem != null) elem.Parent = this; if (sc != null) source_context = sc; return this; } public void AddFirst(class_members el) { if (el == null) throw new ArgumentNullException(nameof(el)); class_def_blocks.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); class_def_blocks.InsertRange(0, els); foreach (var el in els) if (el != null) el.Parent = this; } public void AddMany(params class_members[] els) { if (els == null) throw new ArgumentNullException(nameof(els)); class_def_blocks.AddRange(els); foreach (var el in els) if (el != null) el.Parent = this; } private int FindIndexInList(class_members el) { if (el == null) throw new ArgumentNullException(nameof(el)); var ind = class_def_blocks.FindIndex(x => x == el); if (ind == -1) throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el)); return ind; } public void InsertAfter(class_members el, class_members newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); class_def_blocks.Insert(FindIndexInList(el) + 1, newel); newel.Parent = this; } public void InsertAfter(class_members el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); class_def_blocks.InsertRange(FindIndexInList(el) + 1, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public void InsertBefore(class_members el, class_members newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); class_def_blocks.Insert(FindIndexInList(el), newel); newel.Parent = this; } public void InsertBefore(class_members el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); class_def_blocks.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(class_members el) { return class_def_blocks.Remove(el); } public void ReplaceInList(class_members el, class_members newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); class_def_blocks[FindIndexInList(el)] = newel; newel.Parent = this; } public void ReplaceInList(class_members el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); var ind = FindIndexInList(el); class_def_blocks.RemoveAt(ind); class_def_blocks.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return class_def_blocks.RemoveAll(match); } public class_members Last() { if (class_def_blocks.Count > 0) return class_def_blocks[class_def_blocks.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return class_def_blocks.Count; } } public void Insert(int pos, class_members el) { if (el == null) throw new ArgumentNullException(nameof(el)); class_def_blocks.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { class_body_list copy = new class_body_list(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (class_def_blocks != null) { foreach (class_members elem in class_def_blocks) { if (elem != null) { copy.Add((class_members)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new class_body_list TypedClone() { return Clone() as class_body_list; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (class_def_blocks != null) { foreach (var child in class_def_blocks) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (class_def_blocks != null) { foreach (var child in class_def_blocks) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (class_def_blocks == null ? 0 : class_def_blocks.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(class_def_blocks != null) { if(index_counter < class_def_blocks.Count) { return class_def_blocks[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); Int32 index_counter=ind - 0; if(class_def_blocks != null) { if(index_counter < class_def_blocks.Count) { class_def_blocks[index_counter]= (class_members)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class class_definition : type_definition { /// ///Конструктор без параметров. /// public class_definition() { } /// ///Конструктор с параметрами. /// public class_definition(named_type_reference_list _class_parents,class_body_list _body,class_keyword _keyword,ident_list _template_args,where_definition_list _where_section,class_attribute _attribute,bool _is_auto) { this._class_parents=_class_parents; this._body=_body; this._keyword=_keyword; this._template_args=_template_args; this._where_section=_where_section; this._attribute=_attribute; this._is_auto=_is_auto; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public class_definition(named_type_reference_list _class_parents,class_body_list _body,class_keyword _keyword,ident_list _template_args,where_definition_list _where_section,class_attribute _attribute,bool _is_auto,SourceContext sc) { this._class_parents=_class_parents; this._body=_body; this._keyword=_keyword; this._template_args=_template_args; this._where_section=_where_section; this._attribute=_attribute; this._is_auto=_is_auto; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public class_definition(type_definition_attr_list _attr_list,named_type_reference_list _class_parents,class_body_list _body,class_keyword _keyword,ident_list _template_args,where_definition_list _where_section,class_attribute _attribute,bool _is_auto) { this._attr_list=_attr_list; this._class_parents=_class_parents; this._body=_body; this._keyword=_keyword; this._template_args=_template_args; this._where_section=_where_section; this._attribute=_attribute; this._is_auto=_is_auto; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public class_definition(type_definition_attr_list _attr_list,named_type_reference_list _class_parents,class_body_list _body,class_keyword _keyword,ident_list _template_args,where_definition_list _where_section,class_attribute _attribute,bool _is_auto,SourceContext sc) { this._attr_list=_attr_list; this._class_parents=_class_parents; this._body=_body; this._keyword=_keyword; this._template_args=_template_args; this._where_section=_where_section; this._attribute=_attribute; this._is_auto=_is_auto; source_context = sc; FillParentsInDirectChilds(); } protected named_type_reference_list _class_parents; protected class_body_list _body; protected class_keyword _keyword; protected ident_list _template_args; protected where_definition_list _where_section; protected class_attribute _attribute; protected bool _is_auto; /// /// /// public named_type_reference_list class_parents { get { return _class_parents; } set { _class_parents=value; if (_class_parents != null) _class_parents.Parent = this; } } /// /// /// public class_body_list body { get { return _body; } set { _body=value; if (_body != null) _body.Parent = this; } } /// /// /// public class_keyword keyword { get { return _keyword; } set { _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_section { get { return _where_section; } set { _where_section=value; if (_where_section != null) _where_section.Parent = this; } } /// /// /// public class_attribute attribute { get { return _attribute; } set { _attribute=value; } } /// /// /// public bool is_auto { get { return _is_auto; } set { _is_auto=value; } } /// Создает копию узла public override syntax_tree_node Clone() { class_definition copy = new class_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; } if (class_parents != null) { copy.class_parents = (named_type_reference_list)class_parents.Clone(); copy.class_parents.Parent = copy; } if (body != null) { copy.body = (class_body_list)body.Clone(); copy.body.Parent = copy; } copy.keyword = keyword; if (template_args != null) { copy.template_args = (ident_list)template_args.Clone(); copy.template_args.Parent = copy; } if (where_section != null) { copy.where_section = (where_definition_list)where_section.Clone(); copy.where_section.Parent = copy; } copy.attribute = attribute; copy.is_auto = is_auto; return copy; } /// Получает копию данного узла корректного типа public new class_definition TypedClone() { return Clone() as class_definition; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (attr_list != null) attr_list.Parent = this; if (class_parents != null) class_parents.Parent = this; if (body != null) body.Parent = this; if (template_args != null) template_args.Parent = this; if (where_section != null) where_section.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); attr_list?.FillParentsInAllChilds(); class_parents?.FillParentsInAllChilds(); body?.FillParentsInAllChilds(); template_args?.FillParentsInAllChilds(); where_section?.FillParentsInAllChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 5; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 5; } } /// ///Индексатор для получения всех подузлов /// 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 class_parents; case 2: return body; case 3: return template_args; case 4: return where_section; } 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: class_parents = (named_type_reference_list)value; break; case 2: body = (class_body_list)value; break; case 3: template_args = (ident_list)value; break; case 4: where_section = (where_definition_list)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class default_indexer_property_node : syntax_tree_node { /// ///Конструктор без параметров. /// public default_indexer_property_node() { } /// Создает копию узла public override syntax_tree_node Clone() { default_indexer_property_node copy = new default_indexer_property_node(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); return copy; } /// Получает копию данного узла корректного типа public new default_indexer_property_node TypedClone() { return Clone() as default_indexer_property_node; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа 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 known_type_definition : type_definition { /// ///Конструктор без параметров. /// public known_type_definition() { } /// ///Конструктор с параметрами. /// public known_type_definition(known_type _tp,ident _unit_name) { this._tp=_tp; this._unit_name=_unit_name; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public known_type_definition(known_type _tp,ident _unit_name,SourceContext sc) { this._tp=_tp; this._unit_name=_unit_name; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public known_type_definition(type_definition_attr_list _attr_list,known_type _tp,ident _unit_name) { this._attr_list=_attr_list; this._tp=_tp; this._unit_name=_unit_name; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public known_type_definition(type_definition_attr_list _attr_list,known_type _tp,ident _unit_name,SourceContext sc) { this._attr_list=_attr_list; this._tp=_tp; this._unit_name=_unit_name; source_context = sc; FillParentsInDirectChilds(); } protected known_type _tp; protected ident _unit_name; /// /// /// public known_type tp { get { return _tp; } set { _tp=value; } } /// /// /// public ident unit_name { get { return _unit_name; } set { _unit_name=value; if (_unit_name != null) _unit_name.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { known_type_definition copy = new known_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; } copy.tp = tp; if (unit_name != null) { copy.unit_name = (ident)unit_name.Clone(); copy.unit_name.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new known_type_definition TypedClone() { return Clone() as known_type_definition; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (attr_list != null) attr_list.Parent = this; if (unit_name != null) unit_name.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); attr_list?.FillParentsInAllChilds(); unit_name?.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 unit_name; } 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: unit_name = (ident)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class set_type_definition : type_definition { /// ///Конструктор без параметров. /// public set_type_definition() { } /// ///Конструктор с параметрами. /// public set_type_definition(type_definition _of_type) { this._of_type=_of_type; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public set_type_definition(type_definition _of_type,SourceContext sc) { this._of_type=_of_type; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public set_type_definition(type_definition_attr_list _attr_list,type_definition _of_type) { this._attr_list=_attr_list; this._of_type=_of_type; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public set_type_definition(type_definition_attr_list _attr_list,type_definition _of_type,SourceContext sc) { this._attr_list=_attr_list; this._of_type=_of_type; source_context = sc; FillParentsInDirectChilds(); } protected type_definition _of_type; /// /// /// public type_definition of_type { get { return _of_type; } set { _of_type=value; if (_of_type != null) _of_type.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { set_type_definition copy = new set_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; } if (of_type != null) { copy.of_type = (type_definition)of_type.Clone(); copy.of_type.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new set_type_definition TypedClone() { return Clone() as set_type_definition; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (attr_list != null) attr_list.Parent = this; if (of_type != null) of_type.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); attr_list?.FillParentsInAllChilds(); of_type?.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 of_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: of_type = (type_definition)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class record_const_definition : statement { /// ///Конструктор без параметров. /// public record_const_definition() { } /// ///Конструктор с параметрами. /// public record_const_definition(ident _name,expression _val) { this._name=_name; this._val=_val; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public record_const_definition(ident _name,expression _val,SourceContext sc) { this._name=_name; this._val=_val; source_context = sc; FillParentsInDirectChilds(); } protected ident _name; protected expression _val; /// /// /// public ident name { get { return _name; } set { _name=value; if (_name != null) _name.Parent = this; } } /// /// /// public expression val { get { return _val; } set { _val=value; if (_val != null) _val.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { record_const_definition copy = new record_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 (name != null) { copy.name = (ident)name.Clone(); copy.name.Parent = copy; } if (val != null) { copy.val = (expression)val.Clone(); copy.val.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new record_const_definition TypedClone() { return Clone() as record_const_definition; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (name != null) name.Parent = this; if (val != null) val.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); name?.FillParentsInAllChilds(); val?.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 val; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: name = (ident)value; break; case 1: val = (expression)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class record_const : expression { /// ///Конструктор без параметров. /// public record_const() { } /// ///Конструктор с параметрами. /// public record_const(List _rec_consts) { this._rec_consts=_rec_consts; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public record_const(List _rec_consts,SourceContext sc) { this._rec_consts=_rec_consts; source_context = sc; FillParentsInDirectChilds(); } public record_const(record_const_definition elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected List _rec_consts=new List(); /// /// /// public List rec_consts { get { return _rec_consts; } set { _rec_consts=value; } } public record_const Add(record_const_definition elem, SourceContext sc = null) { rec_consts.Add(elem); if (elem != null) elem.Parent = this; if (sc != null) source_context = sc; return this; } public void AddFirst(record_const_definition el) { if (el == null) throw new ArgumentNullException(nameof(el)); rec_consts.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); rec_consts.InsertRange(0, els); foreach (var el in els) if (el != null) el.Parent = this; } public void AddMany(params record_const_definition[] els) { if (els == null) throw new ArgumentNullException(nameof(els)); rec_consts.AddRange(els); foreach (var el in els) if (el != null) el.Parent = this; } private int FindIndexInList(record_const_definition el) { if (el == null) throw new ArgumentNullException(nameof(el)); var ind = rec_consts.FindIndex(x => x == el); if (ind == -1) throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el)); return ind; } public void InsertAfter(record_const_definition el, record_const_definition newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); rec_consts.Insert(FindIndexInList(el) + 1, newel); newel.Parent = this; } public void InsertAfter(record_const_definition el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); rec_consts.InsertRange(FindIndexInList(el) + 1, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public void InsertBefore(record_const_definition el, record_const_definition newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); rec_consts.Insert(FindIndexInList(el), newel); newel.Parent = this; } public void InsertBefore(record_const_definition el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); rec_consts.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(record_const_definition el) { return rec_consts.Remove(el); } public void ReplaceInList(record_const_definition el, record_const_definition newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); rec_consts[FindIndexInList(el)] = newel; newel.Parent = this; } public void ReplaceInList(record_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); rec_consts.RemoveAt(ind); rec_consts.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return rec_consts.RemoveAll(match); } public record_const_definition Last() { if (rec_consts.Count > 0) return rec_consts[rec_consts.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return rec_consts.Count; } } public void Insert(int pos, record_const_definition el) { if (el == null) throw new ArgumentNullException(nameof(el)); rec_consts.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { record_const copy = new record_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; } if (rec_consts != null) { foreach (record_const_definition elem in rec_consts) { if (elem != null) { copy.Add((record_const_definition)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new record_const TypedClone() { return Clone() as record_const; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (rec_consts != null) { foreach (var child in rec_consts) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); if (rec_consts != null) { foreach (var child in rec_consts) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (rec_consts == null ? 0 : rec_consts.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(rec_consts != null) { if(index_counter < rec_consts.Count) { return rec_consts[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); Int32 index_counter=ind - 0; if(rec_consts != null) { if(index_counter < rec_consts.Count) { rec_consts[index_counter]= (record_const_definition)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class record_type : type_definition { /// ///Конструктор без параметров. /// public record_type() { } /// ///Конструктор с параметрами. /// public record_type(record_type_parts _parts,type_definition _base_type) { this._parts=_parts; this._base_type=_base_type; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public record_type(record_type_parts _parts,type_definition _base_type,SourceContext sc) { this._parts=_parts; this._base_type=_base_type; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public record_type(type_definition_attr_list _attr_list,record_type_parts _parts,type_definition _base_type) { this._attr_list=_attr_list; this._parts=_parts; this._base_type=_base_type; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public record_type(type_definition_attr_list _attr_list,record_type_parts _parts,type_definition _base_type,SourceContext sc) { this._attr_list=_attr_list; this._parts=_parts; this._base_type=_base_type; source_context = sc; FillParentsInDirectChilds(); } protected record_type_parts _parts; protected type_definition _base_type; /// /// /// public record_type_parts parts { get { return _parts; } set { _parts=value; if (_parts != null) _parts.Parent = this; } } /// ///in oberon2 /// public type_definition base_type { get { return _base_type; } set { _base_type=value; if (_base_type != null) _base_type.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { record_type copy = new record_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 (parts != null) { copy.parts = (record_type_parts)parts.Clone(); copy.parts.Parent = copy; } if (base_type != null) { copy.base_type = (type_definition)base_type.Clone(); copy.base_type.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new record_type TypedClone() { return Clone() as record_type; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (attr_list != null) attr_list.Parent = this; if (parts != null) parts.Parent = this; if (base_type != null) base_type.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); attr_list?.FillParentsInAllChilds(); parts?.FillParentsInAllChilds(); base_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 parts; case 2: return base_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: parts = (record_type_parts)value; break; case 2: base_type = (type_definition)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class enum_type_definition : type_definition { /// ///Конструктор без параметров. /// public enum_type_definition() { } /// ///Конструктор с параметрами. /// public enum_type_definition(enumerator_list _enumerators) { this._enumerators=_enumerators; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public enum_type_definition(enumerator_list _enumerators,SourceContext sc) { this._enumerators=_enumerators; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public enum_type_definition(type_definition_attr_list _attr_list,enumerator_list _enumerators) { this._attr_list=_attr_list; this._enumerators=_enumerators; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public enum_type_definition(type_definition_attr_list _attr_list,enumerator_list _enumerators,SourceContext sc) { this._attr_list=_attr_list; this._enumerators=_enumerators; source_context = sc; FillParentsInDirectChilds(); } protected enumerator_list _enumerators; /// /// /// public enumerator_list enumerators { get { return _enumerators; } set { _enumerators=value; if (_enumerators != null) _enumerators.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { enum_type_definition copy = new enum_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; } if (enumerators != null) { copy.enumerators = (enumerator_list)enumerators.Clone(); copy.enumerators.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new enum_type_definition TypedClone() { return Clone() as enum_type_definition; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (attr_list != null) attr_list.Parent = this; if (enumerators != null) enumerators.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); attr_list?.FillParentsInAllChilds(); enumerators?.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 enumerators; } 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: enumerators = (enumerator_list)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// ///Класс, представляющий символьную константу в синтаксическом дереве программы. /// [Serializable] public partial class char_const : literal { /// ///Конструктор без параметров. /// public char_const() { } /// ///Конструктор с параметрами. /// public char_const(char _cconst) { this._cconst=_cconst; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public char_const(char _cconst,SourceContext sc) { this._cconst=_cconst; source_context = sc; FillParentsInDirectChilds(); } protected char _cconst; /// /// /// public char cconst { get { return _cconst; } set { _cconst=value; } } /// Создает копию узла public override syntax_tree_node Clone() { char_const copy = new char_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.cconst = cconst; return copy; } /// Получает копию данного узла корректного типа public new char_const TypedClone() { return Clone() as char_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 raise_statement : statement { /// ///Конструктор без параметров. /// public raise_statement() { } /// ///Конструктор с параметрами. /// public raise_statement(expression _excep) { this._excep=_excep; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public raise_statement(expression _excep,SourceContext sc) { this._excep=_excep; source_context = sc; FillParentsInDirectChilds(); } protected expression _excep; /// ///Выкидываемое исключение. /// public expression excep { get { return _excep; } set { _excep=value; if (_excep != null) _excep.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { raise_statement copy = new raise_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 (excep != null) { copy.excep = (expression)excep.Clone(); copy.excep.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new raise_statement TypedClone() { return Clone() as raise_statement; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (excep != null) excep.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); excep?.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 excep; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: excep = (expression)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// ///Представление в синтаксичеком дереве символьной константы вида #100. /// [Serializable] public partial class sharp_char_const : literal { /// ///Конструктор без параметров. /// public sharp_char_const() { } /// ///Конструктор с параметрами. /// public sharp_char_const(int _char_num) { this._char_num=_char_num; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public sharp_char_const(int _char_num,SourceContext sc) { this._char_num=_char_num; source_context = sc; FillParentsInDirectChilds(); } protected int _char_num; /// /// /// public int char_num { get { return _char_num; } set { _char_num=value; } } /// Создает копию узла public override syntax_tree_node Clone() { sharp_char_const copy = new sharp_char_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.char_num = char_num; return copy; } /// Получает копию данного узла корректного типа public new sharp_char_const TypedClone() { return Clone() as sharp_char_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); } } /// ///Представляет в синтаксическом дереве строку вида #123'abc'#124#125. /// [Serializable] public partial class literal_const_line : literal { /// ///Конструктор без параметров. /// public literal_const_line() { } /// ///Конструктор с параметрами. /// public literal_const_line(List _literals) { this._literals=_literals; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public literal_const_line(List _literals,SourceContext sc) { this._literals=_literals; source_context = sc; FillParentsInDirectChilds(); } public literal_const_line(literal elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected List _literals=new List(); /// /// /// public List literals { get { return _literals; } set { _literals=value; } } public literal_const_line Add(literal elem, SourceContext sc = null) { literals.Add(elem); if (elem != null) elem.Parent = this; if (sc != null) source_context = sc; return this; } public void AddFirst(literal el) { if (el == null) throw new ArgumentNullException(nameof(el)); literals.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); literals.InsertRange(0, els); foreach (var el in els) if (el != null) el.Parent = this; } public void AddMany(params literal[] els) { if (els == null) throw new ArgumentNullException(nameof(els)); literals.AddRange(els); foreach (var el in els) if (el != null) el.Parent = this; } private int FindIndexInList(literal el) { if (el == null) throw new ArgumentNullException(nameof(el)); var ind = literals.FindIndex(x => x == el); if (ind == -1) throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el)); return ind; } public void InsertAfter(literal el, literal newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); literals.Insert(FindIndexInList(el) + 1, newel); newel.Parent = this; } public void InsertAfter(literal el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); literals.InsertRange(FindIndexInList(el) + 1, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public void InsertBefore(literal el, literal newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); literals.Insert(FindIndexInList(el), newel); newel.Parent = this; } public void InsertBefore(literal el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); literals.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(literal el) { return literals.Remove(el); } public void ReplaceInList(literal el, literal newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); literals[FindIndexInList(el)] = newel; newel.Parent = this; } public void ReplaceInList(literal el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); var ind = FindIndexInList(el); literals.RemoveAt(ind); literals.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return literals.RemoveAll(match); } public literal Last() { if (literals.Count > 0) return literals[literals.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return literals.Count; } } public void Insert(int pos, literal el) { if (el == null) throw new ArgumentNullException(nameof(el)); literals.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { literal_const_line copy = new literal_const_line(); 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 (literals != null) { foreach (literal elem in literals) { if (elem != null) { copy.Add((literal)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new literal_const_line TypedClone() { return Clone() as literal_const_line; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (literals != null) { foreach (var child in literals) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); if (literals != null) { foreach (var child in literals) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (literals == null ? 0 : literals.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(literals != null) { if(index_counter < literals.Count) { return literals[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); Int32 index_counter=ind - 0; if(literals != null) { if(index_counter < literals.Count) { literals[index_counter]= (literal)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// ///Представление для класса строки вида string[256]. /// [Serializable] public partial class string_num_definition : type_definition { /// ///Конструктор без параметров. /// public string_num_definition() { } /// ///Конструктор с параметрами. /// public string_num_definition(expression _num_of_symbols,ident _name) { this._num_of_symbols=_num_of_symbols; this._name=_name; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public string_num_definition(expression _num_of_symbols,ident _name,SourceContext sc) { this._num_of_symbols=_num_of_symbols; this._name=_name; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public string_num_definition(type_definition_attr_list _attr_list,expression _num_of_symbols,ident _name) { this._attr_list=_attr_list; this._num_of_symbols=_num_of_symbols; this._name=_name; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public string_num_definition(type_definition_attr_list _attr_list,expression _num_of_symbols,ident _name,SourceContext sc) { this._attr_list=_attr_list; this._num_of_symbols=_num_of_symbols; this._name=_name; source_context = sc; FillParentsInDirectChilds(); } protected expression _num_of_symbols; protected ident _name; /// ///Число символов в строке вида string[256]. /// public expression num_of_symbols { get { return _num_of_symbols; } set { _num_of_symbols=value; if (_num_of_symbols != null) _num_of_symbols.Parent = this; } } /// /// /// public ident name { get { return _name; } set { _name=value; if (_name != null) _name.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { string_num_definition copy = new string_num_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; } if (num_of_symbols != null) { copy.num_of_symbols = (expression)num_of_symbols.Clone(); copy.num_of_symbols.Parent = copy; } if (name != null) { copy.name = (ident)name.Clone(); copy.name.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new string_num_definition TypedClone() { return Clone() as string_num_definition; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (attr_list != null) attr_list.Parent = this; if (num_of_symbols != null) num_of_symbols.Parent = this; if (name != null) name.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); attr_list?.FillParentsInAllChilds(); num_of_symbols?.FillParentsInAllChilds(); name?.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 num_of_symbols; case 2: return name; } 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: num_of_symbols = (expression)value; break; case 2: name = (ident)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class variant : syntax_tree_node { /// ///Конструктор без параметров. /// public variant() { } /// ///Конструктор с параметрами. /// public variant(ident_list _vars,type_definition _vars_type) { this._vars=_vars; this._vars_type=_vars_type; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public variant(ident_list _vars,type_definition _vars_type,SourceContext sc) { this._vars=_vars; this._vars_type=_vars_type; source_context = sc; FillParentsInDirectChilds(); } protected ident_list _vars; protected type_definition _vars_type; /// /// /// 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 override syntax_tree_node Clone() { variant copy = new variant(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); 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; } return copy; } /// Получает копию данного узла корректного типа public new variant TypedClone() { return Clone() as variant; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (vars != null) vars.Parent = this; if (vars_type != null) vars_type.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); vars?.FillParentsInAllChilds(); vars_type?.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 vars; case 1: return vars_type; } 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; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class variant_list : syntax_tree_node { /// ///Конструктор без параметров. /// public variant_list() { } /// ///Конструктор с параметрами. /// public variant_list(List _vars) { this._vars=_vars; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public variant_list(List _vars,SourceContext sc) { this._vars=_vars; source_context = sc; FillParentsInDirectChilds(); } public variant_list(variant elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected List _vars=new List(); /// /// /// public List vars { get { return _vars; } set { _vars=value; } } public variant_list Add(variant elem, SourceContext sc = null) { vars.Add(elem); if (elem != null) elem.Parent = this; if (sc != null) source_context = sc; return this; } public void AddFirst(variant el) { if (el == null) throw new ArgumentNullException(nameof(el)); vars.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); vars.InsertRange(0, els); foreach (var el in els) if (el != null) el.Parent = this; } public void AddMany(params variant[] els) { if (els == null) throw new ArgumentNullException(nameof(els)); vars.AddRange(els); foreach (var el in els) if (el != null) el.Parent = this; } private int FindIndexInList(variant el) { if (el == null) throw new ArgumentNullException(nameof(el)); var ind = vars.FindIndex(x => x == el); if (ind == -1) throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el)); return ind; } public void InsertAfter(variant el, variant newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); vars.Insert(FindIndexInList(el) + 1, newel); newel.Parent = this; } public void InsertAfter(variant el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); vars.InsertRange(FindIndexInList(el) + 1, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public void InsertBefore(variant el, variant newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); vars.Insert(FindIndexInList(el), newel); newel.Parent = this; } public void InsertBefore(variant el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); vars.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(variant el) { return vars.Remove(el); } public void ReplaceInList(variant el, variant newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); vars[FindIndexInList(el)] = newel; newel.Parent = this; } public void ReplaceInList(variant el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); var ind = FindIndexInList(el); vars.RemoveAt(ind); vars.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return vars.RemoveAll(match); } public variant Last() { if (vars.Count > 0) return vars[vars.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return vars.Count; } } public void Insert(int pos, variant el) { if (el == null) throw new ArgumentNullException(nameof(el)); vars.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { variant_list copy = new variant_list(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (vars != null) { foreach (variant elem in vars) { if (elem != null) { copy.Add((variant)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new variant_list TypedClone() { return Clone() as variant_list; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (vars != null) { foreach (var child in vars) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (vars != null) { foreach (var child in vars) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (vars == null ? 0 : vars.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(vars != null) { if(index_counter < vars.Count) { return vars[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); Int32 index_counter=ind - 0; if(vars != null) { if(index_counter < vars.Count) { vars[index_counter]= (variant)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class variant_type : syntax_tree_node { /// ///Конструктор без параметров. /// public variant_type() { } /// ///Конструктор с параметрами. /// public variant_type(expression_list _case_exprs,record_type_parts _parts) { this._case_exprs=_case_exprs; this._parts=_parts; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public variant_type(expression_list _case_exprs,record_type_parts _parts,SourceContext sc) { this._case_exprs=_case_exprs; this._parts=_parts; source_context = sc; FillParentsInDirectChilds(); } protected expression_list _case_exprs; protected record_type_parts _parts; /// /// /// public expression_list case_exprs { get { return _case_exprs; } set { _case_exprs=value; if (_case_exprs != null) _case_exprs.Parent = this; } } /// /// /// public record_type_parts parts { get { return _parts; } set { _parts=value; if (_parts != null) _parts.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { variant_type copy = new variant_type(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (case_exprs != null) { copy.case_exprs = (expression_list)case_exprs.Clone(); copy.case_exprs.Parent = copy; } if (parts != null) { copy.parts = (record_type_parts)parts.Clone(); copy.parts.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new variant_type TypedClone() { return Clone() as variant_type; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (case_exprs != null) case_exprs.Parent = this; if (parts != null) parts.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); case_exprs?.FillParentsInAllChilds(); parts?.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 case_exprs; case 1: return parts; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: case_exprs = (expression_list)value; break; case 1: parts = (record_type_parts)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class variant_types : syntax_tree_node { /// ///Конструктор без параметров. /// public variant_types() { } /// ///Конструктор с параметрами. /// public variant_types(List _vars) { this._vars=_vars; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public variant_types(List _vars,SourceContext sc) { this._vars=_vars; source_context = sc; FillParentsInDirectChilds(); } public variant_types(variant_type elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected List _vars=new List(); /// /// /// public List vars { get { return _vars; } set { _vars=value; } } public variant_types Add(variant_type elem, SourceContext sc = null) { vars.Add(elem); if (elem != null) elem.Parent = this; if (sc != null) source_context = sc; return this; } public void AddFirst(variant_type el) { if (el == null) throw new ArgumentNullException(nameof(el)); vars.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); vars.InsertRange(0, els); foreach (var el in els) if (el != null) el.Parent = this; } public void AddMany(params variant_type[] els) { if (els == null) throw new ArgumentNullException(nameof(els)); vars.AddRange(els); foreach (var el in els) if (el != null) el.Parent = this; } private int FindIndexInList(variant_type el) { if (el == null) throw new ArgumentNullException(nameof(el)); var ind = vars.FindIndex(x => x == el); if (ind == -1) throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el)); return ind; } public void InsertAfter(variant_type el, variant_type newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); vars.Insert(FindIndexInList(el) + 1, newel); newel.Parent = this; } public void InsertAfter(variant_type el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); vars.InsertRange(FindIndexInList(el) + 1, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public void InsertBefore(variant_type el, variant_type newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); vars.Insert(FindIndexInList(el), newel); newel.Parent = this; } public void InsertBefore(variant_type el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); vars.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(variant_type el) { return vars.Remove(el); } public void ReplaceInList(variant_type el, variant_type newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); vars[FindIndexInList(el)] = newel; newel.Parent = this; } public void ReplaceInList(variant_type el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); var ind = FindIndexInList(el); vars.RemoveAt(ind); vars.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return vars.RemoveAll(match); } public variant_type Last() { if (vars.Count > 0) return vars[vars.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return vars.Count; } } public void Insert(int pos, variant_type el) { if (el == null) throw new ArgumentNullException(nameof(el)); vars.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { variant_types copy = new variant_types(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (vars != null) { foreach (variant_type elem in vars) { if (elem != null) { copy.Add((variant_type)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new variant_types TypedClone() { return Clone() as variant_types; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (vars != null) { foreach (var child in vars) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (vars != null) { foreach (var child in vars) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (vars == null ? 0 : vars.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(vars != null) { if(index_counter < vars.Count) { return vars[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); Int32 index_counter=ind - 0; if(vars != null) { if(index_counter < vars.Count) { vars[index_counter]= (variant_type)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class variant_record_type : syntax_tree_node { /// ///Конструктор без параметров. /// public variant_record_type() { } /// ///Конструктор с параметрами. /// public variant_record_type(ident _var_name,type_definition _var_type,variant_types _vars) { this._var_name=_var_name; this._var_type=_var_type; this._vars=_vars; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public variant_record_type(ident _var_name,type_definition _var_type,variant_types _vars,SourceContext sc) { this._var_name=_var_name; this._var_type=_var_type; this._vars=_vars; source_context = sc; FillParentsInDirectChilds(); } protected ident _var_name; protected type_definition _var_type; protected variant_types _vars; /// /// /// public ident var_name { get { return _var_name; } set { _var_name=value; if (_var_name != null) _var_name.Parent = this; } } /// /// /// public type_definition var_type { get { return _var_type; } set { _var_type=value; if (_var_type != null) _var_type.Parent = this; } } /// /// /// public variant_types vars { get { return _vars; } set { _vars=value; if (_vars != null) _vars.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { variant_record_type copy = new variant_record_type(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (var_name != null) { copy.var_name = (ident)var_name.Clone(); copy.var_name.Parent = copy; } if (var_type != null) { copy.var_type = (type_definition)var_type.Clone(); copy.var_type.Parent = copy; } if (vars != null) { copy.vars = (variant_types)vars.Clone(); copy.vars.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new variant_record_type TypedClone() { return Clone() as variant_record_type; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (var_name != null) var_name.Parent = this; if (var_type != null) var_type.Parent = this; if (vars != null) vars.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); var_name?.FillParentsInAllChilds(); var_type?.FillParentsInAllChilds(); vars?.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 var_name; case 1: return var_type; case 2: return vars; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: var_name = (ident)value; break; case 1: var_type = (type_definition)value; break; case 2: vars = (variant_types)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// ///bool is_ident; // является ли вызов процедуры идентификатором. Нужно исключительно для секции write свойств /// [Serializable] public partial class procedure_call : statement { /// ///Конструктор без параметров. /// public procedure_call() { } /// ///Конструктор с параметрами. /// public procedure_call(addressed_value _func_name,bool _is_ident) { this._func_name=_func_name; this._is_ident=_is_ident; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public procedure_call(addressed_value _func_name,bool _is_ident,SourceContext sc) { this._func_name=_func_name; this._is_ident=_is_ident; source_context = sc; FillParentsInDirectChilds(); } protected addressed_value _func_name; protected bool _is_ident; /// /// /// public addressed_value func_name { get { return _func_name; } set { _func_name=value; if (_func_name != null) _func_name.Parent = this; } } /// /// /// public bool is_ident { get { return _is_ident; } set { _is_ident=value; } } /// Создает копию узла public override syntax_tree_node Clone() { procedure_call copy = new procedure_call(); 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 (func_name != null) { copy.func_name = (addressed_value)func_name.Clone(); copy.func_name.Parent = copy; } copy.is_ident = is_ident; return copy; } /// Получает копию данного узла корректного типа public new procedure_call TypedClone() { return Clone() as procedure_call; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (func_name != null) func_name.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); func_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 func_name; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: func_name = (addressed_value)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class class_predefinition : type_declaration { /// ///Конструктор без параметров. /// public class_predefinition() { } /// ///Конструктор с параметрами. /// public class_predefinition(ident _class_name) { this._class_name=_class_name; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public class_predefinition(ident _class_name,SourceContext sc) { this._class_name=_class_name; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public class_predefinition(ident _type_name,type_definition _type_def,ident _class_name) { this._type_name=_type_name; this._type_def=_type_def; this._class_name=_class_name; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public class_predefinition(ident _type_name,type_definition _type_def,ident _class_name,SourceContext sc) { this._type_name=_type_name; this._type_def=_type_def; this._class_name=_class_name; source_context = sc; FillParentsInDirectChilds(); } protected ident _class_name; /// /// /// public ident class_name { get { return _class_name; } set { _class_name=value; if (_class_name != null) _class_name.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { class_predefinition copy = new class_predefinition(); 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; } if (class_name != null) { copy.class_name = (ident)class_name.Clone(); copy.class_name.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new class_predefinition TypedClone() { return Clone() as class_predefinition; } /// Заполняет поля 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; if (class_name != null) class_name.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); type_name?.FillParentsInAllChilds(); type_def?.FillParentsInAllChilds(); class_name?.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 type_name; case 1: return type_def; case 2: return class_name; } 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; case 2: class_name = (ident)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class nil_const : const_node { /// ///Конструктор без параметров. /// public nil_const() { } /// Создает копию узла public override syntax_tree_node Clone() { nil_const copy = new nil_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; } return copy; } /// Получает копию данного узла корректного типа public new nil_const TypedClone() { return Clone() as nil_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 file_type_definition : type_definition { /// ///Конструктор без параметров. /// public file_type_definition() { } /// ///Конструктор с параметрами. /// public file_type_definition(type_definition _elem_type) { this._elem_type=_elem_type; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public file_type_definition(type_definition _elem_type,SourceContext sc) { this._elem_type=_elem_type; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public file_type_definition(type_definition_attr_list _attr_list,type_definition _elem_type) { this._attr_list=_attr_list; this._elem_type=_elem_type; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public file_type_definition(type_definition_attr_list _attr_list,type_definition _elem_type,SourceContext sc) { this._attr_list=_attr_list; this._elem_type=_elem_type; source_context = sc; FillParentsInDirectChilds(); } protected type_definition _elem_type; /// /// /// public type_definition elem_type { get { return _elem_type; } set { _elem_type=value; if (_elem_type != null) _elem_type.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { file_type_definition copy = new file_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; } if (elem_type != null) { copy.elem_type = (type_definition)elem_type.Clone(); copy.elem_type.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new file_type_definition TypedClone() { return Clone() as file_type_definition; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (attr_list != null) attr_list.Parent = this; if (elem_type != null) elem_type.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); attr_list?.FillParentsInAllChilds(); elem_type?.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 elem_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: elem_type = (type_definition)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class constructor : procedure_header { /// ///Конструктор без параметров. /// public constructor() { } /// ///Конструктор с параметрами. /// public constructor(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 constructor(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(); } /// Создает копию узла public override syntax_tree_node Clone() { constructor copy = new constructor(); 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 constructor TypedClone() { return Clone() as constructor; } /// Заполняет поля 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 destructor : procedure_header { /// ///Конструктор без параметров. /// public destructor() { } /// ///Конструктор с параметрами. /// public destructor(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 destructor(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(); } /// Создает копию узла public override syntax_tree_node Clone() { destructor copy = new destructor(); 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 destructor TypedClone() { return Clone() as destructor; } /// Заполняет поля 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 inherited_method_call : statement { /// ///Конструктор без параметров. /// public inherited_method_call() { } /// ///Конструктор с параметрами. /// public inherited_method_call(ident _method_name,expression_list _exprs) { this._method_name=_method_name; this._exprs=_exprs; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public inherited_method_call(ident _method_name,expression_list _exprs,SourceContext sc) { this._method_name=_method_name; this._exprs=_exprs; source_context = sc; FillParentsInDirectChilds(); } protected ident _method_name; protected expression_list _exprs; /// /// /// public ident method_name { get { return _method_name; } set { _method_name=value; if (_method_name != null) _method_name.Parent = this; } } /// /// /// public expression_list exprs { get { return _exprs; } set { _exprs=value; if (_exprs != null) _exprs.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { inherited_method_call copy = new inherited_method_call(); 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 (method_name != null) { copy.method_name = (ident)method_name.Clone(); copy.method_name.Parent = copy; } if (exprs != null) { copy.exprs = (expression_list)exprs.Clone(); copy.exprs.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new inherited_method_call TypedClone() { return Clone() as inherited_method_call; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (method_name != null) method_name.Parent = this; if (exprs != null) exprs.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); method_name?.FillParentsInAllChilds(); exprs?.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 method_name; case 1: return exprs; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: method_name = (ident)value; break; case 1: exprs = (expression_list)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class typecast_node : addressed_value { /// ///Конструктор без параметров. /// public typecast_node() { } /// ///Конструктор с параметрами. /// public typecast_node(addressed_value _expr,type_definition _type_def,op_typecast _cast_op) { this._expr=_expr; this._type_def=_type_def; this._cast_op=_cast_op; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public typecast_node(addressed_value _expr,type_definition _type_def,op_typecast _cast_op,SourceContext sc) { this._expr=_expr; this._type_def=_type_def; this._cast_op=_cast_op; source_context = sc; FillParentsInDirectChilds(); } protected addressed_value _expr; protected type_definition _type_def; protected op_typecast _cast_op; /// /// /// public addressed_value expr { get { return _expr; } set { _expr=value; if (_expr != null) _expr.Parent = this; } } /// /// /// public type_definition type_def { get { return _type_def; } set { _type_def=value; if (_type_def != null) _type_def.Parent = this; } } /// /// /// public op_typecast cast_op { get { return _cast_op; } set { _cast_op=value; } } /// Создает копию узла public override syntax_tree_node Clone() { typecast_node copy = new typecast_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 = (addressed_value)expr.Clone(); copy.expr.Parent = copy; } if (type_def != null) { copy.type_def = (type_definition)type_def.Clone(); copy.type_def.Parent = copy; } copy.cast_op = cast_op; return copy; } /// Получает копию данного узла корректного типа public new typecast_node TypedClone() { return Clone() as typecast_node; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (expr != null) expr.Parent = this; if (type_def != null) type_def.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); expr?.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 expr; 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: expr = (addressed_value)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 interface_node : syntax_tree_node { /// ///Конструктор без параметров. /// public interface_node() { } /// ///Конструктор с параметрами. /// public interface_node(declarations _interface_definitions,uses_list _uses_modules,using_list _using_namespaces) { this._interface_definitions=_interface_definitions; this._uses_modules=_uses_modules; this._using_namespaces=_using_namespaces; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public interface_node(declarations _interface_definitions,uses_list _uses_modules,using_list _using_namespaces,SourceContext sc) { this._interface_definitions=_interface_definitions; this._uses_modules=_uses_modules; this._using_namespaces=_using_namespaces; source_context = sc; FillParentsInDirectChilds(); } protected declarations _interface_definitions; protected uses_list _uses_modules; protected using_list _using_namespaces; /// /// /// public declarations interface_definitions { get { return _interface_definitions; } set { _interface_definitions=value; if (_interface_definitions != null) _interface_definitions.Parent = this; } } /// /// /// public uses_list uses_modules { get { return _uses_modules; } set { _uses_modules=value; if (_uses_modules != null) _uses_modules.Parent = this; } } /// /// /// public using_list using_namespaces { get { return _using_namespaces; } set { _using_namespaces=value; if (_using_namespaces != null) _using_namespaces.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { interface_node copy = new interface_node(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (interface_definitions != null) { copy.interface_definitions = (declarations)interface_definitions.Clone(); copy.interface_definitions.Parent = copy; } if (uses_modules != null) { copy.uses_modules = (uses_list)uses_modules.Clone(); copy.uses_modules.Parent = copy; } if (using_namespaces != null) { copy.using_namespaces = (using_list)using_namespaces.Clone(); copy.using_namespaces.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new interface_node TypedClone() { return Clone() as interface_node; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (interface_definitions != null) interface_definitions.Parent = this; if (uses_modules != null) uses_modules.Parent = this; if (using_namespaces != null) using_namespaces.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); interface_definitions?.FillParentsInAllChilds(); uses_modules?.FillParentsInAllChilds(); using_namespaces?.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 interface_definitions; case 1: return uses_modules; case 2: return using_namespaces; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: interface_definitions = (declarations)value; break; case 1: uses_modules = (uses_list)value; break; case 2: using_namespaces = (using_list)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class implementation_node : syntax_tree_node { /// ///Конструктор без параметров. /// public implementation_node() { } /// ///Конструктор с параметрами. /// public implementation_node(uses_list _uses_modules,declarations _implementation_definitions,using_list _using_namespaces) { this._uses_modules=_uses_modules; this._implementation_definitions=_implementation_definitions; this._using_namespaces=_using_namespaces; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public implementation_node(uses_list _uses_modules,declarations _implementation_definitions,using_list _using_namespaces,SourceContext sc) { this._uses_modules=_uses_modules; this._implementation_definitions=_implementation_definitions; this._using_namespaces=_using_namespaces; source_context = sc; FillParentsInDirectChilds(); } protected uses_list _uses_modules; protected declarations _implementation_definitions; protected using_list _using_namespaces; /// /// /// public uses_list uses_modules { get { return _uses_modules; } set { _uses_modules=value; if (_uses_modules != null) _uses_modules.Parent = this; } } /// /// /// public declarations implementation_definitions { get { return _implementation_definitions; } set { _implementation_definitions=value; if (_implementation_definitions != null) _implementation_definitions.Parent = this; } } /// /// /// public using_list using_namespaces { get { return _using_namespaces; } set { _using_namespaces=value; if (_using_namespaces != null) _using_namespaces.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { implementation_node copy = new implementation_node(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (uses_modules != null) { copy.uses_modules = (uses_list)uses_modules.Clone(); copy.uses_modules.Parent = copy; } if (implementation_definitions != null) { copy.implementation_definitions = (declarations)implementation_definitions.Clone(); copy.implementation_definitions.Parent = copy; } if (using_namespaces != null) { copy.using_namespaces = (using_list)using_namespaces.Clone(); copy.using_namespaces.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new implementation_node TypedClone() { return Clone() as implementation_node; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (uses_modules != null) uses_modules.Parent = this; if (implementation_definitions != null) implementation_definitions.Parent = this; if (using_namespaces != null) using_namespaces.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); uses_modules?.FillParentsInAllChilds(); implementation_definitions?.FillParentsInAllChilds(); using_namespaces?.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 uses_modules; case 1: return implementation_definitions; case 2: return using_namespaces; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: uses_modules = (uses_list)value; break; case 1: implementation_definitions = (declarations)value; break; case 2: using_namespaces = (using_list)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class diap_expr : expression { /// ///Конструктор без параметров. /// public diap_expr() { } /// ///Конструктор с параметрами. /// public diap_expr(expression _left,expression _right) { this._left=_left; this._right=_right; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public diap_expr(expression _left,expression _right,SourceContext sc) { 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() { diap_expr copy = new diap_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; } return copy; } /// Получает копию данного узла корректного типа public new diap_expr TypedClone() { return Clone() as diap_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 block : proc_block { /// ///Конструктор без параметров. /// public block() { } /// ///Конструктор с параметрами. /// public block(declarations _defs,statement_list _program_code) { this._defs=_defs; this._program_code=_program_code; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public block(declarations _defs,statement_list _program_code,SourceContext sc) { this._defs=_defs; this._program_code=_program_code; source_context = sc; FillParentsInDirectChilds(); } protected declarations _defs; protected statement_list _program_code; /// /// /// public declarations defs { get { return _defs; } set { _defs=value; if (_defs != null) _defs.Parent = this; } } /// /// /// public statement_list program_code { get { return _program_code; } set { _program_code=value; if (_program_code != null) _program_code.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { block copy = new block(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (defs != null) { copy.defs = (declarations)defs.Clone(); copy.defs.Parent = copy; } if (program_code != null) { copy.program_code = (statement_list)program_code.Clone(); copy.program_code.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new block TypedClone() { return Clone() as block; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (defs != null) defs.Parent = this; if (program_code != null) program_code.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); defs?.FillParentsInAllChilds(); program_code?.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 defs; case 1: return program_code; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: defs = (declarations)value; break; case 1: program_code = (statement_list)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class proc_block : syntax_tree_node { /// ///Конструктор без параметров. /// public proc_block() { } /// Создает копию узла public override syntax_tree_node Clone() { proc_block copy = new proc_block(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); return copy; } /// Получает копию данного узла корректного типа public new proc_block TypedClone() { return Clone() as proc_block; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа 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); } } /// ///array of type_name /// [Serializable] public partial class array_of_named_type_definition : type_definition { /// ///Конструктор без параметров. /// public array_of_named_type_definition() { } /// ///Конструктор с параметрами. /// public array_of_named_type_definition(named_type_reference _type_name) { this._type_name=_type_name; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public array_of_named_type_definition(named_type_reference _type_name,SourceContext sc) { this._type_name=_type_name; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public array_of_named_type_definition(type_definition_attr_list _attr_list,named_type_reference _type_name) { this._attr_list=_attr_list; this._type_name=_type_name; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public array_of_named_type_definition(type_definition_attr_list _attr_list,named_type_reference _type_name,SourceContext sc) { this._attr_list=_attr_list; this._type_name=_type_name; source_context = sc; FillParentsInDirectChilds(); } protected named_type_reference _type_name; /// /// /// public named_type_reference type_name { get { return _type_name; } set { _type_name=value; if (_type_name != null) _type_name.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { array_of_named_type_definition copy = new array_of_named_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; } if (type_name != null) { copy.type_name = (named_type_reference)type_name.Clone(); copy.type_name.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new array_of_named_type_definition TypedClone() { return Clone() as array_of_named_type_definition; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (attr_list != null) attr_list.Parent = this; if (type_name != null) type_name.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); attr_list?.FillParentsInAllChilds(); type_name?.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 type_name; } 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: type_name = (named_type_reference)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// ///array of const /// [Serializable] public partial class array_of_const_type_definition : type_definition { /// ///Конструктор без параметров. /// public array_of_const_type_definition() { } /// ///Конструктор с параметрами. /// public array_of_const_type_definition(type_definition_attr_list _attr_list) { this._attr_list=_attr_list; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public array_of_const_type_definition(type_definition_attr_list _attr_list,SourceContext sc) { this._attr_list=_attr_list; source_context = sc; FillParentsInDirectChilds(); } /// Создает копию узла public override syntax_tree_node Clone() { array_of_const_type_definition copy = new array_of_const_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 array_of_const_type_definition TypedClone() { return Clone() as array_of_const_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); } } /// ///#12 либо 'abc' /// [Serializable] public partial class literal : const_node { /// ///Конструктор без параметров. /// public literal() { } /// Создает копию узла public override syntax_tree_node Clone() { literal copy = new literal(); 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 literal TypedClone() { return Clone() as literal; } /// Заполняет поля 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 case_variants : syntax_tree_node { /// ///Конструктор без параметров. /// public case_variants() { } /// ///Конструктор с параметрами. /// public case_variants(List _variants) { this._variants=_variants; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public case_variants(List _variants,SourceContext sc) { this._variants=_variants; source_context = sc; FillParentsInDirectChilds(); } public case_variants(case_variant elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected List _variants=new List(); /// /// /// public List variants { get { return _variants; } set { _variants=value; } } public case_variants Add(case_variant elem, SourceContext sc = null) { variants.Add(elem); if (elem != null) elem.Parent = this; if (sc != null) source_context = sc; return this; } public void AddFirst(case_variant el) { if (el == null) throw new ArgumentNullException(nameof(el)); variants.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); variants.InsertRange(0, els); foreach (var el in els) if (el != null) el.Parent = this; } public void AddMany(params case_variant[] els) { if (els == null) throw new ArgumentNullException(nameof(els)); variants.AddRange(els); foreach (var el in els) if (el != null) el.Parent = this; } private int FindIndexInList(case_variant el) { if (el == null) throw new ArgumentNullException(nameof(el)); var ind = variants.FindIndex(x => x == el); if (ind == -1) throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el)); return ind; } public void InsertAfter(case_variant el, case_variant newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); variants.Insert(FindIndexInList(el) + 1, newel); newel.Parent = this; } public void InsertAfter(case_variant el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); variants.InsertRange(FindIndexInList(el) + 1, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public void InsertBefore(case_variant el, case_variant newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); variants.Insert(FindIndexInList(el), newel); newel.Parent = this; } public void InsertBefore(case_variant el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); variants.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(case_variant el) { return variants.Remove(el); } public void ReplaceInList(case_variant el, case_variant newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); variants[FindIndexInList(el)] = newel; newel.Parent = this; } public void ReplaceInList(case_variant el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); var ind = FindIndexInList(el); variants.RemoveAt(ind); variants.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return variants.RemoveAll(match); } public case_variant Last() { if (variants.Count > 0) return variants[variants.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return variants.Count; } } public void Insert(int pos, case_variant el) { if (el == null) throw new ArgumentNullException(nameof(el)); variants.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { case_variants copy = new case_variants(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (variants != null) { foreach (case_variant elem in variants) { if (elem != null) { copy.Add((case_variant)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new case_variants TypedClone() { return Clone() as case_variants; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (variants != null) { foreach (var child in variants) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (variants != null) { foreach (var child in variants) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (variants == null ? 0 : variants.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(variants != null) { if(index_counter < variants.Count) { return variants[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); Int32 index_counter=ind - 0; if(variants != null) { if(index_counter < variants.Count) { variants[index_counter]= (case_variant)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class diapason_expr : expression { /// ///Конструктор без параметров. /// public diapason_expr() { } /// ///Конструктор с параметрами. /// public diapason_expr(expression _left,expression _right) { this._left=_left; this._right=_right; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public diapason_expr(expression _left,expression _right,SourceContext sc) { 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_expr copy = new diapason_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; } return copy; } /// Получает копию данного узла корректного типа public new diapason_expr TypedClone() { return Clone() as diapason_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 var_def_list_for_record : syntax_tree_node { /// ///Конструктор без параметров. /// public var_def_list_for_record() { } /// ///Конструктор с параметрами. /// public var_def_list_for_record(List _vars) { this._vars=_vars; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public var_def_list_for_record(List _vars,SourceContext sc) { this._vars=_vars; source_context = sc; FillParentsInDirectChilds(); } public var_def_list_for_record(var_def_statement elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected List _vars=new List(); /// /// /// public List vars { get { return _vars; } set { _vars=value; } } public var_def_list_for_record Add(var_def_statement elem, SourceContext sc = null) { vars.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)); vars.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); vars.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)); vars.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 = vars.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)); vars.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)); vars.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)); vars.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)); vars.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(var_def_statement el) { return vars.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)); vars[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); vars.RemoveAt(ind); vars.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return vars.RemoveAll(match); } public var_def_statement Last() { if (vars.Count > 0) return vars[vars.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return vars.Count; } } public void Insert(int pos, var_def_statement el) { if (el == null) throw new ArgumentNullException(nameof(el)); vars.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { var_def_list_for_record copy = new var_def_list_for_record(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (vars != null) { foreach (var_def_statement elem in vars) { if (elem != null) { copy.Add((var_def_statement)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new var_def_list_for_record TypedClone() { return Clone() as var_def_list_for_record; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (vars != null) { foreach (var child in vars) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (vars != null) { foreach (var child in vars) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (vars == null ? 0 : vars.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(vars != null) { if(index_counter < vars.Count) { return vars[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); Int32 index_counter=ind - 0; if(vars != null) { if(index_counter < vars.Count) { vars[index_counter]= (var_def_statement)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class record_type_parts : syntax_tree_node { /// ///Конструктор без параметров. /// public record_type_parts() { } /// ///Конструктор с параметрами. /// public record_type_parts(var_def_list_for_record _fixed_part,variant_record_type _variant_part) { this._fixed_part=_fixed_part; this._variant_part=_variant_part; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public record_type_parts(var_def_list_for_record _fixed_part,variant_record_type _variant_part,SourceContext sc) { this._fixed_part=_fixed_part; this._variant_part=_variant_part; source_context = sc; FillParentsInDirectChilds(); } protected var_def_list_for_record _fixed_part; protected variant_record_type _variant_part; /// /// /// public var_def_list_for_record fixed_part { get { return _fixed_part; } set { _fixed_part=value; if (_fixed_part != null) _fixed_part.Parent = this; } } /// /// /// public variant_record_type variant_part { get { return _variant_part; } set { _variant_part=value; if (_variant_part != null) _variant_part.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { record_type_parts copy = new record_type_parts(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (fixed_part != null) { copy.fixed_part = (var_def_list_for_record)fixed_part.Clone(); copy.fixed_part.Parent = copy; } if (variant_part != null) { copy.variant_part = (variant_record_type)variant_part.Clone(); copy.variant_part.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new record_type_parts TypedClone() { return Clone() as record_type_parts; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (fixed_part != null) fixed_part.Parent = this; if (variant_part != null) variant_part.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); fixed_part?.FillParentsInAllChilds(); variant_part?.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 fixed_part; case 1: return variant_part; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: fixed_part = (var_def_list_for_record)value; break; case 1: variant_part = (variant_record_type)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class property_array_default : syntax_tree_node { /// ///Конструктор без параметров. /// public property_array_default() { } /// Создает копию узла public override syntax_tree_node Clone() { property_array_default copy = new property_array_default(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); return copy; } /// Получает копию данного узла корректного типа public new property_array_default TypedClone() { return Clone() as property_array_default; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа 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 property_interface : syntax_tree_node { /// ///Конструктор без параметров. /// public property_interface() { } /// ///Конструктор с параметрами. /// public property_interface(property_parameter_list _parameter_list,type_definition _property_type,expression _index_expression) { this._parameter_list=_parameter_list; this._property_type=_property_type; this._index_expression=_index_expression; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public property_interface(property_parameter_list _parameter_list,type_definition _property_type,expression _index_expression,SourceContext sc) { this._parameter_list=_parameter_list; this._property_type=_property_type; this._index_expression=_index_expression; source_context = sc; FillParentsInDirectChilds(); } protected property_parameter_list _parameter_list; protected type_definition _property_type; protected expression _index_expression; /// /// /// public property_parameter_list parameter_list { get { return _parameter_list; } set { _parameter_list=value; if (_parameter_list != null) _parameter_list.Parent = this; } } /// /// /// public type_definition property_type { get { return _property_type; } set { _property_type=value; if (_property_type != null) _property_type.Parent = this; } } /// /// /// public expression index_expression { get { return _index_expression; } set { _index_expression=value; if (_index_expression != null) _index_expression.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { property_interface copy = new property_interface(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (parameter_list != null) { copy.parameter_list = (property_parameter_list)parameter_list.Clone(); copy.parameter_list.Parent = copy; } if (property_type != null) { copy.property_type = (type_definition)property_type.Clone(); copy.property_type.Parent = copy; } if (index_expression != null) { copy.index_expression = (expression)index_expression.Clone(); copy.index_expression.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new property_interface TypedClone() { return Clone() as property_interface; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (parameter_list != null) parameter_list.Parent = this; if (property_type != null) property_type.Parent = this; if (index_expression != null) index_expression.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); parameter_list?.FillParentsInAllChilds(); property_type?.FillParentsInAllChilds(); index_expression?.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 parameter_list; case 1: return property_type; case 2: return index_expression; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: parameter_list = (property_parameter_list)value; break; case 1: property_type = (type_definition)value; break; case 2: index_expression = (expression)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class property_parameter : syntax_tree_node { /// ///Конструктор без параметров. /// public property_parameter() { } /// ///Конструктор с параметрами. /// public property_parameter(ident_list _names,type_definition _type) { this._names=_names; this._type=_type; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public property_parameter(ident_list _names,type_definition _type,SourceContext sc) { this._names=_names; this._type=_type; source_context = sc; FillParentsInDirectChilds(); } protected ident_list _names; protected type_definition _type; /// /// /// public ident_list names { get { return _names; } set { _names=value; if (_names != null) _names.Parent = this; } } /// /// /// public type_definition type { get { return _type; } set { _type=value; if (_type != null) _type.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { property_parameter copy = new property_parameter(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (names != null) { copy.names = (ident_list)names.Clone(); copy.names.Parent = copy; } if (type != null) { copy.type = (type_definition)type.Clone(); copy.type.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new property_parameter TypedClone() { return Clone() as property_parameter; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (names != null) names.Parent = this; if (type != null) type.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); names?.FillParentsInAllChilds(); type?.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 names; case 1: return type; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: names = (ident_list)value; break; case 1: type = (type_definition)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class property_parameter_list : syntax_tree_node { /// ///Конструктор без параметров. /// public property_parameter_list() { } /// ///Конструктор с параметрами. /// public property_parameter_list(List _parameters) { this._parameters=_parameters; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public property_parameter_list(List _parameters,SourceContext sc) { this._parameters=_parameters; source_context = sc; FillParentsInDirectChilds(); } public property_parameter_list(property_parameter elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected List _parameters=new List(); /// /// /// public List parameters { get { return _parameters; } set { _parameters=value; } } public property_parameter_list Add(property_parameter elem, SourceContext sc = null) { parameters.Add(elem); if (elem != null) elem.Parent = this; if (sc != null) source_context = sc; return this; } public void AddFirst(property_parameter el) { if (el == null) throw new ArgumentNullException(nameof(el)); parameters.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); parameters.InsertRange(0, els); foreach (var el in els) if (el != null) el.Parent = this; } public void AddMany(params property_parameter[] els) { if (els == null) throw new ArgumentNullException(nameof(els)); parameters.AddRange(els); foreach (var el in els) if (el != null) el.Parent = this; } private int FindIndexInList(property_parameter el) { if (el == null) throw new ArgumentNullException(nameof(el)); var ind = parameters.FindIndex(x => x == el); if (ind == -1) throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el)); return ind; } public void InsertAfter(property_parameter el, property_parameter newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); parameters.Insert(FindIndexInList(el) + 1, newel); newel.Parent = this; } public void InsertAfter(property_parameter el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); parameters.InsertRange(FindIndexInList(el) + 1, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public void InsertBefore(property_parameter el, property_parameter newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); parameters.Insert(FindIndexInList(el), newel); newel.Parent = this; } public void InsertBefore(property_parameter el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); parameters.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(property_parameter el) { return parameters.Remove(el); } public void ReplaceInList(property_parameter el, property_parameter newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); parameters[FindIndexInList(el)] = newel; newel.Parent = this; } public void ReplaceInList(property_parameter el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); var ind = FindIndexInList(el); parameters.RemoveAt(ind); parameters.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return parameters.RemoveAll(match); } public property_parameter Last() { if (parameters.Count > 0) return parameters[parameters.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return parameters.Count; } } public void Insert(int pos, property_parameter el) { if (el == null) throw new ArgumentNullException(nameof(el)); parameters.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { property_parameter_list copy = new property_parameter_list(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (parameters != null) { foreach (property_parameter elem in parameters) { if (elem != null) { copy.Add((property_parameter)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new property_parameter_list TypedClone() { return Clone() as property_parameter_list; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (parameters != null) { foreach (var child in parameters) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (parameters != null) { foreach (var child in parameters) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (parameters == null ? 0 : parameters.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(parameters != null) { if(index_counter < parameters.Count) { return parameters[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); Int32 index_counter=ind - 0; if(parameters != null) { if(index_counter < parameters.Count) { parameters[index_counter]= (property_parameter)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class inherited_ident : ident { /// ///Конструктор без параметров. /// public inherited_ident() { } /// ///Конструктор с параметрами. /// public inherited_ident(string _name) { this._name=_name; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public inherited_ident(string _name,SourceContext sc) { this._name=_name; source_context = sc; FillParentsInDirectChilds(); } /// Создает копию узла public override syntax_tree_node Clone() { inherited_ident copy = new inherited_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 inherited_ident TypedClone() { return Clone() as inherited_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); } } /// ///expr:1:2 /// [Serializable] public partial class format_expr : addressed_value { /// ///Конструктор без параметров. /// public format_expr() { } /// ///Конструктор с параметрами. /// public format_expr(expression _expr,expression _format1,expression _format2) { this._expr=_expr; this._format1=_format1; this._format2=_format2; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public format_expr(expression _expr,expression _format1,expression _format2,SourceContext sc) { this._expr=_expr; this._format1=_format1; this._format2=_format2; source_context = sc; FillParentsInDirectChilds(); } protected expression _expr; protected expression _format1; protected expression _format2; /// /// /// public expression expr { get { return _expr; } set { _expr=value; if (_expr != null) _expr.Parent = this; } } /// /// /// public expression format1 { get { return _format1; } set { _format1=value; if (_format1 != null) _format1.Parent = this; } } /// /// /// public expression format2 { get { return _format2; } set { _format2=value; if (_format2 != null) _format2.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { format_expr copy = new format_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 (expr != null) { copy.expr = (expression)expr.Clone(); copy.expr.Parent = copy; } if (format1 != null) { copy.format1 = (expression)format1.Clone(); copy.format1.Parent = copy; } if (format2 != null) { copy.format2 = (expression)format2.Clone(); copy.format2.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new format_expr TypedClone() { return Clone() as format_expr; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (expr != null) expr.Parent = this; if (format1 != null) format1.Parent = this; if (format2 != null) format2.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); expr?.FillParentsInAllChilds(); format1?.FillParentsInAllChilds(); format2?.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 expr; case 1: return format1; case 2: return format2; } 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: format1 = (expression)value; break; case 2: format2 = (expression)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class initfinal_part : syntax_tree_node { /// ///Конструктор без параметров. /// public initfinal_part() { } /// ///Конструктор с параметрами. /// public initfinal_part(statement_list _initialization_sect,statement_list _finalization_sect) { this._initialization_sect=_initialization_sect; this._finalization_sect=_finalization_sect; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public initfinal_part(statement_list _initialization_sect,statement_list _finalization_sect,SourceContext sc) { this._initialization_sect=_initialization_sect; this._finalization_sect=_finalization_sect; source_context = sc; FillParentsInDirectChilds(); } protected statement_list _initialization_sect; protected statement_list _finalization_sect; /// /// /// public statement_list initialization_sect { get { return _initialization_sect; } set { _initialization_sect=value; if (_initialization_sect != null) _initialization_sect.Parent = this; } } /// /// /// public statement_list finalization_sect { get { return _finalization_sect; } set { _finalization_sect=value; if (_finalization_sect != null) _finalization_sect.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { initfinal_part copy = new initfinal_part(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (initialization_sect != null) { copy.initialization_sect = (statement_list)initialization_sect.Clone(); copy.initialization_sect.Parent = copy; } if (finalization_sect != null) { copy.finalization_sect = (statement_list)finalization_sect.Clone(); copy.finalization_sect.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new initfinal_part TypedClone() { return Clone() as initfinal_part; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (initialization_sect != null) initialization_sect.Parent = this; if (finalization_sect != null) finalization_sect.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); initialization_sect?.FillParentsInAllChilds(); finalization_sect?.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 initialization_sect; case 1: return finalization_sect; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: initialization_sect = (statement_list)value; break; case 1: finalization_sect = (statement_list)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class token_info : syntax_tree_node { /// ///Конструктор без параметров. /// public token_info() { } /// ///Конструктор с параметрами. /// public token_info(string _text) { this._text=_text; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public token_info(string _text,SourceContext sc) { this._text=_text; source_context = sc; FillParentsInDirectChilds(); } protected string _text; /// /// /// public string text { get { return _text; } set { _text=value; } } /// Создает копию узла public override syntax_tree_node Clone() { token_info copy = new token_info(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); copy.text = text; return copy; } /// Получает копию данного узла корректного типа public new token_info TypedClone() { return Clone() as token_info; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа 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); } } /// ///raise [expr [at address]] /// [Serializable] public partial class raise_stmt : statement { /// ///Конструктор без параметров. /// public raise_stmt() { } /// ///Конструктор с параметрами. /// public raise_stmt(expression _expr,expression _address) { this._expr=_expr; this._address=_address; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public raise_stmt(expression _expr,expression _address,SourceContext sc) { this._expr=_expr; this._address=_address; source_context = sc; FillParentsInDirectChilds(); } protected expression _expr; protected expression _address; /// /// /// public expression expr { get { return _expr; } set { _expr=value; if (_expr != null) _expr.Parent = this; } } /// /// /// public expression address { get { return _address; } set { _address=value; if (_address != null) _address.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { raise_stmt copy = new raise_stmt(); 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 (address != null) { copy.address = (expression)address.Clone(); copy.address.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new raise_stmt TypedClone() { return Clone() as raise_stmt; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (expr != null) expr.Parent = this; if (address != null) address.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); expr?.FillParentsInAllChilds(); address?.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 address; } 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: address = (expression)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class op_type_node : token_info { /// ///Конструктор без параметров. /// public op_type_node() { } /// ///Конструктор с параметрами. /// public op_type_node(Operators _type) { this._type=_type; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public op_type_node(Operators _type,SourceContext sc) { this._type=_type; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public op_type_node(string _text,Operators _type) { this._text=_text; this._type=_type; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public op_type_node(string _text,Operators _type,SourceContext sc) { this._text=_text; this._type=_type; source_context = sc; FillParentsInDirectChilds(); } protected Operators _type; /// /// /// public Operators type { get { return _type; } set { _type=value; } } /// Создает копию узла public override syntax_tree_node Clone() { op_type_node copy = new op_type_node(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); copy.text = text; copy.type = type; return copy; } /// Получает копию данного узла корректного типа public new op_type_node TypedClone() { return Clone() as op_type_node; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа 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 file_type : type_definition { /// ///Конструктор без параметров. /// public file_type() { } /// ///Конструктор с параметрами. /// public file_type(type_definition _file_of_type) { this._file_of_type=_file_of_type; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public file_type(type_definition _file_of_type,SourceContext sc) { this._file_of_type=_file_of_type; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public file_type(type_definition_attr_list _attr_list,type_definition _file_of_type) { this._attr_list=_attr_list; this._file_of_type=_file_of_type; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public file_type(type_definition_attr_list _attr_list,type_definition _file_of_type,SourceContext sc) { this._attr_list=_attr_list; this._file_of_type=_file_of_type; source_context = sc; FillParentsInDirectChilds(); } protected type_definition _file_of_type; /// /// /// public type_definition file_of_type { get { return _file_of_type; } set { _file_of_type=value; if (_file_of_type != null) _file_of_type.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { file_type copy = new file_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 (file_of_type != null) { copy.file_of_type = (type_definition)file_of_type.Clone(); copy.file_of_type.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new file_type TypedClone() { return Clone() as file_type; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (attr_list != null) attr_list.Parent = this; if (file_of_type != null) file_of_type.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); attr_list?.FillParentsInAllChilds(); file_of_type?.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 file_of_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: file_of_type = (type_definition)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class known_type_ident : ident { /// ///Конструктор без параметров. /// public known_type_ident() { } /// ///Конструктор с параметрами. /// public known_type_ident(known_type _type) { this._type=_type; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public known_type_ident(known_type _type,SourceContext sc) { this._type=_type; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public known_type_ident(string _name,known_type _type) { this._name=_name; this._type=_type; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public known_type_ident(string _name,known_type _type,SourceContext sc) { this._name=_name; this._type=_type; source_context = sc; FillParentsInDirectChilds(); } protected known_type _type; /// /// /// public known_type type { get { return _type; } set { _type=value; } } /// Создает копию узла public override syntax_tree_node Clone() { known_type_ident copy = new known_type_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; copy.type = type; return copy; } /// Получает копию данного узла корректного типа public new known_type_ident TypedClone() { return Clone() as known_type_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 exception_handler : syntax_tree_node { /// ///Конструктор без параметров. /// public exception_handler() { } /// ///Конструктор с параметрами. /// public exception_handler(ident _variable,named_type_reference _type_name,statement _statements) { this._variable=_variable; this._type_name=_type_name; this._statements=_statements; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public exception_handler(ident _variable,named_type_reference _type_name,statement _statements,SourceContext sc) { this._variable=_variable; this._type_name=_type_name; this._statements=_statements; source_context = sc; FillParentsInDirectChilds(); } protected ident _variable; protected named_type_reference _type_name; protected statement _statements; /// /// /// public ident variable { get { return _variable; } set { _variable=value; if (_variable != null) _variable.Parent = this; } } /// /// /// public named_type_reference type_name { get { return _type_name; } set { _type_name=value; if (_type_name != null) _type_name.Parent = this; } } /// /// /// public statement statements { get { return _statements; } set { _statements=value; if (_statements != null) _statements.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { exception_handler copy = new exception_handler(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (variable != null) { copy.variable = (ident)variable.Clone(); copy.variable.Parent = copy; } if (type_name != null) { copy.type_name = (named_type_reference)type_name.Clone(); copy.type_name.Parent = copy; } if (statements != null) { copy.statements = (statement)statements.Clone(); copy.statements.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new exception_handler TypedClone() { return Clone() as exception_handler; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (variable != null) variable.Parent = this; if (type_name != null) type_name.Parent = this; if (statements != null) statements.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); variable?.FillParentsInAllChilds(); type_name?.FillParentsInAllChilds(); statements?.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 variable; case 1: return type_name; case 2: return statements; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: variable = (ident)value; break; case 1: type_name = (named_type_reference)value; break; case 2: statements = (statement)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class exception_ident : syntax_tree_node { /// ///Конструктор без параметров. /// public exception_ident() { } /// ///Конструктор с параметрами. /// public exception_ident(ident _variable,named_type_reference _type_name) { this._variable=_variable; this._type_name=_type_name; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public exception_ident(ident _variable,named_type_reference _type_name,SourceContext sc) { this._variable=_variable; this._type_name=_type_name; source_context = sc; FillParentsInDirectChilds(); } protected ident _variable; protected named_type_reference _type_name; /// /// /// public ident variable { get { return _variable; } set { _variable=value; if (_variable != null) _variable.Parent = this; } } /// /// /// public named_type_reference type_name { get { return _type_name; } set { _type_name=value; if (_type_name != null) _type_name.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { exception_ident copy = new exception_ident(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (variable != null) { copy.variable = (ident)variable.Clone(); copy.variable.Parent = copy; } if (type_name != null) { copy.type_name = (named_type_reference)type_name.Clone(); copy.type_name.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new exception_ident TypedClone() { return Clone() as exception_ident; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (variable != null) variable.Parent = this; if (type_name != null) type_name.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); variable?.FillParentsInAllChilds(); type_name?.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 variable; case 1: return type_name; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: variable = (ident)value; break; case 1: type_name = (named_type_reference)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class exception_handler_list : syntax_tree_node { /// ///Конструктор без параметров. /// public exception_handler_list() { } /// ///Конструктор с параметрами. /// public exception_handler_list(List _handlers) { this._handlers=_handlers; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public exception_handler_list(List _handlers,SourceContext sc) { this._handlers=_handlers; source_context = sc; FillParentsInDirectChilds(); } public exception_handler_list(exception_handler elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected List _handlers=new List(); /// /// /// public List handlers { get { return _handlers; } set { _handlers=value; } } public exception_handler_list Add(exception_handler elem, SourceContext sc = null) { handlers.Add(elem); if (elem != null) elem.Parent = this; if (sc != null) source_context = sc; return this; } public void AddFirst(exception_handler el) { if (el == null) throw new ArgumentNullException(nameof(el)); handlers.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); handlers.InsertRange(0, els); foreach (var el in els) if (el != null) el.Parent = this; } public void AddMany(params exception_handler[] els) { if (els == null) throw new ArgumentNullException(nameof(els)); handlers.AddRange(els); foreach (var el in els) if (el != null) el.Parent = this; } private int FindIndexInList(exception_handler el) { if (el == null) throw new ArgumentNullException(nameof(el)); var ind = handlers.FindIndex(x => x == el); if (ind == -1) throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el)); return ind; } public void InsertAfter(exception_handler el, exception_handler newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); handlers.Insert(FindIndexInList(el) + 1, newel); newel.Parent = this; } public void InsertAfter(exception_handler el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); handlers.InsertRange(FindIndexInList(el) + 1, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public void InsertBefore(exception_handler el, exception_handler newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); handlers.Insert(FindIndexInList(el), newel); newel.Parent = this; } public void InsertBefore(exception_handler el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); handlers.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(exception_handler el) { return handlers.Remove(el); } public void ReplaceInList(exception_handler el, exception_handler newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); handlers[FindIndexInList(el)] = newel; newel.Parent = this; } public void ReplaceInList(exception_handler el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); var ind = FindIndexInList(el); handlers.RemoveAt(ind); handlers.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return handlers.RemoveAll(match); } public exception_handler Last() { if (handlers.Count > 0) return handlers[handlers.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return handlers.Count; } } public void Insert(int pos, exception_handler el) { if (el == null) throw new ArgumentNullException(nameof(el)); handlers.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { exception_handler_list copy = new exception_handler_list(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (handlers != null) { foreach (exception_handler elem in handlers) { if (elem != null) { copy.Add((exception_handler)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new exception_handler_list TypedClone() { return Clone() as exception_handler_list; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (handlers != null) { foreach (var child in handlers) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (handlers != null) { foreach (var child in handlers) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (handlers == null ? 0 : handlers.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(handlers != null) { if(index_counter < handlers.Count) { return handlers[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); Int32 index_counter=ind - 0; if(handlers != null) { if(index_counter < handlers.Count) { handlers[index_counter]= (exception_handler)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class exception_block : syntax_tree_node { /// ///Конструктор без параметров. /// public exception_block() { } /// ///Конструктор с параметрами. /// public exception_block(statement_list _stmt_list,exception_handler_list _handlers,statement_list _else_stmt_list) { this._stmt_list=_stmt_list; this._handlers=_handlers; this._else_stmt_list=_else_stmt_list; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public exception_block(statement_list _stmt_list,exception_handler_list _handlers,statement_list _else_stmt_list,SourceContext sc) { this._stmt_list=_stmt_list; this._handlers=_handlers; this._else_stmt_list=_else_stmt_list; source_context = sc; FillParentsInDirectChilds(); } protected statement_list _stmt_list; protected exception_handler_list _handlers; protected statement_list _else_stmt_list; /// /// /// public statement_list stmt_list { get { return _stmt_list; } set { _stmt_list=value; if (_stmt_list != null) _stmt_list.Parent = this; } } /// /// /// public exception_handler_list handlers { get { return _handlers; } set { _handlers=value; if (_handlers != null) _handlers.Parent = this; } } /// /// /// public statement_list else_stmt_list { get { return _else_stmt_list; } set { _else_stmt_list=value; if (_else_stmt_list != null) _else_stmt_list.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { exception_block copy = new exception_block(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (stmt_list != null) { copy.stmt_list = (statement_list)stmt_list.Clone(); copy.stmt_list.Parent = copy; } if (handlers != null) { copy.handlers = (exception_handler_list)handlers.Clone(); copy.handlers.Parent = copy; } if (else_stmt_list != null) { copy.else_stmt_list = (statement_list)else_stmt_list.Clone(); copy.else_stmt_list.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new exception_block TypedClone() { return Clone() as exception_block; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (stmt_list != null) stmt_list.Parent = this; if (handlers != null) handlers.Parent = this; if (else_stmt_list != null) else_stmt_list.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); stmt_list?.FillParentsInAllChilds(); handlers?.FillParentsInAllChilds(); else_stmt_list?.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 stmt_list; case 1: return handlers; case 2: return else_stmt_list; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: stmt_list = (statement_list)value; break; case 1: handlers = (exception_handler_list)value; break; case 2: else_stmt_list = (statement_list)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class try_handler : syntax_tree_node { /// ///Конструктор без параметров. /// public try_handler() { } /// Создает копию узла public override syntax_tree_node Clone() { try_handler copy = new try_handler(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); return copy; } /// Получает копию данного узла корректного типа public new try_handler TypedClone() { return Clone() as try_handler; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа 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 try_handler_finally : try_handler { /// ///Конструктор без параметров. /// public try_handler_finally() { } /// ///Конструктор с параметрами. /// public try_handler_finally(statement_list _stmt_list) { this._stmt_list=_stmt_list; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public try_handler_finally(statement_list _stmt_list,SourceContext sc) { this._stmt_list=_stmt_list; source_context = sc; FillParentsInDirectChilds(); } protected statement_list _stmt_list; /// /// /// public statement_list stmt_list { get { return _stmt_list; } set { _stmt_list=value; if (_stmt_list != null) _stmt_list.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { try_handler_finally copy = new try_handler_finally(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (stmt_list != null) { copy.stmt_list = (statement_list)stmt_list.Clone(); copy.stmt_list.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new try_handler_finally TypedClone() { return Clone() as try_handler_finally; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (stmt_list != null) stmt_list.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); stmt_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 stmt_list; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: stmt_list = (statement_list)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class try_handler_except : try_handler { /// ///Конструктор без параметров. /// public try_handler_except() { } /// ///Конструктор с параметрами. /// public try_handler_except(exception_block _except_block) { this._except_block=_except_block; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public try_handler_except(exception_block _except_block,SourceContext sc) { this._except_block=_except_block; source_context = sc; FillParentsInDirectChilds(); } protected exception_block _except_block; /// /// /// public exception_block except_block { get { return _except_block; } set { _except_block=value; if (_except_block != null) _except_block.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { try_handler_except copy = new try_handler_except(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (except_block != null) { copy.except_block = (exception_block)except_block.Clone(); copy.except_block.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new try_handler_except TypedClone() { return Clone() as try_handler_except; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (except_block != null) except_block.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); except_block?.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 except_block; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: except_block = (exception_block)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class try_stmt : statement { /// ///Конструктор без параметров. /// public try_stmt() { } /// ///Конструктор с параметрами. /// public try_stmt(statement_list _stmt_list,try_handler _handler) { this._stmt_list=_stmt_list; this._handler=_handler; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public try_stmt(statement_list _stmt_list,try_handler _handler,SourceContext sc) { this._stmt_list=_stmt_list; this._handler=_handler; source_context = sc; FillParentsInDirectChilds(); } protected statement_list _stmt_list; protected try_handler _handler; /// /// /// public statement_list stmt_list { get { return _stmt_list; } set { _stmt_list=value; if (_stmt_list != null) _stmt_list.Parent = this; } } /// /// /// public try_handler handler { get { return _handler; } set { _handler=value; if (_handler != null) _handler.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { try_stmt copy = new try_stmt(); 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 (stmt_list != null) { copy.stmt_list = (statement_list)stmt_list.Clone(); copy.stmt_list.Parent = copy; } if (handler != null) { copy.handler = (try_handler)handler.Clone(); copy.handler.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new try_stmt TypedClone() { return Clone() as try_stmt; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (stmt_list != null) stmt_list.Parent = this; if (handler != null) handler.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); stmt_list?.FillParentsInAllChilds(); handler?.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 stmt_list; case 1: return handler; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: stmt_list = (statement_list)value; break; case 1: handler = (try_handler)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class inherited_message : statement { /// ///Конструктор без параметров. /// public inherited_message() { } /// Создает копию узла public override syntax_tree_node Clone() { inherited_message copy = new inherited_message(); 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 inherited_message TypedClone() { return Clone() as inherited_message; } /// Заполняет поля 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); } } /// ///expression может быть literal или ident /// [Serializable] public partial class external_directive : proc_block { /// ///Конструктор без параметров. /// public external_directive() { } /// ///Конструктор с параметрами. /// public external_directive(expression _modulename,expression _name) { this._modulename=_modulename; this._name=_name; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public external_directive(expression _modulename,expression _name,SourceContext sc) { this._modulename=_modulename; this._name=_name; source_context = sc; FillParentsInDirectChilds(); } protected expression _modulename; protected expression _name; /// /// /// public expression modulename { get { return _modulename; } set { _modulename=value; if (_modulename != null) _modulename.Parent = this; } } /// /// /// public expression name { get { return _name; } set { _name=value; if (_name != null) _name.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { external_directive copy = new external_directive(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (modulename != null) { copy.modulename = (expression)modulename.Clone(); copy.modulename.Parent = copy; } if (name != null) { copy.name = (expression)name.Clone(); copy.name.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new external_directive TypedClone() { return Clone() as external_directive; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (modulename != null) modulename.Parent = this; if (name != null) name.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); modulename?.FillParentsInAllChilds(); name?.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 modulename; case 1: return name; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: modulename = (expression)value; break; case 1: name = (expression)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class using_list : syntax_tree_node { /// ///Конструктор без параметров. /// public using_list() { } /// ///Конструктор с параметрами. /// public using_list(List _namespaces) { this._namespaces=_namespaces; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public using_list(List _namespaces,SourceContext sc) { this._namespaces=_namespaces; source_context = sc; FillParentsInDirectChilds(); } public using_list(unit_or_namespace elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected List _namespaces=new List(); /// /// /// public List namespaces { get { return _namespaces; } set { _namespaces=value; } } public using_list Add(unit_or_namespace elem, SourceContext sc = null) { namespaces.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)); namespaces.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); namespaces.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)); namespaces.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 = namespaces.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)); namespaces.Insert(FindIndexInList(el) + 1, newel); newel.Parent = this; } public void InsertAfter(unit_or_namespace el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); namespaces.InsertRange(FindIndexInList(el) + 1, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public void InsertBefore(unit_or_namespace el, unit_or_namespace newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); namespaces.Insert(FindIndexInList(el), newel); newel.Parent = this; } public void InsertBefore(unit_or_namespace el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); namespaces.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(unit_or_namespace el) { return namespaces.Remove(el); } public void ReplaceInList(unit_or_namespace el, unit_or_namespace newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); namespaces[FindIndexInList(el)] = newel; newel.Parent = this; } public void ReplaceInList(unit_or_namespace el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); var ind = FindIndexInList(el); namespaces.RemoveAt(ind); namespaces.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return namespaces.RemoveAll(match); } public unit_or_namespace Last() { if (namespaces.Count > 0) return namespaces[namespaces.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return namespaces.Count; } } public void Insert(int pos, unit_or_namespace el) { if (el == null) throw new ArgumentNullException(nameof(el)); namespaces.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { using_list copy = new using_list(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (namespaces != null) { foreach (unit_or_namespace elem in namespaces) { if (elem != null) { copy.Add((unit_or_namespace)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new using_list TypedClone() { return Clone() as using_list; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (namespaces != null) { foreach (var child in namespaces) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (namespaces != null) { foreach (var child in namespaces) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (namespaces == null ? 0 : namespaces.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(namespaces != null) { if(index_counter < namespaces.Count) { return namespaces[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); Int32 index_counter=ind - 0; if(namespaces != null) { if(index_counter < namespaces.Count) { namespaces[index_counter]= (unit_or_namespace)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class jump_stmt : statement { /// ///Конструктор без параметров. /// public jump_stmt() { } /// ///Конструктор с параметрами. /// public jump_stmt(expression _expr,JumpStmtType _JumpType) { this._expr=_expr; this._JumpType=_JumpType; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public jump_stmt(expression _expr,JumpStmtType _JumpType,SourceContext sc) { this._expr=_expr; this._JumpType=_JumpType; source_context = sc; FillParentsInDirectChilds(); } protected expression _expr; protected JumpStmtType _JumpType; /// /// /// public expression expr { get { return _expr; } set { _expr=value; if (_expr != null) _expr.Parent = this; } } /// /// /// public JumpStmtType JumpType { get { return _JumpType; } set { _JumpType=value; } } /// Создает копию узла public override syntax_tree_node Clone() { jump_stmt copy = new jump_stmt(); 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; } copy.JumpType = JumpType; return copy; } /// Получает копию данного узла корректного типа public new jump_stmt TypedClone() { return Clone() as jump_stmt; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (expr != null) expr.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); expr?.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 expr; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: expr = (expression)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class loop_stmt : statement { /// ///Конструктор без параметров. /// public loop_stmt() { } /// ///Конструктор с параметрами. /// public loop_stmt(expression _count,statement _stmt) { this._count=_count; this._stmt=_stmt; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public loop_stmt(expression _count,statement _stmt,SourceContext sc) { this._count=_count; this._stmt=_stmt; source_context = sc; FillParentsInDirectChilds(); } protected expression _count; protected statement _stmt; /// /// /// public expression count { get { return _count; } set { _count=value; if (_count != null) _count.Parent = this; } } /// /// /// public statement stmt { get { return _stmt; } set { _stmt=value; if (_stmt != null) _stmt.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { loop_stmt copy = new loop_stmt(); 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 (count != null) { copy.count = (expression)count.Clone(); copy.count.Parent = copy; } if (stmt != null) { copy.stmt = (statement)stmt.Clone(); copy.stmt.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new loop_stmt TypedClone() { return Clone() as loop_stmt; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (count != null) count.Parent = this; if (stmt != null) stmt.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); count?.FillParentsInAllChilds(); stmt?.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 count; case 1: return stmt; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: count = (expression)value; break; case 1: stmt = (statement)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class foreach_stmt : statement { /// ///Конструктор без параметров. /// public foreach_stmt() { } /// ///Конструктор с параметрами. /// public foreach_stmt(ident _identifier,type_definition _type_name,expression _in_what,statement _stmt) { this._identifier=_identifier; this._type_name=_type_name; this._in_what=_in_what; this._stmt=_stmt; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public foreach_stmt(ident _identifier,type_definition _type_name,expression _in_what,statement _stmt,SourceContext sc) { this._identifier=_identifier; this._type_name=_type_name; this._in_what=_in_what; this._stmt=_stmt; source_context = sc; FillParentsInDirectChilds(); } protected ident _identifier; protected type_definition _type_name; protected expression _in_what; protected statement _stmt; /// /// /// public ident identifier { get { return _identifier; } set { _identifier=value; if (_identifier != null) _identifier.Parent = this; } } /// /// /// public type_definition type_name { get { return _type_name; } set { _type_name=value; if (_type_name != null) _type_name.Parent = this; } } /// /// /// public expression in_what { get { return _in_what; } set { _in_what=value; if (_in_what != null) _in_what.Parent = this; } } /// /// /// public statement stmt { get { return _stmt; } set { _stmt=value; if (_stmt != null) _stmt.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { foreach_stmt copy = new foreach_stmt(); 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 (identifier != null) { copy.identifier = (ident)identifier.Clone(); copy.identifier.Parent = copy; } if (type_name != null) { copy.type_name = (type_definition)type_name.Clone(); copy.type_name.Parent = copy; } if (in_what != null) { copy.in_what = (expression)in_what.Clone(); copy.in_what.Parent = copy; } if (stmt != null) { copy.stmt = (statement)stmt.Clone(); copy.stmt.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new foreach_stmt TypedClone() { return Clone() as foreach_stmt; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (identifier != null) identifier.Parent = this; if (type_name != null) type_name.Parent = this; if (in_what != null) in_what.Parent = this; if (stmt != null) stmt.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); identifier?.FillParentsInAllChilds(); type_name?.FillParentsInAllChilds(); in_what?.FillParentsInAllChilds(); stmt?.FillParentsInAllChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 4; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 4; } } /// ///Индексатор для получения всех подузлов /// 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 identifier; case 1: return type_name; case 2: return in_what; case 3: return stmt; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: identifier = (ident)value; break; case 1: type_name = (type_definition)value; break; case 2: in_what = (expression)value; break; case 3: stmt = (statement)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class addressed_value_funcname : addressed_value { /// ///Конструктор без параметров. /// public addressed_value_funcname() { } /// Создает копию узла public override syntax_tree_node Clone() { addressed_value_funcname copy = new addressed_value_funcname(); 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_funcname TypedClone() { return Clone() as addressed_value_funcname; } /// Заполняет поля 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 named_type_reference_list : syntax_tree_node { /// ///Конструктор без параметров. /// public named_type_reference_list() { } /// ///Конструктор с параметрами. /// public named_type_reference_list(List _types) { this._types=_types; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public named_type_reference_list(List _types,SourceContext sc) { this._types=_types; source_context = sc; FillParentsInDirectChilds(); } public named_type_reference_list(named_type_reference elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected List _types=new List(); /// /// /// public List types { get { return _types; } set { _types=value; } } public named_type_reference_list Add(named_type_reference elem, SourceContext sc = null) { types.Add(elem); if (elem != null) elem.Parent = this; if (sc != null) source_context = sc; return this; } public void AddFirst(named_type_reference el) { if (el == null) throw new ArgumentNullException(nameof(el)); types.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); types.InsertRange(0, els); foreach (var el in els) if (el != null) el.Parent = this; } public void AddMany(params named_type_reference[] els) { if (els == null) throw new ArgumentNullException(nameof(els)); types.AddRange(els); foreach (var el in els) if (el != null) el.Parent = this; } private int FindIndexInList(named_type_reference el) { if (el == null) throw new ArgumentNullException(nameof(el)); var ind = types.FindIndex(x => x == el); if (ind == -1) throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el)); return ind; } public void InsertAfter(named_type_reference el, named_type_reference newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); types.Insert(FindIndexInList(el) + 1, newel); newel.Parent = this; } public void InsertAfter(named_type_reference el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); types.InsertRange(FindIndexInList(el) + 1, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public void InsertBefore(named_type_reference el, named_type_reference newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); types.Insert(FindIndexInList(el), newel); newel.Parent = this; } public void InsertBefore(named_type_reference el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); types.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(named_type_reference el) { return types.Remove(el); } public void ReplaceInList(named_type_reference el, named_type_reference newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); types[FindIndexInList(el)] = newel; newel.Parent = this; } public void ReplaceInList(named_type_reference el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); var ind = FindIndexInList(el); types.RemoveAt(ind); types.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return types.RemoveAll(match); } public named_type_reference Last() { if (types.Count > 0) return types[types.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return types.Count; } } public void Insert(int pos, named_type_reference el) { if (el == null) throw new ArgumentNullException(nameof(el)); types.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { named_type_reference_list copy = new named_type_reference_list(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (types != null) { foreach (named_type_reference elem in types) { if (elem != null) { copy.Add((named_type_reference)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new named_type_reference_list TypedClone() { return Clone() as named_type_reference_list; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (types != null) { foreach (var child in types) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (types != null) { foreach (var child in types) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (types == null ? 0 : types.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 != null) { if(index_counter < types.Count) { return types[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 != null) { if(index_counter < types.Count) { types[index_counter]= (named_type_reference)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class template_param_list : dereference { /// ///Конструктор без параметров. /// public template_param_list() { } /// ///Конструктор с параметрами. /// public template_param_list(List _params_list) { this._params_list=_params_list; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public template_param_list(List _params_list,SourceContext sc) { this._params_list=_params_list; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public template_param_list(addressed_value _dereferencing_value,List _params_list) { this._dereferencing_value=_dereferencing_value; this._params_list=_params_list; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public template_param_list(addressed_value _dereferencing_value,List _params_list,SourceContext sc) { this._dereferencing_value=_dereferencing_value; this._params_list=_params_list; source_context = sc; FillParentsInDirectChilds(); } public template_param_list(type_definition 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 template_param_list Add(type_definition 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(type_definition 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 type_definition[] 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(type_definition 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(type_definition el, type_definition 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(type_definition 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(type_definition el, type_definition 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(type_definition 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(type_definition el) { return params_list.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)); params_list[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); 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 type_definition 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, type_definition 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() { template_param_list copy = new template_param_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 (dereferencing_value != null) { copy.dereferencing_value = (addressed_value)dereferencing_value.Clone(); copy.dereferencing_value.Parent = copy; } if (params_list != null) { foreach (type_definition elem in params_list) { if (elem != null) { copy.Add((type_definition)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new template_param_list TypedClone() { return Clone() as template_param_list; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (dereferencing_value != null) dereferencing_value.Parent = this; if (params_list != null) { foreach (var child in params_list) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); dereferencing_value?.FillParentsInAllChilds(); if (params_list != null) { foreach (var child in params_list) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 1; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 1 + (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(); switch(ind) { case 0: return dereferencing_value; } Int32 index_counter=ind - 1; 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(); switch(ind) { case 0: dereferencing_value = (addressed_value)value; break; } Int32 index_counter=ind - 1; if(params_list != null) { if(index_counter < params_list.Count) { params_list[index_counter]= (type_definition)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class template_type_reference : named_type_reference { /// ///Конструктор без параметров. /// public template_type_reference() { } /// ///Конструктор с параметрами. /// public template_type_reference(named_type_reference _name,template_param_list _params_list) { this._name=_name; this._params_list=_params_list; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public template_type_reference(named_type_reference _name,template_param_list _params_list,SourceContext sc) { this._name=_name; this._params_list=_params_list; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public template_type_reference(type_definition_attr_list _attr_list,List _names,named_type_reference _name,template_param_list _params_list) { this._attr_list=_attr_list; this._names=_names; this._name=_name; this._params_list=_params_list; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public template_type_reference(type_definition_attr_list _attr_list,List _names,named_type_reference _name,template_param_list _params_list,SourceContext sc) { this._attr_list=_attr_list; this._names=_names; this._name=_name; this._params_list=_params_list; source_context = sc; FillParentsInDirectChilds(); } protected named_type_reference _name; protected template_param_list _params_list; /// /// /// public named_type_reference name { get { return _name; } set { _name=value; if (_name != null) _name.Parent = this; } } /// /// /// public template_param_list params_list { get { return _params_list; } set { _params_list=value; if (_params_list != null) _params_list.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { template_type_reference copy = new template_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); } } if (name != null) { copy.name = (named_type_reference)name.Clone(); copy.name.Parent = copy; } if (params_list != null) { copy.params_list = (template_param_list)params_list.Clone(); copy.params_list.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new template_type_reference TypedClone() { return Clone() as template_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; } if (name != null) name.Parent = this; if (params_list != null) params_list.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); attr_list?.FillParentsInAllChilds(); if (names != null) { foreach (var child in names) child?.FillParentsInAllChilds(); } name?.FillParentsInAllChilds(); params_list?.FillParentsInAllChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 3; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 3 + (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; case 1: return name; case 2: return params_list; } Int32 index_counter=ind - 3; 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; case 1: name = (named_type_reference)value; break; case 2: params_list = (template_param_list)value; break; } Int32 index_counter=ind - 3; 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); } } /// /// /// [Serializable] public partial class int64_const : const_node { /// ///Конструктор без параметров. /// public int64_const() { } /// ///Конструктор с параметрами. /// public int64_const(Int64 _val) { this._val=_val; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public int64_const(Int64 _val,SourceContext sc) { this._val=_val; source_context = sc; FillParentsInDirectChilds(); } protected Int64 _val; /// /// /// public Int64 val { get { return _val; } set { _val=value; } } /// Создает копию узла public override syntax_tree_node Clone() { int64_const copy = new int64_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 int64_const TypedClone() { return Clone() as int64_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 uint64_const : const_node { /// ///Конструктор без параметров. /// public uint64_const() { } /// ///Конструктор с параметрами. /// public uint64_const(UInt64 _val) { this._val=_val; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public uint64_const(UInt64 _val,SourceContext sc) { this._val=_val; source_context = sc; FillParentsInDirectChilds(); } protected UInt64 _val; /// /// /// public UInt64 val { get { return _val; } set { _val=value; } } /// Создает копию узла public override syntax_tree_node Clone() { uint64_const copy = new uint64_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 uint64_const TypedClone() { return Clone() as uint64_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 new_expr : addressed_value { /// ///Конструктор без параметров. /// public new_expr() { } /// ///Конструктор с параметрами. /// public new_expr(type_definition _type,expression_list _params_list,bool _new_array,array_const _array_init_expr) { this._type=_type; this._params_list=_params_list; this._new_array=_new_array; this._array_init_expr=_array_init_expr; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public new_expr(type_definition _type,expression_list _params_list,bool _new_array,array_const _array_init_expr,SourceContext sc) { this._type=_type; this._params_list=_params_list; this._new_array=_new_array; this._array_init_expr=_array_init_expr; source_context = sc; FillParentsInDirectChilds(); } protected type_definition _type; protected expression_list _params_list; protected bool _new_array; protected array_const _array_init_expr; /// /// /// public type_definition type { get { return _type; } set { _type=value; if (_type != null) _type.Parent = this; } } /// /// /// public expression_list params_list { get { return _params_list; } set { _params_list=value; if (_params_list != null) _params_list.Parent = this; } } /// /// /// public bool new_array { get { return _new_array; } set { _new_array=value; } } /// /// /// public array_const array_init_expr { get { return _array_init_expr; } set { _array_init_expr=value; if (_array_init_expr != null) _array_init_expr.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { new_expr copy = new new_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 (type != null) { copy.type = (type_definition)type.Clone(); copy.type.Parent = copy; } if (params_list != null) { copy.params_list = (expression_list)params_list.Clone(); copy.params_list.Parent = copy; } copy.new_array = new_array; if (array_init_expr != null) { copy.array_init_expr = (array_const)array_init_expr.Clone(); copy.array_init_expr.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new new_expr TypedClone() { return Clone() as new_expr; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (type != null) type.Parent = this; if (params_list != null) params_list.Parent = this; if (array_init_expr != null) array_init_expr.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); type?.FillParentsInAllChilds(); params_list?.FillParentsInAllChilds(); array_init_expr?.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 type; case 1: return params_list; case 2: return array_init_expr; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: type = (type_definition)value; break; case 1: params_list = (expression_list)value; break; case 2: array_init_expr = (array_const)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class where_type_specificator_list : syntax_tree_node { /// ///Конструктор без параметров. /// public where_type_specificator_list() { } /// ///Конструктор с параметрами. /// public where_type_specificator_list(List _defs) { this._defs=_defs; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public where_type_specificator_list(List _defs,SourceContext sc) { this._defs=_defs; source_context = sc; FillParentsInDirectChilds(); } public where_type_specificator_list(type_definition elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected List _defs=new List(); /// /// /// public List defs { get { return _defs; } set { _defs=value; } } public where_type_specificator_list Add(type_definition elem, SourceContext sc = null) { defs.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)); 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 type_definition[] 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(type_definition 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(type_definition el, type_definition 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(type_definition 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(type_definition el, type_definition 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(type_definition 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(type_definition el) { return defs.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)); defs[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); 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 type_definition 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, type_definition 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() { where_type_specificator_list copy = new where_type_specificator_list(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (defs != null) { foreach (type_definition elem in defs) { if (elem != null) { copy.Add((type_definition)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new where_type_specificator_list TypedClone() { return Clone() as where_type_specificator_list; } /// Заполняет поля 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]= (type_definition)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class where_definition : syntax_tree_node { /// ///Конструктор без параметров. /// public where_definition() { } /// ///Конструктор с параметрами. /// public where_definition(ident_list _names,where_type_specificator_list _types) { this._names=_names; this._types=_types; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public where_definition(ident_list _names,where_type_specificator_list _types,SourceContext sc) { this._names=_names; this._types=_types; source_context = sc; FillParentsInDirectChilds(); } protected ident_list _names; protected where_type_specificator_list _types; /// /// /// public ident_list names { get { return _names; } set { _names=value; if (_names != null) _names.Parent = this; } } /// /// /// public where_type_specificator_list types { get { return _types; } set { _types=value; if (_types != null) _types.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { where_definition copy = new where_definition(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (names != null) { copy.names = (ident_list)names.Clone(); copy.names.Parent = copy; } if (types != null) { copy.types = (where_type_specificator_list)types.Clone(); copy.types.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new where_definition TypedClone() { return Clone() as where_definition; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (names != null) names.Parent = this; if (types != null) types.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); names?.FillParentsInAllChilds(); types?.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 names; case 1: return types; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: names = (ident_list)value; break; case 1: types = (where_type_specificator_list)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class where_definition_list : syntax_tree_node { /// ///Конструктор без параметров. /// public where_definition_list() { } /// ///Конструктор с параметрами. /// public where_definition_list(List _defs) { this._defs=_defs; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public where_definition_list(List _defs,SourceContext sc) { this._defs=_defs; source_context = sc; FillParentsInDirectChilds(); } public where_definition_list(where_definition elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected List _defs=new List(); /// /// /// public List defs { get { return _defs; } set { _defs=value; } } public where_definition_list Add(where_definition elem, SourceContext sc = null) { defs.Add(elem); if (elem != null) elem.Parent = this; if (sc != null) source_context = sc; return this; } public void AddFirst(where_definition 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 where_definition[] 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(where_definition 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(where_definition el, where_definition 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(where_definition 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(where_definition el, where_definition 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(where_definition 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(where_definition el) { return defs.Remove(el); } public void ReplaceInList(where_definition el, where_definition 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(where_definition 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 where_definition 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, where_definition 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() { where_definition_list copy = new where_definition_list(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (defs != null) { foreach (where_definition elem in defs) { if (elem != null) { copy.Add((where_definition)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new where_definition_list TypedClone() { return Clone() as where_definition_list; } /// Заполняет поля 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]= (where_definition)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class sizeof_operator : addressed_value { /// ///Конструктор без параметров. /// public sizeof_operator() { } /// ///Конструктор с параметрами. /// public sizeof_operator(type_definition _type_def,expression _expr) { this._type_def=_type_def; this._expr=_expr; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public sizeof_operator(type_definition _type_def,expression _expr,SourceContext sc) { this._type_def=_type_def; this._expr=_expr; source_context = sc; FillParentsInDirectChilds(); } protected type_definition _type_def; protected expression _expr; /// /// /// public type_definition type_def { get { return _type_def; } set { _type_def=value; if (_type_def != null) _type_def.Parent = this; } } /// /// /// public expression expr { get { return _expr; } set { _expr=value; if (_expr != null) _expr.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { sizeof_operator copy = new sizeof_operator(); 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_def != null) { copy.type_def = (type_definition)type_def.Clone(); copy.type_def.Parent = copy; } if (expr != null) { copy.expr = (expression)expr.Clone(); copy.expr.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new sizeof_operator TypedClone() { return Clone() as sizeof_operator; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (type_def != null) type_def.Parent = this; if (expr != null) expr.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); type_def?.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 type_def; case 1: return expr; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: type_def = (type_definition)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 typeof_operator : addressed_value { /// ///Конструктор без параметров. /// public typeof_operator() { } /// ///Конструктор с параметрами. /// public typeof_operator(named_type_reference _type_name) { this._type_name=_type_name; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public typeof_operator(named_type_reference _type_name,SourceContext sc) { this._type_name=_type_name; source_context = sc; FillParentsInDirectChilds(); } protected named_type_reference _type_name; /// /// /// public named_type_reference type_name { get { return _type_name; } set { _type_name=value; if (_type_name != null) _type_name.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { typeof_operator copy = new typeof_operator(); 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 = (named_type_reference)type_name.Clone(); copy.type_name.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new typeof_operator TypedClone() { return Clone() as typeof_operator; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (type_name != null) type_name.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); type_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 type_name; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: type_name = (named_type_reference)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class compiler_directive : syntax_tree_node { /// ///Конструктор без параметров. /// public compiler_directive() { } /// ///Конструктор с параметрами. /// public compiler_directive(token_info _Name,token_info _Directive) { this._Name=_Name; this._Directive=_Directive; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public compiler_directive(token_info _Name,token_info _Directive,SourceContext sc) { this._Name=_Name; this._Directive=_Directive; source_context = sc; FillParentsInDirectChilds(); } protected token_info _Name; protected token_info _Directive; /// /// /// public token_info Name { get { return _Name; } set { _Name=value; if (_Name != null) _Name.Parent = this; } } /// /// /// public token_info Directive { get { return _Directive; } set { _Directive=value; if (_Directive != null) _Directive.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { compiler_directive copy = new compiler_directive(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (Name != null) { copy.Name = (token_info)Name.Clone(); copy.Name.Parent = copy; } if (Directive != null) { copy.Directive = (token_info)Directive.Clone(); copy.Directive.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new compiler_directive TypedClone() { return Clone() as compiler_directive; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (Name != null) Name.Parent = this; if (Directive != null) Directive.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); Name?.FillParentsInAllChilds(); Directive?.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 Directive; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: Name = (token_info)value; break; case 1: Directive = (token_info)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class operator_name_ident : ident { /// ///Конструктор без параметров. /// public operator_name_ident() { } /// ///Конструктор с параметрами. /// public operator_name_ident(Operators _operator_type) { this._operator_type=_operator_type; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public operator_name_ident(Operators _operator_type,SourceContext sc) { this._operator_type=_operator_type; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public operator_name_ident(string _name,Operators _operator_type) { this._name=_name; this._operator_type=_operator_type; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public operator_name_ident(string _name,Operators _operator_type,SourceContext sc) { this._name=_name; this._operator_type=_operator_type; source_context = sc; FillParentsInDirectChilds(); } protected Operators _operator_type; /// /// /// public Operators operator_type { get { return _operator_type; } set { _operator_type=value; } } /// Создает копию узла public override syntax_tree_node Clone() { operator_name_ident copy = new operator_name_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; copy.operator_type = operator_type; return copy; } /// Получает копию данного узла корректного типа public new operator_name_ident TypedClone() { return Clone() as operator_name_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); } } /// ///Однострочное описание переменной внутри begin-end. Хранит внутри var_def_statement /// [Serializable] public partial class var_statement : statement { /// ///Конструктор без параметров. /// public var_statement() { } /// ///Конструктор с параметрами. /// public var_statement(var_def_statement _var_def) { this._var_def=_var_def; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public var_statement(var_def_statement _var_def,SourceContext sc) { this._var_def=_var_def; source_context = sc; FillParentsInDirectChilds(); } protected var_def_statement _var_def; /// /// /// public var_def_statement var_def { get { return _var_def; } set { _var_def=value; if (_var_def != null) _var_def.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { var_statement copy = new var_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 (var_def != null) { copy.var_def = (var_def_statement)var_def.Clone(); copy.var_def.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new var_statement TypedClone() { return Clone() as var_statement; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (var_def != null) var_def.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); var_def?.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 var_def; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: var_def = (var_def_statement)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class question_colon_expression : addressed_value { /// ///Конструктор без параметров. /// public question_colon_expression() { } /// ///Конструктор с параметрами. /// public question_colon_expression(expression _condition,expression _ret_if_true,expression _ret_if_false) { this._condition=_condition; this._ret_if_true=_ret_if_true; this._ret_if_false=_ret_if_false; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public question_colon_expression(expression _condition,expression _ret_if_true,expression _ret_if_false,SourceContext sc) { this._condition=_condition; this._ret_if_true=_ret_if_true; this._ret_if_false=_ret_if_false; source_context = sc; FillParentsInDirectChilds(); } protected expression _condition; protected expression _ret_if_true; protected expression _ret_if_false; /// /// /// public expression condition { get { return _condition; } set { _condition=value; if (_condition != null) _condition.Parent = this; } } /// /// /// public expression ret_if_true { get { return _ret_if_true; } set { _ret_if_true=value; if (_ret_if_true != null) _ret_if_true.Parent = this; } } /// /// /// public expression ret_if_false { get { return _ret_if_false; } set { _ret_if_false=value; if (_ret_if_false != null) _ret_if_false.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { question_colon_expression copy = new question_colon_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; } if (condition != null) { copy.condition = (expression)condition.Clone(); copy.condition.Parent = copy; } if (ret_if_true != null) { copy.ret_if_true = (expression)ret_if_true.Clone(); copy.ret_if_true.Parent = copy; } if (ret_if_false != null) { copy.ret_if_false = (expression)ret_if_false.Clone(); copy.ret_if_false.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new question_colon_expression TypedClone() { return Clone() as question_colon_expression; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (condition != null) condition.Parent = this; if (ret_if_true != null) ret_if_true.Parent = this; if (ret_if_false != null) ret_if_false.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); condition?.FillParentsInAllChilds(); ret_if_true?.FillParentsInAllChilds(); ret_if_false?.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 ret_if_true; case 2: return ret_if_false; } 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: ret_if_true = (expression)value; break; case 2: ret_if_false = (expression)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class expression_as_statement : statement { /// ///Конструктор без параметров. /// public expression_as_statement() { } /// ///Конструктор с параметрами. /// public expression_as_statement(expression _expr) { this._expr=_expr; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public expression_as_statement(expression _expr,SourceContext sc) { this._expr=_expr; source_context = sc; FillParentsInDirectChilds(); } protected expression _expr; /// /// /// public expression expr { get { return _expr; } set { _expr=value; if (_expr != null) _expr.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { expression_as_statement copy = new expression_as_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 (expr != null) { copy.expr = (expression)expr.Clone(); copy.expr.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new expression_as_statement TypedClone() { return Clone() as expression_as_statement; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (expr != null) expr.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); expr?.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 expr; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: expr = (expression)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class c_scalar_type : type_definition { /// ///Конструктор без параметров. /// public c_scalar_type() { } /// ///Конструктор с параметрами. /// public c_scalar_type(c_scalar_type_name _scalar_name,c_scalar_sign _sign) { this._scalar_name=_scalar_name; this._sign=_sign; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public c_scalar_type(c_scalar_type_name _scalar_name,c_scalar_sign _sign,SourceContext sc) { this._scalar_name=_scalar_name; this._sign=_sign; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public c_scalar_type(type_definition_attr_list _attr_list,c_scalar_type_name _scalar_name,c_scalar_sign _sign) { this._attr_list=_attr_list; this._scalar_name=_scalar_name; this._sign=_sign; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public c_scalar_type(type_definition_attr_list _attr_list,c_scalar_type_name _scalar_name,c_scalar_sign _sign,SourceContext sc) { this._attr_list=_attr_list; this._scalar_name=_scalar_name; this._sign=_sign; source_context = sc; FillParentsInDirectChilds(); } protected c_scalar_type_name _scalar_name; protected c_scalar_sign _sign; /// /// /// public c_scalar_type_name scalar_name { get { return _scalar_name; } set { _scalar_name=value; } } /// /// /// public c_scalar_sign sign { get { return _sign; } set { _sign=value; } } /// Создает копию узла public override syntax_tree_node Clone() { c_scalar_type copy = new c_scalar_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; } copy.scalar_name = scalar_name; copy.sign = sign; return copy; } /// Получает копию данного узла корректного типа public new c_scalar_type TypedClone() { return Clone() as c_scalar_type; } /// Заполняет поля 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 c_module : compilation_unit { /// ///Конструктор без параметров. /// public c_module() { } /// ///Конструктор с параметрами. /// public c_module(declarations _defs,uses_list _used_units) { this._defs=_defs; this._used_units=_used_units; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public c_module(declarations _defs,uses_list _used_units,SourceContext sc) { this._defs=_defs; this._used_units=_used_units; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public c_module(string _file_name,List _compiler_directives,LanguageId _Language,declarations _defs,uses_list _used_units) { this._file_name=_file_name; this._compiler_directives=_compiler_directives; this._Language=_Language; this._defs=_defs; this._used_units=_used_units; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public c_module(string _file_name,List _compiler_directives,LanguageId _Language,declarations _defs,uses_list _used_units,SourceContext sc) { this._file_name=_file_name; this._compiler_directives=_compiler_directives; this._Language=_Language; this._defs=_defs; this._used_units=_used_units; source_context = sc; FillParentsInDirectChilds(); } protected declarations _defs; protected uses_list _used_units; /// /// /// public declarations defs { get { return _defs; } set { _defs=value; if (_defs != null) _defs.Parent = this; } } /// /// /// public uses_list used_units { get { return _used_units; } set { _used_units=value; if (_used_units != null) _used_units.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { c_module copy = new c_module(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); copy.file_name = file_name; if (compiler_directives != null) { foreach (compiler_directive elem in compiler_directives) { if (elem != null) { copy.Add((compiler_directive)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } copy.Language = Language; if (defs != null) { copy.defs = (declarations)defs.Clone(); copy.defs.Parent = copy; } if (used_units != null) { copy.used_units = (uses_list)used_units.Clone(); copy.used_units.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new c_module TypedClone() { return Clone() as c_module; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (compiler_directives != null) { foreach (var child in compiler_directives) if (child != null) child.Parent = this; } if (defs != null) defs.Parent = this; if (used_units != null) used_units.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (compiler_directives != null) { foreach (var child in compiler_directives) child?.FillParentsInAllChilds(); } defs?.FillParentsInAllChilds(); used_units?.FillParentsInAllChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 2; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 2 + (compiler_directives == null ? 0 : compiler_directives.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 defs; case 1: return used_units; } Int32 index_counter=ind - 2; if(compiler_directives != null) { if(index_counter < compiler_directives.Count) { return compiler_directives[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: defs = (declarations)value; break; case 1: used_units = (uses_list)value; break; } Int32 index_counter=ind - 2; if(compiler_directives != null) { if(index_counter < compiler_directives.Count) { compiler_directives[index_counter]= (compiler_directive)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class declarations_as_statement : statement { /// ///Конструктор без параметров. /// public declarations_as_statement() { } /// ///Конструктор с параметрами. /// public declarations_as_statement(declarations _defs) { this._defs=_defs; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public declarations_as_statement(declarations _defs,SourceContext sc) { this._defs=_defs; source_context = sc; FillParentsInDirectChilds(); } protected declarations _defs; /// /// /// public declarations defs { get { return _defs; } set { _defs=value; if (_defs != null) _defs.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { declarations_as_statement copy = new declarations_as_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 (defs != null) { copy.defs = (declarations)defs.Clone(); copy.defs.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new declarations_as_statement TypedClone() { return Clone() as declarations_as_statement; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (defs != null) defs.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); defs?.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 defs; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: defs = (declarations)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class array_size : type_definition { /// ///Конструктор без параметров. /// public array_size() { } /// ///Конструктор с параметрами. /// public array_size(expression _max_value) { this._max_value=_max_value; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public array_size(expression _max_value,SourceContext sc) { this._max_value=_max_value; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public array_size(type_definition_attr_list _attr_list,expression _max_value) { this._attr_list=_attr_list; this._max_value=_max_value; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public array_size(type_definition_attr_list _attr_list,expression _max_value,SourceContext sc) { this._attr_list=_attr_list; this._max_value=_max_value; source_context = sc; FillParentsInDirectChilds(); } protected expression _max_value; /// /// /// public expression max_value { get { return _max_value; } set { _max_value=value; if (_max_value != null) _max_value.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { array_size copy = new array_size(); 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 (max_value != null) { copy.max_value = (expression)max_value.Clone(); copy.max_value.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new array_size TypedClone() { return Clone() as array_size; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (attr_list != null) attr_list.Parent = this; if (max_value != null) max_value.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); attr_list?.FillParentsInAllChilds(); max_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 attr_list; case 1: return max_value; } 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: max_value = (expression)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class enumerator : syntax_tree_node { /// ///Конструктор без параметров. /// public enumerator() { } /// ///Конструктор с параметрами. /// public enumerator(type_definition _name,expression _value) { this._name=_name; this._value=_value; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public enumerator(type_definition _name,expression _value,SourceContext sc) { this._name=_name; this._value=_value; source_context = sc; FillParentsInDirectChilds(); } protected type_definition _name; protected expression _value; /// /// /// public type_definition name { get { return _name; } set { _name=value; if (_name != null) _name.Parent = this; } } /// /// /// public expression value { get { return _value; } set { _value=value; if (_value != null) _value.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { enumerator copy = new enumerator(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (name != null) { copy.name = (type_definition)name.Clone(); copy.name.Parent = copy; } if (value != null) { copy.value = (expression)value.Clone(); copy.value.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new enumerator TypedClone() { return Clone() as enumerator; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (name != null) name.Parent = this; if (value != null) value.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); name?.FillParentsInAllChilds(); 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 name; case 1: return value; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: name = (type_definition)value; break; case 1: value = (expression)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class enumerator_list : syntax_tree_node { /// ///Конструктор без параметров. /// public enumerator_list() { } /// ///Конструктор с параметрами. /// public enumerator_list(List _enumerators) { this._enumerators=_enumerators; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public enumerator_list(List _enumerators,SourceContext sc) { this._enumerators=_enumerators; source_context = sc; FillParentsInDirectChilds(); } public enumerator_list(enumerator elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected List _enumerators=new List(); /// /// /// public List enumerators { get { return _enumerators; } set { _enumerators=value; } } public enumerator_list Add(enumerator elem, SourceContext sc = null) { enumerators.Add(elem); if (elem != null) elem.Parent = this; if (sc != null) source_context = sc; return this; } public void AddFirst(enumerator el) { if (el == null) throw new ArgumentNullException(nameof(el)); enumerators.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); enumerators.InsertRange(0, els); foreach (var el in els) if (el != null) el.Parent = this; } public void AddMany(params enumerator[] els) { if (els == null) throw new ArgumentNullException(nameof(els)); enumerators.AddRange(els); foreach (var el in els) if (el != null) el.Parent = this; } private int FindIndexInList(enumerator el) { if (el == null) throw new ArgumentNullException(nameof(el)); var ind = enumerators.FindIndex(x => x == el); if (ind == -1) throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el)); return ind; } public void InsertAfter(enumerator el, enumerator newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); enumerators.Insert(FindIndexInList(el) + 1, newel); newel.Parent = this; } public void InsertAfter(enumerator el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); enumerators.InsertRange(FindIndexInList(el) + 1, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public void InsertBefore(enumerator el, enumerator newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); enumerators.Insert(FindIndexInList(el), newel); newel.Parent = this; } public void InsertBefore(enumerator el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); enumerators.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(enumerator el) { return enumerators.Remove(el); } public void ReplaceInList(enumerator el, enumerator newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); enumerators[FindIndexInList(el)] = newel; newel.Parent = this; } public void ReplaceInList(enumerator el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); var ind = FindIndexInList(el); enumerators.RemoveAt(ind); enumerators.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return enumerators.RemoveAll(match); } public enumerator Last() { if (enumerators.Count > 0) return enumerators[enumerators.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return enumerators.Count; } } public void Insert(int pos, enumerator el) { if (el == null) throw new ArgumentNullException(nameof(el)); enumerators.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { enumerator_list copy = new enumerator_list(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (enumerators != null) { foreach (enumerator elem in enumerators) { if (elem != null) { copy.Add((enumerator)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new enumerator_list TypedClone() { return Clone() as enumerator_list; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (enumerators != null) { foreach (var child in enumerators) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (enumerators != null) { foreach (var child in enumerators) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (enumerators == null ? 0 : enumerators.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(enumerators != null) { if(index_counter < enumerators.Count) { return enumerators[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); Int32 index_counter=ind - 0; if(enumerators != null) { if(index_counter < enumerators.Count) { enumerators[index_counter]= (enumerator)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class c_for_cycle : statement { /// ///Конструктор без параметров. /// public c_for_cycle() { } /// ///Конструктор с параметрами. /// public c_for_cycle(statement _expr1,expression _expr2,expression _expr3,statement _stmt) { this._expr1=_expr1; this._expr2=_expr2; this._expr3=_expr3; this._stmt=_stmt; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public c_for_cycle(statement _expr1,expression _expr2,expression _expr3,statement _stmt,SourceContext sc) { this._expr1=_expr1; this._expr2=_expr2; this._expr3=_expr3; this._stmt=_stmt; source_context = sc; FillParentsInDirectChilds(); } protected statement _expr1; protected expression _expr2; protected expression _expr3; protected statement _stmt; /// /// /// public statement expr1 { get { return _expr1; } set { _expr1=value; if (_expr1 != null) _expr1.Parent = this; } } /// /// /// public expression expr2 { get { return _expr2; } set { _expr2=value; if (_expr2 != null) _expr2.Parent = this; } } /// /// /// public expression expr3 { get { return _expr3; } set { _expr3=value; if (_expr3 != null) _expr3.Parent = this; } } /// /// /// public statement stmt { get { return _stmt; } set { _stmt=value; if (_stmt != null) _stmt.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { c_for_cycle copy = new c_for_cycle(); 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 (expr1 != null) { copy.expr1 = (statement)expr1.Clone(); copy.expr1.Parent = copy; } if (expr2 != null) { copy.expr2 = (expression)expr2.Clone(); copy.expr2.Parent = copy; } if (expr3 != null) { copy.expr3 = (expression)expr3.Clone(); copy.expr3.Parent = copy; } if (stmt != null) { copy.stmt = (statement)stmt.Clone(); copy.stmt.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new c_for_cycle TypedClone() { return Clone() as c_for_cycle; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (expr1 != null) expr1.Parent = this; if (expr2 != null) expr2.Parent = this; if (expr3 != null) expr3.Parent = this; if (stmt != null) stmt.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); expr1?.FillParentsInAllChilds(); expr2?.FillParentsInAllChilds(); expr3?.FillParentsInAllChilds(); stmt?.FillParentsInAllChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 4; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 4; } } /// ///Индексатор для получения всех подузлов /// 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 expr1; case 1: return expr2; case 2: return expr3; case 3: return stmt; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: expr1 = (statement)value; break; case 1: expr2 = (expression)value; break; case 2: expr3 = (expression)value; break; case 3: stmt = (statement)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class switch_stmt : statement { /// ///Конструктор без параметров. /// public switch_stmt() { } /// ///Конструктор с параметрами. /// public switch_stmt(expression _condition,statement _stmt,SwitchPartType _Part) { this._condition=_condition; this._stmt=_stmt; this._Part=_Part; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public switch_stmt(expression _condition,statement _stmt,SwitchPartType _Part,SourceContext sc) { this._condition=_condition; this._stmt=_stmt; this._Part=_Part; source_context = sc; FillParentsInDirectChilds(); } protected expression _condition; protected statement _stmt; protected SwitchPartType _Part; /// /// /// public expression condition { get { return _condition; } set { _condition=value; if (_condition != null) _condition.Parent = this; } } /// /// /// public statement stmt { get { return _stmt; } set { _stmt=value; if (_stmt != null) _stmt.Parent = this; } } /// /// /// public SwitchPartType Part { get { return _Part; } set { _Part=value; } } /// Создает копию узла public override syntax_tree_node Clone() { switch_stmt copy = new switch_stmt(); 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 (stmt != null) { copy.stmt = (statement)stmt.Clone(); copy.stmt.Parent = copy; } copy.Part = Part; return copy; } /// Получает копию данного узла корректного типа public new switch_stmt TypedClone() { return Clone() as switch_stmt; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (condition != null) condition.Parent = this; if (stmt != null) stmt.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); condition?.FillParentsInAllChilds(); stmt?.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 condition; case 1: return stmt; } 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: stmt = (statement)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class type_definition_attr_list : syntax_tree_node { /// ///Конструктор без параметров. /// public type_definition_attr_list() { } /// ///Конструктор с параметрами. /// public type_definition_attr_list(List _attributes) { this._attributes=_attributes; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public type_definition_attr_list(List _attributes,SourceContext sc) { this._attributes=_attributes; source_context = sc; FillParentsInDirectChilds(); } public type_definition_attr_list(type_definition_attr elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected List _attributes=new List(); /// /// /// public List attributes { get { return _attributes; } set { _attributes=value; } } public type_definition_attr_list Add(type_definition_attr elem, SourceContext sc = null) { attributes.Add(elem); if (elem != null) elem.Parent = this; if (sc != null) source_context = sc; return this; } public void AddFirst(type_definition_attr el) { if (el == null) throw new ArgumentNullException(nameof(el)); attributes.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); attributes.InsertRange(0, els); foreach (var el in els) if (el != null) el.Parent = this; } public void AddMany(params type_definition_attr[] els) { if (els == null) throw new ArgumentNullException(nameof(els)); attributes.AddRange(els); foreach (var el in els) if (el != null) el.Parent = this; } private int FindIndexInList(type_definition_attr el) { if (el == null) throw new ArgumentNullException(nameof(el)); var ind = attributes.FindIndex(x => x == el); if (ind == -1) throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el)); return ind; } public void InsertAfter(type_definition_attr el, type_definition_attr newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); attributes.Insert(FindIndexInList(el) + 1, newel); newel.Parent = this; } public void InsertAfter(type_definition_attr el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); attributes.InsertRange(FindIndexInList(el) + 1, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public void InsertBefore(type_definition_attr el, type_definition_attr newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); attributes.Insert(FindIndexInList(el), newel); newel.Parent = this; } public void InsertBefore(type_definition_attr el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); attributes.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(type_definition_attr el) { return attributes.Remove(el); } public void ReplaceInList(type_definition_attr el, type_definition_attr newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); attributes[FindIndexInList(el)] = newel; newel.Parent = this; } public void ReplaceInList(type_definition_attr el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); var ind = FindIndexInList(el); attributes.RemoveAt(ind); attributes.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return attributes.RemoveAll(match); } public type_definition_attr Last() { if (attributes.Count > 0) return attributes[attributes.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return attributes.Count; } } public void Insert(int pos, type_definition_attr el) { if (el == null) throw new ArgumentNullException(nameof(el)); attributes.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { type_definition_attr_list copy = new type_definition_attr_list(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (attributes != null) { foreach (type_definition_attr elem in attributes) { if (elem != null) { copy.Add((type_definition_attr)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new type_definition_attr_list TypedClone() { return Clone() as type_definition_attr_list; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) { foreach (var child in attributes) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (attributes != null) { foreach (var child in attributes) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (attributes == null ? 0 : 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(attributes != null) { if(index_counter < attributes.Count) { return 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(attributes != null) { if(index_counter < attributes.Count) { attributes[index_counter]= (type_definition_attr)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class type_definition_attr : type_definition { /// ///Конструктор без параметров. /// public type_definition_attr() { } /// ///Конструктор с параметрами. /// public type_definition_attr(definition_attribute _attr) { this._attr=_attr; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public type_definition_attr(definition_attribute _attr,SourceContext sc) { this._attr=_attr; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public type_definition_attr(type_definition_attr_list _attr_list,definition_attribute _attr) { this._attr_list=_attr_list; this._attr=_attr; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public type_definition_attr(type_definition_attr_list _attr_list,definition_attribute _attr,SourceContext sc) { this._attr_list=_attr_list; this._attr=_attr; source_context = sc; FillParentsInDirectChilds(); } protected definition_attribute _attr; /// /// /// public definition_attribute attr { get { return _attr; } set { _attr=value; } } /// Создает копию узла public override syntax_tree_node Clone() { type_definition_attr copy = new type_definition_attr(); 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; } copy.attr = attr; return copy; } /// Получает копию данного узла корректного типа public new type_definition_attr TypedClone() { return Clone() as type_definition_attr; } /// Заполняет поля 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 lock_stmt : statement { /// ///Конструктор без параметров. /// public lock_stmt() { } /// ///Конструктор с параметрами. /// public lock_stmt(expression _lock_object,statement _stmt) { this._lock_object=_lock_object; this._stmt=_stmt; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public lock_stmt(expression _lock_object,statement _stmt,SourceContext sc) { this._lock_object=_lock_object; this._stmt=_stmt; source_context = sc; FillParentsInDirectChilds(); } protected expression _lock_object; protected statement _stmt; /// /// /// public expression lock_object { get { return _lock_object; } set { _lock_object=value; if (_lock_object != null) _lock_object.Parent = this; } } /// /// /// public statement stmt { get { return _stmt; } set { _stmt=value; if (_stmt != null) _stmt.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { lock_stmt copy = new lock_stmt(); 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 (lock_object != null) { copy.lock_object = (expression)lock_object.Clone(); copy.lock_object.Parent = copy; } if (stmt != null) { copy.stmt = (statement)stmt.Clone(); copy.stmt.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new lock_stmt TypedClone() { return Clone() as lock_stmt; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (lock_object != null) lock_object.Parent = this; if (stmt != null) stmt.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); lock_object?.FillParentsInAllChilds(); stmt?.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 lock_object; case 1: return stmt; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: lock_object = (expression)value; break; case 1: stmt = (statement)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class compiler_directive_list : compiler_directive { /// ///Конструктор без параметров. /// public compiler_directive_list() { } /// ///Конструктор с параметрами. /// public compiler_directive_list(List _directives) { this._directives=_directives; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public compiler_directive_list(List _directives,SourceContext sc) { this._directives=_directives; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public compiler_directive_list(token_info _Name,token_info _Directive,List _directives) { this._Name=_Name; this._Directive=_Directive; this._directives=_directives; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public compiler_directive_list(token_info _Name,token_info _Directive,List _directives,SourceContext sc) { this._Name=_Name; this._Directive=_Directive; this._directives=_directives; source_context = sc; FillParentsInDirectChilds(); } public compiler_directive_list(compiler_directive elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected List _directives=new List(); /// /// /// public List directives { get { return _directives; } set { _directives=value; } } public compiler_directive_list Add(compiler_directive elem, SourceContext sc = null) { directives.Add(elem); if (elem != null) elem.Parent = this; if (sc != null) source_context = sc; return this; } public void AddFirst(compiler_directive el) { if (el == null) throw new ArgumentNullException(nameof(el)); directives.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); directives.InsertRange(0, els); foreach (var el in els) if (el != null) el.Parent = this; } public void AddMany(params compiler_directive[] els) { if (els == null) throw new ArgumentNullException(nameof(els)); directives.AddRange(els); foreach (var el in els) if (el != null) el.Parent = this; } private int FindIndexInList(compiler_directive el) { if (el == null) throw new ArgumentNullException(nameof(el)); var ind = directives.FindIndex(x => x == el); if (ind == -1) throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el)); return ind; } public void InsertAfter(compiler_directive el, compiler_directive newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); directives.Insert(FindIndexInList(el) + 1, newel); newel.Parent = this; } public void InsertAfter(compiler_directive el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); directives.InsertRange(FindIndexInList(el) + 1, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public void InsertBefore(compiler_directive el, compiler_directive newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); directives.Insert(FindIndexInList(el), newel); newel.Parent = this; } public void InsertBefore(compiler_directive el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); directives.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(compiler_directive el) { return directives.Remove(el); } public void ReplaceInList(compiler_directive el, compiler_directive newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); directives[FindIndexInList(el)] = newel; newel.Parent = this; } public void ReplaceInList(compiler_directive el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); var ind = FindIndexInList(el); directives.RemoveAt(ind); directives.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return directives.RemoveAll(match); } public compiler_directive Last() { if (directives.Count > 0) return directives[directives.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return directives.Count; } } public void Insert(int pos, compiler_directive el) { if (el == null) throw new ArgumentNullException(nameof(el)); directives.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { compiler_directive_list copy = new compiler_directive_list(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (Name != null) { copy.Name = (token_info)Name.Clone(); copy.Name.Parent = copy; } if (Directive != null) { copy.Directive = (token_info)Directive.Clone(); copy.Directive.Parent = copy; } if (directives != null) { foreach (compiler_directive elem in directives) { if (elem != null) { copy.Add((compiler_directive)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new compiler_directive_list TypedClone() { return Clone() as compiler_directive_list; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (Name != null) Name.Parent = this; if (Directive != null) Directive.Parent = this; if (directives != null) { foreach (var child in directives) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); Name?.FillParentsInAllChilds(); Directive?.FillParentsInAllChilds(); if (directives != null) { foreach (var child in directives) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 2; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 2 + (directives == null ? 0 : directives.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 Name; case 1: return Directive; } Int32 index_counter=ind - 2; if(directives != null) { if(index_counter < directives.Count) { return directives[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: Name = (token_info)value; break; case 1: Directive = (token_info)value; break; } Int32 index_counter=ind - 2; if(directives != null) { if(index_counter < directives.Count) { directives[index_counter]= (compiler_directive)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class compiler_directive_if : compiler_directive { /// ///Конструктор без параметров. /// public compiler_directive_if() { } /// ///Конструктор с параметрами. /// public compiler_directive_if(compiler_directive _if_part,compiler_directive _elseif_part) { this._if_part=_if_part; this._elseif_part=_elseif_part; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public compiler_directive_if(compiler_directive _if_part,compiler_directive _elseif_part,SourceContext sc) { this._if_part=_if_part; this._elseif_part=_elseif_part; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public compiler_directive_if(token_info _Name,token_info _Directive,compiler_directive _if_part,compiler_directive _elseif_part) { this._Name=_Name; this._Directive=_Directive; this._if_part=_if_part; this._elseif_part=_elseif_part; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public compiler_directive_if(token_info _Name,token_info _Directive,compiler_directive _if_part,compiler_directive _elseif_part,SourceContext sc) { this._Name=_Name; this._Directive=_Directive; this._if_part=_if_part; this._elseif_part=_elseif_part; source_context = sc; FillParentsInDirectChilds(); } protected compiler_directive _if_part; protected compiler_directive _elseif_part; /// /// /// public compiler_directive if_part { get { return _if_part; } set { _if_part=value; if (_if_part != null) _if_part.Parent = this; } } /// /// /// public compiler_directive elseif_part { get { return _elseif_part; } set { _elseif_part=value; if (_elseif_part != null) _elseif_part.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { compiler_directive_if copy = new compiler_directive_if(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (Name != null) { copy.Name = (token_info)Name.Clone(); copy.Name.Parent = copy; } if (Directive != null) { copy.Directive = (token_info)Directive.Clone(); copy.Directive.Parent = copy; } if (if_part != null) { copy.if_part = (compiler_directive)if_part.Clone(); copy.if_part.Parent = copy; } if (elseif_part != null) { copy.elseif_part = (compiler_directive)elseif_part.Clone(); copy.elseif_part.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new compiler_directive_if TypedClone() { return Clone() as compiler_directive_if; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (Name != null) Name.Parent = this; if (Directive != null) Directive.Parent = this; if (if_part != null) if_part.Parent = this; if (elseif_part != null) elseif_part.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); Name?.FillParentsInAllChilds(); Directive?.FillParentsInAllChilds(); if_part?.FillParentsInAllChilds(); elseif_part?.FillParentsInAllChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 4; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 4; } } /// ///Индексатор для получения всех подузлов /// 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 Directive; case 2: return if_part; case 3: return elseif_part; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: Name = (token_info)value; break; case 1: Directive = (token_info)value; break; case 2: if_part = (compiler_directive)value; break; case 3: elseif_part = (compiler_directive)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class documentation_comment_list : syntax_tree_node { /// ///Конструктор без параметров. /// public documentation_comment_list() { } /// ///Конструктор с параметрами. /// public documentation_comment_list(List _sections) { this._sections=_sections; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public documentation_comment_list(List _sections,SourceContext sc) { this._sections=_sections; source_context = sc; FillParentsInDirectChilds(); } public documentation_comment_list(documentation_comment_section elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected List _sections=new List(); /// /// /// public List sections { get { return _sections; } set { _sections=value; } } public documentation_comment_list Add(documentation_comment_section elem, SourceContext sc = null) { sections.Add(elem); if (elem != null) elem.Parent = this; if (sc != null) source_context = sc; return this; } public void AddFirst(documentation_comment_section el) { if (el == null) throw new ArgumentNullException(nameof(el)); sections.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); sections.InsertRange(0, els); foreach (var el in els) if (el != null) el.Parent = this; } public void AddMany(params documentation_comment_section[] els) { if (els == null) throw new ArgumentNullException(nameof(els)); sections.AddRange(els); foreach (var el in els) if (el != null) el.Parent = this; } private int FindIndexInList(documentation_comment_section el) { if (el == null) throw new ArgumentNullException(nameof(el)); var ind = sections.FindIndex(x => x == el); if (ind == -1) throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el)); return ind; } public void InsertAfter(documentation_comment_section el, documentation_comment_section newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); sections.Insert(FindIndexInList(el) + 1, newel); newel.Parent = this; } public void InsertAfter(documentation_comment_section el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); sections.InsertRange(FindIndexInList(el) + 1, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public void InsertBefore(documentation_comment_section el, documentation_comment_section newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); sections.Insert(FindIndexInList(el), newel); newel.Parent = this; } public void InsertBefore(documentation_comment_section el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); sections.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(documentation_comment_section el) { return sections.Remove(el); } public void ReplaceInList(documentation_comment_section el, documentation_comment_section newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); sections[FindIndexInList(el)] = newel; newel.Parent = this; } public void ReplaceInList(documentation_comment_section el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); var ind = FindIndexInList(el); sections.RemoveAt(ind); sections.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return sections.RemoveAll(match); } public documentation_comment_section Last() { if (sections.Count > 0) return sections[sections.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return sections.Count; } } public void Insert(int pos, documentation_comment_section el) { if (el == null) throw new ArgumentNullException(nameof(el)); sections.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { documentation_comment_list copy = new documentation_comment_list(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (sections != null) { foreach (documentation_comment_section elem in sections) { if (elem != null) { copy.Add((documentation_comment_section)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new documentation_comment_list TypedClone() { return Clone() as documentation_comment_list; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (sections != null) { foreach (var child in sections) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (sections != null) { foreach (var child in sections) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (sections == null ? 0 : sections.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(sections != null) { if(index_counter < sections.Count) { return sections[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); Int32 index_counter=ind - 0; if(sections != null) { if(index_counter < sections.Count) { sections[index_counter]= (documentation_comment_section)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class documentation_comment_tag : syntax_tree_node { /// ///Конструктор без параметров. /// public documentation_comment_tag() { } /// ///Конструктор с параметрами. /// public documentation_comment_tag(string _name,List _parameters,string _text) { this._name=_name; this._parameters=_parameters; this._text=_text; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public documentation_comment_tag(string _name,List _parameters,string _text,SourceContext sc) { this._name=_name; this._parameters=_parameters; this._text=_text; source_context = sc; FillParentsInDirectChilds(); } public documentation_comment_tag(documentation_comment_tag_param elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected string _name; protected List _parameters=new List(); protected string _text; /// /// /// public string name { get { return _name; } set { _name=value; } } /// /// /// public List parameters { get { return _parameters; } set { _parameters=value; } } /// /// /// public string text { get { return _text; } set { _text=value; } } public documentation_comment_tag Add(documentation_comment_tag_param elem, SourceContext sc = null) { parameters.Add(elem); if (elem != null) elem.Parent = this; if (sc != null) source_context = sc; return this; } public void AddFirst(documentation_comment_tag_param el) { if (el == null) throw new ArgumentNullException(nameof(el)); parameters.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); parameters.InsertRange(0, els); foreach (var el in els) if (el != null) el.Parent = this; } public void AddMany(params documentation_comment_tag_param[] els) { if (els == null) throw new ArgumentNullException(nameof(els)); parameters.AddRange(els); foreach (var el in els) if (el != null) el.Parent = this; } private int FindIndexInList(documentation_comment_tag_param el) { if (el == null) throw new ArgumentNullException(nameof(el)); var ind = parameters.FindIndex(x => x == el); if (ind == -1) throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el)); return ind; } public void InsertAfter(documentation_comment_tag_param el, documentation_comment_tag_param newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); parameters.Insert(FindIndexInList(el) + 1, newel); newel.Parent = this; } public void InsertAfter(documentation_comment_tag_param el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); parameters.InsertRange(FindIndexInList(el) + 1, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public void InsertBefore(documentation_comment_tag_param el, documentation_comment_tag_param newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); parameters.Insert(FindIndexInList(el), newel); newel.Parent = this; } public void InsertBefore(documentation_comment_tag_param el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); parameters.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(documentation_comment_tag_param el) { return parameters.Remove(el); } public void ReplaceInList(documentation_comment_tag_param el, documentation_comment_tag_param newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); parameters[FindIndexInList(el)] = newel; newel.Parent = this; } public void ReplaceInList(documentation_comment_tag_param el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); var ind = FindIndexInList(el); parameters.RemoveAt(ind); parameters.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return parameters.RemoveAll(match); } public documentation_comment_tag_param Last() { if (parameters.Count > 0) return parameters[parameters.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return parameters.Count; } } public void Insert(int pos, documentation_comment_tag_param el) { if (el == null) throw new ArgumentNullException(nameof(el)); parameters.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { documentation_comment_tag copy = new documentation_comment_tag(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); copy.name = name; if (parameters != null) { foreach (documentation_comment_tag_param elem in parameters) { if (elem != null) { copy.Add((documentation_comment_tag_param)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } copy.text = text; return copy; } /// Получает копию данного узла корректного типа public new documentation_comment_tag TypedClone() { return Clone() as documentation_comment_tag; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (parameters != null) { foreach (var child in parameters) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (parameters != null) { foreach (var child in parameters) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (parameters == null ? 0 : parameters.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(parameters != null) { if(index_counter < parameters.Count) { return parameters[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); Int32 index_counter=ind - 0; if(parameters != null) { if(index_counter < parameters.Count) { parameters[index_counter]= (documentation_comment_tag_param)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class documentation_comment_tag_param : syntax_tree_node { /// ///Конструктор без параметров. /// public documentation_comment_tag_param() { } /// ///Конструктор с параметрами. /// public documentation_comment_tag_param(string _name,string _value) { this._name=_name; this._value=_value; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public documentation_comment_tag_param(string _name,string _value,SourceContext sc) { this._name=_name; this._value=_value; source_context = sc; FillParentsInDirectChilds(); } protected string _name; protected string _value; /// /// /// public string name { get { return _name; } set { _name=value; } } /// /// /// public string value { get { return _value; } set { _value=value; } } /// Создает копию узла public override syntax_tree_node Clone() { documentation_comment_tag_param copy = new documentation_comment_tag_param(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); copy.name = name; copy.value = value; return copy; } /// Получает копию данного узла корректного типа public new documentation_comment_tag_param TypedClone() { return Clone() as documentation_comment_tag_param; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа 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 documentation_comment_section : syntax_tree_node { /// ///Конструктор без параметров. /// public documentation_comment_section() { } /// ///Конструктор с параметрами. /// public documentation_comment_section(List _tags,string _text) { this._tags=_tags; this._text=_text; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public documentation_comment_section(List _tags,string _text,SourceContext sc) { this._tags=_tags; this._text=_text; source_context = sc; FillParentsInDirectChilds(); } public documentation_comment_section(documentation_comment_tag elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected List _tags=new List(); protected string _text; /// /// /// public List tags { get { return _tags; } set { _tags=value; } } /// /// /// public string text { get { return _text; } set { _text=value; } } public documentation_comment_section Add(documentation_comment_tag elem, SourceContext sc = null) { tags.Add(elem); if (elem != null) elem.Parent = this; if (sc != null) source_context = sc; return this; } public void AddFirst(documentation_comment_tag el) { if (el == null) throw new ArgumentNullException(nameof(el)); tags.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); tags.InsertRange(0, els); foreach (var el in els) if (el != null) el.Parent = this; } public void AddMany(params documentation_comment_tag[] els) { if (els == null) throw new ArgumentNullException(nameof(els)); tags.AddRange(els); foreach (var el in els) if (el != null) el.Parent = this; } private int FindIndexInList(documentation_comment_tag el) { if (el == null) throw new ArgumentNullException(nameof(el)); var ind = tags.FindIndex(x => x == el); if (ind == -1) throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el)); return ind; } public void InsertAfter(documentation_comment_tag el, documentation_comment_tag newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); tags.Insert(FindIndexInList(el) + 1, newel); newel.Parent = this; } public void InsertAfter(documentation_comment_tag el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); tags.InsertRange(FindIndexInList(el) + 1, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public void InsertBefore(documentation_comment_tag el, documentation_comment_tag newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); tags.Insert(FindIndexInList(el), newel); newel.Parent = this; } public void InsertBefore(documentation_comment_tag el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); tags.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(documentation_comment_tag el) { return tags.Remove(el); } public void ReplaceInList(documentation_comment_tag el, documentation_comment_tag newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); tags[FindIndexInList(el)] = newel; newel.Parent = this; } public void ReplaceInList(documentation_comment_tag el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); var ind = FindIndexInList(el); tags.RemoveAt(ind); tags.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return tags.RemoveAll(match); } public documentation_comment_tag Last() { if (tags.Count > 0) return tags[tags.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return tags.Count; } } public void Insert(int pos, documentation_comment_tag el) { if (el == null) throw new ArgumentNullException(nameof(el)); tags.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { documentation_comment_section copy = new documentation_comment_section(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (tags != null) { foreach (documentation_comment_tag elem in tags) { if (elem != null) { copy.Add((documentation_comment_tag)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } copy.text = text; return copy; } /// Получает копию данного узла корректного типа public new documentation_comment_section TypedClone() { return Clone() as documentation_comment_section; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (tags != null) { foreach (var child in tags) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (tags != null) { foreach (var child in tags) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (tags == null ? 0 : tags.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(tags != null) { if(index_counter < tags.Count) { return tags[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); Int32 index_counter=ind - 0; if(tags != null) { if(index_counter < tags.Count) { tags[index_counter]= (documentation_comment_tag)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class token_taginfo : token_info { /// ///Конструктор без параметров. /// public token_taginfo() { } /// ///Конструктор с параметрами. /// public token_taginfo(object _tag) { this._tag=_tag; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public token_taginfo(object _tag,SourceContext sc) { this._tag=_tag; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public token_taginfo(string _text,object _tag) { this._text=_text; this._tag=_tag; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public token_taginfo(string _text,object _tag,SourceContext sc) { this._text=_text; this._tag=_tag; source_context = sc; FillParentsInDirectChilds(); } protected object _tag; /// /// /// public object tag { get { return _tag; } set { _tag=value; } } /// Создает копию узла public override syntax_tree_node Clone() { token_taginfo copy = new token_taginfo(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); copy.text = text; copy.tag = tag; return copy; } /// Получает копию данного узла корректного типа public new token_taginfo TypedClone() { return Clone() as token_taginfo; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа 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 declaration_specificator : type_definition { /// ///Конструктор без параметров. /// public declaration_specificator() { } /// ///Конструктор с параметрами. /// public declaration_specificator(DeclarationSpecificator _specificator,string _name) { this._specificator=_specificator; this._name=_name; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public declaration_specificator(DeclarationSpecificator _specificator,string _name,SourceContext sc) { this._specificator=_specificator; this._name=_name; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public declaration_specificator(type_definition_attr_list _attr_list,DeclarationSpecificator _specificator,string _name) { this._attr_list=_attr_list; this._specificator=_specificator; this._name=_name; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public declaration_specificator(type_definition_attr_list _attr_list,DeclarationSpecificator _specificator,string _name,SourceContext sc) { this._attr_list=_attr_list; this._specificator=_specificator; this._name=_name; source_context = sc; FillParentsInDirectChilds(); } protected DeclarationSpecificator _specificator; protected string _name; /// /// /// public DeclarationSpecificator specificator { get { return _specificator; } set { _specificator=value; } } /// /// /// public string name { get { return _name; } set { _name=value; } } /// Создает копию узла public override syntax_tree_node Clone() { declaration_specificator copy = new declaration_specificator(); 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; } copy.specificator = specificator; copy.name = name; return copy; } /// Получает копию данного узла корректного типа public new declaration_specificator TypedClone() { return Clone() as declaration_specificator; } /// Заполняет поля 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 ident_with_templateparams : addressed_value_funcname { /// ///Конструктор без параметров. /// public ident_with_templateparams() { } /// ///Конструктор с параметрами. /// public ident_with_templateparams(addressed_value _name,template_param_list _template_params) { this._name=_name; this._template_params=_template_params; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public ident_with_templateparams(addressed_value _name,template_param_list _template_params,SourceContext sc) { this._name=_name; this._template_params=_template_params; source_context = sc; FillParentsInDirectChilds(); } protected addressed_value _name; protected template_param_list _template_params; /// /// /// public addressed_value name { get { return _name; } set { _name=value; if (_name != null) _name.Parent = this; } } /// /// /// public template_param_list template_params { get { return _template_params; } set { _template_params=value; if (_template_params != null) _template_params.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { ident_with_templateparams copy = new ident_with_templateparams(); 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 (name != null) { copy.name = (addressed_value)name.Clone(); copy.name.Parent = copy; } if (template_params != null) { copy.template_params = (template_param_list)template_params.Clone(); copy.template_params.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new ident_with_templateparams TypedClone() { return Clone() as ident_with_templateparams; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (name != null) name.Parent = this; if (template_params != null) template_params.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); name?.FillParentsInAllChilds(); template_params?.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 template_params; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: name = (addressed_value)value; break; case 1: template_params = (template_param_list)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class template_type_name : ident { /// ///Конструктор без параметров. /// public template_type_name() { } /// ///Конструктор с параметрами. /// public template_type_name(ident_list _template_args) { this._template_args=_template_args; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public template_type_name(ident_list _template_args,SourceContext sc) { this._template_args=_template_args; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public template_type_name(string _name,ident_list _template_args) { this._name=_name; this._template_args=_template_args; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public template_type_name(string _name,ident_list _template_args,SourceContext sc) { this._name=_name; this._template_args=_template_args; source_context = sc; FillParentsInDirectChilds(); } protected ident_list _template_args; /// /// /// public ident_list template_args { get { return _template_args; } set { _template_args=value; if (_template_args != null) _template_args.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { template_type_name copy = new template_type_name(); 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; if (template_args != null) { copy.template_args = (ident_list)template_args.Clone(); copy.template_args.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new template_type_name TypedClone() { return Clone() as template_type_name; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (template_args != null) template_args.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); template_args?.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 template_args; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: template_args = (ident_list)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class default_operator : addressed_value { /// ///Конструктор без параметров. /// public default_operator() { } /// ///Конструктор с параметрами. /// public default_operator(named_type_reference _type_name) { this._type_name=_type_name; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public default_operator(named_type_reference _type_name,SourceContext sc) { this._type_name=_type_name; source_context = sc; FillParentsInDirectChilds(); } protected named_type_reference _type_name; /// /// /// public named_type_reference type_name { get { return _type_name; } set { _type_name=value; if (_type_name != null) _type_name.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { default_operator copy = new default_operator(); 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 = (named_type_reference)type_name.Clone(); copy.type_name.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new default_operator TypedClone() { return Clone() as default_operator; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (type_name != null) type_name.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); type_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 type_name; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: type_name = (named_type_reference)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class bracket_expr : addressed_value { /// ///Конструктор без параметров. /// public bracket_expr() { } /// ///Конструктор с параметрами. /// public bracket_expr(expression _expr) { this._expr=_expr; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public bracket_expr(expression _expr,SourceContext sc) { this._expr=_expr; source_context = sc; FillParentsInDirectChilds(); } protected expression _expr; /// /// /// public expression expr { get { return _expr; } set { _expr=value; if (_expr != null) _expr.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { bracket_expr copy = new bracket_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 (expr != null) { copy.expr = (expression)expr.Clone(); copy.expr.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new bracket_expr TypedClone() { return Clone() as bracket_expr; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (expr != null) expr.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); expr?.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 expr; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: expr = (expression)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class attribute : syntax_tree_node { /// ///Конструктор без параметров. /// public attribute() { } /// ///Конструктор с параметрами. /// public attribute(ident _qualifier,named_type_reference _type,expression_list _arguments) { this._qualifier=_qualifier; this._type=_type; this._arguments=_arguments; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public attribute(ident _qualifier,named_type_reference _type,expression_list _arguments,SourceContext sc) { this._qualifier=_qualifier; this._type=_type; this._arguments=_arguments; source_context = sc; FillParentsInDirectChilds(); } protected ident _qualifier; protected named_type_reference _type; protected expression_list _arguments; /// /// /// public ident qualifier { get { return _qualifier; } set { _qualifier=value; if (_qualifier != null) _qualifier.Parent = this; } } /// /// /// public named_type_reference type { get { return _type; } set { _type=value; if (_type != null) _type.Parent = this; } } /// /// /// public expression_list arguments { get { return _arguments; } set { _arguments=value; if (_arguments != null) _arguments.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { attribute copy = new attribute(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (qualifier != null) { copy.qualifier = (ident)qualifier.Clone(); copy.qualifier.Parent = copy; } if (type != null) { copy.type = (named_type_reference)type.Clone(); copy.type.Parent = copy; } if (arguments != null) { copy.arguments = (expression_list)arguments.Clone(); copy.arguments.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new attribute TypedClone() { return Clone() as attribute; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (qualifier != null) qualifier.Parent = this; if (type != null) type.Parent = this; if (arguments != null) arguments.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); qualifier?.FillParentsInAllChilds(); type?.FillParentsInAllChilds(); arguments?.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 qualifier; case 1: return type; case 2: return arguments; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: qualifier = (ident)value; break; case 1: type = (named_type_reference)value; break; case 2: arguments = (expression_list)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class simple_attribute_list : syntax_tree_node { /// ///Конструктор без параметров. /// public simple_attribute_list() { } /// ///Конструктор с параметрами. /// public simple_attribute_list(List _attributes) { this._attributes=_attributes; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public simple_attribute_list(List _attributes,SourceContext sc) { this._attributes=_attributes; source_context = sc; FillParentsInDirectChilds(); } public simple_attribute_list(attribute elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected List _attributes=new List(); /// /// /// public List attributes { get { return _attributes; } set { _attributes=value; } } public simple_attribute_list Add(attribute elem, SourceContext sc = null) { attributes.Add(elem); if (elem != null) elem.Parent = this; if (sc != null) source_context = sc; return this; } public void AddFirst(attribute el) { if (el == null) throw new ArgumentNullException(nameof(el)); attributes.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); attributes.InsertRange(0, els); foreach (var el in els) if (el != null) el.Parent = this; } public void AddMany(params attribute[] els) { if (els == null) throw new ArgumentNullException(nameof(els)); attributes.AddRange(els); foreach (var el in els) if (el != null) el.Parent = this; } private int FindIndexInList(attribute el) { if (el == null) throw new ArgumentNullException(nameof(el)); var ind = attributes.FindIndex(x => x == el); if (ind == -1) throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el)); return ind; } public void InsertAfter(attribute el, attribute newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); attributes.Insert(FindIndexInList(el) + 1, newel); newel.Parent = this; } public void InsertAfter(attribute el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); attributes.InsertRange(FindIndexInList(el) + 1, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public void InsertBefore(attribute el, attribute newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); attributes.Insert(FindIndexInList(el), newel); newel.Parent = this; } public void InsertBefore(attribute el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); attributes.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(attribute el) { return attributes.Remove(el); } public void ReplaceInList(attribute el, attribute newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); attributes[FindIndexInList(el)] = newel; newel.Parent = this; } public void ReplaceInList(attribute el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); var ind = FindIndexInList(el); attributes.RemoveAt(ind); attributes.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return attributes.RemoveAll(match); } public attribute Last() { if (attributes.Count > 0) return attributes[attributes.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return attributes.Count; } } public void Insert(int pos, attribute el) { if (el == null) throw new ArgumentNullException(nameof(el)); attributes.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { simple_attribute_list copy = new simple_attribute_list(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (attributes != null) { foreach (attribute elem in attributes) { if (elem != null) { copy.Add((attribute)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new simple_attribute_list TypedClone() { return Clone() as simple_attribute_list; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) { foreach (var child in attributes) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (attributes != null) { foreach (var child in attributes) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (attributes == null ? 0 : 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(attributes != null) { if(index_counter < attributes.Count) { return 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(attributes != null) { if(index_counter < attributes.Count) { attributes[index_counter]= (attribute)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class attribute_list : syntax_tree_node { /// ///Конструктор без параметров. /// public attribute_list() { } /// ///Конструктор с параметрами. /// public attribute_list(List _attributes) { this._attributes=_attributes; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public attribute_list(List _attributes,SourceContext sc) { this._attributes=_attributes; source_context = sc; FillParentsInDirectChilds(); } public attribute_list(simple_attribute_list elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected List _attributes=new List(); /// /// /// public List attributes { get { return _attributes; } set { _attributes=value; } } public attribute_list Add(simple_attribute_list elem, SourceContext sc = null) { attributes.Add(elem); if (elem != null) elem.Parent = this; if (sc != null) source_context = sc; return this; } public void AddFirst(simple_attribute_list el) { if (el == null) throw new ArgumentNullException(nameof(el)); attributes.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); attributes.InsertRange(0, els); foreach (var el in els) if (el != null) el.Parent = this; } public void AddMany(params simple_attribute_list[] els) { if (els == null) throw new ArgumentNullException(nameof(els)); attributes.AddRange(els); foreach (var el in els) if (el != null) el.Parent = this; } private int FindIndexInList(simple_attribute_list el) { if (el == null) throw new ArgumentNullException(nameof(el)); var ind = attributes.FindIndex(x => x == el); if (ind == -1) throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el)); return ind; } public void InsertAfter(simple_attribute_list el, simple_attribute_list newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); attributes.Insert(FindIndexInList(el) + 1, newel); newel.Parent = this; } public void InsertAfter(simple_attribute_list el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); attributes.InsertRange(FindIndexInList(el) + 1, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public void InsertBefore(simple_attribute_list el, simple_attribute_list newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); attributes.Insert(FindIndexInList(el), newel); newel.Parent = this; } public void InsertBefore(simple_attribute_list el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); attributes.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(simple_attribute_list el) { return attributes.Remove(el); } public void ReplaceInList(simple_attribute_list el, simple_attribute_list newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); attributes[FindIndexInList(el)] = newel; newel.Parent = this; } public void ReplaceInList(simple_attribute_list el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); var ind = FindIndexInList(el); attributes.RemoveAt(ind); attributes.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return attributes.RemoveAll(match); } public simple_attribute_list Last() { if (attributes.Count > 0) return attributes[attributes.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return attributes.Count; } } public void Insert(int pos, simple_attribute_list el) { if (el == null) throw new ArgumentNullException(nameof(el)); attributes.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { attribute_list copy = new attribute_list(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (attributes != null) { foreach (simple_attribute_list elem in attributes) { if (elem != null) { copy.Add((simple_attribute_list)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new attribute_list TypedClone() { return Clone() as attribute_list; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) { foreach (var child in attributes) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (attributes != null) { foreach (var child in attributes) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (attributes == null ? 0 : 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(attributes != null) { if(index_counter < attributes.Count) { return 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(attributes != null) { if(index_counter < attributes.Count) { attributes[index_counter]= (simple_attribute_list)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class function_lambda_definition : expression { /// ///Конструктор без параметров. /// public function_lambda_definition() { } /// ///Конструктор с параметрами. /// public function_lambda_definition(ident_list _ident_list,type_definition _return_type,formal_parameters _formal_parameters,statement _proc_body,object _proc_definition,expression_list _parameters,string _lambda_name,List _defs,LambdaVisitMode _lambda_visit_mode,syntax_tree_node _substituting_node,int _usedkeyword) { this._ident_list=_ident_list; this._return_type=_return_type; this._formal_parameters=_formal_parameters; this._proc_body=_proc_body; this._proc_definition=_proc_definition; this._parameters=_parameters; this._lambda_name=_lambda_name; this._defs=_defs; this._lambda_visit_mode=_lambda_visit_mode; this._substituting_node=_substituting_node; this._usedkeyword=_usedkeyword; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public function_lambda_definition(ident_list _ident_list,type_definition _return_type,formal_parameters _formal_parameters,statement _proc_body,object _proc_definition,expression_list _parameters,string _lambda_name,List _defs,LambdaVisitMode _lambda_visit_mode,syntax_tree_node _substituting_node,int _usedkeyword,SourceContext sc) { this._ident_list=_ident_list; this._return_type=_return_type; this._formal_parameters=_formal_parameters; this._proc_body=_proc_body; this._proc_definition=_proc_definition; this._parameters=_parameters; this._lambda_name=_lambda_name; this._defs=_defs; this._lambda_visit_mode=_lambda_visit_mode; this._substituting_node=_substituting_node; this._usedkeyword=_usedkeyword; source_context = sc; FillParentsInDirectChilds(); } public function_lambda_definition(declaration elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected ident_list _ident_list; protected type_definition _return_type; protected formal_parameters _formal_parameters; protected statement _proc_body; protected object _proc_definition; protected expression_list _parameters; protected string _lambda_name; protected List _defs=new List(); protected LambdaVisitMode _lambda_visit_mode; protected syntax_tree_node _substituting_node; protected int _usedkeyword; /// /// /// public ident_list ident_list { get { return _ident_list; } set { _ident_list=value; if (_ident_list != null) _ident_list.Parent = this; } } /// /// /// public type_definition return_type { get { return _return_type; } set { _return_type=value; if (_return_type != null) _return_type.Parent = this; } } /// /// /// public formal_parameters formal_parameters { get { return _formal_parameters; } set { _formal_parameters=value; if (_formal_parameters != null) _formal_parameters.Parent = this; } } /// /// /// public statement proc_body { get { return _proc_body; } set { _proc_body=value; if (_proc_body != null) _proc_body.Parent = this; } } /// /// /// public object proc_definition { get { return _proc_definition; } set { _proc_definition=value; } } /// /// /// public expression_list parameters { get { return _parameters; } set { _parameters=value; if (_parameters != null) _parameters.Parent = this; } } /// /// /// public string lambda_name { get { return _lambda_name; } set { _lambda_name=value; } } /// /// /// public List defs { get { return _defs; } set { _defs=value; } } /// /// /// public LambdaVisitMode lambda_visit_mode { get { return _lambda_visit_mode; } set { _lambda_visit_mode=value; } } /// /// /// public syntax_tree_node substituting_node { get { return _substituting_node; } set { _substituting_node=value; if (_substituting_node != null) _substituting_node.Parent = this; } } /// /// /// public int usedkeyword { get { return _usedkeyword; } set { _usedkeyword=value; } } public function_lambda_definition 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() { function_lambda_definition copy = new function_lambda_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 (ident_list != null) { copy.ident_list = (ident_list)ident_list.Clone(); copy.ident_list.Parent = copy; } if (return_type != null) { copy.return_type = (type_definition)return_type.Clone(); copy.return_type.Parent = copy; } if (formal_parameters != null) { copy.formal_parameters = (formal_parameters)formal_parameters.Clone(); copy.formal_parameters.Parent = copy; } if (proc_body != null) { copy.proc_body = (statement)proc_body.Clone(); copy.proc_body.Parent = copy; } copy.proc_definition = proc_definition; if (parameters != null) { copy.parameters = (expression_list)parameters.Clone(); copy.parameters.Parent = copy; } copy.lambda_name = lambda_name; if (defs != null) { foreach (declaration elem in defs) { if (elem != null) { copy.Add((declaration)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } copy.lambda_visit_mode = lambda_visit_mode; if (substituting_node != null) { copy.substituting_node = substituting_node.Clone(); copy.substituting_node.Parent = copy; } copy.usedkeyword = usedkeyword; return copy; } /// Получает копию данного узла корректного типа public new function_lambda_definition TypedClone() { return Clone() as function_lambda_definition; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (ident_list != null) ident_list.Parent = this; if (return_type != null) return_type.Parent = this; if (formal_parameters != null) formal_parameters.Parent = this; if (proc_body != null) proc_body.Parent = this; if (parameters != null) parameters.Parent = this; if (defs != null) { foreach (var child in defs) if (child != null) child.Parent = this; } if (substituting_node != null) substituting_node.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); ident_list?.FillParentsInAllChilds(); return_type?.FillParentsInAllChilds(); formal_parameters?.FillParentsInAllChilds(); proc_body?.FillParentsInAllChilds(); parameters?.FillParentsInAllChilds(); if (defs != null) { foreach (var child in defs) child?.FillParentsInAllChilds(); } substituting_node?.FillParentsInAllChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 6; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 6 + (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(); switch(ind) { case 0: return ident_list; case 1: return return_type; case 2: return formal_parameters; case 3: return proc_body; case 4: return parameters; case 5: return substituting_node; } Int32 index_counter=ind - 6; 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(); switch(ind) { case 0: ident_list = (ident_list)value; break; case 1: return_type = (type_definition)value; break; case 2: formal_parameters = (formal_parameters)value; break; case 3: proc_body = (statement)value; break; case 4: parameters = (expression_list)value; break; case 5: substituting_node = (syntax_tree_node)value; break; } Int32 index_counter=ind - 6; 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 function_lambda_call : expression { /// ///Конструктор без параметров. /// public function_lambda_call() { } /// ///Конструктор с параметрами. /// public function_lambda_call(function_lambda_definition _f_lambda_def,expression_list _parameters) { this._f_lambda_def=_f_lambda_def; this._parameters=_parameters; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public function_lambda_call(function_lambda_definition _f_lambda_def,expression_list _parameters,SourceContext sc) { this._f_lambda_def=_f_lambda_def; this._parameters=_parameters; source_context = sc; FillParentsInDirectChilds(); } protected function_lambda_definition _f_lambda_def; protected expression_list _parameters; /// /// /// public function_lambda_definition f_lambda_def { get { return _f_lambda_def; } set { _f_lambda_def=value; if (_f_lambda_def != null) _f_lambda_def.Parent = this; } } /// /// /// public expression_list parameters { get { return _parameters; } set { _parameters=value; if (_parameters != null) _parameters.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { function_lambda_call copy = new function_lambda_call(); 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 (f_lambda_def != null) { copy.f_lambda_def = (function_lambda_definition)f_lambda_def.Clone(); copy.f_lambda_def.Parent = copy; } if (parameters != null) { copy.parameters = (expression_list)parameters.Clone(); copy.parameters.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new function_lambda_call TypedClone() { return Clone() as function_lambda_call; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (f_lambda_def != null) f_lambda_def.Parent = this; if (parameters != null) parameters.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); f_lambda_def?.FillParentsInAllChilds(); parameters?.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 f_lambda_def; case 1: return parameters; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: f_lambda_def = (function_lambda_definition)value; break; case 1: parameters = (expression_list)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// ///Узел для семантических проверок на этапе построения семантического дерева. Сделан для узлов синтаксического дерева, реализующих синтаксический сахар. Может, видимо, использоваться и для обычных семантических проверок /// [Serializable] public partial class semantic_check : statement { /// ///Конструктор без параметров. /// public semantic_check() { } /// ///Конструктор с параметрами. /// public semantic_check(string _CheckName,List _param,int _fictive) { this._CheckName=_CheckName; this._param=_param; this._fictive=_fictive; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public semantic_check(string _CheckName,List _param,int _fictive,SourceContext sc) { this._CheckName=_CheckName; this._param=_param; this._fictive=_fictive; source_context = sc; FillParentsInDirectChilds(); } public semantic_check(syntax_tree_node elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected string _CheckName; protected List _param=new List(); protected int _fictive; /// ///Тип проверки. Пока строковый. Например, является ли выражение целым /// public string CheckName { get { return _CheckName; } set { _CheckName=value; } } /// ///Параметры - синтаксические узлы для проверки /// public List param { get { return _param; } set { _param=value; } } /// ///Фиктивное поле - чтобы можно было вручную написать конструктор с params /// public int fictive { get { return _fictive; } set { _fictive=value; } } public semantic_check Add(syntax_tree_node elem, SourceContext sc = null) { param.Add(elem); if (elem != null) elem.Parent = this; if (sc != null) source_context = sc; return this; } public void AddFirst(syntax_tree_node el) { if (el == null) throw new ArgumentNullException(nameof(el)); param.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); param.InsertRange(0, els); foreach (var el in els) if (el != null) el.Parent = this; } public void AddMany(params syntax_tree_node[] els) { if (els == null) throw new ArgumentNullException(nameof(els)); param.AddRange(els); foreach (var el in els) if (el != null) el.Parent = this; } private int FindIndexInList(syntax_tree_node el) { if (el == null) throw new ArgumentNullException(nameof(el)); var ind = param.FindIndex(x => x == el); if (ind == -1) throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el)); return ind; } public void InsertAfter(syntax_tree_node el, syntax_tree_node newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); param.Insert(FindIndexInList(el) + 1, newel); newel.Parent = this; } public void InsertAfter(syntax_tree_node el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); param.InsertRange(FindIndexInList(el) + 1, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public void InsertBefore(syntax_tree_node el, syntax_tree_node newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); param.Insert(FindIndexInList(el), newel); newel.Parent = this; } public void InsertBefore(syntax_tree_node el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); param.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(syntax_tree_node el) { return param.Remove(el); } public void ReplaceInList(syntax_tree_node el, syntax_tree_node newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); param[FindIndexInList(el)] = newel; newel.Parent = this; } public void ReplaceInList(syntax_tree_node el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); var ind = FindIndexInList(el); param.RemoveAt(ind); param.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return param.RemoveAll(match); } public syntax_tree_node Last() { if (param.Count > 0) return param[param.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return param.Count; } } public void Insert(int pos, syntax_tree_node el) { if (el == null) throw new ArgumentNullException(nameof(el)); param.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { semantic_check copy = new semantic_check(); 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.CheckName = CheckName; if (param != null) { foreach (syntax_tree_node elem in param) { if (elem != null) { copy.Add(elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } copy.fictive = fictive; return copy; } /// Получает копию данного узла корректного типа public new semantic_check TypedClone() { return Clone() as semantic_check; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (param != null) { foreach (var child in param) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); if (param != null) { foreach (var child in param) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (param == null ? 0 : param.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(param != null) { if(index_counter < param.Count) { return param[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); Int32 index_counter=ind - 0; if(param != null) { if(index_counter < param.Count) { param[index_counter]= (syntax_tree_node)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class lambda_inferred_type : type_definition { /// ///Конструктор без параметров. /// public lambda_inferred_type() { } /// ///Конструктор с параметрами. /// public lambda_inferred_type(object _real_type) { this._real_type=_real_type; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public lambda_inferred_type(object _real_type,SourceContext sc) { this._real_type=_real_type; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public lambda_inferred_type(type_definition_attr_list _attr_list,object _real_type) { this._attr_list=_attr_list; this._real_type=_real_type; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public lambda_inferred_type(type_definition_attr_list _attr_list,object _real_type,SourceContext sc) { this._attr_list=_attr_list; this._real_type=_real_type; source_context = sc; FillParentsInDirectChilds(); } protected object _real_type; /// /// /// public object real_type { get { return _real_type; } set { _real_type=value; } } /// Создает копию узла public override syntax_tree_node Clone() { lambda_inferred_type copy = new lambda_inferred_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; } copy.real_type = real_type; return copy; } /// Получает копию данного узла корректного типа public new lambda_inferred_type TypedClone() { return Clone() as lambda_inferred_type; } /// Заполняет поля 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 same_type_node : type_definition { /// ///Конструктор без параметров. /// public same_type_node() { } /// ///Конструктор с параметрами. /// public same_type_node(expression _ex) { this._ex=_ex; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public same_type_node(expression _ex,SourceContext sc) { this._ex=_ex; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public same_type_node(type_definition_attr_list _attr_list,expression _ex) { this._attr_list=_attr_list; this._ex=_ex; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public same_type_node(type_definition_attr_list _attr_list,expression _ex,SourceContext sc) { this._attr_list=_attr_list; this._ex=_ex; source_context = sc; FillParentsInDirectChilds(); } protected expression _ex; /// /// /// public expression ex { get { return _ex; } set { _ex=value; if (_ex != null) _ex.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { same_type_node copy = new same_type_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 (attr_list != null) { copy.attr_list = (type_definition_attr_list)attr_list.Clone(); copy.attr_list.Parent = copy; } if (ex != null) { copy.ex = (expression)ex.Clone(); copy.ex.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new same_type_node TypedClone() { return Clone() as same_type_node; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (attr_list != null) attr_list.Parent = this; if (ex != null) ex.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); attr_list?.FillParentsInAllChilds(); ex?.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 ex; } 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: ex = (expression)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class name_assign_expr : syntax_tree_node { /// ///Конструктор без параметров. /// public name_assign_expr() { } /// ///Конструктор с параметрами. /// public name_assign_expr(ident _name,expression _expr) { this._name=_name; this._expr=_expr; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public name_assign_expr(ident _name,expression _expr,SourceContext sc) { this._name=_name; this._expr=_expr; source_context = sc; FillParentsInDirectChilds(); } protected ident _name; protected expression _expr; /// /// /// public ident name { get { return _name; } set { _name=value; if (_name != null) _name.Parent = this; } } /// /// /// public expression expr { get { return _expr; } set { _expr=value; if (_expr != null) _expr.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { name_assign_expr copy = new name_assign_expr(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (name != null) { copy.name = (ident)name.Clone(); copy.name.Parent = copy; } if (expr != null) { copy.expr = (expression)expr.Clone(); copy.expr.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new name_assign_expr TypedClone() { return Clone() as name_assign_expr; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (name != null) name.Parent = this; if (expr != null) expr.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); name?.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 name; case 1: return expr; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: name = (ident)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 name_assign_expr_list : syntax_tree_node { /// ///Конструктор без параметров. /// public name_assign_expr_list() { } /// ///Конструктор с параметрами. /// public name_assign_expr_list(List _name_expr) { this._name_expr=_name_expr; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public name_assign_expr_list(List _name_expr,SourceContext sc) { this._name_expr=_name_expr; source_context = sc; FillParentsInDirectChilds(); } public name_assign_expr_list(name_assign_expr elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected List _name_expr=new List(); /// /// /// public List name_expr { get { return _name_expr; } set { _name_expr=value; } } public name_assign_expr_list Add(name_assign_expr elem, SourceContext sc = null) { name_expr.Add(elem); if (elem != null) elem.Parent = this; if (sc != null) source_context = sc; return this; } public void AddFirst(name_assign_expr el) { if (el == null) throw new ArgumentNullException(nameof(el)); name_expr.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); name_expr.InsertRange(0, els); foreach (var el in els) if (el != null) el.Parent = this; } public void AddMany(params name_assign_expr[] els) { if (els == null) throw new ArgumentNullException(nameof(els)); name_expr.AddRange(els); foreach (var el in els) if (el != null) el.Parent = this; } private int FindIndexInList(name_assign_expr el) { if (el == null) throw new ArgumentNullException(nameof(el)); var ind = name_expr.FindIndex(x => x == el); if (ind == -1) throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el)); return ind; } public void InsertAfter(name_assign_expr el, name_assign_expr newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); name_expr.Insert(FindIndexInList(el) + 1, newel); newel.Parent = this; } public void InsertAfter(name_assign_expr el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); name_expr.InsertRange(FindIndexInList(el) + 1, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public void InsertBefore(name_assign_expr el, name_assign_expr newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); name_expr.Insert(FindIndexInList(el), newel); newel.Parent = this; } public void InsertBefore(name_assign_expr el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); name_expr.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(name_assign_expr el) { return name_expr.Remove(el); } public void ReplaceInList(name_assign_expr el, name_assign_expr newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); name_expr[FindIndexInList(el)] = newel; newel.Parent = this; } public void ReplaceInList(name_assign_expr el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); var ind = FindIndexInList(el); name_expr.RemoveAt(ind); name_expr.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return name_expr.RemoveAll(match); } public name_assign_expr Last() { if (name_expr.Count > 0) return name_expr[name_expr.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return name_expr.Count; } } public void Insert(int pos, name_assign_expr el) { if (el == null) throw new ArgumentNullException(nameof(el)); name_expr.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { name_assign_expr_list copy = new name_assign_expr_list(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (name_expr != null) { foreach (name_assign_expr elem in name_expr) { if (elem != null) { copy.Add((name_assign_expr)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new name_assign_expr_list TypedClone() { return Clone() as name_assign_expr_list; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (name_expr != null) { foreach (var child in name_expr) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (name_expr != null) { foreach (var child in name_expr) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (name_expr == null ? 0 : name_expr.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(name_expr != null) { if(index_counter < name_expr.Count) { return name_expr[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); Int32 index_counter=ind - 0; if(name_expr != null) { if(index_counter < name_expr.Count) { name_expr[index_counter]= (name_assign_expr)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// ///Это - сахарная конструкция. /// Объект безымянного класса. Например: new class(Name := 'Иванов'; Age := 25); /// new_ex - это узел для генерации кода, основной узел предназначен для форматирования /// Сделал потомком addressed_value из-за #1843 /// [Serializable] public partial class unnamed_type_object : addressed_value { /// ///Конструктор без параметров. /// public unnamed_type_object() { } /// ///Конструктор с параметрами. /// public unnamed_type_object(name_assign_expr_list _ne_list,bool _is_class,new_expr _new_ex) { this._ne_list=_ne_list; this._is_class=_is_class; this._new_ex=_new_ex; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public unnamed_type_object(name_assign_expr_list _ne_list,bool _is_class,new_expr _new_ex,SourceContext sc) { this._ne_list=_ne_list; this._is_class=_is_class; this._new_ex=_new_ex; source_context = sc; FillParentsInDirectChilds(); } protected name_assign_expr_list _ne_list; protected bool _is_class; protected new_expr _new_ex; /// /// /// public name_assign_expr_list ne_list { get { return _ne_list; } set { _ne_list=value; if (_ne_list != null) _ne_list.Parent = this; } } /// /// /// public bool is_class { get { return _is_class; } set { _is_class=value; } } /// /// /// public new_expr new_ex { get { return _new_ex; } set { _new_ex=value; if (_new_ex != null) _new_ex.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { unnamed_type_object copy = new unnamed_type_object(); 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 (ne_list != null) { copy.ne_list = (name_assign_expr_list)ne_list.Clone(); copy.ne_list.Parent = copy; } copy.is_class = is_class; if (new_ex != null) { copy.new_ex = (new_expr)new_ex.Clone(); copy.new_ex.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new unnamed_type_object TypedClone() { return Clone() as unnamed_type_object; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (ne_list != null) ne_list.Parent = this; if (new_ex != null) new_ex.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); ne_list?.FillParentsInAllChilds(); new_ex?.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 ne_list; case 1: return new_ex; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: ne_list = (name_assign_expr_list)value; break; case 1: new_ex = (new_expr)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class semantic_type_node : type_definition { /// ///Конструктор без параметров. /// public semantic_type_node() { } /// ///Конструктор с параметрами. /// public semantic_type_node(Object _type) { this._type=_type; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public semantic_type_node(Object _type,SourceContext sc) { this._type=_type; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public semantic_type_node(type_definition_attr_list _attr_list,Object _type) { this._attr_list=_attr_list; this._type=_type; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public semantic_type_node(type_definition_attr_list _attr_list,Object _type,SourceContext sc) { this._attr_list=_attr_list; this._type=_type; source_context = sc; FillParentsInDirectChilds(); } protected Object _type; /// /// /// public Object type { get { return _type; } set { _type=value; } } /// Создает копию узла public override syntax_tree_node Clone() { semantic_type_node copy = new semantic_type_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 (attr_list != null) { copy.attr_list = (type_definition_attr_list)attr_list.Clone(); copy.attr_list.Parent = copy; } copy.type = type; return copy; } /// Получает копию данного узла корректного типа public new semantic_type_node TypedClone() { return Clone() as semantic_type_node; } /// Заполняет поля 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 short_func_definition : procedure_definition { /// ///Конструктор без параметров. /// public short_func_definition() { } /// ///Конструктор с параметрами. /// public short_func_definition(procedure_definition _procdef) { this._procdef=_procdef; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public short_func_definition(procedure_definition _procdef,SourceContext sc) { this._procdef=_procdef; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public short_func_definition(procedure_header _proc_header,proc_block _proc_body,bool _is_short_definition,procedure_definition _procdef) { this._proc_header=_proc_header; this._proc_body=_proc_body; this._is_short_definition=_is_short_definition; this._procdef=_procdef; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public short_func_definition(procedure_header _proc_header,proc_block _proc_body,bool _is_short_definition,procedure_definition _procdef,SourceContext sc) { this._proc_header=_proc_header; this._proc_body=_proc_body; this._is_short_definition=_is_short_definition; this._procdef=_procdef; source_context = sc; FillParentsInDirectChilds(); } protected procedure_definition _procdef; /// /// /// public procedure_definition procdef { get { return _procdef; } set { _procdef=value; if (_procdef != null) _procdef.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { short_func_definition copy = new short_func_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; if (procdef != null) { copy.procdef = (procedure_definition)procdef.Clone(); copy.procdef.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new short_func_definition TypedClone() { return Clone() as short_func_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; if (procdef != null) procdef.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); proc_header?.FillParentsInAllChilds(); proc_body?.FillParentsInAllChilds(); procdef?.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 proc_header; case 1: return proc_body; case 2: return procdef; } 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; case 2: procdef = (procedure_definition)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class no_type_foreach : type_definition { /// ///Конструктор без параметров. /// public no_type_foreach() { } /// ///Конструктор с параметрами. /// public no_type_foreach(type_definition_attr_list _attr_list) { this._attr_list=_attr_list; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public no_type_foreach(type_definition_attr_list _attr_list,SourceContext sc) { this._attr_list=_attr_list; source_context = sc; FillParentsInDirectChilds(); } /// Создает копию узла public override syntax_tree_node Clone() { no_type_foreach copy = new no_type_foreach(); 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 no_type_foreach TypedClone() { return Clone() as no_type_foreach; } /// Заполняет поля 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 matching_expression : addressed_value { /// ///Конструктор без параметров. /// public matching_expression() { } /// ///Конструктор с параметрами. /// public matching_expression(expression _left,expression _right) { this._left=_left; this._right=_right; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public matching_expression(expression _left,expression _right,SourceContext sc) { 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() { matching_expression copy = new matching_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; } 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 matching_expression TypedClone() { return Clone() as matching_expression; } /// Заполняет поля 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 closure_substituting_node : ident { /// ///Конструктор без параметров. /// public closure_substituting_node() { } /// ///Конструктор с параметрами. /// public closure_substituting_node(dot_node _substitution) { this._substitution=_substitution; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public closure_substituting_node(dot_node _substitution,SourceContext sc) { this._substitution=_substitution; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public closure_substituting_node(string _name,dot_node _substitution) { this._name=_name; this._substitution=_substitution; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public closure_substituting_node(string _name,dot_node _substitution,SourceContext sc) { this._name=_name; this._substitution=_substitution; source_context = sc; FillParentsInDirectChilds(); } protected dot_node _substitution; /// /// /// public dot_node substitution { get { return _substitution; } set { _substitution=value; if (_substitution != null) _substitution.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { closure_substituting_node copy = new closure_substituting_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; } copy.name = name; if (substitution != null) { copy.substitution = (dot_node)substitution.Clone(); copy.substitution.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new closure_substituting_node TypedClone() { return Clone() as closure_substituting_node; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (substitution != null) substitution.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); substitution?.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 substitution; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: substitution = (dot_node)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class sequence_type : type_definition { /// ///Конструктор без параметров. /// public sequence_type() { } /// ///Конструктор с параметрами. /// public sequence_type(type_definition _elements_type) { this._elements_type=_elements_type; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public sequence_type(type_definition _elements_type,SourceContext sc) { this._elements_type=_elements_type; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public sequence_type(type_definition_attr_list _attr_list,type_definition _elements_type) { this._attr_list=_attr_list; this._elements_type=_elements_type; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public sequence_type(type_definition_attr_list _attr_list,type_definition _elements_type,SourceContext sc) { this._attr_list=_attr_list; this._elements_type=_elements_type; source_context = sc; FillParentsInDirectChilds(); } protected type_definition _elements_type; /// ///Тип элементов /// 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() { sequence_type copy = new sequence_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 (elements_type != null) { copy.elements_type = (type_definition)elements_type.Clone(); copy.elements_type.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new sequence_type TypedClone() { return Clone() as sequence_type; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (attr_list != null) attr_list.Parent = this; if (elements_type != null) elements_type.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); attr_list?.FillParentsInAllChilds(); elements_type?.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 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: elements_type = (type_definition)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class modern_proc_type : type_definition { /// ///Конструктор без параметров. /// public modern_proc_type() { } /// ///Конструктор с параметрами. /// public modern_proc_type(type_definition _aloneparam,enumerator_list _el,type_definition _res) { this._aloneparam=_aloneparam; this._el=_el; this._res=_res; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public modern_proc_type(type_definition _aloneparam,enumerator_list _el,type_definition _res,SourceContext sc) { this._aloneparam=_aloneparam; this._el=_el; this._res=_res; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public modern_proc_type(type_definition_attr_list _attr_list,type_definition _aloneparam,enumerator_list _el,type_definition _res) { this._attr_list=_attr_list; this._aloneparam=_aloneparam; this._el=_el; this._res=_res; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public modern_proc_type(type_definition_attr_list _attr_list,type_definition _aloneparam,enumerator_list _el,type_definition _res,SourceContext sc) { this._attr_list=_attr_list; this._aloneparam=_aloneparam; this._el=_el; this._res=_res; source_context = sc; FillParentsInDirectChilds(); } protected type_definition _aloneparam; protected enumerator_list _el; protected type_definition _res; /// /// /// public type_definition aloneparam { get { return _aloneparam; } set { _aloneparam=value; if (_aloneparam != null) _aloneparam.Parent = this; } } /// /// /// public enumerator_list el { get { return _el; } set { _el=value; if (_el != null) _el.Parent = this; } } /// /// /// public type_definition res { get { return _res; } set { _res=value; if (_res != null) _res.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { modern_proc_type copy = new modern_proc_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 (aloneparam != null) { copy.aloneparam = (type_definition)aloneparam.Clone(); copy.aloneparam.Parent = copy; } if (el != null) { copy.el = (enumerator_list)el.Clone(); copy.el.Parent = copy; } if (res != null) { copy.res = (type_definition)res.Clone(); copy.res.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new modern_proc_type TypedClone() { return Clone() as modern_proc_type; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (attr_list != null) attr_list.Parent = this; if (aloneparam != null) aloneparam.Parent = this; if (el != null) el.Parent = this; if (res != null) res.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); attr_list?.FillParentsInAllChilds(); aloneparam?.FillParentsInAllChilds(); el?.FillParentsInAllChilds(); res?.FillParentsInAllChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 4; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 4; } } /// ///Индексатор для получения всех подузлов /// 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 aloneparam; case 2: return el; case 3: return res; } 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: aloneparam = (type_definition)value; break; case 2: el = (enumerator_list)value; break; case 3: res = (type_definition)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class yield_node : statement { /// ///Конструктор без параметров. /// public yield_node() { } /// ///Конструктор с параметрами. /// public yield_node(expression _ex) { this._ex=_ex; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public yield_node(expression _ex,SourceContext sc) { this._ex=_ex; source_context = sc; FillParentsInDirectChilds(); } protected expression _ex; /// /// /// public expression ex { get { return _ex; } set { _ex=value; if (_ex != null) _ex.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { yield_node copy = new yield_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 (ex != null) { copy.ex = (expression)ex.Clone(); copy.ex.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new yield_node TypedClone() { return Clone() as yield_node; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (ex != null) ex.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); ex?.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 ex; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: ex = (expression)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class template_operator_name : template_type_name { /// ///Конструктор без параметров. /// public template_operator_name() { } /// ///Конструктор с параметрами. /// public template_operator_name(operator_name_ident _opname) { this._opname=_opname; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public template_operator_name(operator_name_ident _opname,SourceContext sc) { this._opname=_opname; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public template_operator_name(string _name,ident_list _template_args,operator_name_ident _opname) { this._name=_name; this._template_args=_template_args; this._opname=_opname; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public template_operator_name(string _name,ident_list _template_args,operator_name_ident _opname,SourceContext sc) { this._name=_name; this._template_args=_template_args; this._opname=_opname; source_context = sc; FillParentsInDirectChilds(); } protected operator_name_ident _opname; /// /// /// public operator_name_ident opname { get { return _opname; } set { _opname=value; if (_opname != null) _opname.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { template_operator_name copy = new template_operator_name(); 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; if (template_args != null) { copy.template_args = (ident_list)template_args.Clone(); copy.template_args.Parent = copy; } if (opname != null) { copy.opname = (operator_name_ident)opname.Clone(); copy.opname.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new template_operator_name TypedClone() { return Clone() as template_operator_name; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (template_args != null) template_args.Parent = this; if (opname != null) opname.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); template_args?.FillParentsInAllChilds(); opname?.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 template_args; case 1: return opname; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: template_args = (ident_list)value; break; case 1: opname = (operator_name_ident)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class semantic_addr_value : addressed_value { /// ///Конструктор без параметров. /// public semantic_addr_value() { } /// ///Конструктор с параметрами. /// public semantic_addr_value(Object _expr) { this._expr=_expr; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public semantic_addr_value(Object _expr,SourceContext sc) { this._expr=_expr; source_context = sc; FillParentsInDirectChilds(); } protected Object _expr; /// /// /// public Object expr { get { return _expr; } set { _expr=value; } } /// Создает копию узла public override syntax_tree_node Clone() { semantic_addr_value copy = new semantic_addr_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; } copy.expr = expr; return copy; } /// Получает копию данного узла корректного типа public new semantic_addr_value TypedClone() { return Clone() as semantic_addr_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 pair_type_stlist : syntax_tree_node { /// ///Конструктор без параметров. /// public pair_type_stlist() { } /// ///Конструктор с параметрами. /// public pair_type_stlist(type_definition _tn,statement_list _exprs) { this._tn=_tn; this._exprs=_exprs; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public pair_type_stlist(type_definition _tn,statement_list _exprs,SourceContext sc) { this._tn=_tn; this._exprs=_exprs; source_context = sc; FillParentsInDirectChilds(); } protected type_definition _tn; protected statement_list _exprs; /// /// /// public type_definition tn { get { return _tn; } set { _tn=value; if (_tn != null) _tn.Parent = this; } } /// /// /// public statement_list exprs { get { return _exprs; } set { _exprs=value; if (_exprs != null) _exprs.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { pair_type_stlist copy = new pair_type_stlist(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (tn != null) { copy.tn = (type_definition)tn.Clone(); copy.tn.Parent = copy; } if (exprs != null) { copy.exprs = (statement_list)exprs.Clone(); copy.exprs.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new pair_type_stlist TypedClone() { return Clone() as pair_type_stlist; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (tn != null) tn.Parent = this; if (exprs != null) exprs.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); tn?.FillParentsInAllChilds(); exprs?.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 tn; case 1: return exprs; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: tn = (type_definition)value; break; case 1: exprs = (statement_list)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class assign_tuple : statement { /// ///Конструктор без параметров. /// public assign_tuple() { } /// ///Конструктор с параметрами. /// public assign_tuple(addressed_value_list _vars,expression _expr) { this._vars=_vars; this._expr=_expr; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public assign_tuple(addressed_value_list _vars,expression _expr,SourceContext sc) { this._vars=_vars; this._expr=_expr; source_context = sc; FillParentsInDirectChilds(); } protected addressed_value_list _vars; protected expression _expr; /// /// /// public addressed_value_list vars { get { return _vars; } set { _vars=value; if (_vars != null) _vars.Parent = this; } } /// /// /// public expression expr { get { return _expr; } set { _expr=value; if (_expr != null) _expr.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { assign_tuple copy = new assign_tuple(); 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 = (addressed_value_list)vars.Clone(); copy.vars.Parent = copy; } if (expr != null) { copy.expr = (expression)expr.Clone(); copy.expr.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new assign_tuple TypedClone() { return Clone() as assign_tuple; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (vars != null) vars.Parent = this; if (expr != null) expr.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); vars?.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 vars; case 1: return expr; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: vars = (addressed_value_list)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 addressed_value_list : syntax_tree_node { /// ///Конструктор без параметров. /// public addressed_value_list() { } /// ///Конструктор с параметрами. /// public addressed_value_list(List _variables) { this._variables=_variables; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public addressed_value_list(List _variables,SourceContext sc) { this._variables=_variables; source_context = sc; FillParentsInDirectChilds(); } public addressed_value_list(addressed_value elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected List _variables=new List(); /// /// /// public List variables { get { return _variables; } set { _variables=value; } } public addressed_value_list Add(addressed_value elem, SourceContext sc = null) { variables.Add(elem); if (elem != null) elem.Parent = this; if (sc != null) source_context = sc; return this; } public void AddFirst(addressed_value el) { if (el == null) throw new ArgumentNullException(nameof(el)); variables.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); variables.InsertRange(0, els); foreach (var el in els) if (el != null) el.Parent = this; } public void AddMany(params addressed_value[] els) { if (els == null) throw new ArgumentNullException(nameof(els)); variables.AddRange(els); foreach (var el in els) if (el != null) el.Parent = this; } private int FindIndexInList(addressed_value el) { if (el == null) throw new ArgumentNullException(nameof(el)); var ind = variables.FindIndex(x => x == el); if (ind == -1) throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el)); return ind; } public void InsertAfter(addressed_value el, addressed_value newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); variables.Insert(FindIndexInList(el) + 1, newel); newel.Parent = this; } public void InsertAfter(addressed_value el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); variables.InsertRange(FindIndexInList(el) + 1, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public void InsertBefore(addressed_value el, addressed_value newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); variables.Insert(FindIndexInList(el), newel); newel.Parent = this; } public void InsertBefore(addressed_value el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); variables.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(addressed_value el) { return variables.Remove(el); } public void ReplaceInList(addressed_value el, addressed_value newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); variables[FindIndexInList(el)] = newel; newel.Parent = this; } public void ReplaceInList(addressed_value el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); var ind = FindIndexInList(el); variables.RemoveAt(ind); variables.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return variables.RemoveAll(match); } public addressed_value Last() { if (variables.Count > 0) return variables[variables.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return variables.Count; } } public void Insert(int pos, addressed_value el) { if (el == null) throw new ArgumentNullException(nameof(el)); variables.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { addressed_value_list copy = new addressed_value_list(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (variables != null) { foreach (addressed_value elem in variables) { if (elem != null) { copy.Add((addressed_value)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new addressed_value_list TypedClone() { return Clone() as addressed_value_list; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (variables != null) { foreach (var child in variables) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (variables != null) { foreach (var child in variables) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (variables == null ? 0 : variables.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(variables != null) { if(index_counter < variables.Count) { return variables[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); Int32 index_counter=ind - 0; if(variables != null) { if(index_counter < variables.Count) { variables[index_counter]= (addressed_value)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class tuple_node : addressed_value { /// ///Конструктор без параметров. /// public tuple_node() { } /// ///Конструктор с параметрами. /// public tuple_node(expression_list _el) { this._el=_el; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public tuple_node(expression_list _el,SourceContext sc) { this._el=_el; source_context = sc; FillParentsInDirectChilds(); } protected expression_list _el; /// /// /// public expression_list el { get { return _el; } set { _el=value; if (_el != null) _el.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { tuple_node copy = new tuple_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 (el != null) { copy.el = (expression_list)el.Clone(); copy.el.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new tuple_node TypedClone() { return Clone() as tuple_node; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (el != null) el.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); el?.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 el; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: el = (expression_list)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class uses_closure : uses_list { /// ///Конструктор без параметров. /// public uses_closure() { } /// ///Конструктор с параметрами. /// public uses_closure(List _listunitsections) { this._listunitsections=_listunitsections; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public uses_closure(List _listunitsections,SourceContext sc) { this._listunitsections=_listunitsections; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public uses_closure(List _units,List _listunitsections) { this._units=_units; this._listunitsections=_listunitsections; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public uses_closure(List _units,List _listunitsections,SourceContext sc) { this._units=_units; this._listunitsections=_listunitsections; source_context = sc; FillParentsInDirectChilds(); } public uses_closure(uses_list elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected List _listunitsections=new List(); /// /// /// public List listunitsections { get { return _listunitsections; } set { _listunitsections=value; } } public uses_closure Add(uses_list elem, SourceContext sc = null) { listunitsections.Add(elem); if (elem != null) elem.Parent = this; if (sc != null) source_context = sc; return this; } public void AddFirst(uses_list el) { if (el == null) throw new ArgumentNullException(nameof(el)); listunitsections.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); listunitsections.InsertRange(0, els); foreach (var el in els) if (el != null) el.Parent = this; } public void AddMany(params uses_list[] els) { if (els == null) throw new ArgumentNullException(nameof(els)); listunitsections.AddRange(els); foreach (var el in els) if (el != null) el.Parent = this; } private int FindIndexInList(uses_list el) { if (el == null) throw new ArgumentNullException(nameof(el)); var ind = listunitsections.FindIndex(x => x == el); if (ind == -1) throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el)); return ind; } public void InsertAfter(uses_list el, uses_list newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); listunitsections.Insert(FindIndexInList(el) + 1, newel); newel.Parent = this; } public void InsertAfter(uses_list el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); listunitsections.InsertRange(FindIndexInList(el) + 1, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public void InsertBefore(uses_list el, uses_list newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); listunitsections.Insert(FindIndexInList(el), newel); newel.Parent = this; } public void InsertBefore(uses_list el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); listunitsections.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(uses_list el) { return listunitsections.Remove(el); } public void ReplaceInList(uses_list el, uses_list newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); listunitsections[FindIndexInList(el)] = newel; newel.Parent = this; } public void ReplaceInList(uses_list el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); var ind = FindIndexInList(el); listunitsections.RemoveAt(ind); listunitsections.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return listunitsections.RemoveAll(match); } public uses_list Last() { if (listunitsections.Count > 0) return listunitsections[listunitsections.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return listunitsections.Count; } } public void Insert(int pos, uses_list el) { if (el == null) throw new ArgumentNullException(nameof(el)); listunitsections.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { uses_closure copy = new uses_closure(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (units != null) { foreach (unit_or_namespace elem in units) { if (elem != null) { copy.Add((unit_or_namespace)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } if (listunitsections != null) { foreach (uses_list elem in listunitsections) { if (elem != null) { copy.Add((uses_list)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new uses_closure TypedClone() { return Clone() as uses_closure; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (units != null) { foreach (var child in units) if (child != null) child.Parent = this; } if (listunitsections != null) { foreach (var child in listunitsections) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (units != null) { foreach (var child in units) child?.FillParentsInAllChilds(); } if (listunitsections != null) { foreach (var child in listunitsections) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (units == null ? 0 : units.Count) + (listunitsections == null ? 0 : listunitsections.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(units != null) { if(index_counter < units.Count) { return units[index_counter]; } else index_counter = index_counter - units.Count; } if(listunitsections != null) { if(index_counter < listunitsections.Count) { return listunitsections[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); Int32 index_counter=ind - 0; if(units != null) { if(index_counter < units.Count) { units[index_counter]= (unit_or_namespace)value; return; } else index_counter = index_counter - units.Count; } if(listunitsections != null) { if(index_counter < listunitsections.Count) { listunitsections[index_counter]= (uses_list)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class dot_question_node : addressed_value_funcname { /// ///Конструктор без параметров. /// public dot_question_node() { } /// ///Конструктор с параметрами. /// public dot_question_node(addressed_value _left,addressed_value _right) { this._left=_left; this._right=_right; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public dot_question_node(addressed_value _left,addressed_value _right,SourceContext sc) { this._left=_left; this._right=_right; source_context = sc; FillParentsInDirectChilds(); } protected addressed_value _left; protected addressed_value _right; /// /// /// public addressed_value left { get { return _left; } set { _left=value; if (_left != null) _left.Parent = this; } } /// /// /// public addressed_value right { get { return _right; } set { _right=value; if (_right != null) _right.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { dot_question_node copy = new dot_question_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 (left != null) { copy.left = (addressed_value)left.Clone(); copy.left.Parent = copy; } if (right != null) { copy.right = (addressed_value)right.Clone(); copy.right.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new dot_question_node TypedClone() { return Clone() as dot_question_node; } /// Заполняет поля 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 = (addressed_value)value; break; case 1: right = (addressed_value)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class slice_expr : dereference { /// ///Конструктор без параметров. /// public slice_expr() { } /// ///Конструктор с параметрами. /// public slice_expr(addressed_value _v,expression _from,expression _to,expression _step) { this._v=_v; this._from=_from; this._to=_to; this._step=_step; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public slice_expr(addressed_value _v,expression _from,expression _to,expression _step,SourceContext sc) { this._v=_v; this._from=_from; this._to=_to; this._step=_step; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public slice_expr(addressed_value _dereferencing_value,addressed_value _v,expression _from,expression _to,expression _step) { this._dereferencing_value=_dereferencing_value; this._v=_v; this._from=_from; this._to=_to; this._step=_step; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public slice_expr(addressed_value _dereferencing_value,addressed_value _v,expression _from,expression _to,expression _step,SourceContext sc) { this._dereferencing_value=_dereferencing_value; this._v=_v; this._from=_from; this._to=_to; this._step=_step; source_context = sc; FillParentsInDirectChilds(); } protected addressed_value _v; protected expression _from; protected expression _to; protected expression _step; /// /// /// public addressed_value v { get { return _v; } set { _v=value; if (_v != null) _v.Parent = this; } } /// /// /// public expression from { get { return _from; } set { _from=value; if (_from != null) _from.Parent = this; } } /// /// /// public expression to { get { return _to; } set { _to=value; if (_to != null) _to.Parent = this; } } /// /// /// public expression step { get { return _step; } set { _step=value; if (_step != null) _step.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { slice_expr copy = new slice_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 (dereferencing_value != null) { copy.dereferencing_value = (addressed_value)dereferencing_value.Clone(); copy.dereferencing_value.Parent = copy; } if (v != null) { copy.v = (addressed_value)v.Clone(); copy.v.Parent = copy; } if (from != null) { copy.from = (expression)from.Clone(); copy.from.Parent = copy; } if (to != null) { copy.to = (expression)to.Clone(); copy.to.Parent = copy; } if (step != null) { copy.step = (expression)step.Clone(); copy.step.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new slice_expr TypedClone() { return Clone() as slice_expr; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (dereferencing_value != null) dereferencing_value.Parent = this; if (v != null) v.Parent = this; if (from != null) from.Parent = this; if (to != null) to.Parent = this; if (step != null) step.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); dereferencing_value?.FillParentsInAllChilds(); v?.FillParentsInAllChilds(); from?.FillParentsInAllChilds(); to?.FillParentsInAllChilds(); step?.FillParentsInAllChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 5; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 5; } } /// ///Индексатор для получения всех подузлов /// 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 v; case 2: return from; case 3: return to; case 4: return step; } 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: v = (addressed_value)value; break; case 2: from = (expression)value; break; case 3: to = (expression)value; break; case 4: step = (expression)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class no_type : type_definition { /// ///Конструктор без параметров. /// public no_type() { } /// ///Конструктор с параметрами. /// public no_type(type_definition_attr_list _attr_list) { this._attr_list=_attr_list; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public no_type(type_definition_attr_list _attr_list,SourceContext sc) { this._attr_list=_attr_list; source_context = sc; FillParentsInDirectChilds(); } /// Создает копию узла public override syntax_tree_node Clone() { no_type copy = new no_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; } return copy; } /// Получает копию данного узла корректного типа public new no_type TypedClone() { return Clone() as no_type; } /// Заполняет поля 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 yield_unknown_ident : ident { /// ///Конструктор без параметров. /// public yield_unknown_ident() { } /// ///Конструктор с параметрами. /// public yield_unknown_ident(string _name) { this._name=_name; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public yield_unknown_ident(string _name,SourceContext sc) { this._name=_name; source_context = sc; FillParentsInDirectChilds(); } /// Создает копию узла public override syntax_tree_node Clone() { yield_unknown_ident copy = new yield_unknown_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 yield_unknown_ident TypedClone() { return Clone() as yield_unknown_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); } } /// ///Узел для вычисления типа выражения используемого в теле функции-итератора (с yield). Используется для описаний всех переменных с автовыводом типов в теле yield: например, для var a := 1; Дело в том, что эти переменные становятся полями класса, а для описания полей класса нужен тип /// [Serializable] public partial class yield_unknown_expression_type : type_definition { /// ///Конструктор без параметров. /// public yield_unknown_expression_type() { } /// ///Конструктор с параметрами. /// public yield_unknown_expression_type(type_definition_attr_list _attr_list) { this._attr_list=_attr_list; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public yield_unknown_expression_type(type_definition_attr_list _attr_list,SourceContext sc) { this._attr_list=_attr_list; source_context = sc; FillParentsInDirectChilds(); } /// Создает копию узла public override syntax_tree_node Clone() { yield_unknown_expression_type copy = new yield_unknown_expression_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; } return copy; } /// Получает копию данного узла корректного типа public new yield_unknown_expression_type TypedClone() { return Clone() as yield_unknown_expression_type; } /// Заполняет поля 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); } } /// ///Узел для вычисления типа переменной используемой в теле foreach (с yield) /// [Serializable] public partial class yield_unknown_foreach_type : type_definition { /// ///Конструктор без параметров. /// public yield_unknown_foreach_type() { } /// ///Конструктор с параметрами. /// public yield_unknown_foreach_type(type_definition_attr_list _attr_list) { this._attr_list=_attr_list; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public yield_unknown_foreach_type(type_definition_attr_list _attr_list,SourceContext sc) { this._attr_list=_attr_list; source_context = sc; FillParentsInDirectChilds(); } /// Создает копию узла public override syntax_tree_node Clone() { yield_unknown_foreach_type copy = new yield_unknown_foreach_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; } return copy; } /// Получает копию данного узла корректного типа public new yield_unknown_foreach_type TypedClone() { return Clone() as yield_unknown_foreach_type; } /// Заполняет поля 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 yield_sequence_node : statement { /// ///Конструктор без параметров. /// public yield_sequence_node() { } /// ///Конструктор с параметрами. /// public yield_sequence_node(expression _ex) { this._ex=_ex; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public yield_sequence_node(expression _ex,SourceContext sc) { this._ex=_ex; source_context = sc; FillParentsInDirectChilds(); } protected expression _ex; /// /// /// public expression ex { get { return _ex; } set { _ex=value; if (_ex != null) _ex.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { yield_sequence_node copy = new yield_sequence_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 (ex != null) { copy.ex = (expression)ex.Clone(); copy.ex.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new yield_sequence_node TypedClone() { return Clone() as yield_sequence_node; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (ex != null) ex.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); ex?.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 ex; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: ex = (expression)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class assign_var_tuple : statement { /// ///Конструктор без параметров. /// public assign_var_tuple() { } /// ///Конструктор с параметрами. /// public assign_var_tuple(ident_list _idents,expression _expr) { this._idents=_idents; this._expr=_expr; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public assign_var_tuple(ident_list _idents,expression _expr,SourceContext sc) { this._idents=_idents; this._expr=_expr; source_context = sc; FillParentsInDirectChilds(); } protected ident_list _idents; protected expression _expr; /// /// /// public ident_list idents { get { return _idents; } set { _idents=value; if (_idents != null) _idents.Parent = this; } } /// /// /// public expression expr { get { return _expr; } set { _expr=value; if (_expr != null) _expr.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { assign_var_tuple copy = new assign_var_tuple(); 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 (expr != null) { copy.expr = (expression)expr.Clone(); copy.expr.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new assign_var_tuple TypedClone() { return Clone() as assign_var_tuple; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (idents != null) idents.Parent = this; if (expr != null) expr.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); idents?.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 idents; case 1: return expr; } 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: expr = (expression)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class slice_expr_question : slice_expr { /// ///Конструктор без параметров. /// public slice_expr_question() { } /// ///Конструктор с параметрами. /// public slice_expr_question(addressed_value _dereferencing_value,addressed_value _v,expression _from,expression _to,expression _step) { this._dereferencing_value=_dereferencing_value; this._v=_v; this._from=_from; this._to=_to; this._step=_step; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public slice_expr_question(addressed_value _dereferencing_value,addressed_value _v,expression _from,expression _to,expression _step,SourceContext sc) { this._dereferencing_value=_dereferencing_value; this._v=_v; this._from=_from; this._to=_to; this._step=_step; source_context = sc; FillParentsInDirectChilds(); } /// Создает копию узла public override syntax_tree_node Clone() { slice_expr_question copy = new slice_expr_question(); 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 (v != null) { copy.v = (addressed_value)v.Clone(); copy.v.Parent = copy; } if (from != null) { copy.from = (expression)from.Clone(); copy.from.Parent = copy; } if (to != null) { copy.to = (expression)to.Clone(); copy.to.Parent = copy; } if (step != null) { copy.step = (expression)step.Clone(); copy.step.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new slice_expr_question TypedClone() { return Clone() as slice_expr_question; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (dereferencing_value != null) dereferencing_value.Parent = this; if (v != null) v.Parent = this; if (from != null) from.Parent = this; if (to != null) to.Parent = this; if (step != null) step.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); dereferencing_value?.FillParentsInAllChilds(); v?.FillParentsInAllChilds(); from?.FillParentsInAllChilds(); to?.FillParentsInAllChilds(); step?.FillParentsInAllChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 5; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 5; } } /// ///Индексатор для получения всех подузлов /// 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 v; case 2: return from; case 3: return to; case 4: return step; } 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: v = (addressed_value)value; break; case 2: from = (expression)value; break; case 3: to = (expression)value; break; case 4: step = (expression)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class semantic_check_sugared_statement_node : statement { /// ///Конструктор без параметров. /// public semantic_check_sugared_statement_node() { } /// ///Конструктор с параметрами. /// public semantic_check_sugared_statement_node(object _typ,List _lst) { this._typ=_typ; this._lst=_lst; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public semantic_check_sugared_statement_node(object _typ,List _lst,SourceContext sc) { this._typ=_typ; this._lst=_lst; source_context = sc; FillParentsInDirectChilds(); } public semantic_check_sugared_statement_node(syntax_tree_node elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected object _typ; protected List _lst=new List(); /// /// /// public object typ { get { return _typ; } set { _typ=value; } } /// /// /// public List lst { get { return _lst; } set { _lst=value; } } public semantic_check_sugared_statement_node Add(syntax_tree_node elem, SourceContext sc = null) { lst.Add(elem); if (elem != null) elem.Parent = this; if (sc != null) source_context = sc; return this; } public void AddFirst(syntax_tree_node el) { if (el == null) throw new ArgumentNullException(nameof(el)); lst.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); lst.InsertRange(0, els); foreach (var el in els) if (el != null) el.Parent = this; } public void AddMany(params syntax_tree_node[] els) { if (els == null) throw new ArgumentNullException(nameof(els)); lst.AddRange(els); foreach (var el in els) if (el != null) el.Parent = this; } private int FindIndexInList(syntax_tree_node el) { if (el == null) throw new ArgumentNullException(nameof(el)); var ind = lst.FindIndex(x => x == el); if (ind == -1) throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el)); return ind; } public void InsertAfter(syntax_tree_node el, syntax_tree_node newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); lst.Insert(FindIndexInList(el) + 1, newel); newel.Parent = this; } public void InsertAfter(syntax_tree_node el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); lst.InsertRange(FindIndexInList(el) + 1, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public void InsertBefore(syntax_tree_node el, syntax_tree_node newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); lst.Insert(FindIndexInList(el), newel); newel.Parent = this; } public void InsertBefore(syntax_tree_node el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); lst.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(syntax_tree_node el) { return lst.Remove(el); } public void ReplaceInList(syntax_tree_node el, syntax_tree_node newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); lst[FindIndexInList(el)] = newel; newel.Parent = this; } public void ReplaceInList(syntax_tree_node el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); var ind = FindIndexInList(el); lst.RemoveAt(ind); lst.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return lst.RemoveAll(match); } public syntax_tree_node Last() { if (lst.Count > 0) return lst[lst.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return lst.Count; } } public void Insert(int pos, syntax_tree_node el) { if (el == null) throw new ArgumentNullException(nameof(el)); lst.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { semantic_check_sugared_statement_node copy = new semantic_check_sugared_statement_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; } copy.typ = typ; if (lst != null) { foreach (syntax_tree_node elem in lst) { if (elem != null) { copy.Add(elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new semantic_check_sugared_statement_node TypedClone() { return Clone() as semantic_check_sugared_statement_node; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (lst != null) { foreach (var child in lst) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); if (lst != null) { foreach (var child in lst) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (lst == null ? 0 : lst.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(lst != null) { if(index_counter < lst.Count) { return lst[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); Int32 index_counter=ind - 0; if(lst != null) { if(index_counter < lst.Count) { lst[index_counter]= (syntax_tree_node)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// ///Обёртка для сахарного выражения, хранящего сахарный узел для семантических проверок и новое выражение после удаления синтаксического сахара /// [Serializable] public partial class sugared_expression : expression { /// ///Конструктор без параметров. /// public sugared_expression() { } /// ///Конструктор с параметрами. /// public sugared_expression(object _sugared_expr,expression _new_expr) { this._sugared_expr=_sugared_expr; this._new_expr=_new_expr; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public sugared_expression(object _sugared_expr,expression _new_expr,SourceContext sc) { this._sugared_expr=_sugared_expr; this._new_expr=_new_expr; source_context = sc; FillParentsInDirectChilds(); } protected object _sugared_expr; protected expression _new_expr; /// /// /// public object sugared_expr { get { return _sugared_expr; } set { _sugared_expr=value; } } /// /// /// public expression new_expr { get { return _new_expr; } set { _new_expr=value; if (_new_expr != null) _new_expr.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { sugared_expression copy = new sugared_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; } copy.sugared_expr = sugared_expr; if (new_expr != null) { copy.new_expr = (expression)new_expr.Clone(); copy.new_expr.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new sugared_expression TypedClone() { return Clone() as sugared_expression; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (new_expr != null) new_expr.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); new_expr?.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 new_expr; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: new_expr = (expression)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// ///Обёртка для сахарного адресуемого значения, хранящего сахарный узел для семантических проверок и новое выражение после удаления синтаксического сахара /// [Serializable] public partial class sugared_addressed_value : addressed_value { /// ///Конструктор без параметров. /// public sugared_addressed_value() { } /// ///Конструктор с параметрами. /// public sugared_addressed_value(object _sugared_expr,addressed_value _new_addr_value) { this._sugared_expr=_sugared_expr; this._new_addr_value=_new_addr_value; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public sugared_addressed_value(object _sugared_expr,addressed_value _new_addr_value,SourceContext sc) { this._sugared_expr=_sugared_expr; this._new_addr_value=_new_addr_value; source_context = sc; FillParentsInDirectChilds(); } protected object _sugared_expr; protected addressed_value _new_addr_value; /// /// /// public object sugared_expr { get { return _sugared_expr; } set { _sugared_expr=value; } } /// /// /// public addressed_value new_addr_value { get { return _new_addr_value; } set { _new_addr_value=value; if (_new_addr_value != null) _new_addr_value.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { sugared_addressed_value copy = new sugared_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; } copy.sugared_expr = sugared_expr; if (new_addr_value != null) { copy.new_addr_value = (addressed_value)new_addr_value.Clone(); copy.new_addr_value.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new sugared_addressed_value TypedClone() { return Clone() as sugared_addressed_value; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (new_addr_value != null) new_addr_value.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); new_addr_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 new_addr_value; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: new_addr_value = (addressed_value)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class double_question_node : addressed_value_funcname { /// ///Конструктор без параметров. /// public double_question_node() { } /// ///Конструктор с параметрами. /// public double_question_node(expression _left,expression _right) { this._left=_left; this._right=_right; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public double_question_node(expression _left,expression _right,SourceContext sc) { 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() { double_question_node copy = new double_question_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 (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 double_question_node TypedClone() { return Clone() as double_question_node; } /// Заполняет поля 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 pattern_node : syntax_tree_node { /// ///Конструктор без параметров. /// public pattern_node() { } /// ///Конструктор с параметрами. /// public pattern_node(List _parameters) { this._parameters=_parameters; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public pattern_node(List _parameters,SourceContext sc) { this._parameters=_parameters; source_context = sc; FillParentsInDirectChilds(); } public pattern_node(pattern_parameter elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected List _parameters=new List(); /// /// /// public List parameters { get { return _parameters; } set { _parameters=value; } } public pattern_node Add(pattern_parameter elem, SourceContext sc = null) { parameters.Add(elem); if (elem != null) elem.Parent = this; if (sc != null) source_context = sc; return this; } public void AddFirst(pattern_parameter el) { if (el == null) throw new ArgumentNullException(nameof(el)); parameters.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); parameters.InsertRange(0, els); foreach (var el in els) if (el != null) el.Parent = this; } public void AddMany(params pattern_parameter[] els) { if (els == null) throw new ArgumentNullException(nameof(els)); parameters.AddRange(els); foreach (var el in els) if (el != null) el.Parent = this; } private int FindIndexInList(pattern_parameter el) { if (el == null) throw new ArgumentNullException(nameof(el)); var ind = parameters.FindIndex(x => x == el); if (ind == -1) throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el)); return ind; } public void InsertAfter(pattern_parameter el, pattern_parameter newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); parameters.Insert(FindIndexInList(el) + 1, newel); newel.Parent = this; } public void InsertAfter(pattern_parameter el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); parameters.InsertRange(FindIndexInList(el) + 1, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public void InsertBefore(pattern_parameter el, pattern_parameter newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); parameters.Insert(FindIndexInList(el), newel); newel.Parent = this; } public void InsertBefore(pattern_parameter el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); parameters.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(pattern_parameter el) { return parameters.Remove(el); } public void ReplaceInList(pattern_parameter el, pattern_parameter newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); parameters[FindIndexInList(el)] = newel; newel.Parent = this; } public void ReplaceInList(pattern_parameter el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); var ind = FindIndexInList(el); parameters.RemoveAt(ind); parameters.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return parameters.RemoveAll(match); } public pattern_parameter Last() { if (parameters.Count > 0) return parameters[parameters.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return parameters.Count; } } public void Insert(int pos, pattern_parameter el) { if (el == null) throw new ArgumentNullException(nameof(el)); parameters.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { pattern_node copy = new pattern_node(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (parameters != null) { foreach (pattern_parameter elem in parameters) { if (elem != null) { copy.Add((pattern_parameter)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new pattern_node TypedClone() { return Clone() as pattern_node; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (parameters != null) { foreach (var child in parameters) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (parameters != null) { foreach (var child in parameters) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (parameters == null ? 0 : parameters.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(parameters != null) { if(index_counter < parameters.Count) { return parameters[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); Int32 index_counter=ind - 0; if(parameters != null) { if(index_counter < parameters.Count) { parameters[index_counter]= (pattern_parameter)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class type_pattern : pattern_node { /// ///Конструктор без параметров. /// public type_pattern() { } /// ///Конструктор с параметрами. /// public type_pattern(ident _identifier,type_definition _type) { this._identifier=_identifier; this._type=_type; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public type_pattern(ident _identifier,type_definition _type,SourceContext sc) { this._identifier=_identifier; this._type=_type; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public type_pattern(List _parameters,ident _identifier,type_definition _type) { this._parameters=_parameters; this._identifier=_identifier; this._type=_type; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public type_pattern(List _parameters,ident _identifier,type_definition _type,SourceContext sc) { this._parameters=_parameters; this._identifier=_identifier; this._type=_type; source_context = sc; FillParentsInDirectChilds(); } protected ident _identifier; protected type_definition _type; /// /// /// public ident identifier { get { return _identifier; } set { _identifier=value; if (_identifier != null) _identifier.Parent = this; } } /// /// /// public type_definition type { get { return _type; } set { _type=value; if (_type != null) _type.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { type_pattern copy = new type_pattern(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (parameters != null) { foreach (pattern_parameter elem in parameters) { if (elem != null) { copy.Add((pattern_parameter)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } if (identifier != null) { copy.identifier = (ident)identifier.Clone(); copy.identifier.Parent = copy; } if (type != null) { copy.type = (type_definition)type.Clone(); copy.type.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new type_pattern TypedClone() { return Clone() as type_pattern; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (parameters != null) { foreach (var child in parameters) if (child != null) child.Parent = this; } if (identifier != null) identifier.Parent = this; if (type != null) type.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (parameters != null) { foreach (var child in parameters) child?.FillParentsInAllChilds(); } identifier?.FillParentsInAllChilds(); type?.FillParentsInAllChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 2; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 2 + (parameters == null ? 0 : parameters.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 identifier; case 1: return type; } Int32 index_counter=ind - 2; if(parameters != null) { if(index_counter < parameters.Count) { return parameters[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: identifier = (ident)value; break; case 1: type = (type_definition)value; break; } Int32 index_counter=ind - 2; if(parameters != null) { if(index_counter < parameters.Count) { parameters[index_counter]= (pattern_parameter)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class is_pattern_expr : expression { /// ///Конструктор без параметров. /// public is_pattern_expr() { } /// ///Конструктор с параметрами. /// public is_pattern_expr(expression _left,pattern_node _right) { this._left=_left; this._right=_right; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public is_pattern_expr(expression _left,pattern_node _right,SourceContext sc) { this._left=_left; this._right=_right; source_context = sc; FillParentsInDirectChilds(); } protected expression _left; protected pattern_node _right; /// /// /// public expression left { get { return _left; } set { _left=value; if (_left != null) _left.Parent = this; } } /// /// /// public pattern_node right { get { return _right; } set { _right=value; if (_right != null) _right.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { is_pattern_expr copy = new is_pattern_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 = (pattern_node)right.Clone(); copy.right.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new is_pattern_expr TypedClone() { return Clone() as is_pattern_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 = (pattern_node)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class match_with : statement { /// ///Конструктор без параметров. /// public match_with() { } /// ///Конструктор с параметрами. /// public match_with(expression _expr,pattern_cases _case_list,statement _defaultAction) { this._expr=_expr; this._case_list=_case_list; this._defaultAction=_defaultAction; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public match_with(expression _expr,pattern_cases _case_list,statement _defaultAction,SourceContext sc) { this._expr=_expr; this._case_list=_case_list; this._defaultAction=_defaultAction; source_context = sc; FillParentsInDirectChilds(); } protected expression _expr; protected pattern_cases _case_list; protected statement _defaultAction; /// /// /// public expression expr { get { return _expr; } set { _expr=value; if (_expr != null) _expr.Parent = this; } } /// /// /// public pattern_cases case_list { get { return _case_list; } set { _case_list=value; if (_case_list != null) _case_list.Parent = this; } } /// /// /// public statement defaultAction { get { return _defaultAction; } set { _defaultAction=value; if (_defaultAction != null) _defaultAction.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { match_with copy = new match_with(); 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 (case_list != null) { copy.case_list = (pattern_cases)case_list.Clone(); copy.case_list.Parent = copy; } if (defaultAction != null) { copy.defaultAction = (statement)defaultAction.Clone(); copy.defaultAction.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new match_with TypedClone() { return Clone() as match_with; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (expr != null) expr.Parent = this; if (case_list != null) case_list.Parent = this; if (defaultAction != null) defaultAction.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); expr?.FillParentsInAllChilds(); case_list?.FillParentsInAllChilds(); defaultAction?.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 expr; case 1: return case_list; case 2: return defaultAction; } 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: case_list = (pattern_cases)value; break; case 2: defaultAction = (statement)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class pattern_case : statement { /// ///Конструктор без параметров. /// public pattern_case() { } /// ///Конструктор с параметрами. /// public pattern_case(pattern_node _pattern,statement _case_action,expression _condition) { this._pattern=_pattern; this._case_action=_case_action; this._condition=_condition; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public pattern_case(pattern_node _pattern,statement _case_action,expression _condition,SourceContext sc) { this._pattern=_pattern; this._case_action=_case_action; this._condition=_condition; source_context = sc; FillParentsInDirectChilds(); } protected pattern_node _pattern; protected statement _case_action; protected expression _condition; /// /// /// public pattern_node pattern { get { return _pattern; } set { _pattern=value; if (_pattern != null) _pattern.Parent = this; } } /// /// /// public statement case_action { get { return _case_action; } set { _case_action=value; if (_case_action != null) _case_action.Parent = this; } } /// /// /// public expression condition { get { return _condition; } set { _condition=value; if (_condition != null) _condition.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { pattern_case copy = new pattern_case(); 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 (pattern != null) { copy.pattern = (pattern_node)pattern.Clone(); copy.pattern.Parent = copy; } if (case_action != null) { copy.case_action = (statement)case_action.Clone(); copy.case_action.Parent = copy; } if (condition != null) { copy.condition = (expression)condition.Clone(); copy.condition.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new pattern_case TypedClone() { return Clone() as pattern_case; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (pattern != null) pattern.Parent = this; if (case_action != null) case_action.Parent = this; if (condition != null) condition.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); pattern?.FillParentsInAllChilds(); case_action?.FillParentsInAllChilds(); condition?.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 pattern; case 1: return case_action; case 2: return condition; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: pattern = (pattern_node)value; break; case 1: case_action = (statement)value; break; case 2: condition = (expression)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class pattern_cases : statement { /// ///Конструктор без параметров. /// public pattern_cases() { } /// ///Конструктор с параметрами. /// public pattern_cases(List _elements) { this._elements=_elements; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public pattern_cases(List _elements,SourceContext sc) { this._elements=_elements; source_context = sc; FillParentsInDirectChilds(); } public pattern_cases(pattern_case elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected List _elements=new List(); /// /// /// public List elements { get { return _elements; } set { _elements=value; } } public pattern_cases Add(pattern_case elem, SourceContext sc = null) { elements.Add(elem); if (elem != null) elem.Parent = this; if (sc != null) source_context = sc; return this; } public void AddFirst(pattern_case el) { if (el == null) throw new ArgumentNullException(nameof(el)); elements.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); elements.InsertRange(0, els); foreach (var el in els) if (el != null) el.Parent = this; } public void AddMany(params pattern_case[] els) { if (els == null) throw new ArgumentNullException(nameof(els)); elements.AddRange(els); foreach (var el in els) if (el != null) el.Parent = this; } private int FindIndexInList(pattern_case el) { if (el == null) throw new ArgumentNullException(nameof(el)); var ind = elements.FindIndex(x => x == el); if (ind == -1) throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el)); return ind; } public void InsertAfter(pattern_case el, pattern_case newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); elements.Insert(FindIndexInList(el) + 1, newel); newel.Parent = this; } public void InsertAfter(pattern_case el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); elements.InsertRange(FindIndexInList(el) + 1, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public void InsertBefore(pattern_case el, pattern_case newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); elements.Insert(FindIndexInList(el), newel); newel.Parent = this; } public void InsertBefore(pattern_case el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); elements.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(pattern_case el) { return elements.Remove(el); } public void ReplaceInList(pattern_case el, pattern_case newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); elements[FindIndexInList(el)] = newel; newel.Parent = this; } public void ReplaceInList(pattern_case el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); var ind = FindIndexInList(el); elements.RemoveAt(ind); elements.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return elements.RemoveAll(match); } public pattern_case Last() { if (elements.Count > 0) return elements[elements.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return elements.Count; } } public void Insert(int pos, pattern_case el) { if (el == null) throw new ArgumentNullException(nameof(el)); elements.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { pattern_cases copy = new pattern_cases(); 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 (elements != null) { foreach (pattern_case elem in elements) { if (elem != null) { copy.Add((pattern_case)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new pattern_cases TypedClone() { return Clone() as pattern_cases; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (elements != null) { foreach (var child in elements) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); if (elements != null) { foreach (var child in elements) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (elements == null ? 0 : elements.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(elements != null) { if(index_counter < elements.Count) { return elements[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); Int32 index_counter=ind - 0; if(elements != null) { if(index_counter < elements.Count) { elements[index_counter]= (pattern_case)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class deconstructor_pattern : pattern_node { /// ///Конструктор без параметров. /// public deconstructor_pattern() { } /// ///Конструктор с параметрами. /// public deconstructor_pattern(type_definition _type,expression _const_params_check) { this._type=_type; this._const_params_check=_const_params_check; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public deconstructor_pattern(type_definition _type,expression _const_params_check,SourceContext sc) { this._type=_type; this._const_params_check=_const_params_check; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public deconstructor_pattern(List _parameters,type_definition _type,expression _const_params_check) { this._parameters=_parameters; this._type=_type; this._const_params_check=_const_params_check; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public deconstructor_pattern(List _parameters,type_definition _type,expression _const_params_check,SourceContext sc) { this._parameters=_parameters; this._type=_type; this._const_params_check=_const_params_check; source_context = sc; FillParentsInDirectChilds(); } protected type_definition _type; protected expression _const_params_check; /// ///Деконструируемый тип /// public type_definition type { get { return _type; } set { _type=value; if (_type != null) _type.Parent = this; } } /// ///Проверка соответствия для константных параметрах деконструирования /// public expression const_params_check { get { return _const_params_check; } set { _const_params_check=value; if (_const_params_check != null) _const_params_check.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { deconstructor_pattern copy = new deconstructor_pattern(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (parameters != null) { foreach (pattern_parameter elem in parameters) { if (elem != null) { copy.Add((pattern_parameter)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } if (type != null) { copy.type = (type_definition)type.Clone(); copy.type.Parent = copy; } if (const_params_check != null) { copy.const_params_check = (expression)const_params_check.Clone(); copy.const_params_check.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new deconstructor_pattern TypedClone() { return Clone() as deconstructor_pattern; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (parameters != null) { foreach (var child in parameters) if (child != null) child.Parent = this; } if (type != null) type.Parent = this; if (const_params_check != null) const_params_check.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (parameters != null) { foreach (var child in parameters) child?.FillParentsInAllChilds(); } type?.FillParentsInAllChilds(); const_params_check?.FillParentsInAllChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 2; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 2 + (parameters == null ? 0 : parameters.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 type; case 1: return const_params_check; } Int32 index_counter=ind - 2; if(parameters != null) { if(index_counter < parameters.Count) { return parameters[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: type = (type_definition)value; break; case 1: const_params_check = (expression)value; break; } Int32 index_counter=ind - 2; if(parameters != null) { if(index_counter < parameters.Count) { parameters[index_counter]= (pattern_parameter)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// ///Базовый класс параметра для pattern_node /// [Serializable] public partial class pattern_parameter : syntax_tree_node { /// ///Конструктор без параметров. /// public pattern_parameter() { } /// Создает копию узла public override syntax_tree_node Clone() { pattern_parameter copy = new pattern_parameter(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); return copy; } /// Получает копию данного узла корректного типа public new pattern_parameter TypedClone() { return Clone() as pattern_parameter; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа 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 desugared_deconstruction : statement { /// ///Конструктор без параметров. /// public desugared_deconstruction() { } /// ///Конструктор с параметрами. /// public desugared_deconstruction(deconstruction_variables_definition _variables,expression _deconstruction_target) { this._variables=_variables; this._deconstruction_target=_deconstruction_target; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public desugared_deconstruction(deconstruction_variables_definition _variables,expression _deconstruction_target,SourceContext sc) { this._variables=_variables; this._deconstruction_target=_deconstruction_target; source_context = sc; FillParentsInDirectChilds(); } protected deconstruction_variables_definition _variables; protected expression _deconstruction_target; /// ///Объявления порожденных переменных /// public deconstruction_variables_definition variables { get { return _variables; } set { _variables=value; if (_variables != null) _variables.Parent = this; } } /// ///Деконструируемое выражение /// public expression deconstruction_target { get { return _deconstruction_target; } set { _deconstruction_target=value; if (_deconstruction_target != null) _deconstruction_target.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { desugared_deconstruction copy = new desugared_deconstruction(); 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 (variables != null) { copy.variables = (deconstruction_variables_definition)variables.Clone(); copy.variables.Parent = copy; } if (deconstruction_target != null) { copy.deconstruction_target = (expression)deconstruction_target.Clone(); copy.deconstruction_target.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new desugared_deconstruction TypedClone() { return Clone() as desugared_deconstruction; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (variables != null) variables.Parent = this; if (deconstruction_target != null) deconstruction_target.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); variables?.FillParentsInAllChilds(); deconstruction_target?.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 variables; case 1: return deconstruction_target; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: variables = (deconstruction_variables_definition)value; break; case 1: deconstruction_target = (expression)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// ///Параметр-объявление переменной (возможно без типа) /// [Serializable] public partial class var_deconstructor_parameter : pattern_parameter { /// ///Конструктор без параметров. /// public var_deconstructor_parameter() { } /// ///Конструктор с параметрами. /// public var_deconstructor_parameter(ident _identifier,type_definition _type,bool _var_keyword_used) { this._identifier=_identifier; this._type=_type; this._var_keyword_used=_var_keyword_used; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public var_deconstructor_parameter(ident _identifier,type_definition _type,bool _var_keyword_used,SourceContext sc) { this._identifier=_identifier; this._type=_type; this._var_keyword_used=_var_keyword_used; source_context = sc; FillParentsInDirectChilds(); } protected ident _identifier; protected type_definition _type; protected bool _var_keyword_used; /// /// /// public ident identifier { get { return _identifier; } set { _identifier=value; if (_identifier != null) _identifier.Parent = this; } } /// /// /// public type_definition type { get { return _type; } set { _type=value; if (_type != null) _type.Parent = this; } } /// /// /// public bool var_keyword_used { get { return _var_keyword_used; } set { _var_keyword_used=value; } } /// Создает копию узла public override syntax_tree_node Clone() { var_deconstructor_parameter copy = new var_deconstructor_parameter(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (identifier != null) { copy.identifier = (ident)identifier.Clone(); copy.identifier.Parent = copy; } if (type != null) { copy.type = (type_definition)type.Clone(); copy.type.Parent = copy; } copy.var_keyword_used = var_keyword_used; return copy; } /// Получает копию данного узла корректного типа public new var_deconstructor_parameter TypedClone() { return Clone() as var_deconstructor_parameter; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (identifier != null) identifier.Parent = this; if (type != null) type.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); identifier?.FillParentsInAllChilds(); type?.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 identifier; case 1: return type; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: identifier = (ident)value; break; case 1: type = (type_definition)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// ///Параметр-паттерн. Часть рекурсивного паттерна. /// [Serializable] public partial class recursive_deconstructor_parameter : recursive_pattern_parameter { /// ///Конструктор без параметров. /// public recursive_deconstructor_parameter() { } /// ///Конструктор с параметрами. /// public recursive_deconstructor_parameter(pattern_node _pattern) { this._pattern=_pattern; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public recursive_deconstructor_parameter(pattern_node _pattern,SourceContext sc) { this._pattern=_pattern; source_context = sc; FillParentsInDirectChilds(); } /// Создает копию узла public override syntax_tree_node Clone() { recursive_deconstructor_parameter copy = new recursive_deconstructor_parameter(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (pattern != null) { copy.pattern = (pattern_node)pattern.Clone(); copy.pattern.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new recursive_deconstructor_parameter TypedClone() { return Clone() as recursive_deconstructor_parameter; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (pattern != null) pattern.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); pattern?.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 pattern; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: pattern = (pattern_node)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// ///Список объявлений для deconstructor pattern /// [Serializable] public partial class deconstruction_variables_definition : declaration { /// ///Конструктор без параметров. /// public deconstruction_variables_definition() { } /// ///Конструктор с параметрами. /// public deconstruction_variables_definition(List _definitions) { this._definitions=_definitions; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public deconstruction_variables_definition(List _definitions,SourceContext sc) { this._definitions=_definitions; source_context = sc; FillParentsInDirectChilds(); } public deconstruction_variables_definition(var_def_statement elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected List _definitions=new List(); /// /// /// public List definitions { get { return _definitions; } set { _definitions=value; } } public deconstruction_variables_definition Add(var_def_statement elem, SourceContext sc = null) { 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)); definitions.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); 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)); 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 = 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)); 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)); 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)); 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)); definitions.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(var_def_statement el) { return 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)); 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); definitions.RemoveAt(ind); definitions.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return definitions.RemoveAll(match); } public var_def_statement Last() { if (definitions.Count > 0) return definitions[definitions.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return definitions.Count; } } public void Insert(int pos, var_def_statement el) { if (el == null) throw new ArgumentNullException(nameof(el)); definitions.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { deconstruction_variables_definition copy = new deconstruction_variables_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 (definitions != null) { foreach (var_def_statement elem in definitions) { if (elem != null) { copy.Add((var_def_statement)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new deconstruction_variables_definition TypedClone() { return Clone() as deconstruction_variables_definition; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (definitions != null) { foreach (var child in definitions) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); if (definitions != null) { foreach (var child in definitions) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (definitions == null ? 0 : 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(definitions != null) { if(index_counter < definitions.Count) { return 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(definitions != null) { if(index_counter < definitions.Count) { 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 var_tuple_def_statement : var_def_statement { /// ///Конструктор без параметров. /// public var_tuple_def_statement() { } /// ///Конструктор с параметрами. /// public var_tuple_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_tuple_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(); } /// Создает копию узла public override syntax_tree_node Clone() { var_tuple_def_statement copy = new var_tuple_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_tuple_def_statement TypedClone() { return Clone() as var_tuple_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 semantic_check_sugared_var_def_statement_node : var_def_statement { /// ///Конструктор без параметров. /// public semantic_check_sugared_var_def_statement_node() { } /// ///Конструктор с параметрами. /// public semantic_check_sugared_var_def_statement_node(object _typ,List _lst) { this._typ=_typ; this._lst=_lst; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public semantic_check_sugared_var_def_statement_node(object _typ,List _lst,SourceContext sc) { this._typ=_typ; this._lst=_lst; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public semantic_check_sugared_var_def_statement_node(ident_list _vars,type_definition _vars_type,expression _inital_value,definition_attribute _var_attr,bool _is_event,object _typ,List _lst) { this._vars=_vars; this._vars_type=_vars_type; this._inital_value=_inital_value; this._var_attr=_var_attr; this._is_event=_is_event; this._typ=_typ; this._lst=_lst; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public semantic_check_sugared_var_def_statement_node(ident_list _vars,type_definition _vars_type,expression _inital_value,definition_attribute _var_attr,bool _is_event,object _typ,List _lst,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; this._typ=_typ; this._lst=_lst; source_context = sc; FillParentsInDirectChilds(); } public semantic_check_sugared_var_def_statement_node(syntax_tree_node elem, SourceContext sc = null) { Add(elem, sc); FillParentsInDirectChilds(); } protected object _typ; protected List _lst=new List(); /// /// /// public object typ { get { return _typ; } set { _typ=value; } } /// /// /// public List lst { get { return _lst; } set { _lst=value; } } public semantic_check_sugared_var_def_statement_node Add(syntax_tree_node elem, SourceContext sc = null) { lst.Add(elem); if (elem != null) elem.Parent = this; if (sc != null) source_context = sc; return this; } public void AddFirst(syntax_tree_node el) { if (el == null) throw new ArgumentNullException(nameof(el)); lst.Insert(0, el); FillParentsInDirectChilds(); } public void AddFirst(IEnumerable els) { if (els == null) throw new ArgumentNullException(nameof(els)); lst.InsertRange(0, els); foreach (var el in els) if (el != null) el.Parent = this; } public void AddMany(params syntax_tree_node[] els) { if (els == null) throw new ArgumentNullException(nameof(els)); lst.AddRange(els); foreach (var el in els) if (el != null) el.Parent = this; } private int FindIndexInList(syntax_tree_node el) { if (el == null) throw new ArgumentNullException(nameof(el)); var ind = lst.FindIndex(x => x == el); if (ind == -1) throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el)); return ind; } public void InsertAfter(syntax_tree_node el, syntax_tree_node newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); lst.Insert(FindIndexInList(el) + 1, newel); newel.Parent = this; } public void InsertAfter(syntax_tree_node el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); lst.InsertRange(FindIndexInList(el) + 1, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public void InsertBefore(syntax_tree_node el, syntax_tree_node newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); lst.Insert(FindIndexInList(el), newel); newel.Parent = this; } public void InsertBefore(syntax_tree_node el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); lst.InsertRange(FindIndexInList(el), newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public bool Remove(syntax_tree_node el) { return lst.Remove(el); } public void ReplaceInList(syntax_tree_node el, syntax_tree_node newel) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newel == null) throw new ArgumentNullException(nameof(newel)); lst[FindIndexInList(el)] = newel; newel.Parent = this; } public void ReplaceInList(syntax_tree_node el, IEnumerable newels) { if (el == null) throw new ArgumentNullException(nameof(el)); if (newels == null) throw new ArgumentNullException(nameof(newels)); var ind = FindIndexInList(el); lst.RemoveAt(ind); lst.InsertRange(ind, newels); foreach (var newel in newels) if (newel != null) newel.Parent = this; } public int RemoveAll(Predicate match) { return lst.RemoveAll(match); } public syntax_tree_node Last() { if (lst.Count > 0) return lst[lst.Count - 1]; throw new InvalidOperationException("Список пуст"); } public int Count { get { return lst.Count; } } public void Insert(int pos, syntax_tree_node el) { if (el == null) throw new ArgumentNullException(nameof(el)); lst.Insert(pos,el); if (el != null) el.Parent = this; } /// Создает копию узла public override syntax_tree_node Clone() { semantic_check_sugared_var_def_statement_node copy = new semantic_check_sugared_var_def_statement_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 (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; copy.typ = typ; if (lst != null) { foreach (syntax_tree_node elem in lst) { if (elem != null) { copy.Add(elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new semantic_check_sugared_var_def_statement_node TypedClone() { return Clone() as semantic_check_sugared_var_def_statement_node; } /// Заполняет поля 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; if (lst != null) { foreach (var child in lst) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); vars?.FillParentsInAllChilds(); vars_type?.FillParentsInAllChilds(); inital_value?.FillParentsInAllChilds(); if (lst != null) { foreach (var child in lst) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 3; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 3 + (lst == null ? 0 : lst.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 vars; case 1: return vars_type; case 2: return inital_value; } Int32 index_counter=ind - 3; if(lst != null) { if(index_counter < lst.Count) { return lst[index_counter]; } } 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; } Int32 index_counter=ind - 3; if(lst != null) { if(index_counter < lst.Count) { lst[index_counter]= (syntax_tree_node)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// ///паттерн для константного матчинга /// [Serializable] public partial class const_pattern : pattern_node { /// ///Конструктор без параметров. /// public const_pattern() { } /// ///Конструктор с параметрами. /// public const_pattern(expression_list _pattern_expressions) { this._pattern_expressions=_pattern_expressions; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public const_pattern(expression_list _pattern_expressions,SourceContext sc) { this._pattern_expressions=_pattern_expressions; source_context = sc; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public const_pattern(List _parameters,expression_list _pattern_expressions) { this._parameters=_parameters; this._pattern_expressions=_pattern_expressions; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public const_pattern(List _parameters,expression_list _pattern_expressions,SourceContext sc) { this._parameters=_parameters; this._pattern_expressions=_pattern_expressions; source_context = sc; FillParentsInDirectChilds(); } protected expression_list _pattern_expressions; /// /// /// public expression_list pattern_expressions { get { return _pattern_expressions; } set { _pattern_expressions=value; if (_pattern_expressions != null) _pattern_expressions.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { const_pattern copy = new const_pattern(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (parameters != null) { foreach (pattern_parameter elem in parameters) { if (elem != null) { copy.Add((pattern_parameter)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } if (pattern_expressions != null) { copy.pattern_expressions = (expression_list)pattern_expressions.Clone(); copy.pattern_expressions.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new const_pattern TypedClone() { return Clone() as const_pattern; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (parameters != null) { foreach (var child in parameters) if (child != null) child.Parent = this; } if (pattern_expressions != null) pattern_expressions.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (parameters != null) { foreach (var child in parameters) child?.FillParentsInAllChilds(); } pattern_expressions?.FillParentsInAllChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 1; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 1 + (parameters == null ? 0 : parameters.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 pattern_expressions; } Int32 index_counter=ind - 1; if(parameters != null) { if(index_counter < parameters.Count) { return parameters[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: pattern_expressions = (expression_list)value; break; } Int32 index_counter=ind - 1; if(parameters != null) { if(index_counter < parameters.Count) { parameters[index_counter]= (pattern_parameter)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class tuple_pattern_wild_card : pattern_parameter { /// ///Конструктор без параметров. /// public tuple_pattern_wild_card() { } /// Создает копию узла public override syntax_tree_node Clone() { tuple_pattern_wild_card copy = new tuple_pattern_wild_card(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); return copy; } /// Получает копию данного узла корректного типа public new tuple_pattern_wild_card TypedClone() { return Clone() as tuple_pattern_wild_card; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа 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 const_pattern_parameter : pattern_parameter { /// ///Конструктор без параметров. /// public const_pattern_parameter() { } /// ///Конструктор с параметрами. /// public const_pattern_parameter(expression _const_param) { this._const_param=_const_param; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public const_pattern_parameter(expression _const_param,SourceContext sc) { this._const_param=_const_param; source_context = sc; FillParentsInDirectChilds(); } protected expression _const_param; /// /// /// public expression const_param { get { return _const_param; } set { _const_param=value; if (_const_param != null) _const_param.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { const_pattern_parameter copy = new const_pattern_parameter(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (const_param != null) { copy.const_param = (expression)const_param.Clone(); copy.const_param.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new const_pattern_parameter TypedClone() { return Clone() as const_pattern_parameter; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (const_param != null) const_param.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); const_param?.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 const_param; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: const_param = (expression)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class wild_card_deconstructor_parameter : pattern_parameter { /// ///Конструктор без параметров. /// public wild_card_deconstructor_parameter() { } /// Создает копию узла public override syntax_tree_node Clone() { wild_card_deconstructor_parameter copy = new wild_card_deconstructor_parameter(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); return copy; } /// Получает копию данного узла корректного типа public new wild_card_deconstructor_parameter TypedClone() { return Clone() as wild_card_deconstructor_parameter; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа 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 collection_pattern : pattern_node { /// ///Конструктор без параметров. /// public collection_pattern() { } /// ///Конструктор с параметрами. /// public collection_pattern(List _parameters) { this._parameters=_parameters; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public collection_pattern(List _parameters,SourceContext sc) { this._parameters=_parameters; source_context = sc; FillParentsInDirectChilds(); } /// Создает копию узла public override syntax_tree_node Clone() { collection_pattern copy = new collection_pattern(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (parameters != null) { foreach (pattern_parameter elem in parameters) { if (elem != null) { copy.Add((pattern_parameter)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new collection_pattern TypedClone() { return Clone() as collection_pattern; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (parameters != null) { foreach (var child in parameters) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (parameters != null) { foreach (var child in parameters) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (parameters == null ? 0 : parameters.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(parameters != null) { if(index_counter < parameters.Count) { return parameters[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); Int32 index_counter=ind - 0; if(parameters != null) { if(index_counter < parameters.Count) { parameters[index_counter]= (pattern_parameter)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class collection_pattern_gap_parameter : pattern_parameter { /// ///Конструктор без параметров. /// public collection_pattern_gap_parameter() { } /// Создает копию узла public override syntax_tree_node Clone() { collection_pattern_gap_parameter copy = new collection_pattern_gap_parameter(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); return copy; } /// Получает копию данного узла корректного типа public new collection_pattern_gap_parameter TypedClone() { return Clone() as collection_pattern_gap_parameter; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа 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 collection_pattern_wild_card : pattern_parameter { /// ///Конструктор без параметров. /// public collection_pattern_wild_card() { } /// Создает копию узла public override syntax_tree_node Clone() { collection_pattern_wild_card copy = new collection_pattern_wild_card(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); return copy; } /// Получает копию данного узла корректного типа public new collection_pattern_wild_card TypedClone() { return Clone() as collection_pattern_wild_card; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); } /// ///Свойство для получения количества всех подузлов без элементов поля типа 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 collection_pattern_var_parameter : pattern_parameter { /// ///Конструктор без параметров. /// public collection_pattern_var_parameter() { } /// ///Конструктор с параметрами. /// public collection_pattern_var_parameter(ident _identifier,type_definition _type) { this._identifier=_identifier; this._type=_type; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public collection_pattern_var_parameter(ident _identifier,type_definition _type,SourceContext sc) { this._identifier=_identifier; this._type=_type; source_context = sc; FillParentsInDirectChilds(); } protected ident _identifier; protected type_definition _type; /// /// /// public ident identifier { get { return _identifier; } set { _identifier=value; if (_identifier != null) _identifier.Parent = this; } } /// /// /// public type_definition type { get { return _type; } set { _type=value; if (_type != null) _type.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { collection_pattern_var_parameter copy = new collection_pattern_var_parameter(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (identifier != null) { copy.identifier = (ident)identifier.Clone(); copy.identifier.Parent = copy; } if (type != null) { copy.type = (type_definition)type.Clone(); copy.type.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new collection_pattern_var_parameter TypedClone() { return Clone() as collection_pattern_var_parameter; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (identifier != null) identifier.Parent = this; if (type != null) type.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); identifier?.FillParentsInAllChilds(); type?.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 identifier; case 1: return type; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: identifier = (ident)value; break; case 1: type = (type_definition)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// ///Рекурсивный паттерн-параметр. /// [Serializable] public partial class recursive_collection_parameter : recursive_pattern_parameter { /// ///Конструктор без параметров. /// public recursive_collection_parameter() { } /// ///Конструктор с параметрами. /// public recursive_collection_parameter(pattern_node _pattern) { this._pattern=_pattern; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public recursive_collection_parameter(pattern_node _pattern,SourceContext sc) { this._pattern=_pattern; source_context = sc; FillParentsInDirectChilds(); } /// Создает копию узла public override syntax_tree_node Clone() { recursive_collection_parameter copy = new recursive_collection_parameter(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (pattern != null) { copy.pattern = (pattern_node)pattern.Clone(); copy.pattern.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new recursive_collection_parameter TypedClone() { return Clone() as recursive_collection_parameter; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (pattern != null) pattern.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); pattern?.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 pattern; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: pattern = (pattern_node)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// ///Рекурсивный паттерн-параметр. /// [Serializable] public partial class recursive_pattern_parameter : pattern_parameter { /// ///Конструктор без параметров. /// public recursive_pattern_parameter() { } /// ///Конструктор с параметрами. /// public recursive_pattern_parameter(pattern_node _pattern) { this._pattern=_pattern; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public recursive_pattern_parameter(pattern_node _pattern,SourceContext sc) { this._pattern=_pattern; source_context = sc; FillParentsInDirectChilds(); } protected pattern_node _pattern; /// /// /// public pattern_node pattern { get { return _pattern; } set { _pattern=value; if (_pattern != null) _pattern.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { recursive_pattern_parameter copy = new recursive_pattern_parameter(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (pattern != null) { copy.pattern = (pattern_node)pattern.Clone(); copy.pattern.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new recursive_pattern_parameter TypedClone() { return Clone() as recursive_pattern_parameter; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (pattern != null) pattern.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); pattern?.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 pattern; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: pattern = (pattern_node)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class tuple_pattern : pattern_node { /// ///Конструктор без параметров. /// public tuple_pattern() { } /// ///Конструктор с параметрами. /// public tuple_pattern(List _parameters) { this._parameters=_parameters; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public tuple_pattern(List _parameters,SourceContext sc) { this._parameters=_parameters; source_context = sc; FillParentsInDirectChilds(); } /// Создает копию узла public override syntax_tree_node Clone() { tuple_pattern copy = new tuple_pattern(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (parameters != null) { foreach (pattern_parameter elem in parameters) { if (elem != null) { copy.Add((pattern_parameter)elem.Clone()); copy.Last().Parent = copy; } else copy.Add(null); } } return copy; } /// Получает копию данного узла корректного типа public new tuple_pattern TypedClone() { return Clone() as tuple_pattern; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (parameters != null) { foreach (var child in parameters) if (child != null) child.Parent = this; } } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); if (parameters != null) { foreach (var child in parameters) child?.FillParentsInAllChilds(); } } /// ///Свойство для получения количества всех подузлов без элементов поля типа List /// public override Int32 subnodes_without_list_elements_count { get { return 0; } } /// ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List /// public override Int32 subnodes_count { get { return 0 + (parameters == null ? 0 : parameters.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(parameters != null) { if(index_counter < parameters.Count) { return parameters[index_counter]; } } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); Int32 index_counter=ind - 0; if(parameters != null) { if(index_counter < parameters.Count) { parameters[index_counter]= (pattern_parameter)value; return; } } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class tuple_pattern_var_parameter : pattern_parameter { /// ///Конструктор без параметров. /// public tuple_pattern_var_parameter() { } /// ///Конструктор с параметрами. /// public tuple_pattern_var_parameter(ident _identifier,type_definition _type) { this._identifier=_identifier; this._type=_type; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public tuple_pattern_var_parameter(ident _identifier,type_definition _type,SourceContext sc) { this._identifier=_identifier; this._type=_type; source_context = sc; FillParentsInDirectChilds(); } protected ident _identifier; protected type_definition _type; /// /// /// public ident identifier { get { return _identifier; } set { _identifier=value; if (_identifier != null) _identifier.Parent = this; } } /// /// /// public type_definition type { get { return _type; } set { _type=value; if (_type != null) _type.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { tuple_pattern_var_parameter copy = new tuple_pattern_var_parameter(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (identifier != null) { copy.identifier = (ident)identifier.Clone(); copy.identifier.Parent = copy; } if (type != null) { copy.type = (type_definition)type.Clone(); copy.type.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new tuple_pattern_var_parameter TypedClone() { return Clone() as tuple_pattern_var_parameter; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (identifier != null) identifier.Parent = this; if (type != null) type.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); identifier?.FillParentsInAllChilds(); type?.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 identifier; case 1: return type; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: identifier = (ident)value; break; case 1: type = (type_definition)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// ///Рекурсивный паттерн-параметр. /// [Serializable] public partial class recursive_tuple_parameter : recursive_pattern_parameter { /// ///Конструктор без параметров. /// public recursive_tuple_parameter() { } /// ///Конструктор с параметрами. /// public recursive_tuple_parameter(pattern_node _pattern) { this._pattern=_pattern; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public recursive_tuple_parameter(pattern_node _pattern,SourceContext sc) { this._pattern=_pattern; source_context = sc; FillParentsInDirectChilds(); } /// Создает копию узла public override syntax_tree_node Clone() { recursive_tuple_parameter copy = new recursive_tuple_parameter(); copy.Parent = this.Parent; if (source_context != null) copy.source_context = new SourceContext(source_context); if (pattern != null) { copy.pattern = (pattern_node)pattern.Clone(); copy.pattern.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new recursive_tuple_parameter TypedClone() { return Clone() as recursive_tuple_parameter; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (pattern != null) pattern.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); pattern?.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 pattern; } return null; } set { if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1) throw new IndexOutOfRangeException(); switch(ind) { case 0: pattern = (pattern_node)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } /// /// /// [Serializable] public partial class diapason_expr_new : addressed_value { /// ///Конструктор без параметров. /// public diapason_expr_new() { } /// ///Конструктор с параметрами. /// public diapason_expr_new(expression _left,expression _right) { this._left=_left; this._right=_right; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public diapason_expr_new(expression _left,expression _right,SourceContext sc) { 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_expr_new copy = new diapason_expr_new(); 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; } return copy; } /// Получает копию данного узла корректного типа public new diapason_expr_new TypedClone() { return Clone() as diapason_expr_new; } /// Заполняет поля 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 if_expr_new : expression { /// ///Конструктор без параметров. /// public if_expr_new() { } /// ///Конструктор с параметрами. /// public if_expr_new(expression _condition,expression _if_true,expression _if_false) { this._condition=_condition; this._if_true=_if_true; this._if_false=_if_false; FillParentsInDirectChilds(); } /// ///Конструктор с параметрами. /// public if_expr_new(expression _condition,expression _if_true,expression _if_false,SourceContext sc) { this._condition=_condition; this._if_true=_if_true; this._if_false=_if_false; source_context = sc; FillParentsInDirectChilds(); } protected expression _condition; protected expression _if_true; protected expression _if_false; /// /// /// public expression condition { get { return _condition; } set { _condition=value; if (_condition != null) _condition.Parent = this; } } /// /// /// public expression if_true { get { return _if_true; } set { _if_true=value; if (_if_true != null) _if_true.Parent = this; } } /// /// /// public expression if_false { get { return _if_false; } set { _if_false=value; if (_if_false != null) _if_false.Parent = this; } } /// Создает копию узла public override syntax_tree_node Clone() { if_expr_new copy = new if_expr_new(); 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 (if_true != null) { copy.if_true = (expression)if_true.Clone(); copy.if_true.Parent = copy; } if (if_false != null) { copy.if_false = (expression)if_false.Clone(); copy.if_false.Parent = copy; } return copy; } /// Получает копию данного узла корректного типа public new if_expr_new TypedClone() { return Clone() as if_expr_new; } /// Заполняет поля Parent в непосредственных дочерних узлах public override void FillParentsInDirectChilds() { if (attributes != null) attributes.Parent = this; if (condition != null) condition.Parent = this; if (if_true != null) if_true.Parent = this; if (if_false != null) if_false.Parent = this; } /// Заполняет поля Parent во всем поддереве public override void FillParentsInAllChilds() { FillParentsInDirectChilds(); attributes?.FillParentsInAllChilds(); condition?.FillParentsInAllChilds(); if_true?.FillParentsInAllChilds(); if_false?.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 if_true; case 2: return if_false; } 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: if_true = (expression)value; break; case 2: if_false = (expression)value; break; } } } /// ///Метод для обхода дерева посетителем /// ///Объект-посетитель. ///Return value is void public override void visit(IVisitor visitor) { visitor.visit(this); } } }