From 94142b84aadd24319f9802c6a2bfde018d3e6122 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=BE=D0=BD=D0=B4=D0=B0=D1=80=D0=B5=D0=B2=20=D0=98?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD?= Date: Mon, 1 Jun 2020 10:02:56 +0200 Subject: [PATCH] fix #2166 --- .../PascalABCParserNewSaushkin/ABCPascal.cs | 6 +- .../PascalABCParserNewSaushkin/ABCPascal.lst | 79 +- .../PascalABCParserNewSaushkin/ABCPascal.y | 26 + .../ABCPascalYacc.cs | 3299 +++++++++-------- TestSuite/CompilationSamples/keywords.pas | 33 + 5 files changed, 1791 insertions(+), 1652 deletions(-) create mode 100644 TestSuite/CompilationSamples/keywords.pas diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs index 6a8dae13c..a728af81e 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs @@ -1,9 +1,9 @@ // // This CSharp output file generated by Gardens Point LEX // Version: 1.1.3.301 -// Machine: DESKTOP-P4NLNB1 -// DateTime: 5/5/2020 6:55:25 PM -// UserName: fatco +// Machine: IVAN-PC +// DateTime: 31.05.2020 20:42:32 +// UserName: Ivan // GPLEX input file // GPLEX frame file // diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.lst b/Parsers/PascalABCParserNewSaushkin/ABCPascal.lst index ff8df0824..30ab2ebc6 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascal.lst +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascal.lst @@ -3,9 +3,9 @@ // GPPG error listing for yacc source file // ========================================================================== // Version: 1.3.6 -// Machine: DESKTOP-P4NLNB1 -// DateTime: 4/20/2020 4:00:49 PM -// UserName: fatco +// Machine: IVAN-PC +// DateTime: 31.05.2020 20:31:33 +// UserName: Ivan // ========================================================================== @@ -96,7 +96,7 @@ %type const_simple_expr term term1 simple_term typed_const typed_const_plus typed_var_init_expression expr expr_with_func_decl_lambda const_expr elem range_expr const_elem array_const factor relop_expr expr_dq expr_l1 expr_l1_func_decl_lambda expr_l1_for_lambda simple_expr range_term range_factor %type external_directive_ident init_const_expr case_label variable var_reference /*optional_write_expr*/ optional_read_expr simple_expr_or_nothing var_question_point expr_l1_for_question_expr expr_l1_for_new_question_expr %type for_cycle_type -%type format_expr format_const_expr const_expr_or_nothing simple_expr_with_deref_or_nothing simple_expr_with_deref /*expr_l1_for_indexer*/ +%type format_expr format_const_expr const_expr_or_nothing /* simple_expr_with_deref_or_nothing simple_expr_with_deref expr_l1_for_indexer*/ %type foreach_stmt %type for_stmt loop_stmt yield_stmt yield_sequence_stmt %type fp_list fp_sect_list @@ -191,17 +191,12 @@ %type pattern_out_param_list pattern_out_param_list_optional_var collection_pattern_expr_list tuple_pattern_item_list const_pattern_expr_list %% -// Error: NonTerminal symbol "simple_expr_with_deref_or_nothing" has no productions -// Warning: NonTerminal symbol "simple_expr_with_deref" is unreachable -// Error: NonTerminal symbol "simple_expr_with_deref" has no productions -// Warning: NonTerminal symbol "simple_expr_with_deref_or_nothing" is unreachable -// Error: There are 2 non-terminating NonTerminal Symbols - // {simple_expr_with_deref_or_nothing, simple_expr_with_deref} -// Warning: Terminating simple_expr_with_deref_or_nothing fixes the following size-1 NonTerminal set - // {simple_expr_with_deref_or_nothing} -// Warning: Terminating simple_expr_with_deref fixes the following size-1 NonTerminal set - // {simple_expr_with_deref} -// ------------------------------------------------------------------------------------------------- +// Error: NonTerminal symbol "tkExtensionmethod" has no productions +// Warning: Terminating tkExtensionmethod fixes the following size-1 NonTerminal set + // {tkExtensionmethod} +// Error: There are 1 non-terminating NonTerminal Symbols + // {tkExtensionmethod} +// --------------------------------------------------------------------------------- parse_goal : program_file @@ -961,9 +956,7 @@ const_variable if (fe.format1 == null) fe.format1 = new int32_const(int.MaxValue,@3); } - var from = fe.expr is index ? fe.expr : new index(fe.expr, false, fe.expr.source_context); - var to = fe.format1 is index ? fe.format1 : new index(fe.format1, false, fe.format1.source_context); - $$ = new slice_expr($1 as addressed_value,from,to,fe.format2,@$); + $$ = new slice_expr($1 as addressed_value,fe.expr,fe.format1,fe.format2,@$); } ; @@ -2734,9 +2727,7 @@ assignment if (fe.format1 == null) fe.format1 = new int32_const(int.MaxValue,@3); } - var from = fe.expr is index ? fe.expr : new index(fe.expr, false, fe.expr.source_context); - var to = fe.format1 is index ? fe.format1 : new index(fe.format1, false, fe.format1.source_context); - var left = new slice_expr_question($1 as addressed_value,from.to,fe.format2,@$); + var left = new slice_expr_question($1 as addressed_value,fe.expr,fe.format1,fe.format2,@$); $$ = new assign(left, $6, $5.type, @$); } ; @@ -3145,16 +3136,12 @@ expr_with_func_decl_lambda expr : expr_l1 { $$ = $1; } - | tkDeref expr_l1 - { $$ = new simple_expr_with_deref($2, true); } | format_expr { $$ = $1; } ; /* expr_l1_for_indexer - : tkDeref expr_l1 - { $$ = new simple_expr_with_deref($2, true); } - | expr_l1 + : expr_l1 { $$ = $1; } | format_expr { $$ = $1; } @@ -3385,6 +3372,10 @@ relop_expr { $$ = new bin_expr($1, $3, $2.type, @$); } + | relop_expr relop new_question_expr + { + $$ = new bin_expr($1, $3, $2.type, @$); + } | is_type_expr tkRoundOpen pattern_out_param_list tkRoundClose { var isTypeCheck = $1 as typecast_node; @@ -3803,6 +3794,10 @@ term1 { $$ = new bin_expr($1, $3, $2.type, @$); } + | term1 addop new_question_expr + { + $$ = new bin_expr($1, $3, $2.type, @$); + } ; addop @@ -3871,6 +3866,8 @@ term { $$ = new bin_expr($1,$3,($2).type, @$); } | term mulop power_expr { $$ = new bin_expr($1,$3,($2).type, @$); } + | term mulop new_question_expr + { $$ = new bin_expr($1,$3,($2).type, @$); } | as_is_expr { $$ = $1; } ; @@ -4080,9 +4077,7 @@ variable if (fe.format1 == null) fe.format1 = new int32_const(int.MaxValue,@3); } - var from = fe.expr is index ? fe.expr : new index(fe.expr, false, fe.expr.source_context); - var to = fe.format1 is index ? fe.format1 : new index(fe.format1, false, fe.format1.source_context); - $$ = new slice_expr($1 as addressed_value,from,to,fe.format2,@$); + $$ = new slice_expr($1 as addressed_value,fe.expr,fe.format1,fe.format2,@$); } else $$ = new indexer($1 as addressed_value, el, @$); } @@ -4096,9 +4091,7 @@ variable if (fe.format1 == null) fe.format1 = new int32_const(int.MaxValue,@3); } - var from = fe.expr is index ? fe.expr : new index(fe.expr, false, fe.expr.source_context); - var to = fe.format1 is index ? fe.format1 : new index(fe.format1, false, fe.format1.source_context); - $$ = new slice_expr_question($1 as addressed_value,from,to,fe.format2,@$); + $$ = new slice_expr_question($1 as addressed_value,fe.expr,fe.format1,fe.format2,@$); } | variable tkRoundOpen optional_expr_list tkRoundClose { @@ -4469,6 +4462,28 @@ keyword { $$ = $1; } | tkWhen { $$ = $1; } + | tkAbstract + { $$ = $1; } + | tkLock + { $$ = $1; } + | tkImplicit + { $$ = $1; } + | tkExplicit + { $$ = $1; } + | tkOn + { $$ = $1; } + | tkVirtual + { $$ = $1; } + | tkOverride + { $$ = $1; } + | tkLoop + { $$ = $1; } + | tkExtensionmethod + { $$ = $1; } + | tkOverload + { $$ = $1; } + | tkReintroduce + { $$ = $1; } ; reserved_keyword diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.y b/Parsers/PascalABCParserNewSaushkin/ABCPascal.y index 081cff24d..bfcd2b94a 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascal.y +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascal.y @@ -4445,6 +4445,32 @@ keyword { $$ = $1; } | tkWhen { $$ = $1; } + | tkPartial + { $$ = $1; } + | tkAbstract + { $$ = new token_info($1.name, @$); } + | tkLock + { $$ = $1; } + | tkImplicit + { $$ = $1; } + | tkExplicit + { $$ = $1; } + | tkOn + { $$ = new token_info($1.name, @$); } + | tkVirtual + { $$ = new token_info($1.name, @$); } + | tkOverride + { $$ = new token_info($1.name, @$); } + | tkLoop + { $$ = $1; } + | tkExtensionMethod + { $$ = new token_info($1.name, @$); } + | tkOverload + { $$ = new token_info($1.name, @$); } + | tkReintroduce + { $$ = new token_info($1.name, @$); } + | tkForward + { $$ = new token_info($1.name, @$); } ; reserved_keyword diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs index 2643bae14..70d4ec756 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs @@ -1,9 +1,9 @@ // (see accompanying GPPGcopyright.rtf) // GPPG version 1.3.6 -// Machine: DESKTOP-P4NLNB1 -// DateTime: 5/5/2020 6:55:26 PM -// UserName: fatco +// Machine: IVAN-PC +// DateTime: 31.05.2020 20:42:34 +// UserName: Ivan // Input file // options: no-lines gplex @@ -76,8 +76,8 @@ public partial class GPPGParser: ShiftReduceParser aliasses; #pragma warning restore 649 - private static Rule[] rules = new Rule[959]; - private static State[] states = new State[1586]; + private static Rule[] rules = new Rule[972]; + private static State[] states = new State[1599]; 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", @@ -167,13 +167,13 @@ public partial class GPPGParser: ShiftReduceParser tkWhen { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 890: // reserved_keyword -> tkOperator + case 890: // keyword -> tkPartial { CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } break; - case 891: // overload_operator -> tkMinus + case 891: // keyword -> tkAbstract +{ CurrentSemanticValue.ti = new token_info(ValueStack[ValueStack.Depth-1].id.name, CurrentLocationSpan); } + break; + case 892: // keyword -> tkLock +{ CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } + break; + case 893: // keyword -> tkImplicit +{ CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].op; } + break; + case 894: // keyword -> tkExplicit +{ CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].op; } + break; + case 895: // keyword -> tkOn +{ CurrentSemanticValue.ti = new token_info(ValueStack[ValueStack.Depth-1].id.name, CurrentLocationSpan); } + break; + case 896: // keyword -> tkVirtual +{ CurrentSemanticValue.ti = new token_info(ValueStack[ValueStack.Depth-1].id.name, CurrentLocationSpan); } + break; + case 897: // keyword -> tkOverride +{ CurrentSemanticValue.ti = new token_info(ValueStack[ValueStack.Depth-1].id.name, CurrentLocationSpan); } + break; + case 898: // keyword -> tkLoop +{ CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } + break; + case 899: // keyword -> tkExtensionMethod +{ CurrentSemanticValue.ti = new token_info(ValueStack[ValueStack.Depth-1].id.name, CurrentLocationSpan); } + break; + case 900: // keyword -> tkOverload +{ CurrentSemanticValue.ti = new token_info(ValueStack[ValueStack.Depth-1].id.name, CurrentLocationSpan); } + break; + case 901: // keyword -> tkReintroduce +{ CurrentSemanticValue.ti = new token_info(ValueStack[ValueStack.Depth-1].id.name, CurrentLocationSpan); } + break; + case 902: // keyword -> tkForward +{ CurrentSemanticValue.ti = new token_info(ValueStack[ValueStack.Depth-1].id.name, CurrentLocationSpan); } + break; + case 903: // reserved_keyword -> tkOperator +{ CurrentSemanticValue.ti = ValueStack[ValueStack.Depth-1].ti; } + break; + case 904: // overload_operator -> tkMinus { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 892: // overload_operator -> tkPlus + case 905: // overload_operator -> tkPlus { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 893: // overload_operator -> tkSlash + case 906: // overload_operator -> tkSlash { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 894: // overload_operator -> tkStar + case 907: // overload_operator -> tkStar { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 895: // overload_operator -> tkEqual + case 908: // overload_operator -> tkEqual { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 896: // overload_operator -> tkGreater + case 909: // overload_operator -> tkGreater { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 897: // overload_operator -> tkGreaterEqual + case 910: // overload_operator -> tkGreaterEqual { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 898: // overload_operator -> tkLower + case 911: // overload_operator -> tkLower { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 899: // overload_operator -> tkLowerEqual + case 912: // overload_operator -> tkLowerEqual { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 900: // overload_operator -> tkNotEqual + case 913: // overload_operator -> tkNotEqual { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 901: // overload_operator -> tkOr + case 914: // overload_operator -> tkOr { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 902: // overload_operator -> tkXor + case 915: // overload_operator -> tkXor { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 903: // overload_operator -> tkAnd + case 916: // overload_operator -> tkAnd { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 904: // overload_operator -> tkDiv + case 917: // overload_operator -> tkDiv { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 905: // overload_operator -> tkMod + case 918: // overload_operator -> tkMod { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 906: // overload_operator -> tkShl + case 919: // overload_operator -> tkShl { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 907: // overload_operator -> tkShr + case 920: // overload_operator -> tkShr { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 908: // overload_operator -> tkNot + case 921: // overload_operator -> tkNot { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 909: // overload_operator -> tkIn + case 922: // overload_operator -> tkIn { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 910: // overload_operator -> tkImplicit + case 923: // overload_operator -> tkImplicit { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 911: // overload_operator -> tkExplicit + case 924: // overload_operator -> tkExplicit { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 912: // overload_operator -> assign_operator + case 925: // overload_operator -> assign_operator { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 913: // overload_operator -> tkStarStar + case 926: // overload_operator -> tkStarStar { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 914: // assign_operator -> tkAssign + case 927: // assign_operator -> tkAssign { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 915: // assign_operator -> tkPlusEqual + case 928: // assign_operator -> tkPlusEqual { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 916: // assign_operator -> tkMinusEqual + case 929: // assign_operator -> tkMinusEqual { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 917: // assign_operator -> tkMultEqual + case 930: // assign_operator -> tkMultEqual { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 918: // assign_operator -> tkDivEqual + case 931: // assign_operator -> tkDivEqual { CurrentSemanticValue.op = ValueStack[ValueStack.Depth-1].op; } break; - case 919: // func_decl_lambda -> identifier, tkArrow, lambda_function_body + case 932: // 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]); CurrentSemanticValue.ex = new function_lambda_definition(lambdaHelper.CreateLambdaName(), formalPars, new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), LocationStack[LocationStack.Depth-3]), ValueStack[ValueStack.Depth-1].stn as statement_list, CurrentLocationSpan); } break; - case 920: // func_decl_lambda -> tkRoundOpen, tkRoundClose, lambda_type_ref_noproctype, + case 933: // func_decl_lambda -> 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, CurrentLocationSpan); } break; - case 921: // func_decl_lambda -> tkRoundOpen, identifier, tkColon, fptype, tkRoundClose, + case 934: // 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]); @@ -6960,7 +7025,7 @@ public partial class GPPGParser: ShiftReduceParser tkRoundOpen, identifier, tkSemiColon, full_lambda_fp_list, + case 935: // func_decl_lambda -> tkRoundOpen, identifier, tkSemiColon, full_lambda_fp_list, // tkRoundClose, lambda_type_ref_noproctype, tkArrow, // lambda_function_body { @@ -6971,7 +7036,7 @@ public partial class GPPGParser: ShiftReduceParser tkRoundOpen, identifier, tkColon, fptype, tkSemiColon, + case 936: // func_decl_lambda -> tkRoundOpen, identifier, tkColon, fptype, tkSemiColon, // full_lambda_fp_list, tkRoundClose, // lambda_type_ref_noproctype, tkArrow, lambda_function_body { @@ -6983,7 +7048,7 @@ public partial class GPPGParser: ShiftReduceParser tkRoundOpen, expr_l1, tkComma, expr_l1_list, + case 937: // func_decl_lambda -> tkRoundOpen, expr_l1, tkComma, expr_l1_list, // lambda_type_ref, optional_full_lambda_fp_list, // tkRoundClose, rem_lambda { @@ -7045,61 +7110,61 @@ public partial class GPPGParser: ShiftReduceParser expl_func_decl_lambda + case 938: // func_decl_lambda -> expl_func_decl_lambda { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].ex; } break; - case 926: // optional_full_lambda_fp_list -> /* empty */ + case 939: // optional_full_lambda_fp_list -> /* empty */ { CurrentSemanticValue.stn = null; } break; - case 927: // optional_full_lambda_fp_list -> tkSemiColon, full_lambda_fp_list + case 940: // optional_full_lambda_fp_list -> tkSemiColon, full_lambda_fp_list { CurrentSemanticValue.stn = ValueStack[ValueStack.Depth-1].stn; } break; - case 928: // rem_lambda -> lambda_type_ref_noproctype, tkArrow, lambda_function_body + case 941: // 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 929: // expl_func_decl_lambda -> tkFunction, lambda_type_ref, tkArrow, + case 942: // expl_func_decl_lambda -> tkFunction, lambda_type_ref, 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 930: // expl_func_decl_lambda -> tkFunction, tkRoundOpen, tkRoundClose, lambda_type_ref, + case 943: // expl_func_decl_lambda -> tkFunction, tkRoundOpen, tkRoundClose, lambda_type_ref, // 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 931: // expl_func_decl_lambda -> tkFunction, tkRoundOpen, full_lambda_fp_list, + case 944: // expl_func_decl_lambda -> tkFunction, tkRoundOpen, full_lambda_fp_list, // tkRoundClose, lambda_type_ref, 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 932: // expl_func_decl_lambda -> tkProcedure, tkArrow, lambda_procedure_body + case 945: // 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 933: // expl_func_decl_lambda -> tkProcedure, tkRoundOpen, tkRoundClose, tkArrow, + case 946: // 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 934: // expl_func_decl_lambda -> tkProcedure, tkRoundOpen, full_lambda_fp_list, + case 947: // 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 935: // full_lambda_fp_list -> lambda_simple_fp_sect + case 948: // 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) @@ -7119,97 +7184,97 @@ public partial class GPPGParser: ShiftReduceParser full_lambda_fp_list, tkSemiColon, lambda_simple_fp_sect + case 949: // 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 937: // lambda_simple_fp_sect -> ident_list, lambda_type_ref + case 950: // 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 938: // lambda_type_ref -> /* empty */ + case 951: // lambda_type_ref -> /* empty */ { CurrentSemanticValue.td = new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), null); } break; - case 939: // lambda_type_ref -> tkColon, fptype + case 952: // lambda_type_ref -> tkColon, fptype { CurrentSemanticValue.td = ValueStack[ValueStack.Depth-1].td; } break; - case 940: // lambda_type_ref_noproctype -> /* empty */ + case 953: // lambda_type_ref_noproctype -> /* empty */ { CurrentSemanticValue.td = new lambda_inferred_type(new PascalABCCompiler.TreeRealization.lambda_any_type_node(), null); } break; - case 941: // lambda_type_ref_noproctype -> tkColon, fptype_noproctype + case 954: // lambda_type_ref_noproctype -> tkColon, fptype_noproctype { CurrentSemanticValue.td = ValueStack[ValueStack.Depth-1].td; } break; - case 942: // common_lambda_body -> compound_stmt + case 955: // common_lambda_body -> compound_stmt { CurrentSemanticValue.stn = ValueStack[ValueStack.Depth-1].stn; } break; - case 943: // common_lambda_body -> if_stmt + case 956: // common_lambda_body -> if_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 944: // common_lambda_body -> while_stmt + case 957: // common_lambda_body -> while_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 945: // common_lambda_body -> repeat_stmt + case 958: // common_lambda_body -> repeat_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 946: // common_lambda_body -> for_stmt + case 959: // common_lambda_body -> for_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 947: // common_lambda_body -> foreach_stmt + case 960: // common_lambda_body -> foreach_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 948: // common_lambda_body -> loop_stmt + case 961: // common_lambda_body -> loop_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 949: // common_lambda_body -> case_stmt + case 962: // common_lambda_body -> case_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 950: // common_lambda_body -> try_stmt + case 963: // common_lambda_body -> try_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 951: // common_lambda_body -> lock_stmt + case 964: // common_lambda_body -> lock_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 952: // common_lambda_body -> raise_stmt + case 965: // common_lambda_body -> raise_stmt { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 953: // common_lambda_body -> yield_stmt + case 966: // common_lambda_body -> yield_stmt { parsertools.AddErrorFromResource("YIELD_STATEMENT_CANNOT_BE_USED_IN_LAMBDA_BODY", CurrentLocationSpan); } break; - case 954: // lambda_function_body -> expr_l1_for_lambda + case 967: // lambda_function_body -> expr_l1_for_lambda { var id = SyntaxVisitors.ExprHasNameVisitor.HasName(ValueStack[ValueStack.Depth-1].ex, "Result"); if (id != null) @@ -7221,22 +7286,22 @@ public partial class GPPGParser: ShiftReduceParser common_lambda_body + case 968: // lambda_function_body -> common_lambda_body { CurrentSemanticValue.stn = ValueStack[ValueStack.Depth-1].stn; } break; - case 956: // lambda_procedure_body -> proc_call + case 969: // lambda_procedure_body -> proc_call { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 957: // lambda_procedure_body -> assignment + case 970: // lambda_procedure_body -> assignment { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 958: // lambda_procedure_body -> common_lambda_body + case 971: // lambda_procedure_body -> common_lambda_body { CurrentSemanticValue.stn = ValueStack[ValueStack.Depth-1].stn; } diff --git a/TestSuite/CompilationSamples/keywords.pas b/TestSuite/CompilationSamples/keywords.pas new file mode 100644 index 000000000..a73a6bac6 --- /dev/null +++ b/TestSuite/CompilationSamples/keywords.pas @@ -0,0 +1,33 @@ +type + T = class + public static procedure &Abstract := exit; + public static procedure &Operator := exit; + public static procedure &Partial := exit; + public static procedure &Lock := exit; + public static procedure &Implicit := exit; + public static procedure &Explicit := exit; + public static procedure &On := exit; + public static procedure &Overload := exit; + public static procedure &Reintroduce := exit; + public static procedure &Override := exit; + public static procedure &Extensionmethod := exit; + public static procedure &Virtual := exit; + public static procedure &Forward := exit; + public static procedure &Loop := exit; + end; + +begin + T.Abstract(); //Program2.pas(20) : Встречено 'Abstract', а ожидался оператор + T.Partial(); //Program2.pas(22) : Встречено 'Partial', а ожидался оператор + T.Lock(); //Program2.pas(23) : Встречено 'Lock', а ожидался оператор + T.Implicit(); //Program2.pas(24) : Встречено 'Implicit', а ожидался оператор + T.Explicit(); //Program2.pas(25) : Встречено 'Explicit', а ожидался оператор + T.On(); //Program2.pas(26) : Встречено 'On', а ожидался оператор + T.Overload(); //Program2.pas(27) : Встречено 'Overload', а ожидался оператор + T.Reintroduce(); //Program2.pas(28) : Встречено 'Reintroduce', а ожидался оператор + T.Override(); //Program2.pas(29) : Встречено 'Override', а ожидался оператор + T.Extensionmethod(); //Program2.pas(30) : Встречено 'Extensionmethod', а ожидался оператор + T.Virtual(); //Program2.pas(31) : Встречено 'Virtual', а ожидался оператор + T.Forward(); //Program2.pas(32) : Встречено 'Forward', а ожидался оператор + T.Loop(); //Program2.pas(33) : Встречено 'Loop', а ожидался оператор +end. \ No newline at end of file