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/15 13:05:15 UTC
[groovy] branch GROOVY-9400 created (now b300852)
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a change to branch GROOVY-9400
in repository https://gitbox.apache.org/repos/asf/groovy.git.
at b300852 GROOVY-9400: Regression in end of line handling between 2.5.9 and 3.0.0
This branch includes the following new commits:
new b300852 GROOVY-9400: Regression in end of line handling between 2.5.9 and 3.0.0
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[groovy] 01/01: GROOVY-9400: Regression in end of line handling
between 2.5.9 and 3.0.0
Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY-9400
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit b3008523a87da714cc92960467033237fedc7750
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Feb 15 21:04:49 2020 +0800
GROOVY-9400: Regression in end of line handling between 2.5.9 and 3.0.0
---
src/antlr/GroovyLexer.g4 | 9 ++++++--
src/test/groovy/bugs/Groovy9400.groovy | 41 ++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 2 deletions(-)
diff --git a/src/antlr/GroovyLexer.g4 b/src/antlr/GroovyLexer.g4
index 6456af1..d13749d 100644
--- a/src/antlr/GroovyLexer.g4
+++ b/src/antlr/GroovyLexer.g4
@@ -719,7 +719,12 @@ DollarEscape
fragment
LineEscape
- : Backslash '\r'? '\n'
+ : Backslash LineTerminator
+ ;
+
+fragment
+LineTerminator
+ : '\r'? '\n' | '\r'
;
fragment
@@ -941,7 +946,7 @@ WS : ([ \t\u000C]+ | LineEscape+) -> skip
// Inside (...) and [...] but not {...}, ignore newlines.
-NL : '\r'? '\n' { this.ignoreTokenInsideParens(); }
+NL : LineTerminator { this.ignoreTokenInsideParens(); }
;
// Multiple-line comments(including groovydoc comments)
diff --git a/src/test/groovy/bugs/Groovy9400.groovy b/src/test/groovy/bugs/Groovy9400.groovy
new file mode 100644
index 0000000..bd52845
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy9400.groovy
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package groovy.bugs
+
+import groovy.transform.CompileStatic
+import org.junit.Test
+
+import static groovy.test.GroovyAssert.assertScript
+
+@CompileStatic
+final class Groovy9400 {
+ @Test
+ void testLF() {
+ final GroovyShell shell = new GroovyShell()
+ def script = shell.parse("println('hello world 1')\rprintln('hello world 2')")
+ script.run()
+ }
+
+ @Test
+ void testLF2() {
+ final GroovyShell shell = new GroovyShell()
+ def script = shell.parse("def a = 1\rdef b = a\rb")
+ assert 1 == script.run()
+ }
+}