From 30365d76bd95fa74ecd3a00c8cc89d9e501d00c0 Mon Sep 17 00:00:00 2001 From: Marvin Schlegel Date: Fri, 31 May 2024 11:44:10 +0200 Subject: [PATCH] Revert "parser add preincrement and decrement conversion" This reverts commit 2acba0f28330613ecc831128c8790a4d3869ff0f. --- Test/TestParser.hs | 4 ++-- src/Parser/JavaParser.y | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Test/TestParser.hs b/Test/TestParser.hs index 7c38433..521a615 100644 --- a/Test/TestParser.hs +++ b/Test/TestParser.hs @@ -145,10 +145,10 @@ testExpressionPostDecrement = TestCase $ assertEqual "expect PostDecrement" (StatementExpressionExpression $ PostDecrement (Reference "a")) $ parseExpression [IDENTIFIER "a",DECREMENT] testExpressionPreIncrement = TestCase $ - assertEqual "expect PreIncrement" (StatementExpressionExpression $ Assignment (Reference "a") (BinaryOperation Addition (IntegerLiteral 1) (Reference "a"))) $ + assertEqual "expect PreIncrement" (StatementExpressionExpression $ PreIncrement (Reference "a")) $ parseExpression [INCREMENT,IDENTIFIER "a"] testExpressionPreDecrement = TestCase $ - assertEqual "expect PreIncrement" (StatementExpressionExpression $ Assignment (Reference "a") (BinaryOperation Subtraction (IntegerLiteral 1) (Reference "a"))) $ + assertEqual "expect PreIncrement" (StatementExpressionExpression $ PreDecrement (Reference "a")) $ parseExpression [DECREMENT,IDENTIFIER "a"] testExpressionAssign = TestCase $ assertEqual "expect assign 5 to a" (StatementExpressionExpression (Assignment (Reference "a") (IntegerLiteral 5))) $ diff --git a/src/Parser/JavaParser.y b/src/Parser/JavaParser.y index 5f19c34..fd694b6 100644 --- a/src/Parser/JavaParser.y +++ b/src/Parser/JavaParser.y @@ -279,9 +279,9 @@ assignmentoperator : ASSIGN { Nothing } | XOREQUAL { Just BitwiseXor } | OREQUAL{ Just BitwiseOr } -preincrementexpression : INCREMENT unaryexpression { Assignment $2 (BinaryOperation Addition (IntegerLiteral 1) $2) } +preincrementexpression : INCREMENT unaryexpression { PreIncrement $2 } -predecrementexpression : DECREMENT unaryexpression { Assignment $2 (BinaryOperation Subtraction (IntegerLiteral 1) $2) } +predecrementexpression : DECREMENT unaryexpression { PreDecrement $2 } postincrementexpression : postfixexpression INCREMENT { PostIncrement $1 }