diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs index 46be65327..788d54b63 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: SSM -// DateTime: 18.01.2016 8:09:32 +// DateTime: 19.01.2016 22:49:35 // UserName: ????????? // GPLEX input file // GPLEX frame file diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.y b/Parsers/PascalABCParserNewSaushkin/ABCPascal.y index 7115b54ab..bc4dd357d 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascal.y +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascal.y @@ -301,8 +301,12 @@ uses_clause { $$ = null; } - | tkUses used_units_list tkSemiColon + | tkUses used_units_list tkSemiColon { + //if ($1 == null) + //$1 = new uses_closure($3 as uses_list,@$); + //else ($1 as uses_closure).Add($3 as uses_list,@$); + //$$ = $1; $$ = $2; $$.source_context = @$; } @@ -3430,7 +3434,7 @@ func_decl_lambda parsertools.AddErrorFromResource("TUPLE_ELEMENTS_COUNT_MUST_BE_LESSEQUAL_7",@5); if (parsertools.build_tree_for_formatter) - $$ = new tuple_node_for_formatter($4 as expression_list); + $$ = new tuple_node_for_formatter($4 as expression_list,@$); else $$ = new method_call(new dot_node("Tuple","Create"),$4 as expression_list,@$); } diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs index b208696d2..45a27f292 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs @@ -2,7 +2,7 @@ // GPPG version 1.3.6 // Machine: SSM -// DateTime: 18.01.2016 8:09:33 +// DateTime: 19.01.2016 22:49:35 // UserName: ????????? // Input file @@ -2321,6 +2321,10 @@ public partial class GPPGParser: ShiftReduceParser tkUses, used_units_list, tkSemiColon { + //if ($1 == null) + //$1 = new uses_closure($3 as uses_list,@$); + //else ($1 as uses_closure).Add($3 as uses_list,@$); + //$$ = $1; CurrentSemanticValue.stn = ValueStack[ValueStack.Depth-2].stn; CurrentSemanticValue.stn.source_context = CurrentLocationSpan; } @@ -5390,7 +5394,7 @@ public partial class GPPGParser: ShiftReduceParser(); + Int32 ssyy_count = br.ReadInt32(); + for(Int32 ssyy_i = 0; ssyy_i < ssyy_count; ssyy_i++) + { + _uses_closure.listunitsections.Add(_read_node() as uses_list); + } + } + } + } diff --git a/SyntaxTree/tree/SyntaxTreeStreamWriter.cs b/SyntaxTree/tree/SyntaxTreeStreamWriter.cs index 3d87d5ec1..3688a7627 100644 --- a/SyntaxTree/tree/SyntaxTreeStreamWriter.cs +++ b/SyntaxTree/tree/SyntaxTreeStreamWriter.cs @@ -5797,6 +5797,39 @@ namespace PascalABCCompiler.SyntaxTree } } + + public void visit(uses_closure _uses_closure) + { + bw.Write((Int16)208); + write_uses_closure(_uses_closure); + } + + public void write_uses_closure(uses_closure _uses_closure) + { + write_syntax_tree_node(_uses_closure); + if (_uses_closure.listunitsections == null) + { + bw.Write((byte)0); + } + else + { + bw.Write((byte)1); + bw.Write(_uses_closure.listunitsections.Count); + for(Int32 ssyy_i = 0; ssyy_i < _uses_closure.listunitsections.Count; ssyy_i++) + { + if (_uses_closure.listunitsections[ssyy_i] == null) + { + bw.Write((byte)0); + } + else + { + bw.Write((byte)1); + _uses_closure.listunitsections[ssyy_i].visit(this); + } + } + } + } + } diff --git a/SyntaxTree/tree/Tree.cs b/SyntaxTree/tree/Tree.cs index 00f18119a..9ace66909 100644 --- a/SyntaxTree/tree/Tree.cs +++ b/SyntaxTree/tree/Tree.cs @@ -27386,6 +27386,123 @@ namespace PascalABCCompiler.SyntaxTree } + /// + /// + /// + [Serializable] + public partial class uses_closure : syntax_tree_node + { + + /// + ///Конструктор без параметров. + /// + public uses_closure() + { + + } + + /// + ///Конструктор с параметрами. + /// + public uses_closure(List _listunitsections) + { + this._listunitsections=_listunitsections; + } + + /// + ///Конструктор с параметрами. + /// + public uses_closure(List _listunitsections,SourceContext sc) + { + this._listunitsections=_listunitsections; + source_context = sc; + } + + protected List _listunitsections=new List(); + + /// + /// + /// + public List listunitsections + { + get + { + return _listunitsections; + } + set + { + _listunitsections=value; + } + } + + + /// + ///Свойство для получения количества всех подузлов без элементов поля типа List + /// + public override Int32 subnodes_without_list_elements_count + { + get + { + return 0; + } + } + /// + ///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List + /// + public override Int32 subnodes_count + { + get + { + return 0 + (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(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(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); + } + + } + + } diff --git a/SyntaxTree/tree/TreeHelper.cs b/SyntaxTree/tree/TreeHelper.cs index 6797728f9..13291db64 100644 --- a/SyntaxTree/tree/TreeHelper.cs +++ b/SyntaxTree/tree/TreeHelper.cs @@ -1663,5 +1663,21 @@ namespace PascalABCCompiler.SyntaxTree } } + public partial class uses_closure + { + public uses_closure(uses_list st, SourceContext sc) + { + Add(st, sc); + } + public uses_closure Add(uses_list ul, SourceContext sc = null) + { + listunitsections.Add(ul); + if (sc != null) + source_context = sc; + return this; + } + } + + } diff --git a/SyntaxTree/tree/Visitor.cs b/SyntaxTree/tree/Visitor.cs index 3e30e3f66..1716abb8a 100644 --- a/SyntaxTree/tree/Visitor.cs +++ b/SyntaxTree/tree/Visitor.cs @@ -1252,6 +1252,12 @@ namespace PascalABCCompiler.SyntaxTree ///Node to visit /// Return value is void void visit(tuple_node_for_formatter _tuple_node_for_formatter); + /// + ///Method to visit uses_closure. + /// + ///Node to visit + /// Return value is void + void visit(uses_closure _uses_closure); } diff --git a/SyntaxTree/tree/tree.nin b/SyntaxTree/tree/tree.nin index 9137d4eaf..1686d2370 100644 Binary files a/SyntaxTree/tree/tree.nin and b/SyntaxTree/tree/tree.nin differ diff --git a/TestSuite/CompilationSamples/PABCSystem.pas b/TestSuite/CompilationSamples/PABCSystem.pas index 4d15bf868..d75a2b416 100644 --- a/TestSuite/CompilationSamples/PABCSystem.pas +++ b/TestSuite/CompilationSamples/PABCSystem.pas @@ -1574,16 +1574,19 @@ function ReadSeqString(const prompt: string; n: integer): sequence of string; // ----------------------------------------------------- // Tuples // ----------------------------------------------------- -/// Возвращает кортеж из 2 элементов -function Rec(x1: T1; x2: T2): Tuple; -/// Возвращает кортеж из 3 элементов -function Rec(x1: T1; x2: T2; x3: T3): Tuple; -/// Возвращает кортеж из 4 элементов -function Rec(x1: T1; x2: T2; x3: T3; x4: T4): Tuple; -/// Возвращает кортеж из 5 элементов -function Rec(x1: T1; x2: T2; x3: T3; x4: T4; x5: T5): Tuple; -/// Возвращает кортеж из 6 элементов -function Rec(x1: T1; x2: T2; x3: T3; x4: T4; x5: T5; x6: T6): Tuple; +///- function Rec(x1: T1, x2: T2,...): (T1,T2,...); +/// Возвращает кортеж из элементов разных типов +function Rec(x1: T1; x2: T2): System.Tuple; +///-- +function Rec(x1: T1; x2: T2; x3: T3): (T1,T2,T3); +///-- +function Rec(x1: T1; x2: T2; x3: T3; x4: T4): (T1,T2,T3,T4); +///-- +function Rec(x1: T1; x2: T2; x3: T3; x4: T4; x5: T5): (T1,T2,T3,T4,T5); +///-- +function Rec(x1: T1; x2: T2; x3: T3; x4: T4; x5: T5; x6: T6): (T1,T2,T3,T4,T5,T6); +///-- +function Rec(x1: T1; x2: T2; x3: T3; x4: T4; x5: T5; x6: T6; x7: T7): (T1,T2,T3,T4,T5,T6,T7); // ----------------------------------------------------- // Dict, SSet, HSet, Lst // ----------------------------------------------------- @@ -3724,31 +3727,36 @@ begin end; -function Rec(x1: T1; x2: T2): Tuple; +function Rec(x1: T1; x2: T2): System.Tuple; begin Result := Tuple.Create(x1,x2); end; -function Rec(x1: T1; x2: T2; x3: T3): Tuple; +function Rec(x1: T1; x2: T2; x3: T3): (T1,T2,T3); begin Result := Tuple.Create(x1,x2,x3); end; -function Rec(x1: T1; x2: T2; x3: T3; x4: T4): Tuple; +function Rec(x1: T1; x2: T2; x3: T3; x4: T4): (T1,T2,T3,T4); begin Result := Tuple.Create(x1,x2,x3,x4); end; -function Rec(x1: T1; x2: T2; x3: T3; x4: T4; x5: T5): Tuple; +function Rec(x1: T1; x2: T2; x3: T3; x4: T4; x5: T5): (T1,T2,T3,T4,T5); begin Result := Tuple.Create(x1,x2,x3,x4,x5); end; -function Rec(x1: T1; x2: T2; x3: T3; x4: T4; x5: T5; x6: T6): Tuple; +function Rec(x1: T1; x2: T2; x3: T3; x4: T4; x5: T5; x6: T6): (T1,T2,T3,T4,T5,T6); begin Result := Tuple.Create(x1,x2,x3,x4,x5,x6); end; +function Rec(x1: T1; x2: T2; x3: T3; x4: T4; x5: T5; x6: T6; x7: T7): (T1,T2,T3,T4,T5,T6,T7); +begin + Result := Tuple.Create(x1,x2,x3,x4,x5,x6,x7); +end; + function System.Collections.Generic.IDictionary.Get(K: Key): Value; begin var b := Self.TryGetValue(K,Result); diff --git a/bin/Lib/PABCRtl.dll b/bin/Lib/PABCRtl.dll index 709c60aaf..488d5f3b4 100644 Binary files a/bin/Lib/PABCRtl.dll and b/bin/Lib/PABCRtl.dll differ diff --git a/bin/Lib/PABCSystem.pas b/bin/Lib/PABCSystem.pas index a952f6e63..d75a2b416 100644 --- a/bin/Lib/PABCSystem.pas +++ b/bin/Lib/PABCSystem.pas @@ -1576,7 +1576,7 @@ function ReadSeqString(const prompt: string; n: integer): sequence of string; // ----------------------------------------------------- ///- function Rec(x1: T1, x2: T2,...): (T1,T2,...); /// Возвращает кортеж из элементов разных типов -function Rec(x1: T1; x2: T2): (T1,T2); +function Rec(x1: T1; x2: T2): System.Tuple; ///-- function Rec(x1: T1; x2: T2; x3: T3): (T1,T2,T3); ///-- @@ -3727,7 +3727,7 @@ begin end; -function Rec(x1: T1; x2: T2): (T1,T2); +function Rec(x1: T1; x2: T2): System.Tuple; begin Result := Tuple.Create(x1,x2); end;