parser add modifier
This commit is contained in:
parent
32cce1f137
commit
bea9a039a8
@ -27,6 +27,9 @@ testMultipleDeclarationSameLine = TestCase $
|
|||||||
testMultipleDeclarations = TestCase $
|
testMultipleDeclarations = TestCase $
|
||||||
assertEqual "expect class with int and char field" [Class "Multiple" [] [VariableDeclaration "int" "value" Nothing, VariableDeclaration "char" "letter" Nothing]] $
|
assertEqual "expect class with int and char field" [Class "Multiple" [] [VariableDeclaration "int" "value" Nothing, VariableDeclaration "char" "letter" Nothing]] $
|
||||||
parse [CLASS,IDENTIFIER "Multiple",LBRACKET,INT,IDENTIFIER "value",SEMICOLON,CHAR,IDENTIFIER "letter",SEMICOLON,RBRACKET]
|
parse [CLASS,IDENTIFIER "Multiple",LBRACKET,INT,IDENTIFIER "value",SEMICOLON,CHAR,IDENTIFIER "letter",SEMICOLON,RBRACKET]
|
||||||
|
testWithModifier = TestCase $
|
||||||
|
assertEqual "expect class with int field" [Class "WithInt" [] [VariableDeclaration "int" "value" Nothing]] $
|
||||||
|
parse [ABSTRACT,CLASS,IDENTIFIER "WithInt",LBRACKET,PUBLIC,INT,IDENTIFIER "value",SEMICOLON,RBRACKET]
|
||||||
|
|
||||||
|
|
||||||
tests = TestList [
|
tests = TestList [
|
||||||
@ -35,5 +38,6 @@ tests = TestList [
|
|||||||
testBooleanField,
|
testBooleanField,
|
||||||
testIntField,
|
testIntField,
|
||||||
testCustomTypeField,
|
testCustomTypeField,
|
||||||
testMultipleDeclarations
|
testMultipleDeclarations,
|
||||||
|
testWithModifier
|
||||||
]
|
]
|
@ -90,7 +90,7 @@ qualifiedname : name DOT IDENTIFIER { }
|
|||||||
simplename : IDENTIFIER { $1 }
|
simplename : IDENTIFIER { $1 }
|
||||||
|
|
||||||
classdeclaration : CLASS IDENTIFIER classbody { case $3 of (methods, fields) -> Class $2 methods fields }
|
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 }
|
| modifiers CLASS IDENTIFIER classbody { case $4 of (methods, fields) -> Class $3 methods fields }
|
||||||
|
|
||||||
classbody : LBRACKET RBRACKET { ([], []) }
|
classbody : LBRACKET RBRACKET { ([], []) }
|
||||||
| LBRACKET classbodydeclarations RBRACKET { $2 }
|
| LBRACKET classbodydeclarations RBRACKET { $2 }
|
||||||
@ -129,7 +129,7 @@ constructordeclaration : constructordeclarator constructorbody { }
|
|||||||
| modifiers constructordeclarator constructorbody { }
|
| modifiers constructordeclarator constructorbody { }
|
||||||
|
|
||||||
fielddeclaration : type variabledeclarators SEMICOLON { FieldDecls $ map (convertDeclarator $1) $2 }
|
fielddeclaration : type variabledeclarators SEMICOLON { FieldDecls $ map (convertDeclarator $1) $2 }
|
||||||
-- | modifiers type variabledeclarators SEMICOLON {}
|
| modifiers type variabledeclarators SEMICOLON { FieldDecls $ map (convertDeclarator $2) $3 }
|
||||||
|
|
||||||
methoddeclaration : methodheader methodbody { }
|
methoddeclaration : methodheader methodbody { }
|
||||||
|
|
||||||
@ -365,9 +365,6 @@ data MethodOrFieldDeclaration = MethodDecl MethodDeclaration
|
|||||||
|
|
||||||
data Declarator = Declarator Identifier (Maybe Expression)
|
data Declarator = Declarator Identifier (Maybe Expression)
|
||||||
|
|
||||||
-- convertDeclaratorList :: [DataType] -> MethodOrFieldDeclaration
|
|
||||||
-- convertDeclaratorList = FieldDecls $ map
|
|
||||||
|
|
||||||
convertDeclarator :: DataType -> Declarator -> VariableDeclaration
|
convertDeclarator :: DataType -> Declarator -> VariableDeclaration
|
||||||
convertDeclarator dataType (Declarator id assigment) = VariableDeclaration dataType id assigment
|
convertDeclarator dataType (Declarator id assigment) = VariableDeclaration dataType id assigment
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user