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
[*]
tab_width = 4
[*.{java,stg}]
charset = utf-8
insert_final_newline = true

View File

@ -6,7 +6,7 @@ matrix:
include:
- os: linux
compiler: clang
jdk: oraclejdk7
jdk: openjdk7
env:
- TARGET=cpp
- CXX=g++-5
@ -104,13 +104,13 @@ matrix:
- TARGET=dotnet
- GROUP=RECURSION
- os: linux
jdk: oraclejdk7
jdk: openjdk7
env: TARGET=java
- os: linux
jdk: oraclejdk8
env: TARGET=java
- os: linux
jdk: oraclejdk8
jdk: openjdk7
env: TARGET=csharp
- os: linux
jdk: oraclejdk8
@ -131,10 +131,10 @@ matrix:
- TARGET=dotnet
- GROUP=RECURSION
- os: linux
jdk: oraclejdk8
jdk: openjdk7
env: TARGET=python2
- os: linux
jdk: oraclejdk8
jdk: openjdk7
env: TARGET=python3
addons:
apt:
@ -143,10 +143,10 @@ matrix:
packages:
- python3.5
- os: linux
jdk: oraclejdk8
jdk: openjdk7
env: TARGET=javascript
- os: linux
jdk: oraclejdk7
jdk: openjdk7
env: TARGET=go
before_install:
@ -154,4 +154,3 @@ before_install:
script:
- 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/10, jm-mikkelsen, Jan Martin Mikkelsen, janm@transactionware.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/11, dhalperi, Daniel Halperin, daniel@halper.in
2017/07/17, vaibhavaingankar09, Vaibhav Vaingankar, vbhvvaingankar9@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:
[http://www.antlr.org/download.html](http://www.antlr.org/download.html)
and put it somewhere rational like `/usr/local/lib`.
2. Add `antlr-4.5.3-complete.jar` to your `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.
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'
@ -39,7 +41,7 @@ $ alias grun='java org.antlr.v4.gui.TestRig'
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/)
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
* Temporarily, at command line:
```

View File

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

View File

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

View File

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

View File

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

View File

@ -151,8 +151,8 @@ public abstract class CodePointCharStream implements CharStream {
/** Return the UTF-16 encoded string for the given interval */
@Override
public String getText(Interval interval) {
int startIdx = Math.min(interval.a, size - 1);
int len = Math.min(interval.b - interval.a + 1, size);
int startIdx = Math.min(interval.a, size);
int len = Math.min(interval.b - interval.a + 1, size - startIdx);
// 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,

View File

@ -8,6 +8,7 @@ package org.antlr.v4.test.tool;
import org.antlr.v4.Tool;
import org.antlr.v4.tool.ErrorType;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@ -60,6 +61,16 @@ public class TestToolSyntaxErrors extends BaseJavaToolTest {
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 testExtraColon() {

View File

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

View File

@ -1,5 +1,5 @@
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) ::= <<

View File

@ -894,8 +894,10 @@ public class <lexer.name> extends <superClass; null="Lexer"> {
protected static final DFA[] _decisionToDFA;
protected static final PredictionContextCache _sharedContextCache =
new PredictionContextCache();
<if(lexer.tokens)>
public static final int
<lexer.tokens:{k | <k>=<lexer.tokens.(k)>}; separator=", ", wrap, anchor>;
<endif>
<if(lexer.channels)>
public static final int
<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),
/**
* Compiler Error 160.
* Compiler Error 114.
*
* <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.
*
@ -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),
/**
* Compiler Error 134.
* Compiler Error 183.
*
* <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
* {@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.
*