Add initial typechecker for AST #2
@ -179,6 +179,12 @@ testExpressionMethodCallOneParam = TestCase $
|
||||
testExpressionMethodCallTwoParams = TestCase $
|
||||
assertEqual "expect methocall two params" (StatementExpressionExpression (MethodCall (Reference "this") "foo" [Reference "a", IntegerLiteral 5])) $
|
||||
parseExpression [IDENTIFIER "foo",LBRACE,IDENTIFIER "a",COMMA,INTEGERLITERAL 5,RBRACE]
|
||||
testExpressionThisMethodCall = TestCase $
|
||||
assertEqual "expect this methocall" (StatementExpressionExpression (MethodCall (Reference "this") "foo" [])) $
|
||||
parseExpression [THIS,DOT,IDENTIFIER "foo",LBRACE,RBRACE]
|
||||
testExpressionThisMethodCallParam = TestCase $
|
||||
assertEqual "expect this methocall" (StatementExpressionExpression (MethodCall (Reference "this") "foo" [Reference "x"])) $
|
||||
parseExpression [THIS,DOT,IDENTIFIER "foo",LBRACE,IDENTIFIER "x",RBRACE]
|
||||
|
||||
testStatementIfThen = TestCase $
|
||||
assertEqual "expect empty ifthen" [If (Reference "a") (Block [Block []]) Nothing] $
|
||||
@ -251,6 +257,8 @@ tests = TestList [
|
||||
testExpressionMethodCallNoParams,
|
||||
testExpressionMethodCallOneParam,
|
||||
testExpressionMethodCallTwoParams,
|
||||
testExpressionThisMethodCall,
|
||||
testExpressionThisMethodCallParam,
|
||||
testStatementIfThen,
|
||||
testStatementIfThenElse,
|
||||
testStatementWhile,
|
||||
|
@ -289,8 +289,8 @@ postdecrementexpression : postfixexpression DECREMENT { UnaryOperation PostDecre
|
||||
|
||||
methodinvocation : simplename LBRACE RBRACE { MethodCall (Reference "this") $1 [] }
|
||||
| simplename LBRACE argumentlist RBRACE { MethodCall (Reference "this") $1 $3 }
|
||||
-- | primary DOT IDENTIFIER LBRACE RBRACE { }
|
||||
-- | primary DOT IDENTIFIER LBRACE argumentlist RBRACE { }
|
||||
| primary DOT IDENTIFIER LBRACE RBRACE { MethodCall $1 $3 [] }
|
||||
| primary DOT IDENTIFIER LBRACE argumentlist RBRACE { MethodCall $1 $3 $5 }
|
||||
|
||||
classinstancecreationexpression : NEW classtype LBRACE RBRACE { }
|
||||
| NEW classtype LBRACE argumentlist RBRACE { }
|
||||
|
Loading…
Reference in New Issue
Block a user