{"action":"created","comment":{"url":"https://api.github.com/repos/SonarCommunity/sonar-php/pulls/comments/40538714","id":40538714,"diff_hunk":"@@ -0,0 +1,1011 @@\n+/*\n+ * SonarQube PHP Plugin\n+ * Copyright (C) 2010 SonarSource and Akram Ben Aissi\n+ * sonarqube@googlegroups.com\n+ *\n+ * This program is free software; you can redistribute it and/or\n+ * modify it under the terms of the GNU Lesser General Public\n+ * License as published by the Free Software Foundation; either\n+ * version 3 of the License, or (at your option) any later version.\n+ *\n+ * This program is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n+ * Lesser General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU Lesser General Public\n+ * License along with this program; if not, write to the Free Software\n+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02\n+ */\n+package org.sonar.php.parser;\n+\n+import com.sonar.sslr.api.typed.GrammarBuilder;\n+import org.sonar.php.api.PHPKeyword;\n+import org.sonar.php.api.PHPPunctuator;\n+import org.sonar.php.tree.impl.SeparatedList;\n+import org.sonar.php.tree.impl.lexical.InternalSyntaxToken;\n+import org.sonar.php.tree.impl.statement.DeclareStatementTreeImpl.DeclareStatementHead;\n+import org.sonar.php.tree.impl.statement.ForEachStatementTreeImpl.ForEachStatementHeader;\n+import org.sonar.php.tree.impl.statement.ForStatementTreeImpl.ForStatementHeader;\n+import org.sonar.plugins.php.api.tree.Tree.Kind;\n+import org.sonar.plugins.php.api.tree.declaration.FunctionDeclarationTree;\n+import org.sonar.plugins.php.api.tree.declaration.MethodDeclarationTree;\n+import org.sonar.plugins.php.api.tree.declaration.NamespaceNameTree;\n+import org.sonar.plugins.php.api.tree.declaration.ParameterListTree;\n+import org.sonar.plugins.php.api.tree.declaration.ParameterTree;\n+import org.sonar.plugins.php.api.tree.declaration.UseDeclarationTree;\n+import org.sonar.plugins.php.api.tree.declaration.VariableDeclarationTree;\n+import org.sonar.plugins.php.api.tree.expression.ArrayAccessTree;\n+import org.sonar.plugins.php.api.tree.expression.AssignmentExpressionTree;\n+import org.sonar.plugins.php.api.tree.expression.ComputedVariableTree;\n+import org.sonar.plugins.php.api.tree.expression.ExpandableStringCharactersTree;\n+import org.sonar.plugins.php.api.tree.expression.ExpandableStringLiteralTree;\n+import org.sonar.plugins.php.api.tree.expression.ExpressionTree;\n+import org.sonar.plugins.php.api.tree.expression.FunctionCallTree;\n+import org.sonar.plugins.php.api.tree.expression.IdentifierTree;\n+import org.sonar.plugins.php.api.tree.expression.LexicalVariablesTree;\n+import org.sonar.plugins.php.api.tree.expression.ListExpressionTree;\n+import org.sonar.plugins.php.api.tree.expression.LiteralTree;\n+import org.sonar.plugins.php.api.tree.expression.MemberAccessTree;\n+import org.sonar.plugins.php.api.tree.expression.ParenthesisedExpressionTree;\n+import org.sonar.plugins.php.api.tree.expression.ReferenceVariableTree;\n+import org.sonar.plugins.php.api.tree.expression.SpreadArgumentTree;\n+import org.sonar.plugins.php.api.tree.expression.VariableIdentifierTree;\n+import org.sonar.plugins.php.api.tree.expression.VariableTree;\n+import org.sonar.plugins.php.api.tree.expression.YieldExpressionTree;\n+import org.sonar.plugins.php.api.tree.lexical.SyntaxToken;\n+import org.sonar.plugins.php.api.tree.statement.BlockTree;\n+import org.sonar.plugins.php.api.tree.statement.BreakStatementTree;\n+import org.sonar.plugins.php.api.tree.statement.CatchBlockTree;\n+import org.sonar.plugins.php.api.tree.statement.ContinueStatementTree;\n+import org.sonar.plugins.php.api.tree.statement.DeclareStatementTree;\n+import org.sonar.plugins.php.api.tree.statement.DoWhileStatementTree;\n+import org.sonar.plugins.php.api.tree.statement.ElseClauseTree;\n+import org.sonar.plugins.php.api.tree.statement.ElseifClauseTree;\n+import org.sonar.plugins.php.api.tree.statement.EmptyStatementTree;\n+import org.sonar.plugins.php.api.tree.statement.ExpressionStatementTree;\n+import org.sonar.plugins.php.api.tree.statement.ForEachStatementTree;\n+import org.sonar.plugins.php.api.tree.statement.ForStatementTree;\n+import org.sonar.plugins.php.api.tree.statement.GlobalStatementTree;\n+import org.sonar.plugins.php.api.tree.statement.GotoStatementTree;\n+import org.sonar.plugins.php.api.tree.statement.IfStatementTree;\n+import org.sonar.plugins.php.api.tree.statement.InlineHTMLTree;\n+import org.sonar.plugins.php.api.tree.statement.LabelTree;\n+import org.sonar.plugins.php.api.tree.statement.NamespaceStatementTree;\n+import org.sonar.plugins.php.api.tree.statement.ReturnStatementTree;\n+import org.sonar.plugins.php.api.tree.statement.StatementTree;\n+import org.sonar.plugins.php.api.tree.statement.StaticStatementTree;\n+import org.sonar.plugins.php.api.tree.statement.SwitchCaseClauseTree;\n+import org.sonar.plugins.php.api.tree.statement.SwitchStatementTree;\n+import org.sonar.plugins.php.api.tree.statement.ThrowStatementTree;\n+import org.sonar.plugins.php.api.tree.statement.TryStatementTree;\n+import org.sonar.plugins.php.api.tree.statement.UnsetVariableStatementTree;\n+import org.sonar.plugins.php.api.tree.statement.UseStatementTree;\n+import org.sonar.plugins.php.api.tree.statement.WhileStatementTree;\n+import org.sonar.plugins.php.api.tree.statement.YieldStatementTree;\n+\n+import static org.sonar.php.api.PHPKeyword.CLASS;\n+import static org.sonar.php.api.PHPKeyword.LIST;\n+import static org.sonar.php.api.PHPKeyword.STATIC;\n+import static org.sonar.php.api.PHPKeyword.USE;\n+import static org.sonar.php.api.PHPKeyword.YIELD;\n+import static org.sonar.php.api.PHPPunctuator.AMPERSAND;\n+import static org.sonar.php.api.PHPPunctuator.ARROW;\n+import static org.sonar.php.api.PHPPunctuator.COLON;\n+import static org.sonar.php.api.PHPPunctuator.COMMA;\n+import static org.sonar.php.api.PHPPunctuator.DOLLAR_LCURLY;\n+import static org.sonar.php.api.PHPPunctuator.DOUBLEARROW;\n+import static org.sonar.php.api.PHPPunctuator.DOUBLECOLON;\n+import static org.sonar.php.api.PHPPunctuator.ELIPSIS;\n+import static org.sonar.php.api.PHPPunctuator.EQU;\n+import static org.sonar.php.api.PHPPunctuator.LBRACKET;\n+import static org.sonar.php.api.PHPPunctuator.LCURLYBRACE;\n+import static org.sonar.php.api.PHPPunctuator.LPARENTHESIS;\n+import static org.sonar.php.api.PHPPunctuator.RBRACKET;\n+import static org.sonar.php.api.PHPPunctuator.RCURLYBRACE;\n+import static org.sonar.php.api.PHPPunctuator.RPARENTHESIS;\n+\n+public class NewPHPGrammar {\n+\n+  private final GrammarBuilder<InternalSyntaxToken> b;\n+  private final TreeFactory f;\n+\n+  public NewPHPGrammar(GrammarBuilder<InternalSyntaxToken> b, TreeFactory f) {\n+    this.b = b;\n+    this.f = f;\n+  }\n+\n+  /**\n+   * [ START ] Declaration\n+   */\n+\n+  public VariableDeclarationTree MEMBER_CONST_DECLARATION() {\n+    return b.<VariableDeclarationTree>nonterminal(PHPLexicalGrammar.MEMBER_CONST_DECLARATION)\n+        .is(f.memberConstDeclaration(\n+            b.token(PHPLexicalGrammar.IDENTIFIER),\n+            b.optional(f.newTuple18(b.token(EQU), STATIC_SCALAR()))\n+        ));\n+  }\n+\n+  public NamespaceNameTree NAMESPACE_NAME() {\n+    return b.<NamespaceNameTree>nonterminal(PHPLexicalGrammar.NAMESPACE_NAME)\n+        .is(b.firstOf(\n+          f.namespaceName(\n+            b.optional(b.token(PHPPunctuator.NS_SEPARATOR)),\n+            b.zeroOrMore(f.newTuple4(\n+              b.firstOf(b.token(PHPLexicalGrammar.IDENTIFIER)),\n+              b.token(PHPPunctuator.NS_SEPARATOR)\n+            )),\n+            b.token(PHPLexicalGrammar.IDENTIFIER)),\n+          f.namespaceName(\n+              b.token(PHPKeyword.NAMESPACE),\n+              b.token(PHPPunctuator.NS_SEPARATOR),\n+              b.zeroOrMore(f.newTuple6(\n+                  b.firstOf(b.token(PHPLexicalGrammar.IDENTIFIER)),\n+                  b.token(PHPPunctuator.NS_SEPARATOR)\n+              )),\n+              b.token(PHPLexicalGrammar.IDENTIFIER)))\n+    );\n+  }\n+  \n+  public UseDeclarationTree USE_DECLARATION() {\n+    return b.<UseDeclarationTree>nonterminal(PHPLexicalGrammar.USE_DECLARATION).is(\n+      f.useDeclaration(\n+        NAMESPACE_NAME(),\n+        b.optional(\n+          f.newTuple91(\n+            b.token(PHPKeyword.AS), \n+            b.token(PHPLexicalGrammar.IDENTIFIER)))));\n+  }\n+  \n+  public InternalSyntaxToken MEMBER_MODIFIER() {\n+    return b.<InternalSyntaxToken>nonterminal().is(\n+      b.firstOf(\n+        b.token(PHPKeyword.PUBLIC),\n+        b.token(PHPKeyword.PROTECTED),\n+        b.token(PHPKeyword.PRIVATE),\n+        b.token(PHPKeyword.STATIC),\n+        b.token(PHPKeyword.ABSTRACT),\n+        b.token(PHPKeyword.FINAL)\n+      ));\n+  }\n+\n+  public MethodDeclarationTree METHOD_DECLARATION() {\n+    return b.<MethodDeclarationTree>nonterminal(PHPLexicalGrammar.METHOD_DECLARATION).is(\n+      f.methodDeclaration(\n+        b.<SyntaxToken>zeroOrMore(MEMBER_MODIFIER()),\n+        b.token(PHPKeyword.FUNCTION),\n+        b.optional(b.token(PHPPunctuator.AMPERSAND)),\n+        IDENTIFIER(),\n+        PARAMETER_LIST(),\n+        b.firstOf(\n+          EOS(),\n+          BLOCK())\n+      ));\n+  }\n+\n+  public FunctionDeclarationTree FUNCTION_DECLARATION() {\n+    return b.<FunctionDeclarationTree>nonterminal(PHPLexicalGrammar.FUNCTION_DECLARATION).is(\n+      f.functionDeclaration(\n+        b.token(PHPKeyword.FUNCTION),\n+        b.optional(b.token(PHPPunctuator.AMPERSAND)),\n+        IDENTIFIER(),\n+        PARAMETER_LIST(),\n+        BLOCK()));\n+  }\n+  \n+  public ParameterListTree PARAMETER_LIST() {\n+    return b.<ParameterListTree>nonterminal(PHPLexicalGrammar.PARAMETER_LIST).is(\n+      f.parameterList(\n+        b.token(PHPPunctuator.LPARENTHESIS),\n+        b.optional(\n+          f.newTuple94(\n+            PARAMETER(), \n+            b.zeroOrMore(\n+              f.newTuple93(\n+                b.token(PHPPunctuator.COMMA), \n+                PARAMETER())))),\n+        b.token(PHPPunctuator.RPARENTHESIS)));\n+  }\n+  \n+  public ParameterTree PARAMETER() {\n+    return b.<ParameterTree>nonterminal(PHPLexicalGrammar.PARAMETER).is(\n+      f.parameter(\n+        b.optional(\n+          b.firstOf(\n+            b.token(PHPKeyword.ARRAY),\n+            b.token(PHPKeyword.CALLABLE),\n+            NAMESPACE_NAME())),\n+        b.optional(b.token(PHPPunctuator.AMPERSAND)),\n+        b.optional(b.token(PHPPunctuator.ELIPSIS)),\n+        b.token(PHPLexicalGrammar.REGULAR_VAR_IDENTIFIER),\n+        b.optional(\n+          f.newTuple92(\n+            b.token(PHPPunctuator.EQU), \n+            STATIC_SCALAR())))\n+      );      \n+  }\n+\n+  /**\n+   * [ END ] Declaration\n+   */\n+\n+  /**\n+   * [ START ] Statement\n+   */\n+\n+  public StatementTree TOP_STATEMENT() {\n+    return b.<StatementTree>nonterminal(PHPLexicalGrammar.TOP_STATEMENT)\n+        .is(b.firstOf(\n+//            CLASS_DECLARATION(),\n+            FUNCTION_DECLARATION(),\n+//            INTERFACE_DECLARATION(),\n+            NAMESPACE_STATEMENT(),\n+            USE_STATEMENT(),\n+//            CONSTANT_DECLARATION(),\n+            STATEMENT()\n+        ));\n+  }\n+\n+  public NamespaceStatementTree NAMESPACE_STATEMENT() {\n+    return b.<NamespaceStatementTree>nonterminal(PHPLexicalGrammar.NAMESPACE_STATEMENT)\n+        .is(b.firstOf(\n+           f.namespaceStatement(\n+               b.token(PHPKeyword.NAMESPACE),\n+               NAMESPACE_NAME(),\n+               EOS()\n+           ),\n+           f.blockNamespaceStatement(\n+               b.token(PHPKeyword.NAMESPACE),\n+               b.optional(NAMESPACE_NAME()),\n+               b.token(LCURLYBRACE),\n+               b.zeroOrMore(TOP_STATEMENT()),\n+               b.token(RCURLYBRACE)\n+           )\n+        ));\n+  }\n+\n+  public UseStatementTree USE_STATEMENT() {\n+    return b.<UseStatementTree>nonterminal(PHPLexicalGrammar.USE_STATEMENT).is(\n+        f.useStatement(\n+            b.token(PHPKeyword.USE),\n+            b.optional(\n+                b.firstOf(\n+                    b.token(PHPKeyword.CONST),\n+                    b.token(PHPKeyword.FUNCTION))),\n+            USE_DECLARATION(),\n+            b.zeroOrMore(f.newTuple90(b.token(PHPPunctuator.COMMA), USE_DECLARATION())),\n+            EOS())\n+    );\n+  }\n+\n+  public StatementTree STATEMENT() {\n+    return b.<StatementTree>nonterminal(PHPLexicalGrammar.STATEMENT)\n+        .is(b.firstOf(\n+            BLOCK(),\n+            THROW_STATEMENT(),\n+            IF_STATEMENT(),\n+            WHILE_STATEMENT(),\n+            DO_WHILE_STATEMENT(),\n+            FOREACH_STATEMENT(),\n+            FOR_STATEMENT(),\n+            SWITCH_STATEMENT(),\n+            BREAK_STATEMENT(),\n+            CONTINUE_STATEMENT(),\n+            RETURN_STATEMENT(),\n+            EMPTY_STATEMENT(),\n+            YIELD_STATEMENT(),\n+            GLOBAL_STATEMENT(),\n+            STATIC_STATEMENT(),\n+            TRY_STATEMENT(),\n+            DECLARE_STATEMENT(),\n+            GOTO_STATEMENT(),\n+            INLINE_HTML(),\n+            UNSET_VARIABLE_STATEMENT(),\n+            EXPRESSION_STATEMENT(),\n+            LABEL()\n+        ));\n+  }\n+\n+  public StaticStatementTree STATIC_STATEMENT() {\n+    return b.<StaticStatementTree>nonterminal(PHPLexicalGrammar.STATIC_STATEMENT)\n+        .is(f.staticStatement(\n+            b.token(STATIC),\n+            STATIC_VAR(),\n+            b.zeroOrMore(f.newTuple22(b.token(COMMA), STATIC_VAR())),\n+            EOS()\n+        ));\n+  }\n+\n+  public VariableDeclarationTree STATIC_VAR() {\n+    return b.<VariableDeclarationTree>nonterminal(PHPLexicalGrammar.STATIC_VAR)\n+        .is(f.staticVar(\n+            b.token(PHPLexicalGrammar.REGULAR_VAR_IDENTIFIER),\n+            b.optional(f.newTuple24(b.token(EQU), STATIC_SCALAR()))\n+        ));\n+  }\n+\n+  public DeclareStatementTree DECLARE_STATEMENT() {\n+    return b.<DeclareStatementTree>nonterminal(PHPLexicalGrammar.DECLARE_STATEMENT)\n+        .is(b.firstOf(\n+            f.shortDeclareStatement(\n+                DECLARE_STATEMENT_HEAD(),\n+                EOS()\n+            ),\n+            f.declareStatementWithOneStatement(\n+                DECLARE_STATEMENT_HEAD(),\n+                STATEMENT()\n+            ),\n+            f.alternativeDeclareStatement(\n+                DECLARE_STATEMENT_HEAD(),\n+                b.token(COLON),\n+                b.zeroOrMore(INNER_STATEMENT()),\n+                b.token(PHPKeyword.ENDDECLARE),\n+                EOS()\n+            )\n+        ));\n+  }\n+\n+  public DeclareStatementHead DECLARE_STATEMENT_HEAD() {\n+    return b.<DeclareStatementHead>nonterminal()\n+        .is(f.declareStatementHead(\n+            b.token(PHPKeyword.DECLARE),\n+            b.token(LPARENTHESIS),\n+            MEMBER_CONST_DECLARATION(),\n+            b.zeroOrMore(f.newTuple20(b.token(COMMA), MEMBER_CONST_DECLARATION())),\n+            b.token(RPARENTHESIS)\n+        ));\n+  }\n+\n+  public InlineHTMLTree INLINE_HTML() {\n+    return b.<InlineHTMLTree>nonterminal(PHPLexicalGrammar.INLINE_HTML_STATEMENT)\n+        .is(f.inlineHTML(b.token(PHPLexicalGrammar.INLINE_HTML)));\n+  }\n+\n+  public StatementTree INNER_STATEMENT() {\n+    return b.<StatementTree>nonterminal(PHPLexicalGrammar.INNER_STATEMENT)\n+        .is(b.firstOf(\n+            FUNCTION_DECLARATION(),\n+//            CLASS_DECLARATION(),\n+//            INTERFACE_DECLARATION(),\n+            STATEMENT()\n+        ));\n+  }\n+\n+\n+  public GlobalStatementTree GLOBAL_STATEMENT() {\n+    return b.<GlobalStatementTree>nonterminal(PHPLexicalGrammar.GLOBAL_STATEMENT)\n+        .is(f.globalStatement(\n+            b.token(PHPKeyword.GLOBAL),\n+            // fixme (Lena) : should be GLOBAL_VAR instead of COMPOUND_VARIABLE\n+            COMPOUND_VARIABLE(),\n+            b.zeroOrMore(f.newTuple16(b.token(COMMA), COMPOUND_VARIABLE())),\n+            EOS()\n+        ));\n+  }\n+\n+  public UnsetVariableStatementTree UNSET_VARIABLE_STATEMENT() {\n+    return b.<UnsetVariableStatementTree>nonterminal(PHPLexicalGrammar.UNSET_VARIABLE_STATEMENT)\n+        .is(f.unsetVariableStatement(\n+            b.token(PHPKeyword.UNSET),\n+            b.token(LPARENTHESIS),\n+            MEMBER_EXPRESSION(),\n+            b.zeroOrMore(f.newTuple14(b.token(COMMA), MEMBER_EXPRESSION())),\n+            b.token(RPARENTHESIS),\n+            EOS()\n+        ));\n+  }\n+\n+  public YieldStatementTree YIELD_STATEMENT() {\n+    return b.<YieldStatementTree>nonterminal(PHPLexicalGrammar.YIELD_STATEMENT)\n+        .is(f.yieldStatement(YIELD_EXPRESSION(), EOS()));\n+  }\n+\n+  public SwitchStatementTree SWITCH_STATEMENT() {\n+    return b.<SwitchStatementTree>nonterminal(PHPLexicalGrammar.SWITCH_STATEMENT)\n+        .is(b.firstOf(\n+            f.switchStatement(\n+                b.token(PHPKeyword.SWITCH),\n+                PARENTHESIZED_EXPRESSION(),\n+                b.token(PHPPunctuator.LCURLYBRACE),\n+                b.optional(b.token(PHPPunctuator.SEMICOLON)),\n+                b.zeroOrMore(SWITCH_CASE_CLAUSE()),\n+                b.token(PHPPunctuator.RCURLYBRACE)\n+            ),\n+            f.alternativeSwitchStatement(\n+                b.token(PHPKeyword.SWITCH),\n+                PARENTHESIZED_EXPRESSION(),\n+                b.token(PHPPunctuator.COLON),\n+                b.optional(b.token(PHPPunctuator.SEMICOLON)),\n+                b.zeroOrMore(SWITCH_CASE_CLAUSE()),\n+                b.token(PHPKeyword.ENDSWITCH),\n+                EOS()\n+            )\n+        ));\n+  }\n+\n+  public SwitchCaseClauseTree SWITCH_CASE_CLAUSE() {\n+    return b.<SwitchCaseClauseTree>nonterminal(PHPLexicalGrammar.SWITCH_CASE_CLAUSE)\n+        .is(b.firstOf(\n+            f.caseClause(\n+                b.token(PHPKeyword.CASE),\n+                EXPRESSION(),\n+                b.firstOf(b.token(PHPPunctuator.COLON), b.token(PHPPunctuator.SEMICOLON)),\n+                b.zeroOrMore(INNER_STATEMENT())\n+            ),\n+            f.defaultClause(\n+                b.token(PHPKeyword.DEFAULT),\n+                b.firstOf(b.token(PHPPunctuator.COLON), b.token(PHPPunctuator.SEMICOLON)),\n+                b.zeroOrMore(INNER_STATEMENT())\n+            )\n+        ));\n+  }\n+\n+  public WhileStatementTree WHILE_STATEMENT() {\n+    return b.<WhileStatementTree>nonterminal(PHPLexicalGrammar.WHILE_STATEMENT)\n+        .is(b.firstOf(\n+            f.whileStatement(\n+                b.token(PHPKeyword.WHILE),\n+                PARENTHESIZED_EXPRESSION(),\n+                STATEMENT()\n+            ),\n+            f.alternativeWhileStatement(\n+                b.token(PHPKeyword.WHILE),\n+                PARENTHESIZED_EXPRESSION(),\n+                b.token(PHPPunctuator.COLON),\n+                b.zeroOrMore(INNER_STATEMENT()),\n+                b.token(PHPKeyword.ENDWHILE),\n+                EOS()\n+            )\n+        ));\n+  }\n+\n+  public DoWhileStatementTree DO_WHILE_STATEMENT() {\n+    return b.<DoWhileStatementTree>nonterminal(PHPLexicalGrammar.DO_WHILE_STATEMENT)\n+        .is(f.doWhileStatement(\n+            b.token(PHPKeyword.DO),\n+            STATEMENT(),\n+            b.token(PHPKeyword.WHILE),\n+            PARENTHESIZED_EXPRESSION(),\n+            EOS()\n+        ));\n+  }\n+\n+  public IfStatementTree IF_STATEMENT() {\n+    return b.<IfStatementTree>nonterminal(PHPLexicalGrammar.IF_STATEMENT)\n+        .is(b.firstOf(STANDARD_IF_STATEMENT(), ALTERNATIVE_IF_STATEMENT()));\n+  }\n+\n+  public IfStatementTree STANDARD_IF_STATEMENT() {\n+    return b.<IfStatementTree>nonterminal(PHPLexicalGrammar.STANDARD_IF_STATEMENT)\n+        .is(f.ifStatement(\n+            b.token(PHPKeyword.IF),\n+            PARENTHESIZED_EXPRESSION(),\n+            STATEMENT(),\n+            b.zeroOrMore(ELSEIF_CLAUSE()),\n+            b.optional(ELSE_CLAUSE())\n+        ));\n+  }\n+\n+  public IfStatementTree ALTERNATIVE_IF_STATEMENT() {\n+    return b.<IfStatementTree>nonterminal(PHPLexicalGrammar.ALTERNATIVE_IF_STATEMENT)\n+        .is(f.alternativeIfStatement(\n+            b.token(PHPKeyword.IF),\n+            PARENTHESIZED_EXPRESSION(),\n+            b.token(PHPPunctuator.COLON),\n+            b.zeroOrMore(INNER_STATEMENT()),\n+            b.zeroOrMore(ALTERNATIVE_ELSEIF_CLAUSE()),\n+            b.optional(ALTERNATIVE_ELSE_CLAUSE()),\n+            b.token(PHPKeyword.ENDIF),\n+            EOS()\n+        ));\n+  }\n+\n+  public ElseClauseTree ELSE_CLAUSE() {\n+    return b.<ElseClauseTree>nonterminal(PHPLexicalGrammar.ELSE_CLAUSE)\n+        .is(f.elseClause(b.token(PHPKeyword.ELSE), STATEMENT()));\n+  }\n+\n+  public ElseifClauseTree ELSEIF_CLAUSE() {\n+    return b.<ElseifClauseTree>nonterminal(PHPLexicalGrammar.ELSEIF_CLAUSE)\n+        .is(f.elseifClause(\n+            b.token(PHPKeyword.ELSEIF),\n+            PARENTHESIZED_EXPRESSION(),\n+            STATEMENT()\n+        ));\n+  }\n+\n+  public ElseClauseTree ALTERNATIVE_ELSE_CLAUSE() {\n+    return b.<ElseClauseTree>nonterminal(PHPLexicalGrammar.ALTERNATIVE_ELSE_CLAUSE)\n+        .is(f.alternativeElseClause(\n+            b.token(PHPKeyword.ELSE),\n+            b.token(PHPPunctuator.COLON),\n+            b.zeroOrMore(INNER_STATEMENT())\n+        ));\n+  }\n+\n+  public ElseifClauseTree ALTERNATIVE_ELSEIF_CLAUSE() {\n+    return b.<ElseifClauseTree>nonterminal(PHPLexicalGrammar.ALTERNATIVE_ELSEIF_CLAUSE)\n+        .is(f.alternativeElseifClause(\n+            b.token(PHPKeyword.ELSEIF),\n+            PARENTHESIZED_EXPRESSION(),\n+            b.token(PHPPunctuator.COLON),\n+            b.zeroOrMore(INNER_STATEMENT())\n+        ));\n+  }\n+\n+  public ForStatementTree FOR_STATEMENT() {\n+    return b.<ForStatementTree>nonterminal(PHPLexicalGrammar.FOR_STATEMENT)\n+        .is(b.firstOf(\n+                f.forStatement(\n+                    FOR_STATEMENT_HEADER(),\n+                    STATEMENT()\n+                ),\n+                f.forStatementAlternative(\n+                    FOR_STATEMENT_HEADER(),\n+                    b.token(PHPPunctuator.COLON),\n+                    b.zeroOrMore(INNER_STATEMENT()),\n+                    b.token(PHPKeyword.ENDFOR),\n+                    EOS()\n+                ))\n+        );\n+  }\n+\n+  public ForStatementHeader FOR_STATEMENT_HEADER() {\n+    return b.<ForStatementHeader>nonterminal()\n+        .is(f.forStatementHeader(\n+            b.token(PHPKeyword.FOR), b.token(PHPPunctuator.LPARENTHESIS),\n+            b.optional(FOR_EXPR()),\n+            b.token(PHPPunctuator.SEMICOLON),\n+            b.optional(FOR_EXPR()),\n+            b.token(PHPPunctuator.SEMICOLON),\n+            b.optional(FOR_EXPR()),\n+            b.token(PHPPunctuator.RPARENTHESIS)\n+        ));\n+  }\n+\n+  public SeparatedList<ExpressionTree> FOR_EXPR() {\n+    return b.<SeparatedList<ExpressionTree>>nonterminal(PHPLexicalGrammar.FOR_EXRR)\n+        .is(f.forExpr(\n+            EXPRESSION(),\n+            b.zeroOrMore(f.newTuple12(b.token(PHPPunctuator.COMMA), EXPRESSION()))\n+        ));\n+  }\n+\n+  public ForEachStatementTree FOREACH_STATEMENT() {\n+    return b.<ForEachStatementTree>nonterminal(PHPLexicalGrammar.FOREACH_STATEMENT)\n+        .is(b.firstOf(\n+                f.forEachStatement(FOREACH_STATEMENT_HEADER(), STATEMENT()),\n+                f.forEachStatementAlternative(\n+                    FOREACH_STATEMENT_HEADER(),\n+                    b.token(PHPPunctuator.COLON),\n+                    b.zeroOrMore(INNER_STATEMENT()),\n+                    b.token(PHPKeyword.ENDFOREACH),\n+                    EOS()\n+                ))\n+        );\n+  }\n+\n+  public ForEachStatementHeader FOREACH_STATEMENT_HEADER() {","path":"php-frontend/src/main/java/org/sonar/php/parser/NewPHPGrammar.java","position":589,"original_position":589,"commit_id":"a4979a3846296712dde3cf702b5ec9047bfbd643","original_commit_id":"a4979a3846296712dde3cf702b5ec9047bfbd643","user":{"login":"SonarTech","id":1842438,"avatar_url":"https://avatars.githubusercontent.com/u/1842438?v=3","gravatar_id":"","url":"https://api.github.com/users/SonarTech","html_url":"https://github.com/SonarTech","followers_url":"https://api.github.com/users/SonarTech/followers","following_url":"https://api.github.com/users/SonarTech/following{/other_user}","gists_url":"https://api.github.com/users/SonarTech/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarTech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarTech/subscriptions","organizations_url":"https://api.github.com/users/SonarTech/orgs","repos_url":"https://api.github.com/users/SonarTech/repos","events_url":"https://api.github.com/users/SonarTech/events{/privacy}","received_events_url":"https://api.github.com/users/SonarTech/received_events","type":"User","site_admin":false},"body":"![MAJOR](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/severity-major.png) Rename this method name to match the regular expression '^[a-z][a-zA-Z0-9]*$'. [![rule](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/rule.png)](http://nemo.sonarqube.org/coding_rules#rule_key=squid%3AS00100)\n","created_at":"2015-09-28T10:43:20Z","updated_at":"2015-09-28T10:43:20Z","html_url":"https://github.com/SonarCommunity/sonar-php/pull/21#discussion_r40538714","pull_request_url":"https://api.github.com/repos/SonarCommunity/sonar-php/pulls/21","_links":{"self":{"href":"https://api.github.com/repos/SonarCommunity/sonar-php/pulls/comments/40538714"},"html":{"href":"https://github.com/SonarCommunity/sonar-php/pull/21#discussion_r40538714"},"pull_request":{"href":"https://api.github.com/repos/SonarCommunity/sonar-php/pulls/21"}}},"pull_request":{"url":"https://api.github.com/repos/SonarCommunity/sonar-php/pulls/21","id":46022849,"html_url":"https://github.com/SonarCommunity/sonar-php/pull/21","diff_url":"https://github.com/SonarCommunity/sonar-php/pull/21.diff","patch_url":"https://github.com/SonarCommunity/sonar-php/pull/21.patch","issue_url":"https://api.github.com/repos/SonarCommunity/sonar-php/issues/21","number":21,"state":"open","locked":false,"title":"Migration to strongly-typed AST","user":{"login":"vilchik-elena","id":10108186,"avatar_url":"https://avatars.githubusercontent.com/u/10108186?v=3","gravatar_id":"","url":"https://api.github.com/users/vilchik-elena","html_url":"https://github.com/vilchik-elena","followers_url":"https://api.github.com/users/vilchik-elena/followers","following_url":"https://api.github.com/users/vilchik-elena/following{/other_user}","gists_url":"https://api.github.com/users/vilchik-elena/gists{/gist_id}","starred_url":"https://api.github.com/users/vilchik-elena/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vilchik-elena/subscriptions","organizations_url":"https://api.github.com/users/vilchik-elena/orgs","repos_url":"https://api.github.com/users/vilchik-elena/repos","events_url":"https://api.github.com/users/vilchik-elena/events{/privacy}","received_events_url":"https://api.github.com/users/vilchik-elena/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-09-25T15:12:03Z","updated_at":"2015-09-28T10:43:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0ce0f9db3a2a50d28745e4b6a9b063adc1ebaf8c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/SonarCommunity/sonar-php/pulls/21/commits","review_comments_url":"https://api.github.com/repos/SonarCommunity/sonar-php/pulls/21/comments","review_comment_url":"https://api.github.com/repos/SonarCommunity/sonar-php/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SonarCommunity/sonar-php/issues/21/comments","statuses_url":"https://api.github.com/repos/SonarCommunity/sonar-php/statuses/a4979a3846296712dde3cf702b5ec9047bfbd643","head":{"label":"SonarCommunity:strongly-typed","ref":"strongly-typed","sha":"a4979a3846296712dde3cf702b5ec9047bfbd643","user":{"login":"SonarCommunity","id":1303819,"avatar_url":"https://avatars.githubusercontent.com/u/1303819?v=3","gravatar_id":"","url":"https://api.github.com/users/SonarCommunity","html_url":"https://github.com/SonarCommunity","followers_url":"https://api.github.com/users/SonarCommunity/followers","following_url":"https://api.github.com/users/SonarCommunity/following{/other_user}","gists_url":"https://api.github.com/users/SonarCommunity/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarCommunity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarCommunity/subscriptions","organizations_url":"https://api.github.com/users/SonarCommunity/orgs","repos_url":"https://api.github.com/users/SonarCommunity/repos","events_url":"https://api.github.com/users/SonarCommunity/events{/privacy}","received_events_url":"https://api.github.com/users/SonarCommunity/received_events","type":"Organization","site_admin":false},"repo":{"id":4544982,"name":"sonar-php","full_name":"SonarCommunity/sonar-php","owner":{"login":"SonarCommunity","id":1303819,"avatar_url":"https://avatars.githubusercontent.com/u/1303819?v=3","gravatar_id":"","url":"https://api.github.com/users/SonarCommunity","html_url":"https://github.com/SonarCommunity","followers_url":"https://api.github.com/users/SonarCommunity/followers","following_url":"https://api.github.com/users/SonarCommunity/following{/other_user}","gists_url":"https://api.github.com/users/SonarCommunity/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarCommunity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarCommunity/subscriptions","organizations_url":"https://api.github.com/users/SonarCommunity/orgs","repos_url":"https://api.github.com/users/SonarCommunity/repos","events_url":"https://api.github.com/users/SonarCommunity/events{/privacy}","received_events_url":"https://api.github.com/users/SonarCommunity/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SonarCommunity/sonar-php","description":"","fork":false,"url":"https://api.github.com/repos/SonarCommunity/sonar-php","forks_url":"https://api.github.com/repos/SonarCommunity/sonar-php/forks","keys_url":"https://api.github.com/repos/SonarCommunity/sonar-php/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SonarCommunity/sonar-php/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SonarCommunity/sonar-php/teams","hooks_url":"https://api.github.com/repos/SonarCommunity/sonar-php/hooks","issue_events_url":"https://api.github.com/repos/SonarCommunity/sonar-php/issues/events{/number}","events_url":"https://api.github.com/repos/SonarCommunity/sonar-php/events","assignees_url":"https://api.github.com/repos/SonarCommunity/sonar-php/assignees{/user}","branches_url":"https://api.github.com/repos/SonarCommunity/sonar-php/branches{/branch}","tags_url":"https://api.github.com/repos/SonarCommunity/sonar-php/tags","blobs_url":"https://api.github.com/repos/SonarCommunity/sonar-php/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SonarCommunity/sonar-php/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SonarCommunity/sonar-php/git/refs{/sha}","trees_url":"https://api.github.com/repos/SonarCommunity/sonar-php/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SonarCommunity/sonar-php/statuses/{sha}","languages_url":"https://api.github.com/repos/SonarCommunity/sonar-php/languages","stargazers_url":"https://api.github.com/repos/SonarCommunity/sonar-php/stargazers","contributors_url":"https://api.github.com/repos/SonarCommunity/sonar-php/contributors","subscribers_url":"https://api.github.com/repos/SonarCommunity/sonar-php/subscribers","subscription_url":"https://api.github.com/repos/SonarCommunity/sonar-php/subscription","commits_url":"https://api.github.com/repos/SonarCommunity/sonar-php/commits{/sha}","git_commits_url":"https://api.github.com/repos/SonarCommunity/sonar-php/git/commits{/sha}","comments_url":"https://api.github.com/repos/SonarCommunity/sonar-php/comments{/number}","issue_comment_url":"https://api.github.com/repos/SonarCommunity/sonar-php/issues/comments{/number}","contents_url":"https://api.github.com/repos/SonarCommunity/sonar-php/contents/{+path}","compare_url":"https://api.github.com/repos/SonarCommunity/sonar-php/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SonarCommunity/sonar-php/merges","archive_url":"https://api.github.com/repos/SonarCommunity/sonar-php/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SonarCommunity/sonar-php/downloads","issues_url":"https://api.github.com/repos/SonarCommunity/sonar-php/issues{/number}","pulls_url":"https://api.github.com/repos/SonarCommunity/sonar-php/pulls{/number}","milestones_url":"https://api.github.com/repos/SonarCommunity/sonar-php/milestones{/number}","notifications_url":"https://api.github.com/repos/SonarCommunity/sonar-php/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SonarCommunity/sonar-php/labels{/name}","releases_url":"https://api.github.com/repos/SonarCommunity/sonar-php/releases{/id}","created_at":"2012-06-04T08:36:12Z","updated_at":"2015-09-24T13:22:53Z","pushed_at":"2015-09-28T10:38:39Z","git_url":"git://github.com/SonarCommunity/sonar-php.git","ssh_url":"git@github.com:SonarCommunity/sonar-php.git","clone_url":"https://github.com/SonarCommunity/sonar-php.git","svn_url":"https://github.com/SonarCommunity/sonar-php","homepage":"http://docs.codehaus.org/display/SONAR/PHP+Plugin","size":12996,"stargazers_count":41,"watchers_count":41,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":30,"mirror_url":null,"open_issues_count":6,"forks":30,"open_issues":6,"watchers":41,"default_branch":"master"}},"base":{"label":"SonarCommunity:master","ref":"master","sha":"b33d480ad3af96ca110f743e9a771be074ec8a13","user":{"login":"SonarCommunity","id":1303819,"avatar_url":"https://avatars.githubusercontent.com/u/1303819?v=3","gravatar_id":"","url":"https://api.github.com/users/SonarCommunity","html_url":"https://github.com/SonarCommunity","followers_url":"https://api.github.com/users/SonarCommunity/followers","following_url":"https://api.github.com/users/SonarCommunity/following{/other_user}","gists_url":"https://api.github.com/users/SonarCommunity/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarCommunity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarCommunity/subscriptions","organizations_url":"https://api.github.com/users/SonarCommunity/orgs","repos_url":"https://api.github.com/users/SonarCommunity/repos","events_url":"https://api.github.com/users/SonarCommunity/events{/privacy}","received_events_url":"https://api.github.com/users/SonarCommunity/received_events","type":"Organization","site_admin":false},"repo":{"id":4544982,"name":"sonar-php","full_name":"SonarCommunity/sonar-php","owner":{"login":"SonarCommunity","id":1303819,"avatar_url":"https://avatars.githubusercontent.com/u/1303819?v=3","gravatar_id":"","url":"https://api.github.com/users/SonarCommunity","html_url":"https://github.com/SonarCommunity","followers_url":"https://api.github.com/users/SonarCommunity/followers","following_url":"https://api.github.com/users/SonarCommunity/following{/other_user}","gists_url":"https://api.github.com/users/SonarCommunity/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarCommunity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarCommunity/subscriptions","organizations_url":"https://api.github.com/users/SonarCommunity/orgs","repos_url":"https://api.github.com/users/SonarCommunity/repos","events_url":"https://api.github.com/users/SonarCommunity/events{/privacy}","received_events_url":"https://api.github.com/users/SonarCommunity/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SonarCommunity/sonar-php","description":"","fork":false,"url":"https://api.github.com/repos/SonarCommunity/sonar-php","forks_url":"https://api.github.com/repos/SonarCommunity/sonar-php/forks","keys_url":"https://api.github.com/repos/SonarCommunity/sonar-php/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SonarCommunity/sonar-php/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SonarCommunity/sonar-php/teams","hooks_url":"https://api.github.com/repos/SonarCommunity/sonar-php/hooks","issue_events_url":"https://api.github.com/repos/SonarCommunity/sonar-php/issues/events{/number}","events_url":"https://api.github.com/repos/SonarCommunity/sonar-php/events","assignees_url":"https://api.github.com/repos/SonarCommunity/sonar-php/assignees{/user}","branches_url":"https://api.github.com/repos/SonarCommunity/sonar-php/branches{/branch}","tags_url":"https://api.github.com/repos/SonarCommunity/sonar-php/tags","blobs_url":"https://api.github.com/repos/SonarCommunity/sonar-php/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SonarCommunity/sonar-php/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SonarCommunity/sonar-php/git/refs{/sha}","trees_url":"https://api.github.com/repos/SonarCommunity/sonar-php/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SonarCommunity/sonar-php/statuses/{sha}","languages_url":"https://api.github.com/repos/SonarCommunity/sonar-php/languages","stargazers_url":"https://api.github.com/repos/SonarCommunity/sonar-php/stargazers","contributors_url":"https://api.github.com/repos/SonarCommunity/sonar-php/contributors","subscribers_url":"https://api.github.com/repos/SonarCommunity/sonar-php/subscribers","subscription_url":"https://api.github.com/repos/SonarCommunity/sonar-php/subscription","commits_url":"https://api.github.com/repos/SonarCommunity/sonar-php/commits{/sha}","git_commits_url":"https://api.github.com/repos/SonarCommunity/sonar-php/git/commits{/sha}","comments_url":"https://api.github.com/repos/SonarCommunity/sonar-php/comments{/number}","issue_comment_url":"https://api.github.com/repos/SonarCommunity/sonar-php/issues/comments{/number}","contents_url":"https://api.github.com/repos/SonarCommunity/sonar-php/contents/{+path}","compare_url":"https://api.github.com/repos/SonarCommunity/sonar-php/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SonarCommunity/sonar-php/merges","archive_url":"https://api.github.com/repos/SonarCommunity/sonar-php/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SonarCommunity/sonar-php/downloads","issues_url":"https://api.github.com/repos/SonarCommunity/sonar-php/issues{/number}","pulls_url":"https://api.github.com/repos/SonarCommunity/sonar-php/pulls{/number}","milestones_url":"https://api.github.com/repos/SonarCommunity/sonar-php/milestones{/number}","notifications_url":"https://api.github.com/repos/SonarCommunity/sonar-php/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SonarCommunity/sonar-php/labels{/name}","releases_url":"https://api.github.com/repos/SonarCommunity/sonar-php/releases{/id}","created_at":"2012-06-04T08:36:12Z","updated_at":"2015-09-24T13:22:53Z","pushed_at":"2015-09-28T10:38:39Z","git_url":"git://github.com/SonarCommunity/sonar-php.git","ssh_url":"git@github.com:SonarCommunity/sonar-php.git","clone_url":"https://github.com/SonarCommunity/sonar-php.git","svn_url":"https://github.com/SonarCommunity/sonar-php","homepage":"http://docs.codehaus.org/display/SONAR/PHP+Plugin","size":12996,"stargazers_count":41,"watchers_count":41,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":30,"mirror_url":null,"open_issues_count":6,"forks":30,"open_issues":6,"watchers":41,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SonarCommunity/sonar-php/pulls/21"},"html":{"href":"https://github.com/SonarCommunity/sonar-php/pull/21"},"issue":{"href":"https://api.github.com/repos/SonarCommunity/sonar-php/issues/21"},"comments":{"href":"https://api.github.com/repos/SonarCommunity/sonar-php/issues/21/comments"},"review_comments":{"href":"https://api.github.com/repos/SonarCommunity/sonar-php/pulls/21/comments"},"review_comment":{"href":"https://api.github.com/repos/SonarCommunity/sonar-php/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SonarCommunity/sonar-php/pulls/21/commits"},"statuses":{"href":"https://api.github.com/repos/SonarCommunity/sonar-php/statuses/a4979a3846296712dde3cf702b5ec9047bfbd643"}}}}