parser add empty methods
This commit is contained in:
parent
5e90f0d0ee
commit
f57f360abf
@ -30,6 +30,9 @@ 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 $
|
||||||
|
assertEqual "expect class with method" [Class "WithMethod" [MethodDeclaration "int" "foo" [] (Block [])] []] $
|
||||||
|
parse [CLASS,IDENTIFIER "WithMethod",LBRACKET,INT,IDENTIFIER "foo",LBRACE,RBRACE,SEMICOLON,RBRACKET]
|
||||||
|
|
||||||
|
|
||||||
tests = TestList [
|
tests = TestList [
|
||||||
@ -39,5 +42,6 @@ tests = TestList [
|
|||||||
testIntField,
|
testIntField,
|
||||||
testCustomTypeField,
|
testCustomTypeField,
|
||||||
testMultipleDeclarations,
|
testMultipleDeclarations,
|
||||||
testWithModifier
|
testWithModifier,
|
||||||
|
testMethod
|
||||||
]
|
]
|
@ -123,7 +123,7 @@ classbodydeclaration : classmemberdeclaration { $1 }
|
|||||||
classorinterfacetype : name { $1 }
|
classorinterfacetype : name { $1 }
|
||||||
|
|
||||||
classmemberdeclaration : fielddeclaration { $1 }
|
classmemberdeclaration : fielddeclaration { $1 }
|
||||||
-- | methoddeclaration { }
|
| methoddeclaration { $1 }
|
||||||
|
|
||||||
constructordeclaration : constructordeclarator constructorbody { }
|
constructordeclaration : constructordeclarator constructorbody { }
|
||||||
| modifiers constructordeclarator constructorbody { }
|
| modifiers constructordeclarator constructorbody { }
|
||||||
@ -131,10 +131,10 @@ constructordeclaration : constructordeclarator constructorbody { }
|
|||||||
fielddeclaration : type variabledeclarators SEMICOLON { FieldDecls $ map (convertDeclarator $1) $2 }
|
fielddeclaration : type variabledeclarators SEMICOLON { FieldDecls $ map (convertDeclarator $1) $2 }
|
||||||
| modifiers type variabledeclarators SEMICOLON { FieldDecls $ map (convertDeclarator $2) $3 }
|
| modifiers type variabledeclarators SEMICOLON { FieldDecls $ map (convertDeclarator $2) $3 }
|
||||||
|
|
||||||
methoddeclaration : methodheader methodbody { }
|
methoddeclaration : methodheader methodbody { case $1 of (returnType, (name, parameters)) -> MethodDecl (MethodDeclaration returnType name parameters $2) }
|
||||||
|
|
||||||
block : LBRACKET RBRACKET { }
|
block : LBRACKET RBRACKET { Block [] }
|
||||||
| LBRACKET blockstatements RBRACKET { }
|
-- | LBRACKET blockstatements RBRACKET { }
|
||||||
|
|
||||||
constructordeclarator : simplename LBRACE RBRACE { }
|
constructordeclarator : simplename LBRACE RBRACE { }
|
||||||
| simplename LBRACE formalparameterlist RBRACE { }
|
| simplename LBRACE formalparameterlist RBRACE { }
|
||||||
@ -144,10 +144,10 @@ constructorbody : LBRACKET RBRACKET { }
|
|||||||
| LBRACKET blockstatements RBRACKET { }
|
| LBRACKET blockstatements RBRACKET { }
|
||||||
| LBRACKET explicitconstructorinvocation blockstatements RBRACKET { }
|
| LBRACKET explicitconstructorinvocation blockstatements RBRACKET { }
|
||||||
|
|
||||||
methodheader : type methoddeclarator { }
|
methodheader : type methoddeclarator { ($1, $2) }
|
||||||
| modifiers type methoddeclarator { }
|
-- | modifiers type methoddeclarator { }
|
||||||
| VOID methoddeclarator { }
|
-- | VOID methoddeclarator { }
|
||||||
| modifiers VOID methoddeclarator { }
|
-- | modifiers VOID methoddeclarator { }
|
||||||
|
|
||||||
type : primitivetype { $1 }
|
type : primitivetype { $1 }
|
||||||
| referencetype { $1 }
|
| referencetype { $1 }
|
||||||
@ -155,8 +155,8 @@ type : primitivetype { $1 }
|
|||||||
variabledeclarators : variabledeclarator { [$1] }
|
variabledeclarators : variabledeclarator { [$1] }
|
||||||
| variabledeclarators COMMA variabledeclarator { $1 ++ [$3] }
|
| variabledeclarators COMMA variabledeclarator { $1 ++ [$3] }
|
||||||
|
|
||||||
methodbody : block { }
|
methodbody : block { $1 }
|
||||||
| SEMICOLON { }
|
| SEMICOLON { Block [] }
|
||||||
|
|
||||||
blockstatements : blockstatement { }
|
blockstatements : blockstatement { }
|
||||||
| blockstatements blockstatement { }
|
| blockstatements blockstatement { }
|
||||||
@ -170,8 +170,8 @@ explicitconstructorinvocation : THIS LBRACE RBRACE SEMICOLON { }
|
|||||||
classtypelist : classtype { }
|
classtypelist : classtype { }
|
||||||
| classtypelist COMMA classtype { }
|
| classtypelist COMMA classtype { }
|
||||||
|
|
||||||
methoddeclarator : IDENTIFIER LBRACE RBRACE { }
|
methoddeclarator : IDENTIFIER LBRACE RBRACE { ($1, []) }
|
||||||
| IDENTIFIER LBRACE formalparameterlist RBRACE { }
|
-- | IDENTIFIER LBRACE formalparameterlist RBRACE { }
|
||||||
|
|
||||||
primitivetype : BOOLEAN { "boolean" }
|
primitivetype : BOOLEAN { "boolean" }
|
||||||
| numerictype { $1 }
|
| numerictype { $1 }
|
||||||
|
Loading…
Reference in New Issue
Block a user