diff --git a/Test/TestParser.hs b/Test/TestParser.hs index 99ad2c9..5727203 100644 --- a/Test/TestParser.hs +++ b/Test/TestParser.hs @@ -227,7 +227,9 @@ testStatementConstructorCallWithArgs = TestCase $ assertEqual "expect constructor call" [StatementExpressionStatement (ConstructorCall "Foo" [Reference "b"])] $ parseStatement [NEW,IDENTIFIER "Foo",LBRACE,IDENTIFIER "b",RBRACE,SEMICOLON] - +testStatementPreIncrement = TestCase $ + assertEqual "expect increment" [StatementExpressionStatement $ PostIncrement $ Reference "a"] $ + parseStatement [IDENTIFIER "a",INCREMENT,SEMICOLON] tests = TestList [ @@ -296,5 +298,6 @@ tests = TestList [ testStatementAssign, testStatementMethodCallNoParams, testStatementConstructorCall, - testStatementConstructorCallWithArgs + testStatementConstructorCallWithArgs, + testStatementIncrement ] \ No newline at end of file diff --git a/src/Parser/JavaParser.y b/src/Parser/JavaParser.y index 54c4b55..aa22bb8 100644 --- a/src/Parser/JavaParser.y +++ b/src/Parser/JavaParser.y @@ -249,10 +249,10 @@ assignment : lefthandside assignmentoperator assignmentexpression { statementexpression : assignment { $1 } - -- | preincrementexpression { } - -- | predecrementexpression { } - -- | postincrementexpression { } - -- | postdecrementexpression { } + | preincrementexpression { $1 } + | predecrementexpression { $1 } + | postincrementexpression { $1 } + | postdecrementexpression { $1 } | methodinvocation { $1 } | classinstancecreationexpression { $1 }