parser implement assign
This commit is contained in:
parent
524c667c43
commit
9f658397de
@ -144,6 +144,9 @@ testExpressionPreIncrement = TestCase $
|
||||
testExpressionPreDecrement = TestCase $
|
||||
assertEqual "expect PreIncrement" (UnaryOperation PreDecrement (Reference "a")) $
|
||||
parseExpression [DECREMENT,IDENTIFIER "a"]
|
||||
testExpressionAssign = TestCase $
|
||||
assertEqual "expect assign and addition" (StatementExpressionExpression (Assignment (Reference "a") (IntegerLiteral 5))) $
|
||||
parseExpression [IDENTIFIER "a",ASSIGN,INTEGERLITERAL 5]
|
||||
|
||||
testStatementIfThen = TestCase $
|
||||
assertEqual "expect empty ifthen" [If (Reference "a") (Block [Block []]) Nothing] $
|
||||
@ -197,6 +200,7 @@ tests = TestList [
|
||||
testExpressionPostDecrement,
|
||||
testExpressionPreIncrement,
|
||||
testExpressionPreDecrement,
|
||||
testExpressionAssign,
|
||||
testStatementIfThen,
|
||||
testStatementIfThenElse,
|
||||
testStatementWhile
|
||||
|
@ -82,7 +82,7 @@ compilationunit : typedeclarations { $1 }
|
||||
typedeclarations : typedeclaration { [$1] }
|
||||
| typedeclarations typedeclaration { $1 ++ [$2] }
|
||||
|
||||
name : simplename { $1 }
|
||||
name : simplename { Reference $1 }
|
||||
-- | qualifiedname { }
|
||||
|
||||
typedeclaration : classdeclaration { $1 }
|
||||
@ -122,7 +122,7 @@ classtype : classorinterfacetype{ }
|
||||
classbodydeclaration : classmemberdeclaration { $1 }
|
||||
| constructordeclaration { $1 }
|
||||
|
||||
classorinterfacetype : name { $1 }
|
||||
classorinterfacetype : simplename { $1 }
|
||||
|
||||
classmemberdeclaration : fielddeclaration { $1 }
|
||||
| methoddeclaration { $1 }
|
||||
@ -225,7 +225,7 @@ ifthenelsestatement : IF LBRACE expression RBRACE statementnoshortif ELSE state
|
||||
whilestatement : WHILE LBRACE expression RBRACE statement { While $3 (Block $5) }
|
||||
|
||||
assignmentexpression : conditionalexpression { $1 }
|
||||
-- | assignment { }
|
||||
| assignment { StatementExpressionExpression $1 }
|
||||
|
||||
emptystatement : SEMICOLON { Block [] }
|
||||
|
||||
@ -241,7 +241,9 @@ statementnoshortif : statementwithouttrailingsubstatement { $1 }
|
||||
conditionalexpression : conditionalorexpression { $1 }
|
||||
-- | conditionalorexpression QUESMARK expression COLON conditionalexpression { }
|
||||
|
||||
assignment : lefthandside assignmentoperator assignmentexpression { }
|
||||
assignment : lefthandside assignmentoperator assignmentexpression {
|
||||
Assignment $1 $3
|
||||
}
|
||||
|
||||
|
||||
statementexpression : assignment { }
|
||||
@ -262,18 +264,18 @@ conditionalorexpression : conditionalandexpression { $1 }
|
||||
|
||||
lefthandside : name { $1 }
|
||||
|
||||
assignmentoperator : ASSIGN{ }
|
||||
-- | TIMESEQUAL { }
|
||||
-- | DIVIDEEQUAL { }
|
||||
-- | MODULOEQUAL { }
|
||||
-- | PLUSEQUAL { }
|
||||
-- | MINUSEQUAL { }
|
||||
assignmentoperator : ASSIGN { Nothing }
|
||||
| TIMESEQUAL { Just Multiplication }
|
||||
| DIVIDEEQUAL { Just Division }
|
||||
| MODULOEQUAL { Just Modulo }
|
||||
| PLUSEQUAL { Just Addition }
|
||||
| MINUSEQUAL { Just Subtraction }
|
||||
-- | SHIFTLEFTEQUAL { }
|
||||
-- | SIGNEDSHIFTRIGHTEQUAL { }
|
||||
-- | UNSIGNEDSHIFTRIGHTEQUAL { }
|
||||
-- | ANDEQUAL { }
|
||||
-- | XOREQUAL { }
|
||||
-- | OREQUAL{ }
|
||||
| ANDEQUAL { Just BitwiseAnd }
|
||||
| XOREQUAL { Just BitwiseXor }
|
||||
| OREQUAL{ Just BitwiseOr }
|
||||
|
||||
preincrementexpression : INCREMENT unaryexpression { UnaryOperation PreIncrement $2 }
|
||||
|
||||
@ -302,7 +304,7 @@ unaryexpression : unaryexpressionnotplusminus { $1 }
|
||||
| preincrementexpression { $1 }
|
||||
|
||||
postfixexpression : primary { $1 }
|
||||
| name { Reference $1 }
|
||||
| name { $1 }
|
||||
| postincrementexpression { $1 }
|
||||
| postdecrementexpression{ $1 }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user