From 5ec10f6fc46e60f7c5915c070322d6b88c013db5 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Mon, 17 Dec 2018 17:53:58 -0800 Subject: [PATCH] Update PHP assignment --- src/Language/PHP/Assignment.hs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Language/PHP/Assignment.hs b/src/Language/PHP/Assignment.hs index 695d019cc..053d53161 100644 --- a/src/Language/PHP/Assignment.hs +++ b/src/Language/PHP/Assignment.hs @@ -443,12 +443,17 @@ classMemberDeclaration = choice [ traitUseClause ] +-- TODO: What should the `location` be for implicit `public` visibility modifier? +publicVisibility = Assignment Term +publicVisibility = makeTerm <$> location <*> pure Declaration.Public + methodDeclaration :: Assignment Term -methodDeclaration = (makeTerm <$> symbol MethodDeclaration <*> children (makeMethod1 <$> manyTerm methodModifier <*> emptyTerm <*> functionDefinitionParts)) <|> makeTerm <$> symbol MethodDeclaration <*> children (makeMethod2 <$> someTerm methodModifier <*> emptyTerm <*> term name <*> parameters <*> term (returnType <|> emptyTerm) <*> emptyTerm) +methodDeclaration = (makeTerm <$> symbol MethodDeclaration <*> children (makeMethod1 <$> (visibilityModifier <|> publicVisibility) <*> manyTerm methodModifier <*> emptyTerm <*> functionDefinitionParts)) + <|> makeTerm <$> symbol MethodDeclaration <*> children (makeMethod2 <$> (visibilityModifier <|> publicVisibility) <*> someTerm methodModifier <*> emptyTerm <*> term name <*> parameters <*> term (returnType <|> emptyTerm) <*> emptyTerm) where functionDefinitionParts = symbol FunctionDefinition *> children ((,,,) <$> term name <*> parameters <*> term (returnType <|> emptyTerm) <*> (term compoundStatement <|> emptyTerm)) - makeMethod1 modifiers receiver (name, params, returnType, compoundStatement) = Declaration.Method (modifiers <> [returnType]) receiver name params compoundStatement - makeMethod2 modifiers receiver name params returnType compoundStatement = Declaration.Method (modifiers <> [returnType]) receiver name params compoundStatement + makeMethod1 visibility modifiers receiver (name, params, returnType, compoundStatement) = Declaration.Method (modifiers <> [returnType]) receiver visibility name params compoundStatement + makeMethod2 visibility modifiers receiver name params returnType compoundStatement = Declaration.Method (modifiers <> [returnType]) receiver visibility name params compoundStatement classBaseClause :: Assignment Term classBaseClause = makeTerm <$> symbol ClassBaseClause <*> children (Syntax.ClassBaseClause <$> term qualifiedName)