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 2018/03/30 10:56:28 UTC

groovy git commit: GROOVY-8524: Triple quoted string with quotes on end of line

Repository: groovy
Updated Branches:
  refs/heads/master a1af00384 -> 7e7b508c0


GROOVY-8524: Triple quoted string with quotes on end of line


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

Branch: refs/heads/master
Commit: 7e7b508c02bf35e72fca1efcb7cc0d8a4f25038a
Parents: a1af003
Author: sunlan <su...@apache.org>
Authored: Fri Mar 30 18:56:10 2018 +0800
Committer: sunlan <su...@apache.org>
Committed: Fri Mar 30 18:56:24 2018 +0800

----------------------------------------------------------------------
 src/antlr/GroovyLexer.g4                        |  4 ++--
 .../parser/antlr4/GroovyParserTest.groovy       |  4 ++++
 .../src/test/resources/core/String_01x.groovy   | 23 ++++++++++++++++++++
 3 files changed, 29 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/7e7b508c/src/antlr/GroovyLexer.g4
----------------------------------------------------------------------
diff --git a/src/antlr/GroovyLexer.g4 b/src/antlr/GroovyLexer.g4
index bf855bf..78bbd69 100644
--- a/src/antlr/GroovyLexer.g4
+++ b/src/antlr/GroovyLexer.g4
@@ -314,14 +314,14 @@ SqStringCharacter
 // character in the triple double quotation string. e.g. """a"""
 fragment TdqStringCharacter
     :   ~["\\$]
-    |   GStringQuotationMark { !(_input.LA(1) == '"' && _input.LA(2) == '"') }?
+    |   GStringQuotationMark { _input.LA(1) != '"' || _input.LA(2) != '"' || _input.LA(3) == '"' }?
     |   EscapeSequence
     ;
 
 // character in the triple single quotation string. e.g. '''a'''
 fragment TsqStringCharacter
     :   ~['\\]
-    |   SqStringQuotationMark { !(_input.LA(1) == '\'' && _input.LA(2) == '\'') }?
+    |   SqStringQuotationMark { _input.LA(1) != '\'' || _input.LA(2) != '\'' || _input.LA(3) == '\'' }?
     |   EscapeSequence
     ;
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/7e7b508c/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 a4a12e3..4701e77 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
@@ -379,6 +379,10 @@ class GroovyParserTest extends GroovyTestCase {
         doRunAndTestAntlr4('core/Var_01x.groovy');
     }
 
+    void "test groovy core - String"() {
+        doRunAndTestAntlr4('core/String_01x.groovy');
+    }
+
     void "test groovy core - BUG"() {
         doRunAndTestAntlr4('bugs/BUG-GROOVY-4757.groovy')
         doRunAndTestAntlr4('bugs/BUG-GROOVY-5652.groovy')

http://git-wip-us.apache.org/repos/asf/groovy/blob/7e7b508c/subprojects/parser-antlr4/src/test/resources/core/String_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/String_01x.groovy b/subprojects/parser-antlr4/src/test/resources/core/String_01x.groovy
new file mode 100644
index 0000000..8f9a5ca
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/String_01x.groovy
@@ -0,0 +1,23 @@
+/*
+ *  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.
+ */
+
+def v = '''string='a''''
+assert v == '''string=\'a\''''
+def v2 = """string="a""""
+assert v2 == """string=\"a\""""
\ No newline at end of file