You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2020/06/26 00:35:43 UTC
[groovy] 01/01: Tweak `statement` rule
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch danielsun/tweak-statement-rule
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit fc0478bd7c8b29fdff1d80161698cc7af03ce1d3
Author: Daniel Sun <su...@apache.org>
AuthorDate: Fri Jun 26 08:35:22 2020 +0800
Tweak `statement` rule
---
src/antlr/GroovyParser.g4 | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/src/antlr/GroovyParser.g4 b/src/antlr/GroovyParser.g4
index 968bd62..52d7e4a 100644
--- a/src/antlr/GroovyParser.g4
+++ b/src/antlr/GroovyParser.g4
@@ -106,6 +106,9 @@ scriptStatements
scriptStatement
: importDeclaration // Import statement. Can be used in any scope. Has "import x as y" also.
| typeDeclaration
+ // validate the method in the AstBuilder#visitMethodDeclaration, e.g. method without method body is not allowed
+ | { !SemanticPredicates.isInvalidMethodDeclaration(_input) }?
+ methodDeclaration[3, 9]
| statement
;
@@ -634,11 +637,6 @@ statement
| identifier COLON nls statement #labeledStmtAlt
| assertStatement #assertStmtAlt
| localVariableDeclaration #localVariableDeclarationStmtAlt
-
- // validate the method in the AstBuilder#visitMethodDeclaration, e.g. method without method body is not allowed
- | { !SemanticPredicates.isInvalidMethodDeclaration(_input) }?
- methodDeclaration[3, 9] #methodDeclarationStmtAlt
-
| statementExpression #expressionStmtAlt
| SEMI #emptyStmtAlt
;