diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs index ba5430de2..20b10858f 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs @@ -2,7 +2,7 @@ // This CSharp output file generated by Gardens Point LEX // Version: 1.1.3.301 // Machine: OBERON -// DateTime: 4/5/2018 7:25:13 PM +// DateTime: 4/10/2018 5:44:39 PM // UserName: voganesyan // GPLEX input file // GPLEX frame file diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.y b/Parsers/PascalABCParserNewSaushkin/ABCPascal.y index a33a84362..86041fdb2 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascal.y +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascal.y @@ -1568,7 +1568,7 @@ where_part } | tkWhere typeclass_restriction tkSemiColon { - $$ = $1; + $$ = new where_typeclass_constraint($2 as typeclass_restriction); } ; diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs index a554f5b83..60f2c588d 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs @@ -2,7 +2,7 @@ // GPPG version 1.3.6 // Machine: OBERON -// DateTime: 4/5/2018 7:25:14 PM +// DateTime: 4/10/2018 5:44:39 PM // UserName: voganesyan // Input file @@ -3746,7 +3746,7 @@ public partial class GPPGParser: ShiftReduceParser tkWhere, typeclass_restriction, tkSemiColon { - CurrentSemanticValue.stn = ValueStack[ValueStack.Depth-3].ti; + CurrentSemanticValue.stn = new where_typeclass_constraint(ValueStack[ValueStack.Depth-2].id as typeclass_restriction); } break; case 313: // type_ref_and_secific_list -> type_ref_or_secific diff --git a/SyntaxTree/tree/AbstractVisitor.cs b/SyntaxTree/tree/AbstractVisitor.cs index ee687e854..f49d1b94e 100644 --- a/SyntaxTree/tree/AbstractVisitor.cs +++ b/SyntaxTree/tree/AbstractVisitor.cs @@ -1132,6 +1132,11 @@ namespace PascalABCCompiler.SyntaxTree { DefaultVisit(_typeclass_definition); } + + public virtual void visit(where_typeclass_constraint _where_typeclass_constraint) + { + DefaultVisit(_where_typeclass_constraint); + } } diff --git a/SyntaxTree/tree/HierarchyVisitor.cs b/SyntaxTree/tree/HierarchyVisitor.cs index 83c8ddbba..d9964b067 100644 --- a/SyntaxTree/tree/HierarchyVisitor.cs +++ b/SyntaxTree/tree/HierarchyVisitor.cs @@ -1805,6 +1805,14 @@ namespace PascalABCCompiler.SyntaxTree { } + public virtual void pre_do_visit(where_typeclass_constraint _where_typeclass_constraint) + { + } + + public virtual void post_do_visit(where_typeclass_constraint _where_typeclass_constraint) + { + } + public override void visit(expression _expression) { DefaultVisit(_expression); @@ -3732,6 +3740,14 @@ namespace PascalABCCompiler.SyntaxTree visit(typeclass_definition.body); post_do_visit(_typeclass_definition); } + + public override void visit(where_typeclass_constraint _where_typeclass_constraint) + { + DefaultVisit(_where_typeclass_constraint); + pre_do_visit(_where_typeclass_constraint); + visit(where_typeclass_constraint.restriction); + post_do_visit(_where_typeclass_constraint); + } } diff --git a/SyntaxTree/tree/SyntaxTreeStreamReader.cs b/SyntaxTree/tree/SyntaxTreeStreamReader.cs index 4671319b2..92618966d 100644 --- a/SyntaxTree/tree/SyntaxTreeStreamReader.cs +++ b/SyntaxTree/tree/SyntaxTreeStreamReader.cs @@ -470,6 +470,8 @@ namespace PascalABCCompiler.SyntaxTree return new instance_definition(); case 224: return new typeclass_definition(); + case 225: + return new where_typeclass_constraint(); } return null; } @@ -3963,6 +3965,18 @@ namespace PascalABCCompiler.SyntaxTree _typeclass_definition.body = _read_node() as class_body_list; } + + public void visit(where_typeclass_constraint _where_typeclass_constraint) + { + read_where_typeclass_constraint(_where_typeclass_constraint); + } + + public void read_where_typeclass_constraint(where_typeclass_constraint _where_typeclass_constraint) + { + read_where_definition(_where_typeclass_constraint); + _where_typeclass_constraint.restriction = _read_node() as typeclass_restriction; + } + } diff --git a/SyntaxTree/tree/SyntaxTreeStreamWriter.cs b/SyntaxTree/tree/SyntaxTreeStreamWriter.cs index 64a4f2709..9688668d1 100644 --- a/SyntaxTree/tree/SyntaxTreeStreamWriter.cs +++ b/SyntaxTree/tree/SyntaxTreeStreamWriter.cs @@ -6211,6 +6211,27 @@ namespace PascalABCCompiler.SyntaxTree } } + + public void visit(where_typeclass_constraint _where_typeclass_constraint) + { + bw.Write((Int16)225); + write_where_typeclass_constraint(_where_typeclass_constraint); + } + + public void write_where_typeclass_constraint(where_typeclass_constraint _where_typeclass_constraint) + { + write_where_definition(_where_typeclass_constraint); + if (_where_typeclass_constraint.restriction == null) + { + bw.Write((byte)0); + } + else + { + bw.Write((byte)1); + _where_typeclass_constraint.restriction.visit(this); + } + } + } diff --git a/SyntaxTree/tree/Tree.cs b/SyntaxTree/tree/Tree.cs index 1b6ce6530..277b91bd5 100644 --- a/SyntaxTree/tree/Tree.cs +++ b/SyntaxTree/tree/Tree.cs @@ -47992,6 +47992,202 @@ namespace PascalABCCompiler.SyntaxTree } + /// + /// + /// + [Serializable] + public partial class where_typeclass_constraint : where_definition + { + + /// + ///Конструктор без параметров. + /// + public where_typeclass_constraint() + { + + } + + /// + ///Конструктор с параметрами. + /// + public where_typeclass_constraint(typeclass_restriction _restriction) + { + this._restriction=_restriction; + FillParentsInDirectChilds(); + } + + /// + ///Конструктор с параметрами. + /// + public where_typeclass_constraint(typeclass_restriction _restriction,SourceContext sc) + { + this._restriction=_restriction; + source_context = sc; + FillParentsInDirectChilds(); + } + + /// + ///Конструктор с параметрами. + /// + public where_typeclass_constraint(ident_list _names,where_type_specificator_list _types,typeclass_restriction _restriction) + { + this._names=_names; + this._types=_types; + this._restriction=_restriction; + FillParentsInDirectChilds(); + } + + /// + ///Конструктор с параметрами. + /// + public where_typeclass_constraint(ident_list _names,where_type_specificator_list _types,typeclass_restriction _restriction,SourceContext sc) + { + this._names=_names; + this._types=_types; + this._restriction=_restriction; + source_context = sc; + FillParentsInDirectChilds(); + } + protected typeclass_restriction _restriction; + + /// + /// + /// + public typeclass_restriction restriction + { + get + { + return _restriction; + } + set + { + _restriction=value; + } + } + + + /// Создает копию узла + public override syntax_tree_node Clone() + { + where_typeclass_constraint copy = new where_typeclass_constraint(); + 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; + } + if (restriction != null) + { + copy.restriction = (typeclass_restriction)restriction.Clone(); + copy.restriction.Parent = copy; + } + return copy; + } + + /// Получает копию данного узла корректного типа + public new where_typeclass_constraint TypedClone() + { + return Clone() as where_typeclass_constraint; + } + + /// Заполняет поля Parent в непосредственных дочерних узлах + public override void FillParentsInDirectChilds() + { + if (names != null) + names.Parent = this; + if (types != null) + types.Parent = this; + if (restriction != null) + restriction.Parent = this; + } + + /// Заполняет поля Parent во всем поддереве + public override void FillParentsInAllChilds() + { + FillParentsInDirectChilds(); + names?.FillParentsInAllChilds(); + types?.FillParentsInAllChilds(); + restriction?.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 names; + case 1: + return types; + case 2: + return restriction; + } + 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; + case 2: + restriction = (typeclass_restriction)value; + break; + } + } + } + /// + ///Метод для обхода дерева посетителем + /// + ///Объект-посетитель. + ///Return value is void + public override void visit(IVisitor visitor) + { + visitor.visit(this); + } + + } + + } diff --git a/SyntaxTree/tree/Visitor.cs b/SyntaxTree/tree/Visitor.cs index 7a2900a9c..f50fbc0b6 100644 --- a/SyntaxTree/tree/Visitor.cs +++ b/SyntaxTree/tree/Visitor.cs @@ -1354,6 +1354,12 @@ namespace PascalABCCompiler.SyntaxTree ///Node to visit /// Return value is void void visit(typeclass_definition _typeclass_definition); + /// + ///Method to visit where_typeclass_constraint. + /// + ///Node to visit + /// Return value is void + void visit(where_typeclass_constraint _where_typeclass_constraint); } diff --git a/SyntaxTree/tree/tree.xml b/SyntaxTree/tree/tree.xml index c0d2c1630..68daaec60 100644 --- a/SyntaxTree/tree/tree.xml +++ b/SyntaxTree/tree/tree.xml @@ -2906,6 +2906,20 @@ + + + + + + + + 0 + + + 9 + + + Tree.cs @@ -2931,7 +2945,7 @@ - + @@ -2981,6 +2995,7 @@ + @@ -4312,6 +4327,8 @@ + +