parser add and, or, xor
This commit is contained in:
parent
de078639fc
commit
c29aa13d69
@ -123,6 +123,15 @@ testExpressionEqual = TestCase $
|
|||||||
testExpressionNotEqual = TestCase $
|
testExpressionNotEqual = TestCase $
|
||||||
assertEqual "expect comparison equal" (BinaryOperation CompareNotEqual (Reference "bar") (IntegerLiteral 3)) $
|
assertEqual "expect comparison equal" (BinaryOperation CompareNotEqual (Reference "bar") (IntegerLiteral 3)) $
|
||||||
parseExpression [IDENTIFIER "bar",NOTEQUAL,INTEGERLITERAL 3]
|
parseExpression [IDENTIFIER "bar",NOTEQUAL,INTEGERLITERAL 3]
|
||||||
|
testExpressionAnd = TestCase $
|
||||||
|
assertEqual "expect and expression" (BinaryOperation And (Reference "bar") (Reference "baz")) $
|
||||||
|
parseExpression [IDENTIFIER "bar",AND,IDENTIFIER "baz"]
|
||||||
|
testExpressionXor = TestCase $
|
||||||
|
assertEqual "expect xor expression" (BinaryOperation BitwiseXor (Reference "bar") (Reference "baz")) $
|
||||||
|
parseExpression [IDENTIFIER "bar",XOR,IDENTIFIER "baz"]
|
||||||
|
testExpressionOr = TestCase $
|
||||||
|
assertEqual "expect or expression" (BinaryOperation Or (Reference "bar") (Reference "baz")) $
|
||||||
|
parseExpression [IDENTIFIER "bar",OR,IDENTIFIER "baz"]
|
||||||
|
|
||||||
|
|
||||||
tests = TestList [
|
tests = TestList [
|
||||||
@ -157,5 +166,8 @@ tests = TestList [
|
|||||||
testExpressionLessThanEqual,
|
testExpressionLessThanEqual,
|
||||||
testExpressionGreaterThanOrEqual,
|
testExpressionGreaterThanOrEqual,
|
||||||
testExpressionEqual,
|
testExpressionEqual,
|
||||||
testExpressionNotEqual
|
testExpressionNotEqual,
|
||||||
|
testExpressionAnd,
|
||||||
|
testExpressionXor,
|
||||||
|
testExpressionOr
|
||||||
]
|
]
|
@ -44,7 +44,6 @@ import Parser.Lexer
|
|||||||
JNULL { NULLLITERAL }
|
JNULL { NULLLITERAL }
|
||||||
BOOLLITERAL { BOOLLITERAL $$ }
|
BOOLLITERAL { BOOLLITERAL $$ }
|
||||||
DIV { DIV }
|
DIV { DIV }
|
||||||
LOGICALOR { OR }
|
|
||||||
NOTEQUAL { NOTEQUAL }
|
NOTEQUAL { NOTEQUAL }
|
||||||
INSTANCEOF { INSTANCEOF }
|
INSTANCEOF { INSTANCEOF }
|
||||||
ANDEQUAL { ANDEQUAL }
|
ANDEQUAL { ANDEQUAL }
|
||||||
@ -310,7 +309,7 @@ postfixexpression : primary { $1 }
|
|||||||
primary : primarynonewarray { $1 }
|
primary : primarynonewarray { $1 }
|
||||||
|
|
||||||
inclusiveorexpression : exclusiveorexpression { $1 }
|
inclusiveorexpression : exclusiveorexpression { $1 }
|
||||||
-- | inclusiveorexpression OR exclusiveorexpression { }
|
| inclusiveorexpression OR exclusiveorexpression { BinaryOperation Or $1 $3 }
|
||||||
|
|
||||||
primarynonewarray : literal { $1 }
|
primarynonewarray : literal { $1 }
|
||||||
-- | THIS { }
|
-- | THIS { }
|
||||||
@ -325,7 +324,7 @@ unaryexpressionnotplusminus : postfixexpression { $1 }
|
|||||||
-- | castexpression{ }
|
-- | castexpression{ }
|
||||||
|
|
||||||
exclusiveorexpression : andexpression { $1 }
|
exclusiveorexpression : andexpression { $1 }
|
||||||
-- | exclusiveorexpression XOR andexpression { }
|
| exclusiveorexpression XOR andexpression { BinaryOperation BitwiseXor $1 $3 }
|
||||||
|
|
||||||
literal : INTLITERAL { IntegerLiteral $1 }
|
literal : INTLITERAL { IntegerLiteral $1 }
|
||||||
| BOOLLITERAL { BooleanLiteral $1 }
|
| BOOLLITERAL { BooleanLiteral $1 }
|
||||||
@ -336,7 +335,7 @@ castexpression : LBRACE primitivetype RBRACE unaryexpression { }
|
|||||||
| LBRACE expression RBRACE unaryexpressionnotplusminus{ }
|
| LBRACE expression RBRACE unaryexpressionnotplusminus{ }
|
||||||
|
|
||||||
andexpression : equalityexpression { $1 }
|
andexpression : equalityexpression { $1 }
|
||||||
-- | andexpression AND equalityexpression { }
|
| andexpression AND equalityexpression { BinaryOperation And $1 $3 }
|
||||||
|
|
||||||
equalityexpression : relationalexpression { $1 }
|
equalityexpression : relationalexpression { $1 }
|
||||||
| equalityexpression EQUAL relationalexpression { BinaryOperation CompareEqual $1 $3 }
|
| equalityexpression EQUAL relationalexpression { BinaryOperation CompareEqual $1 $3 }
|
||||||
|
Loading…
Reference in New Issue
Block a user