From fe54b731c8252de46aefa5b32861009fd2ad9602 Mon Sep 17 00:00:00 2001 From: Mikhalkovich Stanislav Date: Wed, 19 Jun 2019 14:41:20 +0300 Subject: [PATCH] fix #1996 --- .../PascalABCParserNewSaushkin/ABCPascal.cs | 6 +- .../PascalABCParserNewSaushkin/ABCPascal.y | 12 +- .../ABCPascalYacc.cs | 1674 +++++++++-------- Parsers/PascalABCParserNewSaushkin/PABC.ymc | 1 + TestSuite/Lambda_body_raise.pas | 4 + bin/Lng/Eng/PascalABCParser.dat | 3 +- bin/Lng/Rus/PascalABCParser.dat | 3 +- 7 files changed, 859 insertions(+), 844 deletions(-) create mode 100644 TestSuite/Lambda_body_raise.pas diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs index 08817da43..8fae03c29 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-IF20NRO -// DateTime: 6/19/2019 11:22:12 AM -// UserName: FatCow +// Machine: DESKTOP-G8V08V4 +// DateTime: 19.06.2019 14:36:10 +// UserName: ????????? // GPLEX input file // GPLEX frame file // diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.y b/Parsers/PascalABCParserNewSaushkin/ABCPascal.y index 72bc526ff..fba301020 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascal.y +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascal.y @@ -4677,10 +4677,14 @@ common_lambda_body { $$ = new statement_list($1 as statement, @$); } - /*| yield_stmt + | raise_stmt { $$ = new statement_list($1 as statement, @$); - }*/ + } + | yield_stmt + { + parsertools.AddErrorFromResource("YIELD_STATEMENT_CANNOT_BE_USED_IN_LAMBDA_BODY", @$); + } ; @@ -4711,10 +4715,6 @@ lambda_procedure_body { $$ = new statement_list($1 as statement, @$); } - | raise_stmt - { - $$ = new statement_list($1 as statement, @$); - } | common_lambda_body { $$ = $1; diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs index e5c16723b..203586240 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-IF20NRO -// DateTime: 6/19/2019 11:22:13 AM -// UserName: FatCow +// Machine: DESKTOP-G8V08V4 +// DateTime: 19.06.2019 14:36:11 +// UserName: ????????? // Input file // options: no-lines gplex @@ -75,8 +75,8 @@ public partial class GPPGParser: ShiftReduceParser aliasses; #pragma warning restore 649 - private static Rule[] rules = new Rule[942]; - private static State[] states = new State[1554]; + private static Rule[] rules = new Rule[943]; + private static State[] states = new State[1556]; 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", @@ -166,13 +166,13 @@ public partial class GPPGParser: ShiftReduceParser expr_l1 + case 936: // common_lambda_body -> raise_stmt +{ + CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); + } + break; + case 937: // common_lambda_body -> yield_stmt +{ + parsertools.AddErrorFromResource("YIELD_STATEMENT_CANNOT_BE_USED_IN_LAMBDA_BODY", CurrentLocationSpan); + } + break; + case 938: // lambda_function_body -> expr_l1 { var id = SyntaxVisitors.ExprHasNameVisitor.HasName(ValueStack[ValueStack.Depth-1].ex, "Result"); if (id != null) @@ -7076,27 +7089,22 @@ public partial class GPPGParser: ShiftReduceParser common_lambda_body + case 939: // lambda_function_body -> common_lambda_body { CurrentSemanticValue.stn = ValueStack[ValueStack.Depth-1].stn; } break; - case 938: // lambda_procedure_body -> proc_call + case 940: // lambda_procedure_body -> proc_call { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 939: // lambda_procedure_body -> assignment + case 941: // lambda_procedure_body -> assignment { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 940: // lambda_procedure_body -> raise_stmt -{ - CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); - } - break; - case 941: // lambda_procedure_body -> common_lambda_body + case 942: // 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 9d360ea9c..1ba42d12f 100644 --- a/Parsers/PascalABCParserNewSaushkin/PABC.ymc +++ b/Parsers/PascalABCParserNewSaushkin/PABC.ymc @@ -243,5 +243,6 @@ script= + diff --git a/TestSuite/Lambda_body_raise.pas b/TestSuite/Lambda_body_raise.pas new file mode 100644 index 000000000..e1b7db9f7 --- /dev/null +++ b/TestSuite/Lambda_body_raise.pas @@ -0,0 +1,4 @@ +begin + var p: procedure := + ()->raise new Exception; +end. \ No newline at end of file diff --git a/bin/Lng/Eng/PascalABCParser.dat b/bin/Lng/Eng/PascalABCParser.dat index 742291266..caac0a3a6 100644 --- a/bin/Lng/Eng/PascalABCParser.dat +++ b/bin/Lng/Eng/PascalABCParser.dat @@ -72,4 +72,5 @@ ATTRIBUTE_REDECLARED=This attribute has been already applied to type STATIC_PROPERTIES_CANNOT_HAVE_ATTRBUTE_{0}=Static properties cannot have attribute '{0}' RESULT_IDENT_NOT_EXPECTED_IN_THIS_CONTEXT=Result identifier is not allowed in this context NESTED_RECORD_DEFINITIONS_ARE_ARE_FORBIDDEN=Nested record definitions are forbidden -NIL_IN_UNNAMED_OBJECT=Anonymous class field cannot be initialized by nil constant \ No newline at end of file +NIL_IN_UNNAMED_OBJECT=Anonymous class field cannot be initialized by nil constant +YIELD_STATEMENT_CANNOT_BE_USED_IN_LAMBDA_BODY=yield statement cannot be used in lambda body \ No newline at end of file diff --git a/bin/Lng/Rus/PascalABCParser.dat b/bin/Lng/Rus/PascalABCParser.dat index 2afe0dfb6..8c739048c 100644 --- a/bin/Lng/Rus/PascalABCParser.dat +++ b/bin/Lng/Rus/PascalABCParser.dat @@ -73,4 +73,5 @@ ATTRIBUTE_REDECLARED=Повторное применение атрибута STATIC_PROPERTIES_CANNOT_HAVE_ATTRBUTE_{0}=Статические свойства не могут иметь атрибут '{0}' RESULT_IDENT_NOT_EXPECTED_IN_THIS_CONTEXT=Имя Result недопустимо в этом контексте NESTED_RECORD_DEFINITIONS_ARE_FORBIDDEN=Вложенные описания записей запрещены -NIL_IN_UNNAMED_OBJECT=Поле анонимного класса не может инициализироваться константой nil \ No newline at end of file +NIL_IN_UNNAMED_OBJECT=Поле анонимного класса не может инициализироваться константой nil +YIELD_STATEMENT_CANNOT_BE_USED_IN_LAMBDA_BODY=Оператор yield нельзя использовать в теле лямбда-выражения \ No newline at end of file