parser add unary not, plus and minus
This commit is contained in:
parent
f82776e636
commit
4f61431c79
@ -84,6 +84,13 @@ testReturnVoid = TestCase $
|
|||||||
assertEqual "expect block with return nothing" (Block [Return Nothing]) $
|
assertEqual "expect block with return nothing" (Block [Return Nothing]) $
|
||||||
parseBlock [LBRACKET,RETURN,SEMICOLON,RBRACKET]
|
parseBlock [LBRACKET,RETURN,SEMICOLON,RBRACKET]
|
||||||
|
|
||||||
|
testExpressionNot = TestCase $
|
||||||
|
assertEqual "expect expression not" (UnaryOperation Not (Reference "boar")) $
|
||||||
|
parseExpression [NOT,IDENTIFIER "boar"]
|
||||||
|
testExpressionMinus = TestCase $
|
||||||
|
assertEqual "expect expression minus" (UnaryOperation Minus (Reference "boo")) $
|
||||||
|
parseExpression [MINUS,IDENTIFIER "boo"]
|
||||||
|
|
||||||
tests = TestList [
|
tests = TestList [
|
||||||
testSingleEmptyClass,
|
testSingleEmptyClass,
|
||||||
testTwoEmptyClasses,
|
testTwoEmptyClasses,
|
||||||
@ -108,5 +115,7 @@ tests = TestList [
|
|||||||
testFieldWithInitialization,
|
testFieldWithInitialization,
|
||||||
testLocalBoolWithInitialization,
|
testLocalBoolWithInitialization,
|
||||||
testFieldNullWithInitialization,
|
testFieldNullWithInitialization,
|
||||||
testReturnVoid
|
testReturnVoid,
|
||||||
|
testExpressionNot,
|
||||||
|
testExpressionMinus
|
||||||
]
|
]
|
@ -298,12 +298,12 @@ fieldaccess : primary DOT IDENTIFIER { }
|
|||||||
|
|
||||||
unaryexpression : unaryexpressionnotplusminus { $1 }
|
unaryexpression : unaryexpressionnotplusminus { $1 }
|
||||||
-- | predecrementexpression { }
|
-- | predecrementexpression { }
|
||||||
-- | PLUS unaryexpression { }
|
| PLUS unaryexpression { $2 }
|
||||||
-- | MINUS unaryexpression { }
|
| MINUS unaryexpression { UnaryOperation Minus $2 }
|
||||||
-- | preincrementexpression { $1 }
|
-- | preincrementexpression { $1 }
|
||||||
|
|
||||||
postfixexpression : primary { $1 }
|
postfixexpression : primary { $1 }
|
||||||
-- | name { }
|
| name { Reference $1 }
|
||||||
-- | postincrementexpression { }
|
-- | postincrementexpression { }
|
||||||
-- | postdecrementexpression{ }
|
-- | postdecrementexpression{ }
|
||||||
|
|
||||||
@ -321,7 +321,7 @@ primarynonewarray : literal { $1 }
|
|||||||
|
|
||||||
unaryexpressionnotplusminus : postfixexpression { $1 }
|
unaryexpressionnotplusminus : postfixexpression { $1 }
|
||||||
-- | TILDE unaryexpression { }
|
-- | TILDE unaryexpression { }
|
||||||
-- | EXCLMARK unaryexpression { }
|
| EXCLMARK unaryexpression { UnaryOperation Not $2 }
|
||||||
-- | castexpression{ }
|
-- | castexpression{ }
|
||||||
|
|
||||||
exclusiveorexpression : andexpression { $1 }
|
exclusiveorexpression : andexpression { $1 }
|
||||||
|
Loading…
Reference in New Issue
Block a user