From 7c3273aae899f2933885d658d4e545f1388b6de0 Mon Sep 17 00:00:00 2001 From: Mikhalkovich Stanislav Date: Wed, 24 Feb 2021 00:47:39 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9C=D0=BD=D0=BE=D0=B3=D0=BE=D0=BC=D0=B5?= =?UTF-8?q?=D1=80=D0=BD=D1=8B=D0=B5=20=D1=81=D1=80=D0=B5=D0=B7=D1=8B=20?= =?UTF-8?q?=D0=B1=D0=B5=D0=B7=20=D1=81=D0=B5=D0=BC=D0=B0=D0=BD=D1=82=D0=B8?= =?UTF-8?q?=D1=87=D0=B5=D1=81=D0=BA=D0=B8=D1=85=20=D0=BF=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Разрешил a as array [,] of T --- Configuration/GlobalAssemblyInfo.cs | 2 +- Configuration/Version.defs | 2 +- .../PascalABCParserNewSaushkin/ABCPascal.cs | 2 +- .../PascalABCParserNewSaushkin/ABCPascal.y | 33 + .../ABCPascalYacc.cs | 4095 +++++++++-------- Parsers/PascalABCParserNewSaushkin/PABC.ymc | 4 + Release/pabcversion.txt | 2 +- ReleaseGenerators/PascalABCNET_version.nsh | 2 +- SyntaxTree/tree/TreeHelper.cs | 2 +- .../SugarVisitors/SliceDesugarVisitor.cs | 53 +- TestSuite/CompilationSamples/PABCSystem.pas | 258 ++ bin/Lib/PABCSystem.pas | 258 ++ 12 files changed, 2674 insertions(+), 2039 deletions(-) diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index 445719d67..f87253f13 100644 --- a/Configuration/GlobalAssemblyInfo.cs +++ b/Configuration/GlobalAssemblyInfo.cs @@ -15,7 +15,7 @@ internal static class RevisionClass public const string Major = "3"; public const string Minor = "7"; public const string Build = "2"; - public const string Revision = "2823"; + public const string Revision = "2827"; public const string MainVersion = Major + "." + Minor; public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision; diff --git a/Configuration/Version.defs b/Configuration/Version.defs index e1e48041c..e6c0dfcf7 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ %MINOR%=7 -%REVISION%=2823 +%REVISION%=2827 %COREVERSION%=2 %MAJOR%=3 diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs index 8f03a8007..feefc36e4 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: DESKTOP-G8V08V4 -// DateTime: 22.02.2021 17:50:28 +// DateTime: 24.02.2021 0:24:55 // UserName: ????????? // GPLEX input file // GPLEX frame file diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.y b/Parsers/PascalABCParserNewSaushkin/ABCPascal.y index 64197e76b..02ed0746a 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascal.y +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascal.y @@ -3907,6 +3907,10 @@ as_expr { $$ = NewAsIsExpr($1, op_typecast.as_op, $3, @$); } + | term tkAs array_type + { + $$ = NewAsIsExpr($1, op_typecast.as_op, $3, @$); + } ; is_type_expr @@ -3914,6 +3918,10 @@ is_type_expr { $$ = NewAsIsExpr($1, op_typecast.is_op, $3, @$); } + | term tkIs array_type + { + $$ = NewAsIsExpr($1, op_typecast.as_op, $3, @$); + } ; power_expr @@ -4159,6 +4167,31 @@ variable } $$ = new slice_expr($1 as addressed_value,fe.expr,fe.format1,fe.format2,@$); } + // + else if (el.expressions.Any(e => e is format_expr)) + { + var ll = new List>(); + foreach (var ex in el.expressions) + { + if (ex is format_expr fe) + { + if (fe.expr == null) + fe.expr = new int32_const(int.MaxValue, fe.source_context); + if (fe.format1 == null) + fe.format1 = new int32_const(int.MaxValue, fe.source_context); + if (fe.format2 == null) + fe.format2 = new int32_const(1, fe.source_context); + ll.Add(Tuple.Create(fe.expr, fe.format1, fe.format2)); + } + else + { + ll.Add(Tuple.Create(ex, ex, (expression)new int32_const(int.MaxValue, ex.source_context))); // + } + } + var sle = new slice_expr($1 as addressed_value,null,null,null,@$); + sle.slices = ll; + $$ = sle; + } else $$ = new indexer($1 as addressed_value, el, @$); } | variable_or_literal_or_number tkQuestionSquareOpen format_expr tkSquareClose diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs index c40b17890..a61fefb8c 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs @@ -2,7 +2,7 @@ // GPPG version 1.3.6 // Machine: DESKTOP-G8V08V4 -// DateTime: 22.02.2021 17:50:29 +// DateTime: 24.02.2021 0:24:55 // UserName: ????????? // Input file @@ -76,8 +76,8 @@ public partial class GPPGParser: ShiftReduceParser aliasses; #pragma warning restore 649 - private static Rule[] rules = new Rule[988]; - private static State[] states = new State[1638]; + private static Rule[] rules = new Rule[990]; + private static State[] states = new State[1640]; private static string[] nonTerms = new string[] { "parse_goal", "unit_key_word", "class_or_static", "assignment", "optional_array_initializer", "attribute_declarations", "ot_visibility_specifier", "one_attribute", "attribute_variable", @@ -168,13 +168,13 @@ public partial class GPPGParser: ShiftReduceParser term, tkIs, simple_or_template_type_reference + case 722: // as_expr -> term, tkAs, array_type +{ + CurrentSemanticValue.ex = NewAsIsExpr(ValueStack[ValueStack.Depth-3].ex, op_typecast.as_op, ValueStack[ValueStack.Depth-1].td, CurrentLocationSpan); + } + break; + case 723: // is_type_expr -> term, tkIs, simple_or_template_type_reference { CurrentSemanticValue.ex = NewAsIsExpr(ValueStack[ValueStack.Depth-3].ex, op_typecast.is_op, ValueStack[ValueStack.Depth-1].td, CurrentLocationSpan); } break; - case 723: // power_expr -> factor_without_unary_op, tkStarStar, factor + case 724: // is_type_expr -> term, tkIs, array_type +{ + CurrentSemanticValue.ex = NewAsIsExpr(ValueStack[ValueStack.Depth-3].ex, op_typecast.as_op, ValueStack[ValueStack.Depth-1].td, CurrentLocationSpan); + } + break; + case 725: // power_expr -> factor_without_unary_op, tkStarStar, factor { CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth-3].ex,ValueStack[ValueStack.Depth-1].ex,(ValueStack[ValueStack.Depth-2].op).type, CurrentLocationSpan); } break; - case 724: // power_expr -> factor_without_unary_op, tkStarStar, power_expr + case 726: // power_expr -> factor_without_unary_op, tkStarStar, power_expr { CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth-3].ex,ValueStack[ValueStack.Depth-1].ex,(ValueStack[ValueStack.Depth-2].op).type, CurrentLocationSpan); } break; - case 725: // power_expr -> sign, power_expr + case 727: // power_expr -> sign, power_expr { CurrentSemanticValue.ex = new un_expr(ValueStack[ValueStack.Depth-1].ex, ValueStack[ValueStack.Depth-2].op.type, CurrentLocationSpan); } break; - case 726: // term -> factor + case 728: // term -> factor { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 727: // term -> new_expr + case 729: // term -> new_expr { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 728: // term -> power_expr + case 730: // term -> power_expr { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 729: // term -> term, mulop, factor + case 731: // term -> term, mulop, factor { CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth-3].ex,ValueStack[ValueStack.Depth-1].ex,(ValueStack[ValueStack.Depth-2].op).type, CurrentLocationSpan); } break; - case 730: // term -> term, mulop, power_expr + case 732: // term -> term, mulop, power_expr { CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth-3].ex,ValueStack[ValueStack.Depth-1].ex,(ValueStack[ValueStack.Depth-2].op).type, CurrentLocationSpan); } break; - case 731: // term -> term, mulop, new_question_expr + case 733: // term -> term, mulop, new_question_expr { CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth-3].ex,ValueStack[ValueStack.Depth-1].ex,(ValueStack[ValueStack.Depth-2].op).type, CurrentLocationSpan); } break; - case 732: // term -> as_is_expr + case 734: // term -> as_is_expr { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 733: // mulop -> tkStar + case 735: // mulop -> tkStar { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 734: // mulop -> tkSlash + case 736: // mulop -> tkSlash { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 735: // mulop -> tkDiv + case 737: // mulop -> tkDiv { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 736: // mulop -> tkMod + case 738: // mulop -> tkMod { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 737: // mulop -> tkShl + case 739: // mulop -> tkShl { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 738: // mulop -> tkShr + case 740: // mulop -> tkShr { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 739: // mulop -> tkAnd + case 741: // mulop -> tkAnd { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 740: // default_expr -> tkDefault, tkRoundOpen, simple_or_template_type_reference, + case 742: // default_expr -> tkDefault, tkRoundOpen, simple_or_template_type_reference, // tkRoundClose { CurrentSemanticValue.ex = new default_operator(ValueStack[ValueStack.Depth-2].td as named_type_reference, CurrentLocationSpan); } break; - case 741: // tuple -> tkRoundOpen, expr_l1, tkComma, expr_l1_list, lambda_type_ref, + case 743: // tuple -> tkRoundOpen, expr_l1, tkComma, expr_l1_list, lambda_type_ref, // optional_full_lambda_fp_list, tkRoundClose { /*if ($5 != null) @@ -6397,35 +6411,35 @@ public partial class GPPGParser: ShiftReduceParser literal_or_number + case 744: // factor_without_unary_op -> literal_or_number { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 743: // factor_without_unary_op -> var_reference + case 745: // factor_without_unary_op -> var_reference { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 744: // factor -> tkNil + case 746: // factor -> tkNil { CurrentSemanticValue.ex = new nil_const(); CurrentSemanticValue.ex.source_context = CurrentLocationSpan; } break; - case 745: // factor -> literal_or_number + case 747: // factor -> literal_or_number { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 746: // factor -> default_expr + case 748: // factor -> default_expr { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 747: // factor -> tkSquareOpen, elem_list, tkSquareClose + case 749: // factor -> tkSquareOpen, elem_list, tkSquareClose { CurrentSemanticValue.ex = new pascal_set_constant(ValueStack[ValueStack.Depth-2].stn as expression_list, CurrentLocationSpan); } break; - case 748: // factor -> tkNot, factor + case 750: // factor -> tkNot, factor { CurrentSemanticValue.ex = new un_expr(ValueStack[ValueStack.Depth-1].ex, ValueStack[ValueStack.Depth-2].op.type, CurrentLocationSpan); } break; - case 749: // factor -> sign, factor + case 751: // factor -> sign, factor { if (ValueStack[ValueStack.Depth-2].op.type == Operators.Minus) { @@ -6451,96 +6465,96 @@ public partial class GPPGParser: ShiftReduceParser tkDeref, factor + case 752: // factor -> tkDeref, factor { CurrentSemanticValue.ex = new index(ValueStack[ValueStack.Depth-1].ex, true, CurrentLocationSpan); } break; - case 751: // factor -> var_reference + case 753: // factor -> var_reference { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 752: // factor -> tuple + case 754: // factor -> tuple { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 753: // literal_or_number -> literal + case 755: // literal_or_number -> literal { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 754: // literal_or_number -> unsigned_number + case 756: // literal_or_number -> unsigned_number { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 755: // var_question_point -> variable, tkQuestionPoint, variable + case 757: // var_question_point -> variable, tkQuestionPoint, variable { CurrentSemanticValue.ex = new dot_question_node(ValueStack[ValueStack.Depth-3].ex as addressed_value,ValueStack[ValueStack.Depth-1].ex as addressed_value,CurrentLocationSpan); } break; - case 756: // var_question_point -> variable, tkQuestionPoint, var_question_point + case 758: // var_question_point -> variable, tkQuestionPoint, var_question_point { CurrentSemanticValue.ex = new dot_question_node(ValueStack[ValueStack.Depth-3].ex as addressed_value,ValueStack[ValueStack.Depth-1].ex as addressed_value,CurrentLocationSpan); } break; - case 757: // var_reference -> var_address, variable + case 759: // var_reference -> var_address, variable { CurrentSemanticValue.ex = NewVarReference(ValueStack[ValueStack.Depth-2].stn as get_address, ValueStack[ValueStack.Depth-1].ex as addressed_value, CurrentLocationSpan); } break; - case 758: // var_reference -> variable + case 760: // var_reference -> variable { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 759: // var_reference -> var_question_point + case 761: // var_reference -> var_question_point { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 760: // var_address -> tkAddressOf + case 762: // var_address -> tkAddressOf { CurrentSemanticValue.stn = NewVarAddress(CurrentLocationSpan); } break; - case 761: // var_address -> var_address, tkAddressOf + case 763: // var_address -> var_address, tkAddressOf { CurrentSemanticValue.stn = NewVarAddress(ValueStack[ValueStack.Depth-2].stn as get_address, CurrentLocationSpan); } break; - case 762: // attribute_variable -> simple_type_identifier, optional_expr_list_with_bracket + case 764: // attribute_variable -> simple_type_identifier, optional_expr_list_with_bracket { CurrentSemanticValue.stn = new attribute(null, ValueStack[ValueStack.Depth-2].td as named_type_reference, ValueStack[ValueStack.Depth-1].stn as expression_list, CurrentLocationSpan); } break; - case 763: // attribute_variable -> template_type, optional_expr_list_with_bracket + case 765: // attribute_variable -> template_type, optional_expr_list_with_bracket { CurrentSemanticValue.stn = new attribute(null, ValueStack[ValueStack.Depth-2].td as named_type_reference, ValueStack[ValueStack.Depth-1].stn as expression_list, CurrentLocationSpan); } break; - case 764: // dotted_identifier -> identifier + case 766: // dotted_identifier -> identifier { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].id; } break; - case 765: // dotted_identifier -> dotted_identifier, tkPoint, identifier_or_keyword + case 767: // dotted_identifier -> dotted_identifier, tkPoint, identifier_or_keyword { CurrentSemanticValue.ex = new dot_node(ValueStack[ValueStack.Depth-3].ex as addressed_value, ValueStack[ValueStack.Depth-1].id as addressed_value, CurrentLocationSpan); } break; - case 766: // variable_as_type -> dotted_identifier + case 768: // variable_as_type -> dotted_identifier { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex;} break; - case 767: // variable_as_type -> dotted_identifier, template_type_params + case 769: // variable_as_type -> dotted_identifier, template_type_params { CurrentSemanticValue.ex = new ident_with_templateparams(ValueStack[ValueStack.Depth-2].ex as addressed_value, ValueStack[ValueStack.Depth-1].stn as template_param_list, CurrentLocationSpan); } break; - case 768: // variable_or_literal_or_number -> variable + case 770: // variable_or_literal_or_number -> variable { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 769: // variable_or_literal_or_number -> literal_or_number + case 771: // variable_or_literal_or_number -> literal_or_number { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 770: // variable -> identifier + case 772: // variable -> identifier { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].id; } break; - case 771: // variable -> operator_name_ident + case 773: // variable -> operator_name_ident { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 772: // variable -> tkInherited, identifier + case 774: // variable -> tkInherited, identifier { CurrentSemanticValue.ex = new inherited_ident(ValueStack[ValueStack.Depth-1].id.name, CurrentLocationSpan); } break; - case 773: // variable -> tkRoundOpen, expr, tkRoundClose + case 775: // variable -> tkRoundOpen, expr, tkRoundClose { if (!parsertools.build_tree_for_formatter) { @@ -6550,18 +6564,18 @@ public partial class GPPGParser: ShiftReduceParser sizeof_expr + case 776: // variable -> sizeof_expr { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 775: // variable -> typeof_expr + case 777: // variable -> typeof_expr { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 776: // variable -> literal_or_number, tkPoint, identifier_or_keyword + case 778: // variable -> literal_or_number, tkPoint, identifier_or_keyword { CurrentSemanticValue.ex = new dot_node(ValueStack[ValueStack.Depth-3].ex as addressed_value, ValueStack[ValueStack.Depth-1].id as addressed_value, CurrentLocationSpan); } break; - case 777: // variable -> variable_or_literal_or_number, tkSquareOpen, expr_list, + case 779: // variable -> variable_or_literal_or_number, tkSquareOpen, expr_list, // tkSquareClose { var el = ValueStack[ValueStack.Depth-2].stn as expression_list; // SSM 10/03/16 @@ -6577,10 +6591,35 @@ public partial class GPPGParser: ShiftReduceParser e is format_expr)) + { + var ll = new List>(); + foreach (var ex in el.expressions) + { + if (ex is format_expr fe) + { + if (fe.expr == null) + fe.expr = new int32_const(int.MaxValue, fe.source_context); + if (fe.format1 == null) + fe.format1 = new int32_const(int.MaxValue, fe.source_context); + if (fe.format2 == null) + fe.format2 = new int32_const(1, fe.source_context); + ll.Add(Tuple.Create(fe.expr, fe.format1, fe.format2)); + } + else + { + ll.Add(Tuple.Create(ex, ex, (expression)new int32_const(int.MaxValue, ex.source_context))); // ��������� �������� ������ ����� + } + } + var sle = new slice_expr(ValueStack[ValueStack.Depth-4].ex as addressed_value,null,null,null,CurrentLocationSpan); + sle.slices = ll; + CurrentSemanticValue.ex = sle; + } else CurrentSemanticValue.ex = new indexer(ValueStack[ValueStack.Depth-4].ex as addressed_value, el, CurrentLocationSpan); } break; - case 778: // variable -> variable_or_literal_or_number, tkQuestionSquareOpen, format_expr, + case 780: // variable -> variable_or_literal_or_number, tkQuestionSquareOpen, format_expr, // tkSquareClose { var fe = ValueStack[ValueStack.Depth-2].ex as format_expr; // SSM 9/01/17 @@ -6594,76 +6633,76 @@ public partial class GPPGParser: ShiftReduceParser tkVertParen, elem_list, tkVertParen + case 781: // variable -> tkVertParen, elem_list, tkVertParen { CurrentSemanticValue.ex = new array_const_new(ValueStack[ValueStack.Depth-2].stn as expression_list, CurrentLocationSpan); } break; - case 780: // variable -> variable, tkRoundOpen, optional_expr_list, tkRoundClose + case 782: // variable -> variable, tkRoundOpen, optional_expr_list, tkRoundClose { CurrentSemanticValue.ex = new method_call(ValueStack[ValueStack.Depth-4].ex as addressed_value,ValueStack[ValueStack.Depth-2].stn as expression_list, CurrentLocationSpan); } break; - case 781: // variable -> variable, tkPoint, identifier_keyword_operatorname + case 783: // variable -> variable, tkPoint, identifier_keyword_operatorname { CurrentSemanticValue.ex = new dot_node(ValueStack[ValueStack.Depth-3].ex as addressed_value, ValueStack[ValueStack.Depth-1].id as addressed_value, CurrentLocationSpan); } break; - case 782: // variable -> tuple, tkPoint, identifier_keyword_operatorname + case 784: // variable -> tuple, tkPoint, identifier_keyword_operatorname { CurrentSemanticValue.ex = new dot_node(ValueStack[ValueStack.Depth-3].ex as addressed_value, ValueStack[ValueStack.Depth-1].id as addressed_value, CurrentLocationSpan); } break; - case 783: // variable -> variable, tkDeref + case 785: // variable -> variable, tkDeref { CurrentSemanticValue.ex = new roof_dereference(ValueStack[ValueStack.Depth-2].ex as addressed_value,CurrentLocationSpan); } break; - case 784: // variable -> variable, tkAmpersend, template_type_params + case 786: // variable -> variable, tkAmpersend, template_type_params { CurrentSemanticValue.ex = new ident_with_templateparams(ValueStack[ValueStack.Depth-3].ex as addressed_value, ValueStack[ValueStack.Depth-1].stn as template_param_list, CurrentLocationSpan); } break; - case 785: // optional_expr_list -> expr_list + case 787: // optional_expr_list -> expr_list { CurrentSemanticValue.stn = ValueStack[ValueStack.Depth-1].stn; } break; - case 786: // optional_expr_list -> /* empty */ + case 788: // optional_expr_list -> /* empty */ { CurrentSemanticValue.stn = null; } break; - case 787: // elem_list -> elem_list1 + case 789: // elem_list -> elem_list1 { CurrentSemanticValue.stn = ValueStack[ValueStack.Depth-1].stn; } break; - case 788: // elem_list -> /* empty */ + case 790: // elem_list -> /* empty */ { CurrentSemanticValue.stn = null; } break; - case 789: // elem_list1 -> elem + case 791: // elem_list1 -> elem { CurrentSemanticValue.stn = new expression_list(ValueStack[ValueStack.Depth-1].ex, CurrentLocationSpan); } break; - case 790: // elem_list1 -> elem_list1, tkComma, elem + case 792: // elem_list1 -> elem_list1, tkComma, elem { CurrentSemanticValue.stn = (ValueStack[ValueStack.Depth-3].stn as expression_list).Add(ValueStack[ValueStack.Depth-1].ex, CurrentLocationSpan); } break; - case 791: // elem -> expr + case 793: // elem -> expr { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 792: // elem -> expr, tkDotDot, expr + case 794: // elem -> expr, tkDotDot, expr { CurrentSemanticValue.ex = new diapason_expr(ValueStack[ValueStack.Depth-3].ex, ValueStack[ValueStack.Depth-1].ex, CurrentLocationSpan); } break; - case 793: // one_literal -> tkStringLiteral + case 795: // one_literal -> tkStringLiteral { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].stn as literal; } break; - case 794: // one_literal -> tkAsciiChar + case 796: // one_literal -> tkAsciiChar { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].stn as literal; } break; - case 795: // literal -> literal_list + case 797: // literal -> literal_list { CurrentSemanticValue.ex = NewLiteral(ValueStack[ValueStack.Depth-1].stn as literal_const_line); } break; - case 796: // literal -> tkFormatStringLiteral + case 798: // literal -> tkFormatStringLiteral { if (parsertools.build_tree_for_formatter) { @@ -6675,12 +6714,12 @@ public partial class GPPGParser: ShiftReduceParser one_literal + case 799: // literal_list -> one_literal { CurrentSemanticValue.stn = new literal_const_line(ValueStack[ValueStack.Depth-1].ex as literal, CurrentLocationSpan); } break; - case 798: // literal_list -> literal_list, one_literal + case 800: // literal_list -> literal_list, one_literal { var line = ValueStack[ValueStack.Depth-2].stn as literal_const_line; if (line.literals.Last() is string_const && ValueStack[ValueStack.Depth-1].ex is string_const) @@ -6688,475 +6727,475 @@ public partial class GPPGParser: ShiftReduceParser tkOperator, overload_operator + case 801: // operator_name_ident -> tkOperator, overload_operator { CurrentSemanticValue.ex = new operator_name_ident((ValueStack[ValueStack.Depth-1].op as op_type_node).text, (ValueStack[ValueStack.Depth-1].op as op_type_node).type, CurrentLocationSpan); } break; - case 800: // optional_method_modificators -> tkSemiColon + case 802: // optional_method_modificators -> tkSemiColon { CurrentSemanticValue.stn = new procedure_attributes_list(new List(),CurrentLocationSpan); } break; - case 801: // optional_method_modificators -> tkSemiColon, meth_modificators, tkSemiColon + case 803: // optional_method_modificators -> tkSemiColon, meth_modificators, tkSemiColon { //parsertools.AddModifier((procedure_attributes_list)$2, proc_attribute.attr_overload); CurrentSemanticValue.stn = ValueStack[ValueStack.Depth-2].stn; } break; - case 802: // optional_method_modificators1 -> /* empty */ + case 804: // optional_method_modificators1 -> /* empty */ { CurrentSemanticValue.stn = new procedure_attributes_list(new List(),CurrentLocationSpan); } break; - case 803: // optional_method_modificators1 -> tkSemiColon, meth_modificators + case 805: // optional_method_modificators1 -> tkSemiColon, meth_modificators { //parsertools.AddModifier((procedure_attributes_list)$2, proc_attribute.attr_overload); CurrentSemanticValue.stn = ValueStack[ValueStack.Depth-1].stn; } break; - case 804: // meth_modificators -> meth_modificator + case 806: // meth_modificators -> meth_modificator { CurrentSemanticValue.stn = new procedure_attributes_list(ValueStack[ValueStack.Depth-1].id as procedure_attribute, CurrentLocationSpan); } break; - case 805: // meth_modificators -> meth_modificators, tkSemiColon, meth_modificator + case 807: // meth_modificators -> meth_modificators, tkSemiColon, meth_modificator { CurrentSemanticValue.stn = (ValueStack[ValueStack.Depth-3].stn as procedure_attributes_list).Add(ValueStack[ValueStack.Depth-1].id as procedure_attribute, CurrentLocationSpan); } break; - case 806: // identifier -> tkIdentifier + case 808: // identifier -> tkIdentifier { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 807: // identifier -> property_specifier_directives + case 809: // identifier -> property_specifier_directives { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 808: // identifier -> non_reserved + case 810: // identifier -> non_reserved { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 809: // identifier_or_keyword -> identifier + case 811: // identifier_or_keyword -> identifier { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 810: // identifier_or_keyword -> keyword + case 812: // identifier_or_keyword -> keyword { CurrentSemanticValue.id = new ident(ValueStack[ValueStack.Depth-1].ti.text, CurrentLocationSpan); } break; - case 811: // identifier_or_keyword -> reserved_keyword + case 813: // identifier_or_keyword -> reserved_keyword { CurrentSemanticValue.id = new ident(ValueStack[ValueStack.Depth-1].ti.text, CurrentLocationSpan); } break; - case 812: // identifier_keyword_operatorname -> identifier + case 814: // identifier_keyword_operatorname -> identifier { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 813: // identifier_keyword_operatorname -> keyword + case 815: // identifier_keyword_operatorname -> keyword { CurrentSemanticValue.id = new ident(ValueStack[ValueStack.Depth-1].ti.text, CurrentLocationSpan); } break; - case 814: // identifier_keyword_operatorname -> operator_name_ident + case 816: // identifier_keyword_operatorname -> operator_name_ident { CurrentSemanticValue.id = (ident)ValueStack[ValueStack.Depth-1].ex; } break; - case 815: // meth_modificator -> tkAbstract + case 817: // meth_modificator -> tkAbstract { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 816: // meth_modificator -> tkOverload + case 818: // meth_modificator -> tkOverload { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; parsertools.AddWarningFromResource("OVERLOAD_IS_NOT_USED", ValueStack[ValueStack.Depth-1].id.source_context); } break; - case 817: // meth_modificator -> tkReintroduce + case 819: // meth_modificator -> tkReintroduce { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 818: // meth_modificator -> tkOverride + case 820: // meth_modificator -> tkOverride { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 819: // meth_modificator -> tkExtensionMethod + case 821: // meth_modificator -> tkExtensionMethod { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 820: // meth_modificator -> tkVirtual + case 822: // meth_modificator -> tkVirtual { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 821: // property_modificator -> tkVirtual + case 823: // property_modificator -> tkVirtual { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 822: // property_modificator -> tkOverride + case 824: // property_modificator -> tkOverride { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 823: // property_modificator -> tkAbstract + case 825: // property_modificator -> tkAbstract { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 824: // property_modificator -> tkReintroduce + case 826: // property_modificator -> tkReintroduce { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 825: // property_specifier_directives -> tkRead + case 827: // property_specifier_directives -> tkRead { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 826: // property_specifier_directives -> tkWrite + case 828: // property_specifier_directives -> tkWrite { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 827: // non_reserved -> tkName + case 829: // non_reserved -> tkName { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 828: // non_reserved -> tkNew + case 830: // non_reserved -> tkNew { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 829: // visibility_specifier -> tkInternal + case 831: // visibility_specifier -> tkInternal { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 830: // visibility_specifier -> tkPublic + case 832: // visibility_specifier -> tkPublic { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 831: // visibility_specifier -> tkProtected + case 833: // visibility_specifier -> tkProtected { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 832: // visibility_specifier -> tkPrivate + case 834: // visibility_specifier -> tkPrivate { CurrentSemanticValue.id = ValueStack[ValueStack.Depth-1].id; } break; - case 833: // keyword -> visibility_specifier + case 835: // keyword -> visibility_specifier { CurrentSemanticValue.ti = new token_info(ValueStack[ValueStack.Depth-1].id.name, CurrentLocationSpan); } break; - case 834: // keyword -> tkSealed + case 836: // keyword -> tkSealed { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 835: // keyword -> tkTemplate + case 837: // keyword -> tkTemplate { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 836: // keyword -> tkOr + case 838: // keyword -> tkOr { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].op; } break; - case 837: // keyword -> tkTypeOf + case 839: // keyword -> tkTypeOf { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 838: // keyword -> tkSizeOf + case 840: // keyword -> tkSizeOf { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 839: // keyword -> tkDefault + case 841: // keyword -> tkDefault { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 840: // keyword -> tkWhere + case 842: // keyword -> tkWhere { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 841: // keyword -> tkXor + case 843: // keyword -> tkXor { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].op; } break; - case 842: // keyword -> tkAnd + case 844: // keyword -> tkAnd { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].op; } break; - case 843: // keyword -> tkDiv + case 845: // keyword -> tkDiv { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].op; } break; - case 844: // keyword -> tkMod + case 846: // keyword -> tkMod { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].op; } break; - case 845: // keyword -> tkShl + case 847: // keyword -> tkShl { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].op; } break; - case 846: // keyword -> tkShr + case 848: // keyword -> tkShr { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].op; } break; - case 847: // keyword -> tkNot + case 849: // keyword -> tkNot { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].op; } break; - case 848: // keyword -> tkAs + case 850: // keyword -> tkAs { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].op; } break; - case 849: // keyword -> tkIn + case 851: // keyword -> tkIn { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].op; } break; - case 850: // keyword -> tkIs + case 852: // keyword -> tkIs { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].op; } break; - case 851: // keyword -> tkArray + case 853: // keyword -> tkArray { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 852: // keyword -> tkSequence + case 854: // keyword -> tkSequence { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 853: // keyword -> tkBegin + case 855: // keyword -> tkBegin { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 854: // keyword -> tkCase + case 856: // keyword -> tkCase { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 855: // keyword -> tkClass + case 857: // keyword -> tkClass { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 856: // keyword -> tkConst + case 858: // keyword -> tkConst { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 857: // keyword -> tkConstructor + case 859: // keyword -> tkConstructor { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 858: // keyword -> tkDestructor + case 860: // keyword -> tkDestructor { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 859: // keyword -> tkDownto + case 861: // keyword -> tkDownto { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 860: // keyword -> tkDo + case 862: // keyword -> tkDo { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 861: // keyword -> tkElse + case 863: // keyword -> tkElse { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 862: // keyword -> tkEnd + case 864: // keyword -> tkEnd { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 863: // keyword -> tkExcept + case 865: // keyword -> tkExcept { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 864: // keyword -> tkFile + case 866: // keyword -> tkFile { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 865: // keyword -> tkAuto + case 867: // keyword -> tkAuto { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 866: // keyword -> tkFinalization + case 868: // keyword -> tkFinalization { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 867: // keyword -> tkFinally + case 869: // keyword -> tkFinally { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 868: // keyword -> tkFor + case 870: // keyword -> tkFor { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 869: // keyword -> tkForeach + case 871: // keyword -> tkForeach { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 870: // keyword -> tkFunction + case 872: // keyword -> tkFunction { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 871: // keyword -> tkIf + case 873: // keyword -> tkIf { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 872: // keyword -> tkImplementation + case 874: // keyword -> tkImplementation { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 873: // keyword -> tkInherited + case 875: // keyword -> tkInherited { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 874: // keyword -> tkInitialization + case 876: // keyword -> tkInitialization { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 875: // keyword -> tkInterface + case 877: // keyword -> tkInterface { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 876: // keyword -> tkProcedure + case 878: // keyword -> tkProcedure { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 877: // keyword -> tkProperty + case 879: // keyword -> tkProperty { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 878: // keyword -> tkRaise + case 880: // keyword -> tkRaise { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 879: // keyword -> tkRecord + case 881: // keyword -> tkRecord { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 880: // keyword -> tkRepeat + case 882: // keyword -> tkRepeat { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 881: // keyword -> tkSet + case 883: // keyword -> tkSet { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 882: // keyword -> tkTry + case 884: // keyword -> tkTry { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 883: // keyword -> tkType + case 885: // keyword -> tkType { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 884: // keyword -> tkStatic + case 886: // keyword -> tkStatic { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 885: // keyword -> tkThen + case 887: // keyword -> tkThen { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 886: // keyword -> tkTo + case 888: // keyword -> tkTo { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 887: // keyword -> tkUntil + case 889: // keyword -> tkUntil { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 888: // keyword -> tkUses + case 890: // keyword -> tkUses { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 889: // keyword -> tkVar + case 891: // keyword -> tkVar { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 890: // keyword -> tkWhile + case 892: // keyword -> tkWhile { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 891: // keyword -> tkWith + case 893: // keyword -> tkWith { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 892: // keyword -> tkNil + case 894: // keyword -> tkNil { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 893: // keyword -> tkGoto + case 895: // keyword -> tkGoto { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 894: // keyword -> tkOf + case 896: // keyword -> tkOf { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 895: // keyword -> tkLabel + case 897: // keyword -> tkLabel { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 896: // keyword -> tkProgram + case 898: // keyword -> tkProgram { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 897: // keyword -> tkUnit + case 899: // keyword -> tkUnit { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 898: // keyword -> tkLibrary + case 900: // keyword -> tkLibrary { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 899: // keyword -> tkNamespace + case 901: // keyword -> tkNamespace { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 900: // keyword -> tkExternal + case 902: // keyword -> tkExternal { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 901: // keyword -> tkParams + case 903: // keyword -> tkParams { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 902: // keyword -> tkEvent + case 904: // keyword -> tkEvent { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 903: // keyword -> tkYield + case 905: // keyword -> tkYield { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 904: // keyword -> tkMatch + case 906: // keyword -> tkMatch { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 905: // keyword -> tkWhen + case 907: // keyword -> tkWhen { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 906: // keyword -> tkPartial + case 908: // keyword -> tkPartial { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 907: // keyword -> tkAbstract + case 909: // keyword -> tkAbstract { CurrentSemanticValue.ti = new token_info(ValueStack[ValueStack.Depth-1].id.name, CurrentLocationSpan); } break; - case 908: // keyword -> tkLock + case 910: // keyword -> tkLock { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 909: // keyword -> tkImplicit + case 911: // keyword -> tkImplicit { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].op; } break; - case 910: // keyword -> tkExplicit + case 912: // keyword -> tkExplicit { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].op; } break; - case 911: // keyword -> tkOn + case 913: // keyword -> tkOn { CurrentSemanticValue.ti = new token_info(ValueStack[ValueStack.Depth-1].id.name, CurrentLocationSpan); } break; - case 912: // keyword -> tkVirtual + case 914: // keyword -> tkVirtual { CurrentSemanticValue.ti = new token_info(ValueStack[ValueStack.Depth-1].id.name, CurrentLocationSpan); } break; - case 913: // keyword -> tkOverride + case 915: // keyword -> tkOverride { CurrentSemanticValue.ti = new token_info(ValueStack[ValueStack.Depth-1].id.name, CurrentLocationSpan); } break; - case 914: // keyword -> tkLoop + case 916: // keyword -> tkLoop { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 915: // keyword -> tkExtensionMethod + case 917: // keyword -> tkExtensionMethod { CurrentSemanticValue.ti = new token_info(ValueStack[ValueStack.Depth-1].id.name, CurrentLocationSpan); } break; - case 916: // keyword -> tkOverload + case 918: // keyword -> tkOverload { CurrentSemanticValue.ti = new token_info(ValueStack[ValueStack.Depth-1].id.name, CurrentLocationSpan); } break; - case 917: // keyword -> tkReintroduce + case 919: // keyword -> tkReintroduce { CurrentSemanticValue.ti = new token_info(ValueStack[ValueStack.Depth-1].id.name, CurrentLocationSpan); } break; - case 918: // keyword -> tkForward + case 920: // keyword -> tkForward { CurrentSemanticValue.ti = new token_info(ValueStack[ValueStack.Depth-1].id.name, CurrentLocationSpan); } break; - case 919: // reserved_keyword -> tkOperator + case 921: // reserved_keyword -> tkOperator { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 920: // overload_operator -> tkMinus + case 922: // overload_operator -> tkMinus { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 921: // overload_operator -> tkPlus + case 923: // overload_operator -> tkPlus { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 922: // overload_operator -> tkSlash + case 924: // overload_operator -> tkSlash { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 923: // overload_operator -> tkStar + case 925: // overload_operator -> tkStar { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 924: // overload_operator -> tkEqual + case 926: // overload_operator -> tkEqual { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 925: // overload_operator -> tkGreater + case 927: // overload_operator -> tkGreater { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 926: // overload_operator -> tkGreaterEqual + case 928: // overload_operator -> tkGreaterEqual { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 927: // overload_operator -> tkLower + case 929: // overload_operator -> tkLower { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 928: // overload_operator -> tkLowerEqual + case 930: // overload_operator -> tkLowerEqual { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 929: // overload_operator -> tkNotEqual + case 931: // overload_operator -> tkNotEqual { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 930: // overload_operator -> tkOr + case 932: // overload_operator -> tkOr { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 931: // overload_operator -> tkXor + case 933: // overload_operator -> tkXor { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 932: // overload_operator -> tkAnd + case 934: // overload_operator -> tkAnd { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 933: // overload_operator -> tkDiv + case 935: // overload_operator -> tkDiv { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 934: // overload_operator -> tkMod + case 936: // overload_operator -> tkMod { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 935: // overload_operator -> tkShl + case 937: // overload_operator -> tkShl { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 936: // overload_operator -> tkShr + case 938: // overload_operator -> tkShr { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 937: // overload_operator -> tkNot + case 939: // overload_operator -> tkNot { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 938: // overload_operator -> tkIn + case 940: // overload_operator -> tkIn { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 939: // overload_operator -> tkImplicit + case 941: // overload_operator -> tkImplicit { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 940: // overload_operator -> tkExplicit + case 942: // overload_operator -> tkExplicit { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 941: // overload_operator -> assign_operator + case 943: // overload_operator -> assign_operator { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 942: // overload_operator -> tkStarStar + case 944: // overload_operator -> tkStarStar { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 943: // assign_operator -> tkAssign + case 945: // assign_operator -> tkAssign { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 944: // assign_operator -> tkPlusEqual + case 946: // assign_operator -> tkPlusEqual { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 945: // assign_operator -> tkMinusEqual + case 947: // assign_operator -> tkMinusEqual { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 946: // assign_operator -> tkMultEqual + case 948: // assign_operator -> tkMultEqual { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 947: // assign_operator -> tkDivEqual + case 949: // assign_operator -> tkDivEqual { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 948: // func_decl_lambda -> identifier, tkArrow, lambda_function_body + case 950: // func_decl_lambda -> identifier, tkArrow, lambda_function_body { var idList = new ident_list(ValueStack[ValueStack.Depth-3].id, LocationStack[LocationStack.Depth-3]); var formalPars = new formal_parameters(new typed_parameters(idList, new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), LocationStack[LocationStack.Depth-3]), parametr_kind.none, null, LocationStack[LocationStack.Depth-3]), LocationStack[LocationStack.Depth-3]); @@ -7167,7 +7206,7 @@ public partial class GPPGParser: ShiftReduceParser tkRoundOpen, tkRoundClose, lambda_type_ref_noproctype, + case 951: // func_decl_lambda -> tkRoundOpen, tkRoundClose, lambda_type_ref_noproctype, // tkArrow, lambda_function_body { // ����� ���� ������������� �� ���� � ���� ��������� lambda_inferred_type, ���� ������ ��� null! @@ -7177,7 +7216,7 @@ public partial class GPPGParser: ShiftReduceParser tkRoundOpen, identifier, tkColon, fptype, tkRoundClose, + case 952: // func_decl_lambda -> tkRoundOpen, identifier, tkColon, fptype, tkRoundClose, // lambda_type_ref_noproctype, tkArrow, lambda_function_body { var idList = new ident_list(ValueStack[ValueStack.Depth-7].id, LocationStack[LocationStack.Depth-7]); @@ -7189,7 +7228,7 @@ public partial class GPPGParser: ShiftReduceParser tkRoundOpen, identifier, tkSemiColon, full_lambda_fp_list, + case 953: // func_decl_lambda -> tkRoundOpen, identifier, tkSemiColon, full_lambda_fp_list, // tkRoundClose, lambda_type_ref_noproctype, tkArrow, // lambda_function_body { @@ -7203,7 +7242,7 @@ public partial class GPPGParser: ShiftReduceParser tkRoundOpen, identifier, tkColon, fptype, tkSemiColon, + case 954: // func_decl_lambda -> tkRoundOpen, identifier, tkColon, fptype, tkSemiColon, // full_lambda_fp_list, tkRoundClose, // lambda_type_ref_noproctype, tkArrow, lambda_function_body { @@ -7218,7 +7257,7 @@ public partial class GPPGParser: ShiftReduceParser tkRoundOpen, expr_l1, tkComma, expr_l1_list, + case 955: // func_decl_lambda -> tkRoundOpen, expr_l1, tkComma, expr_l1_list, // lambda_type_ref, optional_full_lambda_fp_list, // tkRoundClose, rem_lambda { @@ -7287,62 +7326,62 @@ public partial class GPPGParser: ShiftReduceParser expl_func_decl_lambda + case 956: // func_decl_lambda -> expl_func_decl_lambda { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 955: // optional_full_lambda_fp_list -> /* empty */ + case 957: // optional_full_lambda_fp_list -> /* empty */ { CurrentSemanticValue.stn = null; } break; - case 956: // optional_full_lambda_fp_list -> tkSemiColon, full_lambda_fp_list + case 958: // optional_full_lambda_fp_list -> tkSemiColon, full_lambda_fp_list { CurrentSemanticValue.stn = ValueStack[ValueStack.Depth-1].stn; } break; - case 957: // rem_lambda -> lambda_type_ref_noproctype, tkArrow, lambda_function_body + case 959: // rem_lambda -> lambda_type_ref_noproctype, tkArrow, lambda_function_body { CurrentSemanticValue.ob = new pair_type_stlist(ValueStack[ValueStack.Depth-3].td,ValueStack[ValueStack.Depth-1].stn as statement_list); } break; - case 958: // expl_func_decl_lambda -> tkFunction, lambda_type_ref_noproctype, tkArrow, + case 960: // expl_func_decl_lambda -> tkFunction, lambda_type_ref_noproctype, tkArrow, // lambda_function_body { CurrentSemanticValue.ex = new function_lambda_definition(lambdaHelper.CreateLambdaName(), null, ValueStack[ValueStack.Depth-3].td, ValueStack[ValueStack.Depth-1].stn as statement_list, 1, CurrentLocationSpan); } break; - case 959: // expl_func_decl_lambda -> tkFunction, tkRoundOpen, tkRoundClose, + case 961: // expl_func_decl_lambda -> tkFunction, tkRoundOpen, tkRoundClose, // lambda_type_ref_noproctype, tkArrow, // lambda_function_body { CurrentSemanticValue.ex = new function_lambda_definition(lambdaHelper.CreateLambdaName(), null, ValueStack[ValueStack.Depth-3].td, ValueStack[ValueStack.Depth-1].stn as statement_list, 1, CurrentLocationSpan); } break; - case 960: // expl_func_decl_lambda -> tkFunction, tkRoundOpen, full_lambda_fp_list, + case 962: // expl_func_decl_lambda -> tkFunction, tkRoundOpen, full_lambda_fp_list, // tkRoundClose, lambda_type_ref_noproctype, tkArrow, // lambda_function_body { CurrentSemanticValue.ex = new function_lambda_definition(lambdaHelper.CreateLambdaName(), ValueStack[ValueStack.Depth-5].stn as formal_parameters, ValueStack[ValueStack.Depth-3].td, ValueStack[ValueStack.Depth-1].stn as statement_list, 1, CurrentLocationSpan); } break; - case 961: // expl_func_decl_lambda -> tkProcedure, tkArrow, lambda_procedure_body + case 963: // expl_func_decl_lambda -> tkProcedure, tkArrow, lambda_procedure_body { CurrentSemanticValue.ex = new function_lambda_definition(lambdaHelper.CreateLambdaName(), null, null, ValueStack[ValueStack.Depth-1].stn as statement_list, 2, CurrentLocationSpan); } break; - case 962: // expl_func_decl_lambda -> tkProcedure, tkRoundOpen, tkRoundClose, tkArrow, + case 964: // expl_func_decl_lambda -> tkProcedure, tkRoundOpen, tkRoundClose, tkArrow, // lambda_procedure_body { CurrentSemanticValue.ex = new function_lambda_definition(lambdaHelper.CreateLambdaName(), null, null, ValueStack[ValueStack.Depth-1].stn as statement_list, 2, CurrentLocationSpan); } break; - case 963: // expl_func_decl_lambda -> tkProcedure, tkRoundOpen, full_lambda_fp_list, + case 965: // expl_func_decl_lambda -> tkProcedure, tkRoundOpen, full_lambda_fp_list, // tkRoundClose, tkArrow, lambda_procedure_body { CurrentSemanticValue.ex = new function_lambda_definition(lambdaHelper.CreateLambdaName(), ValueStack[ValueStack.Depth-4].stn as formal_parameters, null, ValueStack[ValueStack.Depth-1].stn as statement_list, 2, CurrentLocationSpan); } break; - case 964: // full_lambda_fp_list -> lambda_simple_fp_sect + case 966: // full_lambda_fp_list -> lambda_simple_fp_sect { var typed_pars = ValueStack[ValueStack.Depth-1].stn as typed_parameters; if (typed_pars.vars_type is lambda_inferred_type) @@ -7362,97 +7401,97 @@ public partial class GPPGParser: ShiftReduceParser full_lambda_fp_list, tkSemiColon, lambda_simple_fp_sect + case 967: // full_lambda_fp_list -> full_lambda_fp_list, tkSemiColon, lambda_simple_fp_sect { CurrentSemanticValue.stn =(ValueStack[ValueStack.Depth-3].stn as formal_parameters).Add(ValueStack[ValueStack.Depth-1].stn as typed_parameters, CurrentLocationSpan); } break; - case 966: // lambda_simple_fp_sect -> ident_list, lambda_type_ref + case 968: // lambda_simple_fp_sect -> ident_list, lambda_type_ref { CurrentSemanticValue.stn = new typed_parameters(ValueStack[ValueStack.Depth-2].stn as ident_list, ValueStack[ValueStack.Depth-1].td, parametr_kind.none, null, CurrentLocationSpan); } break; - case 967: // lambda_type_ref -> /* empty */ + case 969: // lambda_type_ref -> /* empty */ { CurrentSemanticValue.td = new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), null); } break; - case 968: // lambda_type_ref -> tkColon, fptype + case 970: // lambda_type_ref -> tkColon, fptype { CurrentSemanticValue.td = ValueStack[ValueStack.Depth-1].td; } break; - case 969: // lambda_type_ref_noproctype -> /* empty */ + case 971: // lambda_type_ref_noproctype -> /* empty */ { CurrentSemanticValue.td = new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), null); } break; - case 970: // lambda_type_ref_noproctype -> tkColon, fptype_noproctype + case 972: // lambda_type_ref_noproctype -> tkColon, fptype_noproctype { CurrentSemanticValue.td = ValueStack[ValueStack.Depth-1].td; } break; - case 971: // common_lambda_body -> compound_stmt + case 973: // common_lambda_body -> compound_stmt { CurrentSemanticValue.stn = ValueStack[ValueStack.Depth-1].stn; } break; - case 972: // common_lambda_body -> if_stmt + case 974: // common_lambda_body -> if_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 973: // common_lambda_body -> while_stmt + case 975: // common_lambda_body -> while_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 974: // common_lambda_body -> repeat_stmt + case 976: // common_lambda_body -> repeat_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 975: // common_lambda_body -> for_stmt + case 977: // common_lambda_body -> for_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 976: // common_lambda_body -> foreach_stmt + case 978: // common_lambda_body -> foreach_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 977: // common_lambda_body -> loop_stmt + case 979: // common_lambda_body -> loop_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 978: // common_lambda_body -> case_stmt + case 980: // common_lambda_body -> case_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 979: // common_lambda_body -> try_stmt + case 981: // common_lambda_body -> try_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 980: // common_lambda_body -> lock_stmt + case 982: // common_lambda_body -> lock_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 981: // common_lambda_body -> raise_stmt + case 983: // common_lambda_body -> raise_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 982: // common_lambda_body -> yield_stmt + case 984: // common_lambda_body -> yield_stmt { parsertools.AddErrorFromResource("YIELD_STATEMENT_CANNOT_BE_USED_IN_LAMBDA_BODY", CurrentLocationSpan); } break; - case 983: // lambda_function_body -> expr_l1_for_lambda + case 985: // lambda_function_body -> expr_l1_for_lambda { var id = SyntaxVisitors.HasNameVisitor.HasName(ValueStack[ValueStack.Depth-1].ex, "Result"); if (id != null) @@ -7464,22 +7503,22 @@ public partial class GPPGParser: ShiftReduceParser common_lambda_body + case 986: // lambda_function_body -> common_lambda_body { CurrentSemanticValue.stn = ValueStack[ValueStack.Depth-1].stn; } break; - case 985: // lambda_procedure_body -> proc_call + case 987: // lambda_procedure_body -> proc_call { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 986: // lambda_procedure_body -> assignment + case 988: // lambda_procedure_body -> assignment { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 987: // lambda_procedure_body -> common_lambda_body + case 989: // lambda_procedure_body -> common_lambda_body { CurrentSemanticValue.stn = ValueStack[ValueStack.Depth-1].stn; } diff --git a/Parsers/PascalABCParserNewSaushkin/PABC.ymc b/Parsers/PascalABCParserNewSaushkin/PABC.ymc index 59adc3c0a..14cbb81e8 100644 --- a/Parsers/PascalABCParserNewSaushkin/PABC.ymc +++ b/Parsers/PascalABCParserNewSaushkin/PABC.ymc @@ -306,6 +306,10 @@ script= + + + + diff --git a/Release/pabcversion.txt b/Release/pabcversion.txt index 2ab71146e..6c11c5fa8 100644 --- a/Release/pabcversion.txt +++ b/Release/pabcversion.txt @@ -1 +1 @@ -3.7.2.2823 +3.7.2.2827 diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index 48bc84910..7975f41db 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.7.2.2823' +!define VERSION '3.7.2.2827' diff --git a/SyntaxTree/tree/TreeHelper.cs b/SyntaxTree/tree/TreeHelper.cs index daddd8232..e0e94409a 100644 --- a/SyntaxTree/tree/TreeHelper.cs +++ b/SyntaxTree/tree/TreeHelper.cs @@ -1769,7 +1769,7 @@ namespace PascalABCCompiler.SyntaxTree public partial class slice_expr { - public List> slices = new List>(); + public List> slices; // = new List>(); public override string ToString() => this.v + "[" + this.from + ":" + this.to + ":" + this.step + "]"; } diff --git a/SyntaxVisitors/SugarVisitors/SliceDesugarVisitor.cs b/SyntaxVisitors/SugarVisitors/SliceDesugarVisitor.cs index d492b08ea..436eb1d3e 100644 --- a/SyntaxVisitors/SugarVisitors/SliceDesugarVisitor.cs +++ b/SyntaxVisitors/SugarVisitors/SliceDesugarVisitor.cs @@ -16,6 +16,26 @@ namespace SyntaxVisitors.SugarVisitors get { return new SliceDesugarVisitor(); } } + expression_list construct_expression_list_for_slice_expr_multi(slice_expr sl) + { + if (sl.slices == null) + return null; // упадёт - это ошибка компилятора + var el = new expression_list(); // будем наполнять кортежами - самое простое + var sc = sl.source_context; + foreach (var slice in sl.slices) + { + var tup = new dot_node(new dot_node(new ident("?System",sc), new ident("Tuple",sc), sc), new ident("Create",sc), sc); + // пока без ^1 + var eel = new expression_list(); + eel.Add(slice.Item1); + eel.Add(slice.Item2); + eel.Add(slice.Item3); + var mc = new method_call(tup, eel, sc); // sc - не очень хорошо - ошибка будет в общем месте + el.Add(mc); + // по идее все параметры готовы. Надо только проверить, что они целые + } + return el; + } expression_list construct_expression_list_for_slice_expr(slice_expr sl) { // situation = 0 - ничего не пропущено @@ -80,9 +100,19 @@ namespace SyntaxVisitors.SugarVisitors public override void visit(slice_expr sl) { - var el = construct_expression_list_for_slice_expr(sl); + expression_list el = null; + if (sl.slices == null) + el = construct_expression_list_for_slice_expr(sl); + else el = construct_expression_list_for_slice_expr_multi(sl); // то это многомерный массив + // надо как-то запретить многомерные слайсы в левой части присваивания if (sl.Parent is assign parent_assign && parent_assign.to == sl) { + // если это многомерный слайс - кинуть ошибку + if (sl.slices != null) + { + // запретим пока или вовсе + throw new SyntaxVisitorError("MULTIDIMENSIONAL_SLICES_FORBIDDEN_IN_LEFT_SIDE_OF_ASSIGNMENT", sl.source_context); + } el.Insert(0, parent_assign.from); var mc = method_call.NewP( dot_node.NewP( @@ -99,10 +129,23 @@ namespace SyntaxVisitors.SugarVisitors } else { - var mc = method_call.NewP(dot_node.NewP(sl.v, new ident("SystemSlice", sl.v.source_context), sl.v.source_context), el, sl.source_context); - var sug = sugared_addressed_value.NewP(sl, mc, sl.source_context); - ReplaceUsingParent(sl, sug); - visit(mc); // обойти заменённое на предмет наличия такого же синтаксического сахара + if (sl.slices == null) // значит, это одномерный слайс - вызываем старый код + { + var mc = method_call.NewP(dot_node.NewP(sl.v, new ident("SystemSlice", sl.v.source_context), sl.v.source_context), el, sl.source_context); + var sug = sugared_addressed_value.NewP(sl, mc, sl.source_context); + ReplaceUsingParent(sl, sug); + visit(mc); // обойти заменённое на предмет наличия такого же синтаксического сахара + } + else // многомерный слайс на чтение - вызываем груду новых функций + { + // Определим, сколько размерностей надо оставлять в многомерном слайсе + // Столько - сколько в sl.slices кортежей с шагом int.MaxValue. Считаем: + var N = sl.slices.Count(s => { var u = s.Item3 as int32_const; return u == null || u.val != int.MaxValue; }); + var mc = method_call.NewP(dot_node.NewP(sl.v, new ident("SystemSliceN"+N, sl.v.source_context), sl.v.source_context), el, sl.source_context); + // пока без семантической проверки + ReplaceUsingParent(sl, mc); + visit(mc); + } } } diff --git a/TestSuite/CompilationSamples/PABCSystem.pas b/TestSuite/CompilationSamples/PABCSystem.pas index 84ea77108..21e8e72ba 100644 --- a/TestSuite/CompilationSamples/PABCSystem.pas +++ b/TestSuite/CompilationSamples/PABCSystem.pas @@ -12042,6 +12042,264 @@ begin Result := SystemSliceArrayImplQuestion(Self, situation, from, &to, step); end; +// Срезы многомерных массивов - вспомогательные типы и функции +type + SliceType = class + situation,from, &to, step, count: integer; + oneelem: boolean; + constructor (sit,f,t: integer; st: integer := 1; oneel: boolean := false); + begin + situation := sit; + from := f; + &to := t; + step := st; + count := -1; // заполняется во внешней функции + oneelem := oneel; + if step = integer.MaxValue then + oneelem := True; + end; + procedure CorrectSliceAndCalcCount(len: integer); + begin + if oneelem then + count := 1 + else count := CheckAndCorrectFromToAndCalcCountForSystemSlice(situation, len, from, &to, step); + end; + static function operator implicit(i: integer): SliceType; + static function operator implicit(ir: IntRange): SliceType; + static function operator implicit(sl: (integer,integer,integer)): SliceType; + end; + +function Diap(f, t: integer) := new SliceType(0, f, t, 1, false); +function Elem(ind: integer) := new SliceType(0, ind, ind+1, 1, true); +function Slice(f, t: integer; st: integer := 1; oneel: boolean := false): SliceType; +begin + var sit := 0; + if f = integer.MaxValue then + sit += 1; + if t = integer.MaxValue then + sit += 2; + if st = integer.MaxValue then + oneel := True; + Result := new SliceType(sit, f, t, st, oneel); +end; + +static function SliceType.operator implicit(i: integer): SliceType; +begin + Result := Elem(i); +end; + +static function SliceType.operator implicit(ir: IntRange): SliceType; +begin + Result := Diap(ir.Low,ir.High); +end; + +static function SliceType.operator implicit(sl: (integer,integer,integer)): SliceType; +begin + Result := Slice(sl[0],sl[1],sl[2]); +end; + + +function ToOneDim(a: array [,] of T; l: array of SliceType): array of T; +begin + for var i:=0 to l.Length-1 do + l[i].CorrectSliceAndCalcCount(a.GetLength(i)); + var onedimsz := l[0].count * l[1].count; + var res := new T[onedimsz]; + if onedimsz>0 then + begin + var cur := 0; + var i0 := l[0].from; + loop l[0].count do + begin + var i1:=l[1].from; + loop l[1].count do + begin + res[cur] := a[i0,i1]; + cur += 1; + i1 += l[1].step; + end; + i0 += l[0].step; + end; + end; + Result := res; +end; + +function ToOneDim(a: array [,,] of T; l: array of SliceType): array of T; +begin + for var i:=0 to l.Length-1 do + l[i].CorrectSliceAndCalcCount(a.GetLength(i)); + var onedimsz := l[0].count * l[1].count * l[2].count; + var res := new T[onedimsz]; + if onedimsz>0 then + begin + var cur := 0; + var i0 := l[0].from; + loop l[0].count do + begin + var i1:=l[1].from; + loop l[1].count do + begin + var i2 := l[2].from; + loop l[2].count do + begin + res[cur] := a[i0,i1,i2]; + cur += 1; + i2 += l[2].step; + end; + i1 += l[1].step; + end; + i0 += l[0].step; + end; + end; + Result := res; +end; + +function ToOneDim(a: array [,,,] of T; l: array of SliceType): array of T; +begin + for var i:=0 to l.Length-1 do + l[i].CorrectSliceAndCalcCount(a.GetLength(i)); + var onedimsz := l[0].count * l[1].count * l[2].count * l[3].count; + var res := new T[onedimsz]; + if onedimsz>0 then + begin + var cur := 0; + var i0 := l[0].from; + loop l[0].count do + begin + var i1:=l[1].from; + loop l[1].count do + begin + var i2 := l[2].from; + loop l[2].count do + begin + var i3 := l[3].from; + loop l[3].count do + begin + res[cur] := a[i0,i1,i2,i3]; + cur += 1; + i3 += l[3].step; + end; + i2 += l[2].step; + end; + i1 += l[1].step; + end; + i0 += l[0].step; + end; + end; + Result := res; +end; + +function FromOneDim2(r: array of T; l: array of SliceType): array [,] of T; +begin + var dims := l.FindAll(x -> x.oneelem = False).ConvertAll(x -> x.count); + Assert(dims.Length = 2); + var cur := 0; + var res := new T[dims[0],dims[1]]; + for var i0:=0 to dims[0]-1 do + for var i1:=0 to dims[1]-1 do + begin + res[i0,i1] := r[cur]; + cur += 1; + end; + Result := res; +end; + +function FromOneDim3(r: array of T; l: array of SliceType): array [,,] of T; +begin + var dims := l.FindAll(x -> x.oneelem = False).ConvertAll(x -> x.count); + Assert(dims.Length = 3); + var cur := 0; + var res := new T[dims[0],dims[1],dims[2]]; + for var i0:=0 to dims[0]-1 do + for var i1:=0 to dims[1]-1 do + for var i2:=0 to dims[2]-1 do + begin + res[i0,i1,i2] := r[cur]; + cur += 1; + end; + Result := res; +end; + +function FromOneDim4(r: array of T; l: array of SliceType): array [,,,] of T; +begin + var dims := l.FindAll(x -> x.oneelem = False).ConvertAll(x -> x.count); + Assert(dims.Length = 4); + var cur := 0; + var res := new T[dims[0],dims[1],dims[2],dims[3]]; + for var i0:=0 to dims[0]-1 do + for var i1:=0 to dims[1]-1 do + for var i2:=0 to dims[2]-1 do + for var i3:=0 to dims[3]-1 do + begin + res[i0,i1,i2,i3] := r[cur]; + cur += 1; + end; + Result := res; +end; + +function FromOneDimN(r: array of T; l: array of SliceType): System.Array; +begin + var rank := l.Count(x -> x.oneelem = False); + case rank of + 1: Result := r; + 2: Result := FromOneDim2(r,l); + 3: Result := FromOneDim3(r,l); + 4: Result := FromOneDim4(r,l); + end; +end; + +function SliceN(a: array[,] of T; l: array of SliceType): System.Array; +begin + var r := ToOneDim(a,l); + Result := FromOneDimN(r,l); +end; + +function SliceN(a: array[,,] of T; l: array of SliceType): System.Array; +begin + var r := ToOneDim(a,l); + Result := FromOneDimN(r,l); +end; + +function SliceN(a: array[,,,] of T; l: array of SliceType): System.Array; +begin + var r := ToOneDim(a,l); + Result := FromOneDimN(r,l); +end; + +{type + ArrT = array of T; + Arr2T = array [,] of T; + Arr3T = array [,,] of T; + Arr4T = array [,,,] of T;} + +///-- +function SystemSliceN1(Self: array[,] of T; params l: array of SliceType): array of T; extensionmethod + := SliceN(Self,l) as array of T; +///-- +function SystemSliceN1(Self: array[,,] of T; params l: array of SliceType): array of T; extensionmethod + := SliceN(Self,l) as array of T; +///-- +function SystemSliceN1(Self: array[,,,] of T; params l: array of SliceType): array of T; extensionmethod + := SliceN(Self,l) as array of T; +///-- +function SystemSliceN2(Self: array[,] of T; params l: array of SliceType): array[,] of T; extensionmethod + := SliceN(Self,l) as array [,] of T; +///-- +function SystemSliceN2(Self: array[,,] of T; params l: array of SliceType): array[,] of T; extensionmethod + := SliceN(Self,l) as array [,] of T; +///-- +function SystemSliceN2(Self: array[,,,] of T; params l: array of SliceType): array[,] of T; extensionmethod + := SliceN(Self,l) as array [,] of T; +///-- +function SystemSliceN3(Self: array[,,] of T; params l: array of SliceType): array[,,] of T; extensionmethod + := SliceN(Self,l) as array [,,] of T; +///-- +function SystemSliceN3(Self: array[,,,] of T; params l: array of SliceType): array[,,] of T; extensionmethod + := SliceN(Self,l) as array [,,] of T; +///-- +function SystemSliceN4(Self: array[,,,] of T; params l: array of SliceType): array[,,,] of T; extensionmethod + := SliceN(Self,l) as array [,,,] of T; + // ----------------------------------------------------- //>> Методы расширения типа integer # Extension methods for integer // ----------------------------------------------------- diff --git a/bin/Lib/PABCSystem.pas b/bin/Lib/PABCSystem.pas index 84ea77108..21e8e72ba 100644 --- a/bin/Lib/PABCSystem.pas +++ b/bin/Lib/PABCSystem.pas @@ -12042,6 +12042,264 @@ begin Result := SystemSliceArrayImplQuestion(Self, situation, from, &to, step); end; +// Срезы многомерных массивов - вспомогательные типы и функции +type + SliceType = class + situation,from, &to, step, count: integer; + oneelem: boolean; + constructor (sit,f,t: integer; st: integer := 1; oneel: boolean := false); + begin + situation := sit; + from := f; + &to := t; + step := st; + count := -1; // заполняется во внешней функции + oneelem := oneel; + if step = integer.MaxValue then + oneelem := True; + end; + procedure CorrectSliceAndCalcCount(len: integer); + begin + if oneelem then + count := 1 + else count := CheckAndCorrectFromToAndCalcCountForSystemSlice(situation, len, from, &to, step); + end; + static function operator implicit(i: integer): SliceType; + static function operator implicit(ir: IntRange): SliceType; + static function operator implicit(sl: (integer,integer,integer)): SliceType; + end; + +function Diap(f, t: integer) := new SliceType(0, f, t, 1, false); +function Elem(ind: integer) := new SliceType(0, ind, ind+1, 1, true); +function Slice(f, t: integer; st: integer := 1; oneel: boolean := false): SliceType; +begin + var sit := 0; + if f = integer.MaxValue then + sit += 1; + if t = integer.MaxValue then + sit += 2; + if st = integer.MaxValue then + oneel := True; + Result := new SliceType(sit, f, t, st, oneel); +end; + +static function SliceType.operator implicit(i: integer): SliceType; +begin + Result := Elem(i); +end; + +static function SliceType.operator implicit(ir: IntRange): SliceType; +begin + Result := Diap(ir.Low,ir.High); +end; + +static function SliceType.operator implicit(sl: (integer,integer,integer)): SliceType; +begin + Result := Slice(sl[0],sl[1],sl[2]); +end; + + +function ToOneDim(a: array [,] of T; l: array of SliceType): array of T; +begin + for var i:=0 to l.Length-1 do + l[i].CorrectSliceAndCalcCount(a.GetLength(i)); + var onedimsz := l[0].count * l[1].count; + var res := new T[onedimsz]; + if onedimsz>0 then + begin + var cur := 0; + var i0 := l[0].from; + loop l[0].count do + begin + var i1:=l[1].from; + loop l[1].count do + begin + res[cur] := a[i0,i1]; + cur += 1; + i1 += l[1].step; + end; + i0 += l[0].step; + end; + end; + Result := res; +end; + +function ToOneDim(a: array [,,] of T; l: array of SliceType): array of T; +begin + for var i:=0 to l.Length-1 do + l[i].CorrectSliceAndCalcCount(a.GetLength(i)); + var onedimsz := l[0].count * l[1].count * l[2].count; + var res := new T[onedimsz]; + if onedimsz>0 then + begin + var cur := 0; + var i0 := l[0].from; + loop l[0].count do + begin + var i1:=l[1].from; + loop l[1].count do + begin + var i2 := l[2].from; + loop l[2].count do + begin + res[cur] := a[i0,i1,i2]; + cur += 1; + i2 += l[2].step; + end; + i1 += l[1].step; + end; + i0 += l[0].step; + end; + end; + Result := res; +end; + +function ToOneDim(a: array [,,,] of T; l: array of SliceType): array of T; +begin + for var i:=0 to l.Length-1 do + l[i].CorrectSliceAndCalcCount(a.GetLength(i)); + var onedimsz := l[0].count * l[1].count * l[2].count * l[3].count; + var res := new T[onedimsz]; + if onedimsz>0 then + begin + var cur := 0; + var i0 := l[0].from; + loop l[0].count do + begin + var i1:=l[1].from; + loop l[1].count do + begin + var i2 := l[2].from; + loop l[2].count do + begin + var i3 := l[3].from; + loop l[3].count do + begin + res[cur] := a[i0,i1,i2,i3]; + cur += 1; + i3 += l[3].step; + end; + i2 += l[2].step; + end; + i1 += l[1].step; + end; + i0 += l[0].step; + end; + end; + Result := res; +end; + +function FromOneDim2(r: array of T; l: array of SliceType): array [,] of T; +begin + var dims := l.FindAll(x -> x.oneelem = False).ConvertAll(x -> x.count); + Assert(dims.Length = 2); + var cur := 0; + var res := new T[dims[0],dims[1]]; + for var i0:=0 to dims[0]-1 do + for var i1:=0 to dims[1]-1 do + begin + res[i0,i1] := r[cur]; + cur += 1; + end; + Result := res; +end; + +function FromOneDim3(r: array of T; l: array of SliceType): array [,,] of T; +begin + var dims := l.FindAll(x -> x.oneelem = False).ConvertAll(x -> x.count); + Assert(dims.Length = 3); + var cur := 0; + var res := new T[dims[0],dims[1],dims[2]]; + for var i0:=0 to dims[0]-1 do + for var i1:=0 to dims[1]-1 do + for var i2:=0 to dims[2]-1 do + begin + res[i0,i1,i2] := r[cur]; + cur += 1; + end; + Result := res; +end; + +function FromOneDim4(r: array of T; l: array of SliceType): array [,,,] of T; +begin + var dims := l.FindAll(x -> x.oneelem = False).ConvertAll(x -> x.count); + Assert(dims.Length = 4); + var cur := 0; + var res := new T[dims[0],dims[1],dims[2],dims[3]]; + for var i0:=0 to dims[0]-1 do + for var i1:=0 to dims[1]-1 do + for var i2:=0 to dims[2]-1 do + for var i3:=0 to dims[3]-1 do + begin + res[i0,i1,i2,i3] := r[cur]; + cur += 1; + end; + Result := res; +end; + +function FromOneDimN(r: array of T; l: array of SliceType): System.Array; +begin + var rank := l.Count(x -> x.oneelem = False); + case rank of + 1: Result := r; + 2: Result := FromOneDim2(r,l); + 3: Result := FromOneDim3(r,l); + 4: Result := FromOneDim4(r,l); + end; +end; + +function SliceN(a: array[,] of T; l: array of SliceType): System.Array; +begin + var r := ToOneDim(a,l); + Result := FromOneDimN(r,l); +end; + +function SliceN(a: array[,,] of T; l: array of SliceType): System.Array; +begin + var r := ToOneDim(a,l); + Result := FromOneDimN(r,l); +end; + +function SliceN(a: array[,,,] of T; l: array of SliceType): System.Array; +begin + var r := ToOneDim(a,l); + Result := FromOneDimN(r,l); +end; + +{type + ArrT = array of T; + Arr2T = array [,] of T; + Arr3T = array [,,] of T; + Arr4T = array [,,,] of T;} + +///-- +function SystemSliceN1(Self: array[,] of T; params l: array of SliceType): array of T; extensionmethod + := SliceN(Self,l) as array of T; +///-- +function SystemSliceN1(Self: array[,,] of T; params l: array of SliceType): array of T; extensionmethod + := SliceN(Self,l) as array of T; +///-- +function SystemSliceN1(Self: array[,,,] of T; params l: array of SliceType): array of T; extensionmethod + := SliceN(Self,l) as array of T; +///-- +function SystemSliceN2(Self: array[,] of T; params l: array of SliceType): array[,] of T; extensionmethod + := SliceN(Self,l) as array [,] of T; +///-- +function SystemSliceN2(Self: array[,,] of T; params l: array of SliceType): array[,] of T; extensionmethod + := SliceN(Self,l) as array [,] of T; +///-- +function SystemSliceN2(Self: array[,,,] of T; params l: array of SliceType): array[,] of T; extensionmethod + := SliceN(Self,l) as array [,] of T; +///-- +function SystemSliceN3(Self: array[,,] of T; params l: array of SliceType): array[,,] of T; extensionmethod + := SliceN(Self,l) as array [,,] of T; +///-- +function SystemSliceN3(Self: array[,,,] of T; params l: array of SliceType): array[,,] of T; extensionmethod + := SliceN(Self,l) as array [,,] of T; +///-- +function SystemSliceN4(Self: array[,,,] of T; params l: array of SliceType): array[,,,] of T; extensionmethod + := SliceN(Self,l) as array [,,,] of T; + // ----------------------------------------------------- //>> Методы расширения типа integer # Extension methods for integer // -----------------------------------------------------