Add initial typechecker for AST #2
@ -58,6 +58,9 @@ testEmptyBlock = TestCase $ assertEqual "expect empty block" (Block []) $ parseB
|
||||
testBlockWithLocalVarDecl = TestCase $
|
||||
assertEqual "expect block with local var delcaration" (Block [LocalVariableDeclaration $ VariableDeclaration "int" "localvar" Nothing]) $
|
||||
parseBlock [LBRACKET,INT,IDENTIFIER "localvar",SEMICOLON,RBRACKET]
|
||||
testBlockWithMultipleLocalVarDecls = TestCase $
|
||||
assertEqual "expect block with multiple local var declarations" (Block [LocalVariableDeclaration $ VariableDeclaration "int" "var1" Nothing, LocalVariableDeclaration $ VariableDeclaration "boolean" "var2" Nothing]) $
|
||||
parseBlock [LBRACKET,INT,IDENTIFIER "var1",SEMICOLON,BOOLEAN,IDENTIFIER "var2",SEMICOLON,RBRACKET]
|
||||
|
||||
|
||||
tests = TestList [
|
||||
@ -76,5 +79,6 @@ tests = TestList [
|
||||
testClassWithMethodAndField,
|
||||
testClassWithConstructor,
|
||||
testEmptyBlock,
|
||||
testBlockWithLocalVarDecl
|
||||
testBlockWithLocalVarDecl,
|
||||
testBlockWithMultipleLocalVarDecls
|
||||
]
|
@ -161,7 +161,7 @@ methodbody : block { $1 }
|
||||
| SEMICOLON { Block [] }
|
||||
|
||||
blockstatements : blockstatement { Block $1 }
|
||||
-- | blockstatements blockstatement { }
|
||||
| blockstatements blockstatement { case $1 of Block stmts -> Block (stmts ++ $2)}
|
||||
|
||||
formalparameterlist : formalparameter { [$1] }
|
||||
| formalparameterlist COMMA formalparameter { $1 ++ [$3] }
|
||||
|
Loading…
Reference in New Issue
Block a user