groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject groovy git commit: GROOVY-8312: Deprecate useless features of unicode sequences
Date Fri, 08 Sep 2017 18:59:41 GMT
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_6_X 302a78e3d -> 7dd30235d


GROOVY-8312: Deprecate useless features of unicode sequences

(cherry picked from commit 7a2cdd2)


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

Branch: refs/heads/GROOVY_2_6_X
Commit: 7dd30235db428b94c74b4d8e3a71e5dff85208e6
Parents: 302a78e
Author: sunlan <sunlan@apache.org>
Authored: Sat Sep 9 02:56:50 2017 +0800
Committer: sunlan <sunlan@apache.org>
Committed: Sat Sep 9 02:59:29 2017 +0800

----------------------------------------------------------------------
 src/main/antlr/GroovyLexer.g4                       |  8 +-------
 src/tck/test/gls/ch03/s01/Unicode2.groovy           |  2 ++
 src/tck/test/gls/ch03/s03/UnicodeEscapes1.groovy    |  2 ++
 src/tck/test/gls/ch03/s03/UnicodeEscapes2.groovy    |  4 ++++
 .../org/apache/groovy/parser/antlr4/AstBuilder.java | 16 ++--------------
 .../groovy/parser/antlr4/util/StringUtils.java      |  2 +-
 .../groovy/parser/antlr4/GroovyParserTest.groovy    |  2 ++
 7 files changed, 14 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/7dd30235/src/main/antlr/GroovyLexer.g4
----------------------------------------------------------------------
diff --git a/src/main/antlr/GroovyLexer.g4 b/src/main/antlr/GroovyLexer.g4
index 9e44ae3..05fb767 100644
--- a/src/main/antlr/GroovyLexer.g4
+++ b/src/main/antlr/GroovyLexer.g4
@@ -677,7 +677,7 @@ OctalEscape
 // Groovy allows 1 or more u's after the backslash
 fragment
 UnicodeEscape
-    :   Backslash 'u'+ HexDigit HexDigit HexDigit HexDigit
+    :   Backslash 'u' HexDigit HexDigit HexDigit HexDigit
     ;
 
 fragment
@@ -842,16 +842,10 @@ ELVIS_ASSIGN    : '?=';
 // ยง3.8 Identifiers (must appear after all keywords in the grammar)
 CapitalizedIdentifier
     :   [A-Z] JavaLetterOrDigit*
-
-    // FIXME REMOVE THE FOLLOWING ALTERNATIVE. Groovy's identifier can be unicode escape(e.g.
def \u4e00\u9fa5 = '123'), which will impact the performance and is pointless to support IMO
-    |   [A-Z] (JavaLetterOrDigit | UnicodeEscape)*
     ;
 
 Identifier
     :   JavaLetter JavaLetterOrDigit*
-
-    // FIXME REMOVE THE FOLLOWING ALTERNATIVE. Groovy's identifier can be unicode escape(e.g.
def \u4e00\u9fa5 = '123'), which will impact the performance and is pointless to support IMO
-    |   (JavaLetter | UnicodeEscape) (JavaLetterOrDigit | UnicodeEscape)*
     ;
 
 fragment

http://git-wip-us.apache.org/repos/asf/groovy/blob/7dd30235/src/tck/test/gls/ch03/s01/Unicode2.groovy
----------------------------------------------------------------------
diff --git a/src/tck/test/gls/ch03/s01/Unicode2.groovy b/src/tck/test/gls/ch03/s01/Unicode2.groovy
index 35fbf72..b845366 100644
--- a/src/tck/test/gls/ch03/s01/Unicode2.groovy
+++ b/src/tck/test/gls/ch03/s01/Unicode2.groovy
@@ -30,9 +30,11 @@ class Unicode2 extends GroovyTestCase {
         assert 1 == s.codePointCount(0, s.length()) // number of Unicode code points
     }
 
+    /*
     void testIdentifiers() {
         def foo\u0044 = 12
         assert 20 == foo\u0044 + 8
     }
+    */
 }
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/7dd30235/src/tck/test/gls/ch03/s03/UnicodeEscapes1.groovy
----------------------------------------------------------------------
diff --git a/src/tck/test/gls/ch03/s03/UnicodeEscapes1.groovy b/src/tck/test/gls/ch03/s03/UnicodeEscapes1.groovy
index 6411c34..3f23dfd 100644
--- a/src/tck/test/gls/ch03/s03/UnicodeEscapes1.groovy
+++ b/src/tck/test/gls/ch03/s03/UnicodeEscapes1.groovy
@@ -39,11 +39,13 @@ class UnicodeEscapes1 extends GroovyTestCase {
     }
 
     // There can be 1 or more u's after the backslash
+    /*
     void testMultipleUs() {
         assert "\uu0061" == "a"
         assert "\uuu0061" == "a"
         assert "\uuuuu0061" == "a"
     }
+    */
 
     void testOtherVariations() {
         // Capital 'U' not allowed

http://git-wip-us.apache.org/repos/asf/groovy/blob/7dd30235/src/tck/test/gls/ch03/s03/UnicodeEscapes2.groovy
----------------------------------------------------------------------
diff --git a/src/tck/test/gls/ch03/s03/UnicodeEscapes2.groovy b/src/tck/test/gls/ch03/s03/UnicodeEscapes2.groovy
index 58eafbe..e78a3d7 100644
--- a/src/tck/test/gls/ch03/s03/UnicodeEscapes2.groovy
+++ b/src/tck/test/gls/ch03/s03/UnicodeEscapes2.groovy
@@ -29,6 +29,7 @@ class UnicodeEscapes2 extends GroovyTestCase {
 
     // GLS: If an even number of backslashes precede the 'u', it is not 
     // an escape
+    /*
     void testCountBackslash() {
         def a = 1
         assert \u0061 == 1 // char 61 is 'a'
@@ -42,10 +43,12 @@ class UnicodeEscapes2 extends GroovyTestCase {
         assert "\\\u0061".length() == 2
         
     }
+    */
 
     // GLS: If an eligible \ is followed by u, or more than one u, and the last u
     // is not followed by four hexadecimal digits, then a compile-time error
     // occurs.
+    /*
     void testFourHexDigits() {
         // If five digits, only the first four count
         def \u00610 = 2
@@ -57,6 +60,7 @@ class UnicodeEscapes2 extends GroovyTestCase {
         // def /u61 = 2 //@fail:parse 
         // def /u061 = 2 //@fail:parse 
     }
+    */
 
     void testInvalidHexDigits() {
         // Subsequent lines won't work. The backslash has been replaced by a forward slash

http://git-wip-us.apache.org/repos/asf/groovy/blob/7dd30235/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
----------------------------------------------------------------------
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 50dd5a1..1ba83fc 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
@@ -3870,24 +3870,12 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object>
implements Groov
 
     @Override
     public String visitClassName(ClassNameContext ctx) {
-        String text = ctx.getText();
-
-        if (!text.contains("\\")) {
-            return text;
-        }
-
-        return StringUtils.replaceHexEscapes(text);
+        return ctx.getText();
     }
 
     @Override
     public String visitIdentifier(IdentifierContext ctx) {
-        String text = ctx.getText();
-
-        if (!text.contains("\\")) {
-            return text;
-        }
-
-        return StringUtils.replaceHexEscapes(text);
+        return ctx.getText();
     }
 
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/7dd30235/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java
b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java
index 0a1ff77..49b3f3c 100644
--- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java
+++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java
@@ -33,7 +33,7 @@ import java.util.regex.Pattern;
  */
 public class StringUtils {
 	public static String replaceHexEscapes(String text) {
-		Pattern p = Pattern.compile("(\\\\*)\\\\u+([0-9abcdefABCDEF]{4})");
+		Pattern p = Pattern.compile("(\\\\*)\\\\u([0-9abcdefABCDEF]{4})");
 		return StringGroovyMethods.replaceAll((CharSequence) text, p, new Closure<Void>(null,
null) {
 			Object doCall(String _0, String _1, String _2) {
 				if (isLengthOdd(_1)) {

http://git-wip-us.apache.org/repos/asf/groovy/blob/7dd30235/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
index 6ee27f5..8a36491 100644
--- a/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
+++ b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
@@ -342,9 +342,11 @@ class GroovyParserTest extends GroovyTestCase {
         doRunAndTest('core/Command_06x.groovy')
     }
 
+    /*
     void "test groovy core - Unicode"() {
         doTest('core/Unicode_01.groovy');
     }
+    */
 
     void "test groovy core - BreakingChanges"() {
         doRunAndTest('core/BreakingChange_01x.groovy');


Mime
View raw message