groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [2/2] incubator-groovy git commit: GROOVY-7377: Interpolated variable followed by asterisk in slashy-string causes compiler error (tweak)
Date Thu, 25 Jun 2015 11:19:51 GMT
GROOVY-7377: Interpolated variable followed by asterisk in slashy-string causes compiler error
(tweak)


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

Branch: refs/heads/GROOVY_2_4_X
Commit: 4ca482d765258a5bce86bf1bc58be219e11dad30
Parents: 2fdfc9c
Author: paulk <paulk@asert.com.au>
Authored: Thu Jun 25 20:39:24 2015 +1000
Committer: paulk <paulk@asert.com.au>
Committed: Thu Jun 25 21:18:09 2015 +1000

----------------------------------------------------------------------
 src/main/org/codehaus/groovy/antlr/groovy.g | 51 +++++++++++++-----------
 1 file changed, 28 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/4ca482d7/src/main/org/codehaus/groovy/antlr/groovy.g
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/antlr/groovy.g b/src/main/org/codehaus/groovy/antlr/groovy.g
index ee62f03..16f28fa 100644
--- a/src/main/org/codehaus/groovy/antlr/groovy.g
+++ b/src/main/org/codehaus/groovy/antlr/groovy.g
@@ -3536,6 +3536,10 @@ options {
         return LA(1) == '$' && LA(2) == '$';
     }
 
+    protected boolean atMultiCommentStart() throws CharStreamException {
+        return LA(1) == '/' && LA(2) == '*';
+    }
+
     protected boolean atDollarSlashEscape() throws CharStreamException {
         return LA(1) == '$' && LA(2) == '/';
     }
@@ -3802,7 +3806,7 @@ ML_COMMENT
 options {
     paraphrase="a multi-line comment";
 }
-    :   "/*"
+    :   { atMultiCommentStart() }? "/*"
         (   /*  '\r' '\n' can be matched in one alternative or by matching
                 '\r' in one iteration and '\n' in another. I am trying to
                 handle any flavor of newline that comes in, but the language
@@ -3899,29 +3903,30 @@ options {
     paraphrase="a multiline regular expression literal";
 }
         {int tt=0;}
-    :   ( '/' ~('*'|'=') ) =>
-        {allowRegexpLiteral()}?
-        '/'!
-        {++suppressNewline;}
-        //Do this, but require it to be non-trivial:  REGEXP_CTOR_END[true]
-        // There must be at least one symbol or $ escape, lest the regexp collapse to '//'.
-        // (This should be simpler, but I don't know how to do it w/o ANTLR warnings vs.
'//' comments.)
-        (
-            REGEXP_SYMBOL
-            tt=REGEXP_CTOR_END[true]
-        |   {!atValidDollarEscape()}? '$'
-            tt=REGEXP_CTOR_END[true]
-        |   '$'!
-            {
-                // Yes, it's a regexp constructor, and we've got a value part.
-                tt = STRING_CTOR_START;
-                stringCtorState = SCS_VAL + SCS_RE_TYPE;
-            }
-        )
-        {$setType(tt);}
+    :   { !atMultiCommentStart() }?
+        (   {allowRegexpLiteral()}?
+            '/'!
+            {++suppressNewline;}
+            //Do this, but require it to be non-trivial:  REGEXP_CTOR_END[true]
+            // There must be at least one symbol or $ escape, lest the regexp collapse to
'//'.
+            // (This should be simpler, but I don't know how to do it w/o ANTLR warnings
vs. '//' comments.)
+            (
+                REGEXP_SYMBOL
+                tt=REGEXP_CTOR_END[true]
+            |   {!atValidDollarEscape()}? '$'
+                tt=REGEXP_CTOR_END[true]
+            |   '$'!
+                {
+                    // Yes, it's a regexp constructor, and we've got a value part.
+                    tt = STRING_CTOR_START;
+                    stringCtorState = SCS_VAL + SCS_RE_TYPE;
+                }
+            )
+            {$setType(tt);}
 
-    |   ( '/' ~('*'|'=') ) => DIV {$setType(DIV);}
-    |   DIV_ASSIGN {$setType(DIV_ASSIGN);}
+        |   ( '/' ~'=' ) => DIV {$setType(DIV);}
+        |   DIV_ASSIGN {$setType(DIV_ASSIGN);}
+        )
     ;
 
 DOLLAR_REGEXP_LITERAL


Mime
View raw message