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/01 00:02:50 UTC

[groovy] 04/08: Tweak `pathElement` rule

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

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

commit 56d4d3ab9f81cf920260fdb44e9145b09f620f55
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Feb 1 03:25:02 2020 +0800

    Tweak `pathElement` rule
    
    (cherry picked from commit 029e76f0e4a84aa5ee94e1cda85dda3ab93cc303)
---
 src/antlr/GroovyParser.g4 | 40 +++++++++++++++++++++-------------------
 1 file changed, 21 insertions(+), 19 deletions(-)

diff --git a/src/antlr/GroovyParser.g4 b/src/antlr/GroovyParser.g4
index 9c6602a..b24c0a4 100644
--- a/src/antlr/GroovyParser.g4
+++ b/src/antlr/GroovyParser.g4
@@ -952,31 +952,33 @@ pathExpression returns [int t]
 
 pathElement returns [int t]
     :   nls
-
-        // AT: foo.@bar selects the field (or attribute), not property
         (
-            (   DOT                 // The all-powerful dot.
-            |   SPREAD_DOT          // Spread operator:  x*.y  ===  x?.collect{it.y}
-            |   SAFE_DOT            // Optional-null operator:  x?.y  === (x==null)?null:x.y
-            |   SAFE_CHAIN_DOT      // Optional-null chain operator:  x??.y.z  === x?.y?.z
-            ) nls (AT | nonWildcardTypeArguments)?
-        |
-            METHOD_POINTER nls      // Method pointer operator: foo.&y == foo.metaClass.getMethodPointer(foo, "y")
+            // AT: foo.@bar selects the field (or attribute), not property
+            (
+                (   DOT                 // The all-powerful dot.
+                |   SPREAD_DOT          // Spread operator:  x*.y  ===  x?.collect{it.y}
+                |   SAFE_DOT            // Optional-null operator:  x?.y  === (x==null)?null:x.y
+                |   SAFE_CHAIN_DOT      // Optional-null chain operator:  x??.y.z  === x?.y?.z
+                ) nls (AT | nonWildcardTypeArguments)?
+            |
+                METHOD_POINTER nls      // Method pointer operator: foo.&y == foo.metaClass.getMethodPointer(foo, "y")
+            |
+                METHOD_REFERENCE nls    // Method reference: System.out::println
+            )
+            namePart
+            { $t = 1; }
         |
-            METHOD_REFERENCE nls    // Method reference: System.out::println
+            DOT nls NEW creator[1]
+            { $t = 6; }
+
+            // Can always append a block, as foo{bar}
+        |   closureOrLambdaExpression
+            { $t = 3; }
         )
-        namePart
-        { $t = 1; }
-    |
-        nls DOT nls NEW creator[1]
-        { $t = 6; }
+
     |   arguments
         { $t = 2; }
 
-    // Can always append a block, as foo{bar}
-    |   nls closureOrLambdaExpression
-        { $t = 3; }
-
     // Element selection is always an option, too.
     // In Groovy, the stuff between brackets is a general argument list,
     // since the bracket operator is transformed into a method call.