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 2017/04/02 09:25:01 UTC

groovy git commit: Support expressions span rows

Repository: groovy
Updated Branches:
  refs/heads/parrot c9b4ee7be -> 929bf8111


Support expressions span rows


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/929bf811
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/929bf811
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/929bf811

Branch: refs/heads/parrot
Commit: 929bf81114a2f0ea4fa231e283ac3e3b4b2bc5d4
Parents: c9b4ee7
Author: sunlan <su...@apache.org>
Authored: Sun Apr 2 17:24:43 2017 +0800
Committer: sunlan <su...@apache.org>
Committed: Sun Apr 2 17:24:43 2017 +0800

----------------------------------------------------------------------
 .../apache/groovy/parser/antlr4/GroovyParser.g4 | 26 +++++++-------
 .../test/resources/core/Expression_23x.groovy   | 38 ++++++++++++++++++++
 2 files changed, 51 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/929bf811/subprojects/groovy-parser-antlr4/src/main/antlr4/org/apache/groovy/parser/antlr4/GroovyParser.g4
----------------------------------------------------------------------
diff --git a/subprojects/groovy-parser-antlr4/src/main/antlr4/org/apache/groovy/parser/antlr4/GroovyParser.g4 b/subprojects/groovy-parser-antlr4/src/main/antlr4/org/apache/groovy/parser/antlr4/GroovyParser.g4
index 501938b..a328054 100644
--- a/subprojects/groovy-parser-antlr4/src/main/antlr4/org/apache/groovy/parser/antlr4/GroovyParser.g4
+++ b/subprojects/groovy-parser-antlr4/src/main/antlr4/org/apache/groovy/parser/antlr4/GroovyParser.g4
@@ -829,7 +829,7 @@ expression
     |   left=expression op=(ADD | SUB) nls right=expression                                 #additiveExprAlt
 
     // bit shift expressions (level 6)
-    |   left=expression
+    |   left=expression nls
             (           (   dlOp=LT LT
                         |   tgOp=GT GT GT
                         |   dgOp=GT GT
@@ -841,11 +841,11 @@ expression
         right=expression                                                                    #shiftExprAlt
 
     // boolean relational expressions (level 7)
-    |   left=expression op=(AS | INSTANCEOF | NOT_INSTANCEOF) nls type                      #relationalExprAlt
-    |   left=expression op=(LE | GE | GT | LT | IN | NOT_IN)  nls right=expression          #relationalExprAlt
+    |   left=expression nls op=(AS | INSTANCEOF | NOT_INSTANCEOF) nls type                      #relationalExprAlt
+    |   left=expression nls op=(LE | GE | GT | LT | IN | NOT_IN)  nls right=expression          #relationalExprAlt
 
     // equality/inequality (==/!=) (level 8)
-    |   left=expression
+    |   left=expression nls
             op=(    IDENTICAL
                |    NOT_IDENTICAL
                |    EQUAL
@@ -857,27 +857,27 @@ expression
     // regex find and match (=~ and ==~) (level 8.5)
     // jez: moved =~ closer to precedence of == etc, as...
     // 'if (foo =~ "a.c")' is very close in intent to 'if (foo == "abc")'
-    |   left=expression op=(REGEX_FIND | REGEX_MATCH) nls right=expression                  #regexExprAlt
+    |   left=expression nls op=(REGEX_FIND | REGEX_MATCH) nls right=expression                  #regexExprAlt
 
     // bitwise or non-short-circuiting and (&)  (level 9)
-    |   left=expression op=BITAND nls right=expression                                      #andExprAlt
+    |   left=expression nls op=BITAND nls right=expression                                      #andExprAlt
 
     // exclusive or (^)  (level 10)
-    |   left=expression op=XOR nls right=expression                                         #exclusiveOrExprAlt
+    |   left=expression nls op=XOR nls right=expression                                         #exclusiveOrExprAlt
 
     // bitwise or non-short-circuiting or (|)  (level 11)
-    |   left=expression op=BITOR nls right=expression                                       #inclusiveOrExprAlt
+    |   left=expression nls op=BITOR nls right=expression                                       #inclusiveOrExprAlt
 
     // logical and (&&)  (level 12)
-    |   left=expression op=AND nls right=expression                                         #logicalAndExprAlt
+    |   left=expression nls op=AND nls right=expression                                         #logicalAndExprAlt
 
     // logical or (||)  (level 13)
-    |   left=expression op=OR nls right=expression                                          #logicalOrExprAlt
+    |   left=expression nls op=OR nls right=expression                                          #logicalOrExprAlt
 
     // conditional test (level 14)
-    |   <assoc=right> con=expression
-        (   nls QUESTION nls tb=expression nls COLON nls
-        |   nls ELVIS nls
+    |   <assoc=right> con=expression nls
+        (   QUESTION nls tb=expression nls COLON nls
+        |   ELVIS nls
         )
         fb=expression                                                                       #conditionalExprAlt
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/929bf811/subprojects/groovy-parser-antlr4/src/test/resources/core/Expression_23x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/groovy-parser-antlr4/src/test/resources/core/Expression_23x.groovy b/subprojects/groovy-parser-antlr4/src/test/resources/core/Expression_23x.groovy
index 8962219..b87b58d 100644
--- a/subprojects/groovy-parser-antlr4/src/test/resources/core/Expression_23x.groovy
+++ b/subprojects/groovy-parser-antlr4/src/test/resources/core/Expression_23x.groovy
@@ -43,3 +43,41 @@ def m(p1
 }
 assert 6 == m()
 
+def w
+    =
+        1
+            <<
+                2
+assert 4 == w
+assert 'a'
+            instanceof
+                        String
+assert 1
+            <
+                2
+
+assert 1
+            ==
+                1
+
+assert 'a'
+            ==~
+                /a/
+assert true
+            &
+                true
+assert true
+            ^
+                false
+assert true
+            |
+                true
+
+assert true
+            &&
+                true
+
+assert true
+            ||
+                true
+