Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

tagging Groovy 1.7.9

git-svn-id: http://svn.codehaus.org/groovy/tags/GROOVY_1_7_9@21776 a5544e8c-8a19-0410-ba12-f9af4593a198
  • Loading branch information...
commit c4d73cbe0510c0f97fb2325fbb89f1da8059cc28 1 parent 3dab902
Jochen Theodorou blackdrag authored
4 build.properties
View
@@ -1,6 +1,6 @@
-groovyVersion = 1.7.9-SNAPSHOT
+groovyVersion = 1.7.9
# bundle version format: major('.'minor('.'micro('.'qualifier)?)?)? (first 3 only digits)
-groovyBundleVersion = 1.7.9-SNAPSHOT
+groovyBundleVersion = 1.7.9
# Many people have reported problems testing UberTestCaseGroovySourceSubPackages, others have no difficulties with the default
# values ant junit task uses. The decision has been taken to provide the values to try and cause the least
2  pom.xml
View
@@ -8,7 +8,7 @@
<name>Groovy</name>
<packaging>jar</packaging>
- <version>1.7.8</version>
+ <version>1.7.9</version>
<description>
Groovy: A powerful, dynamic language for the JVM
3  src/main/org/codehaus/groovy/antlr/AntlrParserPlugin.java
View
@@ -113,7 +113,8 @@ protected void transformCSTIntoAST(SourceUnit sourceUnit, Reader reader, SourceB
// TODO find a way to inject any GroovyLexer/GroovyRecognizer
UnicodeEscapingReader unicodeReader = new UnicodeEscapingReader(reader, sourceBuffer);
- GroovyLexer lexer = new GroovyLexer(unicodeReader);
+ UnicodeLexerSharedInputState inputState = new UnicodeLexerSharedInputState(unicodeReader);
+ GroovyLexer lexer = new GroovyLexer(inputState);
unicodeReader.setLexer(lexer);
GroovyRecognizer parser = GroovyRecognizer.make(lexer);
parser.setSourceBuffer(sourceBuffer);
47 src/main/org/codehaus/groovy/antlr/UnicodeEscapingReader.java
View
@@ -21,12 +21,14 @@
import java.io.Reader;
import antlr.CharScanner;
+import antlr.Token;
+import antlr.TokenStreamException;
/**
* Translates GLS-defined unicode escapes into characters. Throws an exception
* in the event of an invalid unicode escape being detected.
*
- * <p>No attempt has been made to optimise this class for speed or
+ * <p>No attempt has been made to optimize this class for speed or
* space.</p>
*
* @version $Revision$
@@ -38,7 +40,27 @@
private boolean hasNextChar = false;
private int nextChar;
private final SourceBuffer sourceBuffer;
-
+ private int previousLine;
+ private int numUnicodeEscapesFound = 0;
+ private int numUnicodeEscapesFoundOnCurrentLine = 0;
+
+ private static class DummyLexer extends CharScanner{
+ final private Token t = new Token();
+ @Override
+ public Token nextToken() throws TokenStreamException {
+ return t;
+ }
+ @Override
+ public int getColumn() {
+ return 0;
+ }
+ @Override
+ public int getLine() {
+ return 0;
+ }
+
+ }
+
/**
* Constructor.
* @param reader The reader that this reader will filter over.
@@ -46,6 +68,7 @@
public UnicodeEscapingReader(Reader reader,SourceBuffer sourceBuffer) {
this.reader = reader;
this.sourceBuffer = sourceBuffer;
+ this.lexer = new DummyLexer();
}
/**
@@ -82,6 +105,12 @@ public int read() throws IOException {
return nextChar;
}
+ if (previousLine != lexer.getLine()) {
+ // new line, so reset unicode escapes
+ numUnicodeEscapesFoundOnCurrentLine = 0;
+ previousLine = lexer.getLine();
+ }
+
int c = reader.read();
if (c != '\\') {
write(c);
@@ -98,7 +127,9 @@ public int read() throws IOException {
}
// Swallow multiple 'u's
+ int numberOfUChars = 0;
do {
+ numberOfUChars++;
c = reader.read();
} while (c == 'u');
@@ -115,6 +146,10 @@ public int read() throws IOException {
}
int rv = Integer.parseInt(charNum.toString(), 16);
write(rv);
+
+ numUnicodeEscapesFound += 4 + numberOfUChars;
+ numUnicodeEscapesFoundOnCurrentLine += 4 + numberOfUChars;
+
return rv;
}
private void write(int c) {
@@ -140,6 +175,14 @@ private void checkHexDigit(int c) throws IOException {
+ " line: " + lexer.getLine() + " col:" + lexer.getColumn());
}
+ public int getUnescapedUnicodeColumnCount() {
+ return numUnicodeEscapesFoundOnCurrentLine;
+ }
+
+ public int getUnescapedUnicodeOffsetCount() {
+ return numUnicodeEscapesFound;
+ }
+
/**
* Closes this reader by calling close on the underlying reader.
* @see java.io.Reader#close()
49 src/main/org/codehaus/groovy/antlr/UnicodeLexerSharedInputState.java
View
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2011 the original author or authors.
+ *
+ * Licensed 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 org.codehaus.groovy.antlr;
+
+import antlr.LexerSharedInputState;
+
+/**
+ * GRECLIPSE-805 Support for unicode escape sequences
+ * @author Andrew Eisenberg
+ * @created Mar 3, 2011
+ */
+public class UnicodeLexerSharedInputState extends LexerSharedInputState {
+ private final UnicodeEscapingReader escapingReader;
+
+ private int prevUnescape;
+
+ public UnicodeLexerSharedInputState(UnicodeEscapingReader in) {
+ super(in);
+ escapingReader = in;
+ }
+
+ @Override
+ public int getColumn() {
+ prevUnescape = escapingReader.getUnescapedUnicodeColumnCount();
+ return super.getColumn() + prevUnescape;
+ }
+
+ @Override
+ public int getTokenStartColumn() {
+ if (line == tokenStartLine) {
+ return super.getTokenStartColumn() + escapingReader.getUnescapedUnicodeColumnCount();
+ } else {
+ return super.getTokenStartColumn() + prevUnescape;
+ }
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.