You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2017/06/03 08:43:03 UTC
[2/2] groovy git commit: GROOVY-8216: invalid octal split into two
arguments
GROOVY-8216: invalid octal split into two arguments
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/f3d87bcd
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/f3d87bcd
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/f3d87bcd
Branch: refs/heads/GROOVY_2_6_X
Commit: f3d87bcd6d2cd61678d97f7b0dda2d9b195b67ec
Parents: 2d5dcd3
Author: sunlan <su...@apache.org>
Authored: Fri Jun 2 23:34:46 2017 +0800
Committer: paulk <pa...@asert.com.au>
Committed: Sat Jun 3 18:22:05 2017 +1000
----------------------------------------------------------------------
.../apache/groovy/parser/antlr4/GroovyLexer.g4 | 4 ++++
.../groovy/parser/antlr4/SyntaxErrorTest.groovy | 1 +
.../test/resources/bugs/BUG-GROOVY-8216.groovy | 19 +++++++++++++++++++
3 files changed, 24 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/f3d87bcd/subprojects/parser-antlr4/src/main/antlr4/org/apache/groovy/parser/antlr4/GroovyLexer.g4
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/main/antlr4/org/apache/groovy/parser/antlr4/GroovyLexer.g4 b/subprojects/parser-antlr4/src/main/antlr4/org/apache/groovy/parser/antlr4/GroovyLexer.g4
index 7bcec42..bc7131c 100644
--- a/subprojects/parser-antlr4/src/main/antlr4/org/apache/groovy/parser/antlr4/GroovyLexer.g4
+++ b/subprojects/parser-antlr4/src/main/antlr4/org/apache/groovy/parser/antlr4/GroovyLexer.g4
@@ -52,6 +52,7 @@ options {
@members {
private long tokenIndex = 0;
private int lastTokenType = 0;
+ private int invalidDigitCount = 0;
/**
* Record the index and token type of the current token while emitting tokens.
@@ -444,6 +445,9 @@ IntegerLiteral
| HexIntegerLiteral
| OctalIntegerLiteral
| BinaryIntegerLiteral
+
+ // !!! Error Alternative !!!
+ | '0' ([0-9] { invalidDigitCount++; })+ { require(false, "Invalid octal number", -(invalidDigitCount + 1), true); } IntegerTypeSuffix?
;
fragment
http://git-wip-us.apache.org/repos/asf/groovy/blob/f3d87bcd/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/SyntaxErrorTest.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/SyntaxErrorTest.groovy b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/SyntaxErrorTest.groovy
index f311642..03ba016 100644
--- a/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/SyntaxErrorTest.groovy
+++ b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/SyntaxErrorTest.groovy
@@ -121,6 +121,7 @@ class SyntaxErrorTest extends GroovyTestCase {
void "test groovy core - BUGs"() {
TestUtils.doRunAndShouldFail('bugs/BUG-GROOVY-5318.groovy');
TestUtils.doRunAndShouldFail('bugs/BUG-GROOVY-8150.groovy');
+ TestUtils.doRunAndShouldFail('bugs/BUG-GROOVY-8216.groovy');
}
void "test groovy core - DoWhile"() {
http://git-wip-us.apache.org/repos/asf/groovy/blob/f3d87bcd/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-8216.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-8216.groovy b/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-8216.groovy
new file mode 100644
index 0000000..431d54c
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-8216.groovy
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+println 09
\ No newline at end of file