Add initial typechecker for AST #2
@ -30,9 +30,16 @@ testMultipleDeclarations = TestCase $
|
|||||||
testWithModifier = TestCase $
|
testWithModifier = TestCase $
|
||||||
assertEqual "expect class with int field" [Class "WithInt" [] [VariableDeclaration "int" "value" Nothing]] $
|
assertEqual "expect class with int field" [Class "WithInt" [] [VariableDeclaration "int" "value" Nothing]] $
|
||||||
parse [ABSTRACT,CLASS,IDENTIFIER "WithInt",LBRACKET,PUBLIC,INT,IDENTIFIER "value",SEMICOLON,RBRACKET]
|
parse [ABSTRACT,CLASS,IDENTIFIER "WithInt",LBRACKET,PUBLIC,INT,IDENTIFIER "value",SEMICOLON,RBRACKET]
|
||||||
testMethod = TestCase $
|
|
||||||
|
testEmptyMethod = TestCase $
|
||||||
assertEqual "expect class with method" [Class "WithMethod" [MethodDeclaration "int" "foo" [] (Block [])] []] $
|
assertEqual "expect class with method" [Class "WithMethod" [MethodDeclaration "int" "foo" [] (Block [])] []] $
|
||||||
parse [CLASS,IDENTIFIER "WithMethod",LBRACKET,INT,IDENTIFIER "foo",LBRACE,RBRACE,SEMICOLON,RBRACKET]
|
parse [CLASS,IDENTIFIER "WithMethod",LBRACKET,INT,IDENTIFIER "foo",LBRACE,RBRACE,SEMICOLON,RBRACKET]
|
||||||
|
testEmptyPrivateMethod = TestCase $
|
||||||
|
assertEqual "expect class with method" [Class "WithMethod" [MethodDeclaration "int" "foo" [] (Block [])] []] $
|
||||||
|
parse [CLASS,IDENTIFIER "WithMethod",LBRACKET,PRIVATE,INT,IDENTIFIER "foo",LBRACE,RBRACE,LBRACKET,RBRACKET,RBRACKET]
|
||||||
|
testEmptyVoidMethod = TestCase $
|
||||||
|
assertEqual "expect class with method" [Class "WithMethod" [MethodDeclaration "void" "foo" [] (Block [])] []] $
|
||||||
|
parse [CLASS,IDENTIFIER "WithMethod",LBRACKET,VOID,IDENTIFIER "foo",LBRACE,RBRACE,LBRACKET,RBRACKET,RBRACKET]
|
||||||
|
|
||||||
|
|
||||||
tests = TestList [
|
tests = TestList [
|
||||||
@ -43,5 +50,7 @@ tests = TestList [
|
|||||||
testCustomTypeField,
|
testCustomTypeField,
|
||||||
testMultipleDeclarations,
|
testMultipleDeclarations,
|
||||||
testWithModifier,
|
testWithModifier,
|
||||||
testMethod
|
testEmptyMethod,
|
||||||
|
testEmptyPrivateMethod,
|
||||||
|
testEmptyVoidMethod
|
||||||
]
|
]
|
@ -145,9 +145,9 @@ constructorbody : LBRACKET RBRACKET { }
|
|||||||
| LBRACKET explicitconstructorinvocation blockstatements RBRACKET { }
|
| LBRACKET explicitconstructorinvocation blockstatements RBRACKET { }
|
||||||
|
|
||||||
methodheader : type methoddeclarator { ($1, $2) }
|
methodheader : type methoddeclarator { ($1, $2) }
|
||||||
-- | modifiers type methoddeclarator { }
|
| modifiers type methoddeclarator { ($2, $3) }
|
||||||
-- | VOID methoddeclarator { }
|
| VOID methoddeclarator { ("void", $2) }
|
||||||
-- | modifiers VOID methoddeclarator { }
|
| modifiers VOID methoddeclarator { ("void", $3)}
|
||||||
|
|
||||||
type : primitivetype { $1 }
|
type : primitivetype { $1 }
|
||||||
| referencetype { $1 }
|
| referencetype { $1 }
|
||||||
|
Loading…
Reference in New Issue
Block a user