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/02/02 14:50:51 UTC

[groovy] branch master updated: Tweak `classifiedModifiers` rule: remove redundant alternative

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new 0efe035  Tweak `classifiedModifiers` rule: remove redundant alternative
0efe035 is described below

commit 0efe035d42f32ae7b2827ecc6a3356326f4f7ca0
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sun Feb 2 19:47:51 2020 +0800

    Tweak `classifiedModifiers` rule: remove redundant alternative
---
 src/antlr/GroovyParser.g4                                    | 12 +++++-------
 .../java/org/apache/groovy/parser/antlr4/AstBuilder.java     | 12 ++----------
 2 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/src/antlr/GroovyParser.g4 b/src/antlr/GroovyParser.g4
index 4b73f50..a8f59e7 100644
--- a/src/antlr/GroovyParser.g4
+++ b/src/antlr/GroovyParser.g4
@@ -585,9 +585,7 @@ localVariableDeclaration
     ;
 
 classifiedModifiers[int t]
-    :   (   { 0 == $t }? variableModifiers
-        |   { 1 == $t }? modifiers
-        ) nls
+    :   modifiers nls
     ;
 
 /**
@@ -1158,14 +1156,14 @@ identifier
     :   Identifier
     |   CapitalizedIdentifier
     |   VAR
-    |
-        // if 'static' followed by DOT, we can treat them as identifiers, e.g. static.unused = { -> }
-        { DOT == _input.LT(2).getType() }?
-        STATIC
     |   IN
 //    |   DEF
     |   TRAIT
     |   AS
+    |
+        // if 'static' followed by DOT, we can treat them as identifiers, e.g. static.unused = { -> }
+        { DOT == _input.LT(2).getType() }?
+        STATIC
     ;
 
 builtInType
diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
index 7e1e7aa..bdce08f 100644
--- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
+++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
@@ -1731,19 +1731,11 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> {
 
     @Override
     public List<ModifierNode> visitClassifiedModifiers(ClassifiedModifiersContext ctx) {
-        List<ModifierNode> modifierNodeList = Collections.emptyList();
-
         if (!asBoolean(ctx)) {
-            return modifierNodeList;
-        }
-
-        if (asBoolean(ctx.variableModifiers())) {
-            modifierNodeList = this.visitVariableModifiers(ctx.variableModifiers());
-        } if (asBoolean(ctx.modifiers())) {
-            modifierNodeList = this.visitModifiers(ctx.modifiers());
+            return Collections.emptyList();
         }
 
-        return modifierNodeList;
+        return this.visitModifiers(ctx.modifiers());
     }
 
     @Override