From 01f279772293ea6f0924fae6b1fab005973e2567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20?= =?UTF-8?q?=D0=9F=D0=BE=D0=B3=D0=BE=D1=80=D0=B5=D0=BB=D0=BE=D0=B2?= Date: Fri, 28 Jun 2019 08:54:19 +0300 Subject: [PATCH] fix #2023 --- Parsers/PascalABCParserNewSaushkin/ABCPascal.cs | 6 +++--- Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs | 6 +++--- .../SugarVisitors/ExtendedIsDesugaringVisitor.cs | 10 +++++----- ...ded-is-short.pas => patterns-extended-is-short.pas} | 0 TestSuite/patterns-extended-is-var-chain.pas | 7 +++++++ 5 files changed, 18 insertions(+), 11 deletions(-) rename TestSuite/{patterns/extended-is-short.pas => patterns-extended-is-short.pas} (100%) create mode 100644 TestSuite/patterns-extended-is-var-chain.pas diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs index 700583922..1ed320df2 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-G8V08V4 -// DateTime: 24.06.2019 15:32:41 -// UserName: ????????? +// Machine: DESKTOP-IF20NRO +// DateTime: 6/28/2019 7:30:18 AM +// UserName: FatCow // GPLEX input file // GPLEX frame file // diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs index 75f5a2389..7a1136442 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-G8V08V4 -// DateTime: 24.06.2019 15:32:41 -// UserName: ????????? +// Machine: DESKTOP-IF20NRO +// DateTime: 6/28/2019 7:30:19 AM +// UserName: FatCow // Input file // options: no-lines gplex diff --git a/SyntaxVisitors/SugarVisitors/ExtendedIsDesugaringVisitor.cs b/SyntaxVisitors/SugarVisitors/ExtendedIsDesugaringVisitor.cs index d0883ebb1..1eaaf6088 100644 --- a/SyntaxVisitors/SugarVisitors/ExtendedIsDesugaringVisitor.cs +++ b/SyntaxVisitors/SugarVisitors/ExtendedIsDesugaringVisitor.cs @@ -19,21 +19,21 @@ namespace SyntaxVisitors.SugarVisitors if_node leftExprIfNode = null; if (binEpxr.operation_type == Operators.LogicalAND) { - rightExprIfNode = new if_node(binEpxr.right, _if_node.then_body, _if_node.else_body, _if_node.source_context); - leftExprIfNode = new if_node(binEpxr.left, rightExprIfNode, _if_node.else_body, _if_node.source_context); + rightExprIfNode = new if_node(binEpxr.right, (statement)_if_node.then_body?.Clone(), (statement)_if_node.else_body?.Clone(), _if_node.source_context); + leftExprIfNode = new if_node(binEpxr.left, rightExprIfNode, (statement)_if_node.else_body?.Clone(), _if_node.source_context); } else if (binEpxr.operation_type == Operators.LogicalOR) { rightExprIfNode = new if_node( new un_expr(binEpxr.right, Operators.LogicalNOT, binEpxr.source_context), - _if_node.else_body, - _if_node.then_body, + (statement)_if_node.else_body?.Clone(), + (statement)_if_node.then_body?.Clone(), _if_node.source_context); leftExprIfNode = new if_node( new un_expr(binEpxr.left, Operators.LogicalNOT, binEpxr.source_context), rightExprIfNode, - _if_node.then_body, + (statement)_if_node.then_body?.Clone(), _if_node.source_context); } ReplaceUsingParent(_if_node, leftExprIfNode); diff --git a/TestSuite/patterns/extended-is-short.pas b/TestSuite/patterns-extended-is-short.pas similarity index 100% rename from TestSuite/patterns/extended-is-short.pas rename to TestSuite/patterns-extended-is-short.pas diff --git a/TestSuite/patterns-extended-is-var-chain.pas b/TestSuite/patterns-extended-is-var-chain.pas new file mode 100644 index 000000000..62989e05b --- /dev/null +++ b/TestSuite/patterns-extended-is-var-chain.pas @@ -0,0 +1,7 @@ +begin + var o1, o2, o3: object; + if (o1 is word(var p1)) and (o2 is real(var p2)) + then + else + if (o3 is byte(var v1)) then +end. \ No newline at end of file