From aa3242524a2b8f48c123397580343ecdf749a104 Mon Sep 17 00:00:00 2001 From: Mikhalkovich Stanislav Date: Tue, 18 Jun 2019 16:02:15 +0300 Subject: [PATCH] bug fix #1526 and bug fix #1533 --- Configuration/GlobalAssemblyInfo.cs | 2 +- Configuration/Version.defs | 4 +- .../PascalABCParserNewSaushkin/ABCPascal.cs | 6 +- .../PascalABCParserNewSaushkin/ABCPascal.y | 12 +- .../ABCPascalYacc.cs | 1660 ++++++++--------- Parsers/PascalABCParserNewSaushkin/PABC.tags | 3 - Parsers/PascalABCParserNewSaushkin/PABC.ymc | 1 + ReleaseGenerators/PascalABCNET_version.nsh | 2 +- TestSuite/lambda_func_with_Result_1.pas | 8 + TestSuite/lambda_func_with_Result_2.pas | 11 + .../TreeConversion/syntax_tree_visitor.cs | 6 +- 11 files changed, 864 insertions(+), 851 deletions(-) create mode 100644 TestSuite/lambda_func_with_Result_1.pas create mode 100644 TestSuite/lambda_func_with_Result_2.pas diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index a4fba5d9c..cbe4305ed 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 = "5"; public const string Build = "0"; - public const string Revision = "2111"; + public const string Revision = "2114"; 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 55328ce38..d00b6194a 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ -%MINOR%=5 -%REVISION%=2111 %COREVERSION%=0 +%REVISION%=2114 +%MINOR%=5 %MAJOR%=3 diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs index f85fd86ea..b71c0b702 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/15/2019 8:40:57 AM -// UserName: FatCow +// Machine: DESKTOP-G8V08V4 +// DateTime: 18.06.2019 14:40:06 +// UserName: ????????? // GPLEX input file // GPLEX frame file // diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.y b/Parsers/PascalABCParserNewSaushkin/ABCPascal.y index 6f50d03ea..44d264895 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascal.y +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascal.y @@ -4675,14 +4675,10 @@ common_lambda_body { $$ = new statement_list($1 as statement, @$); } - | yield_stmt + /*| yield_stmt { $$ = new statement_list($1 as statement, @$); - } - | raise_stmt - { - $$ = new statement_list($1 as statement, @$); - } + }*/ ; @@ -4713,6 +4709,10 @@ 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 935545940..1d1d4b7cb 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/15/2019 8:40:57 AM -// UserName: FatCow +// Machine: DESKTOP-G8V08V4 +// DateTime: 18.06.2019 14:40:07 +// 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[949]; - private static State[] states = new State[1567]; + private static Rule[] rules = new Rule[948]; + private static State[] states = new State[1565]; 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 yield_stmt -{ - CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); - } - break; - case 943: // common_lambda_body -> raise_stmt -{ - CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); - } - break; - case 944: // lambda_function_body -> expr_l1 + case 942: // lambda_function_body -> expr_l1 { var id = SyntaxVisitors.ExprHasNameVisitor.HasName(ValueStack[ValueStack.Depth-1].ex, "Result"); if (id != null) @@ -7147,22 +7134,27 @@ public partial class GPPGParser: ShiftReduceParser common_lambda_body + case 943: // lambda_function_body -> common_lambda_body { CurrentSemanticValue.stn = ValueStack[ValueStack.Depth-1].stn; } break; - case 946: // lambda_procedure_body -> proc_call + case 944: // lambda_procedure_body -> proc_call { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 947: // lambda_procedure_body -> assignment + case 945: // lambda_procedure_body -> assignment { CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); } break; - case 948: // lambda_procedure_body -> common_lambda_body + case 946: // lambda_procedure_body -> raise_stmt +{ + CurrentSemanticValue.stn = new statement_list(ValueStack[ValueStack.Depth-1].stn as statement, CurrentLocationSpan); + } + break; + case 947: // lambda_procedure_body -> common_lambda_body { CurrentSemanticValue.stn = ValueStack[ValueStack.Depth-1].stn; } diff --git a/Parsers/PascalABCParserNewSaushkin/PABC.tags b/Parsers/PascalABCParserNewSaushkin/PABC.tags index e421d5473..0d0c593d4 100644 --- a/Parsers/PascalABCParserNewSaushkin/PABC.tags +++ b/Parsers/PascalABCParserNewSaushkin/PABC.tags @@ -7,7 +7,6 @@ - @@ -137,7 +136,6 @@ - @@ -157,7 +155,6 @@ - diff --git a/Parsers/PascalABCParserNewSaushkin/PABC.ymc b/Parsers/PascalABCParserNewSaushkin/PABC.ymc index 0e5406013..9d360ea9c 100644 --- a/Parsers/PascalABCParserNewSaushkin/PABC.ymc +++ b/Parsers/PascalABCParserNewSaushkin/PABC.ymc @@ -242,5 +242,6 @@ script= + diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index 2ff016197..70ee72969 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.5.0.2111' +!define VERSION '3.5.0.2114' diff --git a/TestSuite/lambda_func_with_Result_1.pas b/TestSuite/lambda_func_with_Result_1.pas new file mode 100644 index 000000000..1194de301 --- /dev/null +++ b/TestSuite/lambda_func_with_Result_1.pas @@ -0,0 +1,8 @@ +begin + var p: ()->boolean := ()-> + begin + case 0 of + 0: Result := true; + end + end; +end. \ No newline at end of file diff --git a/TestSuite/lambda_func_with_Result_2.pas b/TestSuite/lambda_func_with_Result_2.pas new file mode 100644 index 000000000..f2b7b84c8 --- /dev/null +++ b/TestSuite/lambda_func_with_Result_2.pas @@ -0,0 +1,11 @@ +procedure p1(f: real-> real) := exit; + +begin + p1(r -> + begin + try + Result := r; + except + end; + end); +end. \ No newline at end of file diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index b272a593a..b03ad2923 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -19394,7 +19394,11 @@ namespace PascalABCCompiler.TreeConverter if (!stl.expr_lambda_body) // SSM 26.11.18 // значит, первый и единственный оператор - не присваивание и это лямбда - процедура! { - _function_lambda_definition.return_type = null; + var rns = new LambdaHelper.ResultNodesSearcher(_function_lambda_definition.proc_body); + if (rns.exprList.Count == 0) // Значит, это процедура, т.к. в блоке begin-end нет ни одного result := ... + { + _function_lambda_definition.return_type = null; + } } } else if (_function_lambda_definition.return_type is lambda_inferred_type && stl != null && stl.list.Count > 1 && _function_lambda_definition.usedkeyword == 0)