Compare commits

..

No commits in common. "a4d41b9ef73429649f262acf7183a80d7bd21b50" and "524c667c43d41790c0100f09d0985cdefc68f6f2" have entirely different histories.

2 changed files with 14 additions and 39 deletions

View File

@ -144,21 +144,6 @@ testExpressionPreIncrement = TestCase $
testExpressionPreDecrement = TestCase $ testExpressionPreDecrement = TestCase $
assertEqual "expect PreIncrement" (UnaryOperation PreDecrement (Reference "a")) $ assertEqual "expect PreIncrement" (UnaryOperation PreDecrement (Reference "a")) $
parseExpression [DECREMENT,IDENTIFIER "a"] parseExpression [DECREMENT,IDENTIFIER "a"]
testExpressionAssign = TestCase $
assertEqual "expect assign 5 to a" (StatementExpressionExpression (Assignment (Reference "a") (IntegerLiteral 5))) $
parseExpression [IDENTIFIER "a",ASSIGN,INTEGERLITERAL 5]
testExpressionTimesEqual = TestCase $
assertEqual "expect assign and multiplication" (StatementExpressionExpression (Assignment (Reference "a") (BinaryOperation Multiplication (Reference "a") (IntegerLiteral 5)))) $
parseExpression [IDENTIFIER "a",TIMESEQUAL,INTEGERLITERAL 5]
testExpressionDivideEqual = TestCase $
assertEqual "expect assign and division" (StatementExpressionExpression (Assignment (Reference "a") (BinaryOperation Division (Reference "a") (IntegerLiteral 5)))) $
parseExpression [IDENTIFIER "a",DIVEQUAL,INTEGERLITERAL 5]
testExpressionPlusEqual = TestCase $
assertEqual "expect assign and addition" (StatementExpressionExpression (Assignment (Reference "a") (BinaryOperation Addition (Reference "a") (IntegerLiteral 5)))) $
parseExpression [IDENTIFIER "a",PLUSEQUAL,INTEGERLITERAL 5]
testExpressionMinusEqual = TestCase $
assertEqual "expect assign and subtraction" (StatementExpressionExpression (Assignment (Reference "a") (BinaryOperation Subtraction (Reference "a") (IntegerLiteral 5)))) $
parseExpression [IDENTIFIER "a",MINUSEQUAL,INTEGERLITERAL 5]
testStatementIfThen = TestCase $ testStatementIfThen = TestCase $
assertEqual "expect empty ifthen" [If (Reference "a") (Block [Block []]) Nothing] $ assertEqual "expect empty ifthen" [If (Reference "a") (Block [Block []]) Nothing] $
@ -212,12 +197,6 @@ tests = TestList [
testExpressionPostDecrement, testExpressionPostDecrement,
testExpressionPreIncrement, testExpressionPreIncrement,
testExpressionPreDecrement, testExpressionPreDecrement,
testExpressionAssign,
testExpressionTimesEqual,
testExpressionTimesEqual,
testExpressionDivideEqual,
testExpressionPlusEqual,
testExpressionMinusEqual,
testStatementIfThen, testStatementIfThen,
testStatementIfThenElse, testStatementIfThenElse,
testStatementWhile testStatementWhile

View File

@ -82,7 +82,7 @@ compilationunit : typedeclarations { $1 }
typedeclarations : typedeclaration { [$1] } typedeclarations : typedeclaration { [$1] }
| typedeclarations typedeclaration { $1 ++ [$2] } | typedeclarations typedeclaration { $1 ++ [$2] }
name : simplename { Reference $1 } name : simplename { $1 }
-- | qualifiedname { } -- | qualifiedname { }
typedeclaration : classdeclaration { $1 } typedeclaration : classdeclaration { $1 }
@ -122,7 +122,7 @@ classtype : classorinterfacetype{ }
classbodydeclaration : classmemberdeclaration { $1 } classbodydeclaration : classmemberdeclaration { $1 }
| constructordeclaration { $1 } | constructordeclaration { $1 }
classorinterfacetype : simplename { $1 } classorinterfacetype : name { $1 }
classmemberdeclaration : fielddeclaration { $1 } classmemberdeclaration : fielddeclaration { $1 }
| methoddeclaration { $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) } whilestatement : WHILE LBRACE expression RBRACE statement { While $3 (Block $5) }
assignmentexpression : conditionalexpression { $1 } assignmentexpression : conditionalexpression { $1 }
| assignment { StatementExpressionExpression $1 } -- | assignment { }
emptystatement : SEMICOLON { Block [] } emptystatement : SEMICOLON { Block [] }
@ -241,11 +241,7 @@ statementnoshortif : statementwithouttrailingsubstatement { $1 }
conditionalexpression : conditionalorexpression { $1 } conditionalexpression : conditionalorexpression { $1 }
-- | conditionalorexpression QUESMARK expression COLON conditionalexpression { } -- | conditionalorexpression QUESMARK expression COLON conditionalexpression { }
assignment : lefthandside assignmentoperator assignmentexpression { assignment : lefthandside assignmentoperator assignmentexpression { }
case $2 of
Nothing -> Assignment $1 $3
Just operator -> Assignment $1 (BinaryOperation operator $1 $3)
}
statementexpression : assignment { } statementexpression : assignment { }
@ -266,18 +262,18 @@ conditionalorexpression : conditionalandexpression { $1 }
lefthandside : name { $1 } lefthandside : name { $1 }
assignmentoperator : ASSIGN { Nothing } assignmentoperator : ASSIGN{ }
| TIMESEQUAL { Just Multiplication } -- | TIMESEQUAL { }
| DIVIDEEQUAL { Just Division } -- | DIVIDEEQUAL { }
| MODULOEQUAL { Just Modulo } -- | MODULOEQUAL { }
| PLUSEQUAL { Just Addition } -- | PLUSEQUAL { }
| MINUSEQUAL { Just Subtraction } -- | MINUSEQUAL { }
-- | SHIFTLEFTEQUAL { } -- | SHIFTLEFTEQUAL { }
-- | SIGNEDSHIFTRIGHTEQUAL { } -- | SIGNEDSHIFTRIGHTEQUAL { }
-- | UNSIGNEDSHIFTRIGHTEQUAL { } -- | UNSIGNEDSHIFTRIGHTEQUAL { }
| ANDEQUAL { Just BitwiseAnd } -- | ANDEQUAL { }
| XOREQUAL { Just BitwiseXor } -- | XOREQUAL { }
| OREQUAL{ Just BitwiseOr } -- | OREQUAL{ }
preincrementexpression : INCREMENT unaryexpression { UnaryOperation PreIncrement $2 } preincrementexpression : INCREMENT unaryexpression { UnaryOperation PreIncrement $2 }
@ -306,7 +302,7 @@ unaryexpression : unaryexpressionnotplusminus { $1 }
| preincrementexpression { $1 } | preincrementexpression { $1 }
postfixexpression : primary { $1 } postfixexpression : primary { $1 }
| name { $1 } | name { Reference $1 }
| postincrementexpression { $1 } | postincrementexpression { $1 }
| postdecrementexpression{ $1 } | postdecrementexpression{ $1 }