Add initial typechecker for AST #2
@ -132,6 +132,18 @@ testExpressionXor = TestCase $
|
|||||||
testExpressionOr = TestCase $
|
testExpressionOr = TestCase $
|
||||||
assertEqual "expect or expression" (BinaryOperation Or (Reference "bar") (Reference "baz")) $
|
assertEqual "expect or expression" (BinaryOperation Or (Reference "bar") (Reference "baz")) $
|
||||||
parseExpression [IDENTIFIER "bar",OR,IDENTIFIER "baz"]
|
parseExpression [IDENTIFIER "bar",OR,IDENTIFIER "baz"]
|
||||||
|
testExpressionPostIncrement = TestCase $
|
||||||
|
assertEqual "expect PostIncrement" (UnaryOperation PostIncrement (Reference "a")) $
|
||||||
|
parseExpression [IDENTIFIER "a",INCREMENT]
|
||||||
|
testExpressionPostDecrement = TestCase $
|
||||||
|
assertEqual "expect PostDecrement" (UnaryOperation PostDecrement (Reference "a")) $
|
||||||
|
parseExpression [IDENTIFIER "a",DECREMENT]
|
||||||
|
testExpressionPreIncrement = TestCase $
|
||||||
|
assertEqual "expect PreIncrement" (UnaryOperation PreIncrement (Reference "a")) $
|
||||||
|
parseExpression [INCREMENT,IDENTIFIER "a"]
|
||||||
|
testExpressionPreDecrement = TestCase $
|
||||||
|
assertEqual "expect PreIncrement" (UnaryOperation PreDecrement (Reference "a")) $
|
||||||
|
parseExpression [DECREMENT,IDENTIFIER "a"]
|
||||||
|
|
||||||
|
|
||||||
tests = TestList [
|
tests = TestList [
|
||||||
@ -169,5 +181,9 @@ tests = TestList [
|
|||||||
testExpressionNotEqual,
|
testExpressionNotEqual,
|
||||||
testExpressionAnd,
|
testExpressionAnd,
|
||||||
testExpressionXor,
|
testExpressionXor,
|
||||||
testExpressionOr
|
testExpressionOr,
|
||||||
|
testExpressionPostIncrement,
|
||||||
|
testExpressionPostDecrement,
|
||||||
|
testExpressionPreIncrement,
|
||||||
|
testExpressionPreDecrement
|
||||||
]
|
]
|
@ -275,13 +275,13 @@ assignmentoperator : ASSIGN{ }
|
|||||||
-- | XOREQUAL { }
|
-- | XOREQUAL { }
|
||||||
-- | OREQUAL{ }
|
-- | OREQUAL{ }
|
||||||
|
|
||||||
preincrementexpression : INCREMENT unaryexpression { }
|
preincrementexpression : INCREMENT unaryexpression { UnaryOperation PreIncrement $2 }
|
||||||
|
|
||||||
predecrementexpression : DECREMENT unaryexpression { }
|
predecrementexpression : DECREMENT unaryexpression { UnaryOperation PreDecrement $2 }
|
||||||
|
|
||||||
postincrementexpression : postfixexpression INCREMENT { }
|
postincrementexpression : postfixexpression INCREMENT { UnaryOperation PostIncrement $1 }
|
||||||
|
|
||||||
postdecrementexpression : postfixexpression DECREMENT { }
|
postdecrementexpression : postfixexpression DECREMENT { UnaryOperation PostDecrement $1 }
|
||||||
|
|
||||||
methodinvocation : name LBRACE RBRACE { }
|
methodinvocation : name LBRACE RBRACE { }
|
||||||
| name LBRACE argumentlist RBRACE { }
|
| name LBRACE argumentlist RBRACE { }
|
||||||
@ -296,15 +296,15 @@ conditionalandexpression : inclusiveorexpression { $1 }
|
|||||||
fieldaccess : primary DOT IDENTIFIER { }
|
fieldaccess : primary DOT IDENTIFIER { }
|
||||||
|
|
||||||
unaryexpression : unaryexpressionnotplusminus { $1 }
|
unaryexpression : unaryexpressionnotplusminus { $1 }
|
||||||
-- | predecrementexpression { }
|
| predecrementexpression { $1 }
|
||||||
| PLUS unaryexpression { $2 }
|
| PLUS unaryexpression { $2 }
|
||||||
| MINUS unaryexpression { UnaryOperation Minus $2 }
|
| MINUS unaryexpression { UnaryOperation Minus $2 }
|
||||||
-- | preincrementexpression { $1 }
|
| preincrementexpression { $1 }
|
||||||
|
|
||||||
postfixexpression : primary { $1 }
|
postfixexpression : primary { $1 }
|
||||||
| name { Reference $1 }
|
| name { Reference $1 }
|
||||||
-- | postincrementexpression { }
|
| postincrementexpression { $1 }
|
||||||
-- | postdecrementexpression{ }
|
| postdecrementexpression{ $1 }
|
||||||
|
|
||||||
primary : primarynonewarray { $1 }
|
primary : primarynonewarray { $1 }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user