parser add custom type fields
This commit is contained in:
parent
af7162ea54
commit
e04c475c55
@ -18,11 +18,16 @@ testBooleanField = TestCase $
|
||||
testIntField = TestCase $
|
||||
assertEqual "expect class with int field" [Class "WithInt" [] [VariableDeclaration "int" "value" Nothing]] $
|
||||
parse [CLASS,IDENTIFIER "WithInt",LBRACKET,INT,IDENTIFIER "value",SEMICOLON,RBRACKET]
|
||||
testCustomTypeField = TestCase $
|
||||
assertEqual "expect class with foo field" [Class "WithFoo" [] [VariableDeclaration "Foo" "value" Nothing]] $
|
||||
parse [CLASS,IDENTIFIER "WithFoo",LBRACKET,IDENTIFIER "Foo",IDENTIFIER "value",SEMICOLON,RBRACKET]
|
||||
|
||||
|
||||
|
||||
tests = TestList [
|
||||
testSingleEmptyClass,
|
||||
testTwoEmptyClasses,
|
||||
testBooleanField,
|
||||
testIntField
|
||||
testIntField,
|
||||
testCustomTypeField
|
||||
]
|
@ -80,14 +80,14 @@ compilationunit : typedeclarations { $1 }
|
||||
typedeclarations : typedeclaration { [$1] }
|
||||
| typedeclarations typedeclaration { $1 ++ [$2] }
|
||||
|
||||
name : qualifiedname { }
|
||||
| simplename { }
|
||||
name : simplename { $1 }
|
||||
-- | qualifiedname { }
|
||||
|
||||
typedeclaration : classdeclaration { $1 }
|
||||
|
||||
qualifiedname : name DOT IDENTIFIER { }
|
||||
|
||||
simplename : IDENTIFIER { }
|
||||
simplename : IDENTIFIER { $1 }
|
||||
|
||||
classdeclaration : CLASS IDENTIFIER classbody { case $3 of (methods, fields) -> Class $2 methods fields }
|
||||
-- | modifiers CLASS IDENTIFIER classbody { case $4 of (methods, fields) -> Class $3 methods fields }
|
||||
@ -120,7 +120,7 @@ classtype : classorinterfacetype{ }
|
||||
classbodydeclaration : classmemberdeclaration { $1 }
|
||||
-- | constructordeclaration { FieldDecl $ VariableDeclaration "int" "a" Nothing } -- TODO
|
||||
|
||||
classorinterfacetype : name{ }
|
||||
classorinterfacetype : name { $1 }
|
||||
|
||||
classmemberdeclaration : fielddeclaration { $1 }
|
||||
-- | methoddeclaration { }
|
||||
@ -150,7 +150,7 @@ methodheader : type methoddeclarator { }
|
||||
| modifiers VOID methoddeclarator { }
|
||||
|
||||
type : primitivetype { $1 }
|
||||
-- | referencetype { }
|
||||
| referencetype { $1 }
|
||||
|
||||
variabledeclarators : variabledeclarator { [$1] }
|
||||
-- | variabledeclarators COMMA variabledeclarator { $1 ++ [$3] }
|
||||
@ -176,7 +176,7 @@ methoddeclarator : IDENTIFIER LBRACE RBRACE { }
|
||||
primitivetype : BOOLEAN { "boolean" }
|
||||
| numerictype { $1 }
|
||||
|
||||
referencetype : classorinterfacetype { }
|
||||
referencetype : classorinterfacetype { $1 }
|
||||
|
||||
|
||||
variabledeclarator : variabledeclaratorid { Declarator $1 Nothing }
|
||||
|
Loading…
Reference in New Issue
Block a user