parser add preincrement and decrement conversion
This commit is contained in:
parent
84613fabe0
commit
2acba0f283
@ -145,10 +145,10 @@ testExpressionPostDecrement = TestCase $
|
|||||||
assertEqual "expect PostDecrement" (StatementExpressionExpression $ PostDecrement (Reference "a")) $
|
assertEqual "expect PostDecrement" (StatementExpressionExpression $ PostDecrement (Reference "a")) $
|
||||||
parseExpression [IDENTIFIER "a",DECREMENT]
|
parseExpression [IDENTIFIER "a",DECREMENT]
|
||||||
testExpressionPreIncrement = TestCase $
|
testExpressionPreIncrement = TestCase $
|
||||||
assertEqual "expect PreIncrement" (StatementExpressionExpression $ PreIncrement (Reference "a")) $
|
assertEqual "expect PreIncrement" (StatementExpressionExpression $ Assignment (Reference "a") (BinaryOperation Addition (IntegerLiteral 1) (Reference "a"))) $
|
||||||
parseExpression [INCREMENT,IDENTIFIER "a"]
|
parseExpression [INCREMENT,IDENTIFIER "a"]
|
||||||
testExpressionPreDecrement = TestCase $
|
testExpressionPreDecrement = TestCase $
|
||||||
assertEqual "expect PreIncrement" (StatementExpressionExpression $ PreDecrement (Reference "a")) $
|
assertEqual "expect PreIncrement" (StatementExpressionExpression $ Assignment (Reference "a") (BinaryOperation Subtraction (IntegerLiteral 1) (Reference "a"))) $
|
||||||
parseExpression [DECREMENT,IDENTIFIER "a"]
|
parseExpression [DECREMENT,IDENTIFIER "a"]
|
||||||
testExpressionAssign = TestCase $
|
testExpressionAssign = TestCase $
|
||||||
assertEqual "expect assign 5 to a" (StatementExpressionExpression (Assignment (Reference "a") (IntegerLiteral 5))) $
|
assertEqual "expect assign 5 to a" (StatementExpressionExpression (Assignment (Reference "a") (IntegerLiteral 5))) $
|
||||||
|
@ -279,9 +279,9 @@ assignmentoperator : ASSIGN { Nothing }
|
|||||||
| XOREQUAL { Just BitwiseXor }
|
| XOREQUAL { Just BitwiseXor }
|
||||||
| OREQUAL{ Just BitwiseOr }
|
| OREQUAL{ Just BitwiseOr }
|
||||||
|
|
||||||
preincrementexpression : INCREMENT unaryexpression { PreIncrement $2 }
|
preincrementexpression : INCREMENT unaryexpression { Assignment $2 (BinaryOperation Addition (IntegerLiteral 1) $2) }
|
||||||
|
|
||||||
predecrementexpression : DECREMENT unaryexpression { PreDecrement $2 }
|
predecrementexpression : DECREMENT unaryexpression { Assignment $2 (BinaryOperation Subtraction (IntegerLiteral 1) $2) }
|
||||||
|
|
||||||
postincrementexpression : postfixexpression INCREMENT { PostIncrement $1 }
|
postincrementexpression : postfixexpression INCREMENT { PostIncrement $1 }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user