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]) $
|
||||
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 [
|
||||
testSingleEmptyClass,
|
||||
testTwoEmptyClasses,
|
||||
@ -108,5 +115,7 @@ tests = TestList [
|
||||
testFieldWithInitialization,
|
||||
testLocalBoolWithInitialization,
|
||||
testFieldNullWithInitialization,
|
||||
testReturnVoid
|
||||
testReturnVoid,
|
||||
testExpressionNot,
|
||||
testExpressionMinus
|
||||
]
|
@ -298,12 +298,12 @@ fieldaccess : primary DOT IDENTIFIER { }
|
||||
|
||||
unaryexpression : unaryexpressionnotplusminus { $1 }
|
||||
-- | predecrementexpression { }
|
||||
-- | PLUS unaryexpression { }
|
||||
-- | MINUS unaryexpression { }
|
||||
| PLUS unaryexpression { $2 }
|
||||
| MINUS unaryexpression { UnaryOperation Minus $2 }
|
||||
-- | preincrementexpression { $1 }
|
||||
|
||||
postfixexpression : primary { $1 }
|
||||
-- | name { }
|
||||
| name { Reference $1 }
|
||||
-- | postincrementexpression { }
|
||||
-- | postdecrementexpression{ }
|
||||
|
||||
@ -321,7 +321,7 @@ primarynonewarray : literal { $1 }
|
||||
|
||||
unaryexpressionnotplusminus : postfixexpression { $1 }
|
||||
-- | TILDE unaryexpression { }
|
||||
-- | EXCLMARK unaryexpression { }
|
||||
| EXCLMARK unaryexpression { UnaryOperation Not $2 }
|
||||
-- | castexpression{ }
|
||||
|
||||
exclusiveorexpression : andexpression { $1 }
|
||||
|
Loading…
Reference in New Issue
Block a user