Compare commits
No commits in common. "1e59ba9e277f291285983f21347a605deefa3811" and "f81a812f59f95d1c2fb7e20ab462015d0646ef53" have entirely different histories.
1e59ba9e27
...
f81a812f59
@ -52,12 +52,6 @@ testClassWithMethodAndField = TestCase $
|
||||
testClassWithConstructor = TestCase $
|
||||
assertEqual "expect class with constructor" [Class "WithConstructor" [MethodDeclaration "void" "<init>" [] (Block [])] []] $
|
||||
parse [CLASS,IDENTIFIER "WithConstructor",LBRACKET,IDENTIFIER "WithConstructor",LBRACE,RBRACE,LBRACKET,RBRACKET,RBRACKET]
|
||||
testConstructorWithParams = TestCase $
|
||||
assertEqual "expect constructor with params" [Class "WithParams" [MethodDeclaration "void" "<init>" [ParameterDeclaration "int" "p1"] (Block [])] []] $
|
||||
parse [CLASS,IDENTIFIER "WithParams",LBRACKET,IDENTIFIER "WithParams",LBRACE,INT,IDENTIFIER "p1",RBRACE,LBRACKET,RBRACKET,RBRACKET]
|
||||
testConstructorWithStatements = TestCase $
|
||||
assertEqual "expect constructor with statement" [Class "WithConstructor" [MethodDeclaration "void" "<init>" [] (Block [Return Nothing])] []] $
|
||||
parse [CLASS,IDENTIFIER "WithConstructor",LBRACKET,IDENTIFIER "WithConstructor",LBRACE,RBRACE,LBRACKET,RETURN,SEMICOLON,RBRACKET,RBRACKET]
|
||||
|
||||
|
||||
testEmptyBlock = TestCase $ assertEqual "expect empty block" [Block []] $ parseStatement [LBRACKET,RBRACKET]
|
||||
@ -176,22 +170,6 @@ testExpressionPrecedence = TestCase $
|
||||
assertEqual "expect times to be inner expression" (BinaryOperation Addition (BinaryOperation Multiplication (Reference "b") (Reference "a")) (IntegerLiteral 3)) $
|
||||
parseExpression [IDENTIFIER "b",TIMES,IDENTIFIER "a",PLUS,INTEGERLITERAL 3]
|
||||
|
||||
testExpressionMethodCallNoParams = TestCase $
|
||||
assertEqual "expect methodcall no params" (StatementExpressionExpression (MethodCall (Reference "this") "foo" [])) $
|
||||
parseExpression [IDENTIFIER "foo",LBRACE,RBRACE]
|
||||
testExpressionMethodCallOneParam = TestCase $
|
||||
assertEqual "expect methodcall one param" (StatementExpressionExpression (MethodCall (Reference "this") "foo" [Reference "a"])) $
|
||||
parseExpression [IDENTIFIER "foo",LBRACE,IDENTIFIER "a",RBRACE]
|
||||
testExpressionMethodCallTwoParams = TestCase $
|
||||
assertEqual "expect methocall two params" (StatementExpressionExpression (MethodCall (Reference "this") "foo" [Reference "a", IntegerLiteral 5])) $
|
||||
parseExpression [IDENTIFIER "foo",LBRACE,IDENTIFIER "a",COMMA,INTEGERLITERAL 5,RBRACE]
|
||||
testExpressionThisMethodCall = TestCase $
|
||||
assertEqual "expect this methocall" (StatementExpressionExpression (MethodCall (Reference "this") "foo" [])) $
|
||||
parseExpression [THIS,DOT,IDENTIFIER "foo",LBRACE,RBRACE]
|
||||
testExpressionThisMethodCallParam = TestCase $
|
||||
assertEqual "expect this methocall" (StatementExpressionExpression (MethodCall (Reference "this") "foo" [Reference "x"])) $
|
||||
parseExpression [THIS,DOT,IDENTIFIER "foo",LBRACE,IDENTIFIER "x",RBRACE]
|
||||
|
||||
testStatementIfThen = TestCase $
|
||||
assertEqual "expect empty ifthen" [If (Reference "a") (Block [Block []]) Nothing] $
|
||||
parseStatement [IF,LBRACE,IDENTIFIER "a",RBRACE,LBRACKET,RBRACKET]
|
||||
@ -201,13 +179,6 @@ testStatementIfThenElse = TestCase $
|
||||
testStatementWhile = TestCase $
|
||||
assertEqual "expect while" [While (Reference "a") (Block [Block []])] $
|
||||
parseStatement [WHILE,LBRACE,IDENTIFIER "a",RBRACE,LBRACKET,RBRACKET]
|
||||
testStatementAssign = TestCase $
|
||||
assertEqual "expect assign 5" [StatementExpressionStatement (Assignment (Reference "a") (IntegerLiteral 5))] $
|
||||
parseStatement [IDENTIFIER "a",ASSIGN,INTEGERLITERAL 5,SEMICOLON]
|
||||
|
||||
testStatementMethodCallNoParams = TestCase $
|
||||
assertEqual "expect methodcall statement no params" [StatementExpressionStatement (MethodCall (Reference "this") "foo" [])] $
|
||||
parseStatement [IDENTIFIER "foo",LBRACE,RBRACE,SEMICOLON]
|
||||
|
||||
|
||||
|
||||
@ -226,8 +197,6 @@ tests = TestList [
|
||||
testEmptyMethodWithParams,
|
||||
testClassWithMethodAndField,
|
||||
testClassWithConstructor,
|
||||
testConstructorWithParams,
|
||||
testConstructorWithStatements,
|
||||
testEmptyBlock,
|
||||
testBlockWithLocalVarDecl,
|
||||
testBlockWithMultipleLocalVarDecls,
|
||||
@ -262,14 +231,7 @@ tests = TestList [
|
||||
testExpressionBraced,
|
||||
testExpressionThis,
|
||||
testExpressionPrecedence,
|
||||
testExpressionMethodCallNoParams,
|
||||
testExpressionMethodCallOneParam,
|
||||
testExpressionMethodCallTwoParams,
|
||||
testExpressionThisMethodCall,
|
||||
testExpressionThisMethodCallParam,
|
||||
testStatementIfThen,
|
||||
testStatementIfThenElse,
|
||||
testStatementWhile,
|
||||
testStatementAssign,
|
||||
testStatementMethodCallNoParams
|
||||
testStatementWhile
|
||||
]
|
@ -127,8 +127,8 @@ classorinterfacetype : simplename { $1 }
|
||||
classmemberdeclaration : fielddeclaration { $1 }
|
||||
| methoddeclaration { $1 }
|
||||
|
||||
constructordeclaration : constructordeclarator constructorbody { MethodDecl $ MethodDeclaration "void" "<init>" $1 $2 }
|
||||
| modifiers constructordeclarator constructorbody { MethodDecl $ MethodDeclaration "void" "<init>" $2 $3 }
|
||||
constructordeclaration : constructordeclarator constructorbody { case $1 of (classname, parameters) -> MethodDecl $ MethodDeclaration "void" "<init>" parameters $2 }
|
||||
| modifiers constructordeclarator constructorbody { case $2 of (classname, parameters) -> MethodDecl $ MethodDeclaration "void" "<init>" parameters $3 }
|
||||
|
||||
fielddeclaration : type variabledeclarators SEMICOLON { FieldDecls $ map (convertDeclarator $1) $2 }
|
||||
| modifiers type variabledeclarators SEMICOLON { FieldDecls $ map (convertDeclarator $2) $3 }
|
||||
@ -138,12 +138,12 @@ methoddeclaration : methodheader methodbody { case $1 of (returnType, (name, par
|
||||
block : LBRACKET RBRACKET { Block [] }
|
||||
| LBRACKET blockstatements RBRACKET { Block $2 }
|
||||
|
||||
constructordeclarator : simplename LBRACE RBRACE { [] }
|
||||
| simplename LBRACE formalparameterlist RBRACE { $3 }
|
||||
constructordeclarator : simplename LBRACE RBRACE { ($1, []) }
|
||||
| simplename LBRACE formalparameterlist RBRACE { ($1, $3) }
|
||||
|
||||
constructorbody : LBRACKET RBRACKET { Block [] }
|
||||
-- | LBRACKET explicitconstructorinvocation RBRACKET { }
|
||||
| LBRACKET blockstatements RBRACKET { Block $2 }
|
||||
-- | LBRACKET blockstatements RBRACKET { }
|
||||
-- | LBRACKET explicitconstructorinvocation blockstatements RBRACKET { }
|
||||
|
||||
methodheader : type methoddeclarator { ($1, $2) }
|
||||
@ -189,8 +189,8 @@ blockstatement : localvariabledeclarationstatement { $1 } -- expected ty
|
||||
|
||||
formalparameter : type variabledeclaratorid { ParameterDeclaration $1 $2 }
|
||||
|
||||
argumentlist : expression { [$1] }
|
||||
| argumentlist COMMA expression { $1 ++ [$3] }
|
||||
argumentlist : expression { }
|
||||
| argumentlist COMMA expression { }
|
||||
|
||||
numerictype : integraltype { $1 }
|
||||
|
||||
@ -253,7 +253,7 @@ statementexpression : assignment { $1 }
|
||||
-- | predecrementexpression { }
|
||||
-- | postincrementexpression { }
|
||||
-- | postdecrementexpression { }
|
||||
| methodinvocation { $1 }
|
||||
-- | methodinvocation { }
|
||||
-- | classinstancecreationexpression { }
|
||||
|
||||
ifthenelsestatementnoshortif :IF LBRACE expression RBRACE statementnoshortif
|
||||
@ -287,10 +287,10 @@ postincrementexpression : postfixexpression INCREMENT { UnaryOperation PostIncre
|
||||
|
||||
postdecrementexpression : postfixexpression DECREMENT { UnaryOperation PostDecrement $1 }
|
||||
|
||||
methodinvocation : simplename LBRACE RBRACE { MethodCall (Reference "this") $1 [] }
|
||||
| simplename LBRACE argumentlist RBRACE { MethodCall (Reference "this") $1 $3 }
|
||||
| primary DOT IDENTIFIER LBRACE RBRACE { MethodCall $1 $3 [] }
|
||||
| primary DOT IDENTIFIER LBRACE argumentlist RBRACE { MethodCall $1 $3 $5 }
|
||||
methodinvocation : name LBRACE RBRACE { }
|
||||
| name LBRACE argumentlist RBRACE { }
|
||||
| primary DOT IDENTIFIER LBRACE RBRACE { }
|
||||
| primary DOT IDENTIFIER LBRACE argumentlist RBRACE { }
|
||||
|
||||
classinstancecreationexpression : NEW classtype LBRACE RBRACE { }
|
||||
| NEW classtype LBRACE argumentlist RBRACE { }
|
||||
@ -320,7 +320,7 @@ primarynonewarray : literal { $1 }
|
||||
| LBRACE expression RBRACE { $2 }
|
||||
-- | classinstancecreationexpression { }
|
||||
-- | fieldaccess { }
|
||||
| methodinvocation { StatementExpressionExpression $1 }
|
||||
-- | methodinvocation { }
|
||||
|
||||
unaryexpressionnotplusminus : postfixexpression { $1 }
|
||||
-- | TILDE unaryexpression { }
|
||||
|
Loading…
Reference in New Issue
Block a user