diff --git a/Test/TestParser.hs b/Test/TestParser.hs index 8e8db60..090fac1 100644 --- a/Test/TestParser.hs +++ b/Test/TestParser.hs @@ -139,16 +139,16 @@ testExpressionOr = TestCase $ assertEqual "expect or expression" (BinaryOperation Or (Reference "bar") (Reference "baz")) $ parseExpression [IDENTIFIER "bar",OR,IDENTIFIER "baz"] testExpressionPostIncrement = TestCase $ - assertEqual "expect PostIncrement" (UnaryOperation PostIncrement (Reference "a")) $ + assertEqual "expect PostIncrement" (StatementExpressionExpression $ PostIncrement (Reference "a")) $ parseExpression [IDENTIFIER "a",INCREMENT] testExpressionPostDecrement = TestCase $ - assertEqual "expect PostDecrement" (UnaryOperation PostDecrement (Reference "a")) $ + assertEqual "expect PostDecrement" (StatementExpressionExpression $ PostDecrement (Reference "a")) $ parseExpression [IDENTIFIER "a",DECREMENT] testExpressionPreIncrement = TestCase $ - assertEqual "expect PreIncrement" (UnaryOperation PreIncrement (Reference "a")) $ + assertEqual "expect PreIncrement" (StatementExpressionExpression $ PreIncrement (Reference "a")) $ parseExpression [INCREMENT,IDENTIFIER "a"] testExpressionPreDecrement = TestCase $ - assertEqual "expect PreIncrement" (UnaryOperation PreDecrement (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 45206a5..21d7be1 100644 --- a/src/Parser/JavaParser.y +++ b/src/Parser/JavaParser.y @@ -279,13 +279,13 @@ assignmentoperator : ASSIGN { Nothing } | XOREQUAL { Just BitwiseXor } | OREQUAL{ Just BitwiseOr } -preincrementexpression : INCREMENT unaryexpression { UnaryOperation PreIncrement $2 } +preincrementexpression : INCREMENT unaryexpression { PreIncrement $2 } -predecrementexpression : DECREMENT unaryexpression { UnaryOperation PreDecrement $2 } +predecrementexpression : DECREMENT unaryexpression { PreDecrement $2 } -postincrementexpression : postfixexpression INCREMENT { UnaryOperation PostIncrement $1 } +postincrementexpression : postfixexpression INCREMENT { PostIncrement $1 } -postdecrementexpression : postfixexpression DECREMENT { UnaryOperation PostDecrement $1 } +postdecrementexpression : postfixexpression DECREMENT { PostDecrement $1 } methodinvocation : simplename LBRACE RBRACE { MethodCall (Reference "this") $1 [] } | simplename LBRACE argumentlist RBRACE { MethodCall (Reference "this") $1 $3 } @@ -300,15 +300,15 @@ conditionalandexpression : inclusiveorexpression { $1 } fieldaccess : primary DOT IDENTIFIER { } unaryexpression : unaryexpressionnotplusminus { $1 } - | predecrementexpression { $1 } + | predecrementexpression { StatementExpressionExpression $1 } | PLUS unaryexpression { $2 } | MINUS unaryexpression { UnaryOperation Minus $2 } - | preincrementexpression { $1 } + | preincrementexpression { StatementExpressionExpression $1 } postfixexpression : primary { $1 } | name { $1 } - | postincrementexpression { $1 } - | postdecrementexpression{ $1 } + | postincrementexpression { StatementExpressionExpression $1 } + | postdecrementexpression { StatementExpressionExpression $1 } primary : primarynonewarray { $1 }