Merge branch 'master' into fix-unicode-2031

This commit is contained in:
Terence Parr 2017-10-12 09:38:16 -07:00 committed by GitHub
commit 7d2a0978b5
14 changed files with 48 additions and 18 deletions

View File

@ -1,5 +1,8 @@
root = true root = true
[*]
tab_width = 4
[*.{java,stg}] [*.{java,stg}]
charset = utf-8 charset = utf-8
insert_final_newline = true insert_final_newline = true

View File

@ -6,7 +6,7 @@ matrix:
include: include:
- os: linux - os: linux
compiler: clang compiler: clang
jdk: oraclejdk7 jdk: openjdk7
env: env:
- TARGET=cpp - TARGET=cpp
- CXX=g++-5 - CXX=g++-5
@ -104,13 +104,13 @@ matrix:
- TARGET=dotnet - TARGET=dotnet
- GROUP=RECURSION - GROUP=RECURSION
- os: linux - os: linux
jdk: oraclejdk7 jdk: openjdk7
env: TARGET=java env: TARGET=java
- os: linux - os: linux
jdk: oraclejdk8 jdk: oraclejdk8
env: TARGET=java env: TARGET=java
- os: linux - os: linux
jdk: oraclejdk8 jdk: openjdk7
env: TARGET=csharp env: TARGET=csharp
- os: linux - os: linux
jdk: oraclejdk8 jdk: oraclejdk8
@ -131,10 +131,10 @@ matrix:
- TARGET=dotnet - TARGET=dotnet
- GROUP=RECURSION - GROUP=RECURSION
- os: linux - os: linux
jdk: oraclejdk8 jdk: openjdk7
env: TARGET=python2 env: TARGET=python2
- os: linux - os: linux
jdk: oraclejdk8 jdk: openjdk7
env: TARGET=python3 env: TARGET=python3
addons: addons:
apt: apt:
@ -143,10 +143,10 @@ matrix:
packages: packages:
- python3.5 - python3.5
- os: linux - os: linux
jdk: oraclejdk8 jdk: openjdk7
env: TARGET=javascript env: TARGET=javascript
- os: linux - os: linux
jdk: oraclejdk7 jdk: openjdk7
env: TARGET=go env: TARGET=go
before_install: before_install:
@ -154,4 +154,3 @@ before_install:
script: script:
- cd runtime-testsuite; ../.travis/run-tests-$TARGET.sh - cd runtime-testsuite; ../.travis/run-tests-$TARGET.sh

View File

@ -151,8 +151,16 @@ YYYY/MM/DD, github id, Full name, email
2017/06/11, erikbra, Erik A. Brandstadmoen, erik@brandstadmoen.net 2017/06/11, erikbra, Erik A. Brandstadmoen, erik@brandstadmoen.net
2017/06/10, jm-mikkelsen, Jan Martin Mikkelsen, janm@transactionware.com 2017/06/10, jm-mikkelsen, Jan Martin Mikkelsen, janm@transactionware.com
2017/06/25, alimg, Alim Gökkaya, alim.gokkaya@gmail.com 2017/06/25, alimg, Alim Gökkaya, alim.gokkaya@gmail.com
2017/06/28, jBugman, Sergey Parshukov, codedby@bugman.me
2017/07/09, neatnerd, Mike Arshinskiy, neatnerd@users.noreply.github.com 2017/07/09, neatnerd, Mike Arshinskiy, neatnerd@users.noreply.github.com
2017/07/11, dhalperi, Daniel Halperin, daniel@halper.in 2017/07/11, dhalperi, Daniel Halperin, daniel@halper.in
2017/07/17, vaibhavaingankar09, Vaibhav Vaingankar, vbhvvaingankar9@gmail.com 2017/07/17, vaibhavaingankar09, Vaibhav Vaingankar, vbhvvaingankar9@gmail.com
2017/07/23, venkatperi, Venkat Peri, venkatperi@gmail.com 2017/07/23, venkatperi, Venkat Peri, venkatperi@gmail.com
2017/07/27, shirou, WAKAYAMA Shirou, shirou.faw@gmail.com 2017/07/27, shirou, WAKAYAMA Shirou, shirou.faw@gmail.com
2017/07/09, neatnerd, Mike Arshinskiy, neatnerd@users.noreply.github.com
2017/07/27, matthauck, Matt Hauck, matthauck@gmail.com
2017/07/27, shirou, WAKAYAMA Shirou, shirou.faw@gmail.com
2017/08/20, tiagomazzutti, Tiago Mazzutti, tiagomzt@gmail.com
2017/09/09, brauliobz, Bráulio Bezerra, brauliobezerra@gmail.com
2017/09/11, sachinjain024, Sachin Jain, sachinjain024@gmail.com
2017/10/06, bramp, Andrew Brampton, brampton@gmail.com

View File

@ -21,11 +21,13 @@ $ curl -O http://www.antlr.org/download/antlr-4.5.3-complete.jar
Or just download in browser from website: Or just download in browser from website:
[http://www.antlr.org/download.html](http://www.antlr.org/download.html) [http://www.antlr.org/download.html](http://www.antlr.org/download.html)
and put it somewhere rational like `/usr/local/lib`. and put it somewhere rational like `/usr/local/lib`.
2. Add `antlr-4.5.3-complete.jar` to your `CLASSPATH`: 2. Add `antlr-4.5.3-complete.jar` to your `CLASSPATH`:
``` ```
$ export CLASSPATH=".:/usr/local/lib/antlr-4.5.3-complete.jar:$CLASSPATH" $ export CLASSPATH=".:/usr/local/lib/antlr-4.5.3-complete.jar:$CLASSPATH"
``` ```
It's also a good idea to put this in your `.bash_profile` or whatever your startup script is. It's also a good idea to put this in your `.bash_profile` or whatever your startup script is.
3. Create aliases for the ANTLR Tool, and `TestRig`. 3. Create aliases for the ANTLR Tool, and `TestRig`.
``` ```
$ alias antlr4='java -Xmx500M -cp "/usr/local/lib/antlr-4.5.3-complete.jar:$CLASSPATH" org.antlr.v4.Tool' $ alias antlr4='java -Xmx500M -cp "/usr/local/lib/antlr-4.5.3-complete.jar:$CLASSPATH" org.antlr.v4.Tool'
@ -39,7 +41,7 @@ $ alias grun='java org.antlr.v4.gui.TestRig'
0. Install Java (version 1.6 or higher) 0. Install Java (version 1.6 or higher)
1. Download antlr-4.5.3-complete.jar (or whatever version) from [http://www.antlr.org/download/](http://www.antlr.org/download/) 1. Download antlr-4.5.3-complete.jar (or whatever version) from [http://www.antlr.org/download/](http://www.antlr.org/download/)
Save to your directory for 3rd party Java libraries, say `C:\Javalib` Save to your directory for 3rd party Java libraries, say `C:\Javalib`
2. Add `antlr-4.5-complete.jar` to CLASSPATH, either: 2. Add `antlr-4.5.3-complete.jar` to CLASSPATH, either:
* Permanently: Using System Properties dialog > Environment variables > Create or append to `CLASSPATH` variable * Permanently: Using System Properties dialog > Environment variables > Create or append to `CLASSPATH` variable
* Temporarily, at command line: * Temporarily, at command line:
``` ```

View File

@ -23,6 +23,7 @@ public class TestCodePointCharStream {
CodePointCharStream s = CharStreams.fromString(""); CodePointCharStream s = CharStreams.fromString("");
assertEquals(0, s.size()); assertEquals(0, s.size());
assertEquals(0, s.index()); assertEquals(0, s.index());
assertEquals("", s.toString());
} }
@Test @Test

View File

@ -33,6 +33,7 @@ endif()
if(CMAKE_VERSION VERSION_EQUAL "3.3.0" OR if(CMAKE_VERSION VERSION_EQUAL "3.3.0" OR
CMAKE_VERSION VERSION_GREATER "3.3.0") CMAKE_VERSION VERSION_GREATER "3.3.0")
CMAKE_POLICY(SET CMP0059 OLD) CMAKE_POLICY(SET CMP0059 OLD)
CMAKE_POLICY(SET CMP0054 OLD)
endif() endif()
if(CMAKE_SYSTEM_NAME MATCHES "Linux") if(CMAKE_SYSTEM_NAME MATCHES "Linux")

View File

@ -15,7 +15,7 @@ namespace atn {
* utility methods for analyzing configuration sets for conflicts and/or * utility methods for analyzing configuration sets for conflicts and/or
* ambiguities. * ambiguities.
*/ */
enum class ANTLR4CPP_PUBLIC PredictionMode { enum class PredictionMode {
/** /**
* The SLL(*) prediction mode. This prediction mode ignores the current * The SLL(*) prediction mode. This prediction mode ignores the current
* parser context when making predictions. This is the fastest prediction * parser context when making predictions. This is the fastest prediction

View File

@ -27,6 +27,7 @@
<plugin> <!-- create src jar --> <plugin> <!-- create src jar -->
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId> <artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions> <executions>
<execution> <execution>
<goals> <goals>

View File

@ -151,8 +151,8 @@ public abstract class CodePointCharStream implements CharStream {
/** Return the UTF-16 encoded string for the given interval */ /** Return the UTF-16 encoded string for the given interval */
@Override @Override
public String getText(Interval interval) { public String getText(Interval interval) {
int startIdx = Math.min(interval.a, size - 1); int startIdx = Math.min(interval.a, size);
int len = Math.min(interval.b - interval.a + 1, size); int len = Math.min(interval.b - interval.a + 1, size - startIdx);
// We know the maximum code point in byteArray is U+00FF, // We know the maximum code point in byteArray is U+00FF,
// so we can treat this as if it were ISO-8859-1, aka Latin-1, // so we can treat this as if it were ISO-8859-1, aka Latin-1,

View File

@ -8,6 +8,7 @@ package org.antlr.v4.test.tool;
import org.antlr.v4.Tool; import org.antlr.v4.Tool;
import org.antlr.v4.tool.ErrorType; import org.antlr.v4.tool.ErrorType;
import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -60,6 +61,16 @@ public class TestToolSyntaxErrors extends BaseJavaToolTest {
super.testSetUp(); super.testSetUp();
} }
@Test
public void AllErrorCodesDistinct() {
ErrorType[] errorTypes = ErrorType.class.getEnumConstants();
for (int i = 0; i < errorTypes.length; i++) {
for (int j = i + 1; j < errorTypes.length; j++) {
Assert.assertNotEquals(errorTypes[i].code, errorTypes[j].code);
}
}
}
@Test public void testA() { super.testErrors(A, true); } @Test public void testA() { super.testErrors(A, true); }
@Test public void testExtraColon() { @Test public void testExtraColon() {

View File

@ -58,6 +58,7 @@
<plugin> <!-- create src jar --> <plugin> <!-- create src jar -->
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId> <artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions> <executions>
<execution> <execution>
<goals> <goals>
@ -86,6 +87,7 @@
<plugin> <!-- include code-generated sources --> <plugin> <!-- include code-generated sources -->
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId> <artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions> <executions>
<execution> <execution>
<phase>generate-sources</phase> <phase>generate-sources</phase>

View File

@ -1,5 +1,5 @@
fileHeader(grammarFileName, ANTLRVersion) ::= << fileHeader(grammarFileName, ANTLRVersion) ::= <<
// Generated from <grammarFileName; format="java-escape"> by ANTLR <ANTLRVersion>. // Code generated from <grammarFileName; format="java-escape"> by ANTLR <ANTLRVersion>. DO NOT EDIT.
>> >>
ParserFile(file, parser, namedActions, contextSuperClass) ::= << ParserFile(file, parser, namedActions, contextSuperClass) ::= <<

View File

@ -894,8 +894,10 @@ public class <lexer.name> extends <superClass; null="Lexer"> {
protected static final DFA[] _decisionToDFA; protected static final DFA[] _decisionToDFA;
protected static final PredictionContextCache _sharedContextCache = protected static final PredictionContextCache _sharedContextCache =
new PredictionContextCache(); new PredictionContextCache();
<if(lexer.tokens)>
public static final int public static final int
<lexer.tokens:{k | <k>=<lexer.tokens.(k)>}; separator=", ", wrap, anchor>; <lexer.tokens:{k | <k>=<lexer.tokens.(k)>}; separator=", ", wrap, anchor>;
<endif>
<if(lexer.channels)> <if(lexer.channels)>
public static final int public static final int
<lexer.channels:{c | <c>=<lexer.channels.(c)>}; separator=", ", wrap, anchor>; <lexer.channels:{c | <c>=<lexer.channels.(c)>}; separator=", ", wrap, anchor>;

View File

@ -394,11 +394,11 @@ public enum ErrorType {
*/ */
IMPORT_NAME_CLASH(113, "<arg.typeString> grammar <arg.name> and imported <arg2.typeString> grammar <arg2.name> both generate <arg2.recognizerName>", ErrorSeverity.ERROR), IMPORT_NAME_CLASH(113, "<arg.typeString> grammar <arg.name> and imported <arg2.typeString> grammar <arg2.name> both generate <arg2.recognizerName>", ErrorSeverity.ERROR),
/** /**
* Compiler Error 160. * Compiler Error 114.
* *
* <p>cannot find tokens file <em>filename</em></p> * <p>cannot find tokens file <em>filename</em></p>
*/ */
CANNOT_FIND_TOKENS_FILE_REFD_IN_GRAMMAR(160, "cannot find tokens file <arg>", ErrorSeverity.ERROR), CANNOT_FIND_TOKENS_FILE_REFD_IN_GRAMMAR(114, "cannot find tokens file <arg>", ErrorSeverity.ERROR),
/** /**
* Compiler Warning 118. * Compiler Warning 118.
* *
@ -522,7 +522,7 @@ public enum ErrorType {
*/ */
USE_OF_BAD_WORD(134, "symbol <arg> conflicts with generated code in target language or runtime", ErrorSeverity.ERROR), USE_OF_BAD_WORD(134, "symbol <arg> conflicts with generated code in target language or runtime", ErrorSeverity.ERROR),
/** /**
* Compiler Error 134. * Compiler Error 183.
* *
* <p>rule reference <em>rule</em> is not currently supported in a set</p> * <p>rule reference <em>rule</em> is not currently supported in a set</p>
* *
@ -530,7 +530,7 @@ public enum ErrorType {
* Note: This error has the same number as the unrelated error * Note: This error has the same number as the unrelated error
* {@link #USE_OF_BAD_WORD}.</p> * {@link #USE_OF_BAD_WORD}.</p>
*/ */
UNSUPPORTED_REFERENCE_IN_LEXER_SET(134, "rule reference <arg> is not currently supported in a set", ErrorSeverity.ERROR), UNSUPPORTED_REFERENCE_IN_LEXER_SET(183, "rule reference <arg> is not currently supported in a set", ErrorSeverity.ERROR),
/** /**
* Compiler Error 135. * Compiler Error 135.
* *