parser implement methodcall with params
This commit is contained in:
parent
3c70f9f1f6
commit
24c2920c9c
@ -173,6 +173,12 @@ testExpressionPrecedence = TestCase $
|
|||||||
testExpressionMethodCallNoParams = TestCase $
|
testExpressionMethodCallNoParams = TestCase $
|
||||||
assertEqual "expect methodcall no params" (StatementExpressionExpression (MethodCall (Reference "this") "foo" [])) $
|
assertEqual "expect methodcall no params" (StatementExpressionExpression (MethodCall (Reference "this") "foo" [])) $
|
||||||
parseExpression [IDENTIFIER "foo",LBRACE,RBRACE]
|
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]
|
||||||
|
|
||||||
testStatementIfThen = TestCase $
|
testStatementIfThen = TestCase $
|
||||||
assertEqual "expect empty ifthen" [If (Reference "a") (Block [Block []]) Nothing] $
|
assertEqual "expect empty ifthen" [If (Reference "a") (Block [Block []]) Nothing] $
|
||||||
@ -243,6 +249,8 @@ tests = TestList [
|
|||||||
testExpressionThis,
|
testExpressionThis,
|
||||||
testExpressionPrecedence,
|
testExpressionPrecedence,
|
||||||
testExpressionMethodCallNoParams,
|
testExpressionMethodCallNoParams,
|
||||||
|
testExpressionMethodCallOneParam,
|
||||||
|
testExpressionMethodCallTwoParams,
|
||||||
testStatementIfThen,
|
testStatementIfThen,
|
||||||
testStatementIfThenElse,
|
testStatementIfThenElse,
|
||||||
testStatementWhile,
|
testStatementWhile,
|
||||||
|
@ -189,8 +189,8 @@ blockstatement : localvariabledeclarationstatement { $1 } -- expected ty
|
|||||||
|
|
||||||
formalparameter : type variabledeclaratorid { ParameterDeclaration $1 $2 }
|
formalparameter : type variabledeclaratorid { ParameterDeclaration $1 $2 }
|
||||||
|
|
||||||
argumentlist : expression { }
|
argumentlist : expression { [$1] }
|
||||||
| argumentlist COMMA expression { }
|
| argumentlist COMMA expression { $1 ++ [$3] }
|
||||||
|
|
||||||
numerictype : integraltype { $1 }
|
numerictype : integraltype { $1 }
|
||||||
|
|
||||||
@ -288,7 +288,7 @@ postincrementexpression : postfixexpression INCREMENT { UnaryOperation PostIncre
|
|||||||
postdecrementexpression : postfixexpression DECREMENT { UnaryOperation PostDecrement $1 }
|
postdecrementexpression : postfixexpression DECREMENT { UnaryOperation PostDecrement $1 }
|
||||||
|
|
||||||
methodinvocation : simplename LBRACE RBRACE { MethodCall (Reference "this") $1 [] }
|
methodinvocation : simplename LBRACE RBRACE { MethodCall (Reference "this") $1 [] }
|
||||||
-- | name LBRACE argumentlist RBRACE { }
|
| simplename LBRACE argumentlist RBRACE { MethodCall (Reference "this") $1 $3 }
|
||||||
-- | primary DOT IDENTIFIER LBRACE RBRACE { }
|
-- | primary DOT IDENTIFIER LBRACE RBRACE { }
|
||||||
-- | primary DOT IDENTIFIER LBRACE argumentlist RBRACE { }
|
-- | primary DOT IDENTIFIER LBRACE argumentlist RBRACE { }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user