Merge branch 'master' into patch-1

This commit is contained in:
Alexander Bigerl 2021-04-08 16:06:07 +02:00 committed by GitHub
commit 3238961241
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
283 changed files with 16108 additions and 1007 deletions

128
.appveyor/workflow.yml Normal file
View File

@ -0,0 +1,128 @@
environment:
matrix:
- job_name: java-tool-and-runtime
- job_name: csharp-runtime
job_depends_on: java-tool-and-runtime
- job_name: dart-runtime
job_depends_on: java-tool-and-runtime
- job_name: go-runtime
job_depends_on: java-tool-and-runtime
- job_name: javascript-runtime
job_depends_on: java-tool-and-runtime
- job_name: php-runtime
job_depends_on: java-tool-and-runtime
- job_name: python2-runtime
job_depends_on: java-tool-and-runtime
- job_name: python3-runtime
job_depends_on: java-tool-and-runtime
matrix:
fast_finish: false
version: '4.9.1-SNAPSHOT+AppVeyor.{build}'
cache:
- '%USERPROFILE%\.m2'
- '%USERPROFILE%\.nuget\packages -> **\project.json'
image: Visual Studio 2019
# not using MSBuild
build: off
for:
- matrix:
only:
- job_name: java-tool-and-runtime
build_script:
- mvn -q -DskipTests install --batch-mode
test_script:
- cd tool-testsuite
- mvn -q test
- cd ..\runtime-testsuite
- mvn -q -Dtest=java.* test
- matrix:
only:
- job_name: csharp-runtime
build_script:
- mvn -q -DskipTests install --batch-mode
- dotnet build runtime/CSharp/src/Antlr4.csproj -c Release
after_build:
- dotnet pack runtime/CSharp/src/Antlr4.csproj -c Release
test_script:
- cd runtime-testsuite
- mvn -q -Dtest=csharp.* test
artifacts:
- path: 'runtime\**\*.nupkg'
name: NuGet
- matrix:
only:
- job_name: dart-runtime
install:
- cinst -y dart-sdk --version=2.8.4
build_script:
- mvn -q -DskipTests install --batch-mode
test_script:
- cd runtime-testsuite
- mvn -q -Dtest=dart.* test -Dantlr-dart-dart="C:\tools\dart-sdk\bin\dart.exe" -Dantlr-dart-pub="C:\tools\dart-sdk\bin\pub.bat" -Dantlr-dart-dart2native="C:\tools\dart-sdk\bin\dart2native.bat"
- matrix:
only:
- job_name: go-runtime
build_script:
- mvn -q -DskipTests install --batch-mode
test_script:
- cd runtime-testsuite
- mvn -q -Dtest=go.* test
- matrix:
only:
- job_name: javascript-runtime
install:
- cinst nodejs.install
- node --version
- npm --version
- npm install -g yarn@v1.22.10
build_script:
- cd runtime\JavaScript\
- npm install
- npm link
- cd ..\..
- mvn -q -DskipTests install --batch-mode
test_script:
- cd runtime\JavaScript\
- yarn test
- cd ..\..
- cd runtime-testsuite
- mvn -q -Dtest=javascript.* test -Dantlr-javascript-npm="C:\Program Files\nodejs\npm.cmd" -Dantlr-javascript-nodejs="C:\Program Files\nodejs\node.exe"
- matrix:
only:
- job_name: php-runtime
install:
- git clone https://github.com/antlr/antlr-php-runtime.git
- mv antlr-php-runtime runtime/PHP
- cinst -y php --params "/InstallDir:C:\tools\php"
- cinst -y composer
build_script:
- mvn -q -DskipTests install --batch-mode
test_script:
- cd runtime-testsuite
- mvn -q -Dtest=php.* test -Dantlr-php-php="C:\tools\php\php.exe"
- matrix:
only:
- job_name: python2-runtime
build_script:
- mvn -q -DskipTests install --batch-mode
test_script:
- cd runtime-testsuite
- mvn -q -Dtest=python2.* test -Dantlr-python2-python="C:\Python27\python.exe"
- matrix:
only:
- job_name: python3-runtime
build_script:
- mvn -q -DskipTests install --batch-mode
test_script:
- cd runtime-testsuite
- mvn -q -Dtest=python3.* test -Dantlr-python3-python="C:\Python35\python.exe"

View File

@ -57,7 +57,7 @@ workflows:
- test_runtime: - test_runtime:
matrix: matrix:
parameters: parameters:
target: [ dart, go, python2, python3, javascript ] target: [ dart, go, python2, python3, javascript, php ]
- test_runtime: - test_runtime:
matrix: matrix:
parameters: parameters:

View File

@ -15,5 +15,5 @@ echo "done installing .Net SDK"
# we need to build the runtime before test run, since we used "--no-dependencies" # we need to build the runtime before test run, since we used "--no-dependencies"
# when we call dotnet cli for restore and build, in order to speed up # when we call dotnet cli for restore and build, in order to speed up
echo "building runtime..." echo "building runtime..."
dotnet build -c Release -f netstandard2.0 runtime/CSharp/Antlr4.csproj dotnet build -c Release -f netstandard2.0 runtime/CSharp/src/Antlr4.csproj
echo "done building runtime" echo "done building runtime"

View File

@ -7,7 +7,11 @@ echo "installing nodejs..."
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs sudo apt-get install -y nodejs
echo node version: $(node --version) echo node version: $(node --version)
echo "done installing nodejs..." echo "done installing nodejs"
echo "installing yarn..."
sudo npm install -g yarn@v1.22.10
echo "done installing yarn"
echo "packaging javascript runtime..." echo "packaging javascript runtime..."
pushd runtime/JavaScript pushd runtime/JavaScript

View File

@ -5,7 +5,14 @@ set -euo pipefail
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
sudo apt-get update -qq sudo apt-get update -qq
sudo apt update
sudo apt install php-all-dev
php -v php -v
git clone https://github.com/antlr/antlr-php-runtime.git sudo apt install composer
git clone https://github.com/antlr/antlr-php-runtime.git runtime/PHP
composer install -d runtime/PHP
mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V

View File

@ -2,7 +2,22 @@
set -euo pipefail set -euo pipefail
declare -i RESULT=0
pushd runtime/JavaScript
echo "running jest tests..."
yarn test
RESULT+=$?
popd
pushd runtime-testsuite pushd runtime-testsuite
echo "running maven tests..." echo "running maven tests..."
mvn -q -Dtest=javascript.* test mvn -q -Dtest=javascript.* test
popd RESULT+=$?
popd
exit $RESULT

View File

@ -2,8 +2,10 @@
set -euo pipefail set -euo pipefail
php -v
php_path=$(which php) php_path=$(which php)
pushd runtime-testsuite
composer install -d ../runtime/PHP echo "running maven tests..."
mvn -q -DPHP_PATH="${php_path}" -Dparallel=methods -DthreadCount=4 -Dtest=php.* test
mvn -q -DPHP_PATH="${php_path}" -Dparallel=methods -DthreadCount=4 -Dtest=php.* test popd

View File

@ -7,7 +7,7 @@ export PATH=$PATH:/Users/travis/.dotnet
# we need to build the runtime before test run, since we used "--no-dependencies" # we need to build the runtime before test run, since we used "--no-dependencies"
# when we call dotnet cli for restore and build, in order to speed up # when we call dotnet cli for restore and build, in order to speed up
dotnet build -c Release -f netstandard2.0 ../runtime/CSharp/Antlr4.csproj dotnet build -c Release -f netstandard2.0 ../runtime/CSharp/src/Antlr4.csproj
# call test # call test

View File

@ -40,7 +40,7 @@ ANTLR project lead and supreme dictator for life
* [Official site](http://www.antlr.org/) * [Official site](http://www.antlr.org/)
* [Documentation](https://github.com/antlr/antlr4/blob/master/doc/index.md) * [Documentation](https://github.com/antlr/antlr4/blob/master/doc/index.md)
* [FAQ](https://github.com/antlr/antlr4/blob/master/doc/faq/index.md) * [FAQ](https://github.com/antlr/antlr4/blob/master/doc/faq/index.md)
* [ANTLR code generation targets](https://github.com/antlr/antlr4/blob/master/doc/targets.md)<br>(Currently: Java, C#, Python2|3, JavaScript, Go, C++, Swift) * [ANTLR code generation targets](https://github.com/antlr/antlr4/blob/master/doc/targets.md)<br>(Currently: Java, C#, Python2|3, JavaScript, Go, C++, Swift, Dart, PHP)
* [Java API](http://www.antlr.org/api/Java/index.html) * [Java API](http://www.antlr.org/api/Java/index.html)
* [ANTLR v3](http://www.antlr3.org/) * [ANTLR v3](http://www.antlr3.org/)
* [v3 to v4 Migration, differences](https://github.com/antlr/antlr4/blob/master/doc/faq/general.md) * [v3 to v4 Migration, differences](https://github.com/antlr/antlr4/blob/master/doc/faq/general.md)

View File

@ -8,7 +8,7 @@
<parent> <parent>
<groupId>org.antlr</groupId> <groupId>org.antlr</groupId>
<artifactId>antlr4-master</artifactId> <artifactId>antlr4-master</artifactId>
<version>4.9.2-SNAPSHOT</version> <version>4.9.3-SNAPSHOT</version>
</parent> </parent>
<artifactId>antlr4-maven-plugin</artifactId> <artifactId>antlr4-maven-plugin</artifactId>
<packaging>maven-plugin</packaging> <packaging>maven-plugin</packaging>

View File

@ -55,7 +55,7 @@ import java.util.Set;
name = "antlr4", name = "antlr4",
defaultPhase = LifecyclePhase.GENERATE_SOURCES, defaultPhase = LifecyclePhase.GENERATE_SOURCES,
requiresDependencyResolution = ResolutionScope.COMPILE, requiresDependencyResolution = ResolutionScope.COMPILE,
requiresProject = true) requiresProject = true, threadSafe = true)
public class Antlr4Mojo extends AbstractMojo { public class Antlr4Mojo extends AbstractMojo {
// First, let's deal with the options that the ANTLR tool itself // First, let's deal with the options that the ANTLR tool itself

View File

@ -1,22 +0,0 @@
version: '4.9.1-SNAPSHOT+AppVeyor.{build}'
cache:
- '%USERPROFILE%\.m2'
- '%USERPROFILE%\.nuget\packages -> **\project.json'
image: Visual Studio 2019
build: off
install:
- git clone https://github.com/antlr/antlr-php-runtime.git
- mv antlr-php-runtime runtime/PHP
- cinst -y php --params "/InstallDir:C:\tools\php"
- cinst -y composer
- cinst -y dart-sdk --version=2.8.4
build_script:
- mvn -DskipTests install --batch-mode
- dotnet build runtime/CSharp/Antlr4.csproj -c Release
after_build:
- dotnet pack runtime/CSharp/Antlr4.csproj -c Release
test_script:
- mvn install -Dantlr-php-php="C:\tools\php\php.exe" -Dantlr-dart-dart="C:\tools\dart-sdk\bin\dart.exe" -Dantlr-dart-pub="C:\tools\dart-sdk\bin\pub.bat" -Dantlr-dart-dart2native="C:\tools\dart-sdk\bin\dart2native.bat" -Dantlr-python2-python="C:\Python27\python.exe" -Dantlr-python3-python="C:\Python35\python.exe" --batch-mode
artifacts:
- path: 'runtime\**\*.nupkg'
name: NuGet

View File

@ -284,5 +284,10 @@ YYYY/MM/DD, github id, Full name, email
2020/11/26, mr-c, Michael R. Crusoe, 1330696+mr-c@users.noreply.github.com 2020/11/26, mr-c, Michael R. Crusoe, 1330696+mr-c@users.noreply.github.com
2020/12/01, maxence-lefebvre, Maxence Lefebvre, maxence-lefebvre@users.noreply.github.com 2020/12/01, maxence-lefebvre, Maxence Lefebvre, maxence-lefebvre@users.noreply.github.com
2020/12/03, electrum, David Phillips, david@acz.org 2020/12/03, electrum, David Phillips, david@acz.org
2020/12/03, bigerl, Alexander Bigerl, bigerl@mail.upb.de 2021/01/25, l215884529, Qiheng Liu, 13607681+l215884529@users.noreply.github.com
2021/01/25, l215884529, Qiheng Liu, 13607681+l215884529@users.noreply.github.com 2021/02/02, tsotnikov, Taras Sotnikov, taras.sotnikov@gmail.com
2021/02/21, namasikanam, Xingyu Xie, namasikanam@gmail.com
2021/02/27, khmarbaise, Karl Heinz Marbaise, github@soebes.com
2021/03/02, hackeris
2021/03/03, xTachyon, Damian Andrei, xTachyon@users.noreply.github.com
2020/04/08, bigerl, Alexander Bigerl, bigerl@mail.upb.de

View File

@ -57,11 +57,9 @@ $ mvn install -DskipTests=true # make sure all artifacts are visible on this m
Now, make sure C# runtime is built and installed locally. Now, make sure C# runtime is built and installed locally.
```bash ```bash
cd ~/antlr/code/antlr4/runtime/CSharp/runtime/CSharp cd ~/antlr/code/antlr4/runtime/CSharp/src
# kill previous ones manually as "xbuild /t:Clean" didn't seem to do it rm -rf `find . -name '{obj,bin}'`
find . -name '*.dll' -exec rm {} \; dotnet build -c Release runtime/CSharp/src/Antlr4.csproj
# build
xbuild /p:Configuration=Release Antlr4.Runtime/Antlr4.Runtime.mono.csproj
``` ```
C++ test rig automatically builds C++ runtime during tests. Others don't need a prebuilt lib. C++ test rig automatically builds C++ runtime during tests. Others don't need a prebuilt lib.

View File

@ -25,6 +25,22 @@ Checking connectivity... done.
Checking out files: 100% (1427/1427), done. Checking out files: 100% (1427/1427), done.
``` ```
# Check your environment
If you are starting from a clean, minimum Ubuntu OS, check your environment.
```bash
$ sudo apt-get update
$ # Get Java
$ java > /dev/null 2>&1
$ if [[ "$?" != "0" ]]; then sudo apt install -y openjdk-11-jre-headless; fi
$ # Get Mvn
$ mvn > /dev/null 2>&1
$ if [[ "$?" != "0" ]]; then sudo apt install -y maven; fi
```
# Compile # Compile
```bash ```bash

View File

@ -36,7 +36,7 @@ using Antlr4.Runtime.Tree;
public void MyParseMethod() { public void MyParseMethod() {
String input = "your text to parse here"; String input = "your text to parse here";
ICharStream stream = CharStreams.fromstring(input); ICharStream stream = CharStreams.fromString(input);
ITokenSource lexer = new MyGrammarLexer(stream); ITokenSource lexer = new MyGrammarLexer(stream);
ITokenStream tokens = new CommonTokenStream(lexer); ITokenStream tokens = new CommonTokenStream(lexer);
MyGrammarParser parser = new MyGrammarParser(tokens); MyGrammarParser parser = new MyGrammarParser(tokens);

View File

@ -91,7 +91,7 @@ Now a fully functioning script might look like the following:
```javascript ```javascript
import antlr4 from 'antlr4'; import antlr4 from 'antlr4';
import MyGrammarLexer from './MyGrammarLexer.js'); import MyGrammarLexer from './MyGrammarLexer.js';
import MyGrammarParser from './MyGrammarParser.js'; import MyGrammarParser from './MyGrammarParser.js';
import MyGrammarListener from './MyGrammarListener.js'; import MyGrammarListener from './MyGrammarListener.js';

View File

@ -79,7 +79,7 @@ These more or less correspond to `isJavaIdentifierPart` and `isJavaIdentifierSta
## Literals ## Literals
ANTLR does not distinguish between character and string literals as most languages do. All literal strings one or more characters in length are enclosed in single quotes such as `;`, `if`, `>=`, and `\` (refers to the one-character string containing the single quote character). Literals never contain regular expressions. ANTLR does not distinguish between character and string literals as most languages do. All literal strings one or more characters in length are enclosed in single quotes such as `;`, `if`, `>=`, and `\` (refers to the one-character string containing the single quote character). Literals never contain regular expressions.
Literals can contain Unicode escape sequences of the form `\uXXXX` (for Unicode code points up to `U+FFFF`) or `\u{XXXXXX}` (for all Unicode code points), where `XXXX` is the hexadecimal Unicode code point value. Literals can contain Unicode escape sequences of the form `\uXXXX` (for Unicode code points up to `U+FFFF`) or `\u{XXXXXX}` (for all Unicode code points), where `XXXX` is the hexadecimal Unicode code point value.

View File

@ -24,11 +24,11 @@ $ git push upstream 4.9-rc1
## Copy PHP runtime over ## Copy PHP runtime over
Bump version to 4.9 in `runtime/PHP/src/RuntimeMetaData.php` in separate repository and commit plus push. Bump version to 4.9 in `~/antlr/code/antlr-php-runtime/src/RuntimeMetaData.php` in separate repository and commit plus push.
``` ```
cd ~/antlr/code/antlr-php-runtime cd ~/antlr/code/antlr-php-runtime/src
... vi src/RuntimeMetaData.php ... ... vi RuntimeMetaData.php ...
git commit -a -m "Update PHP Runtime to latest version" git commit -a -m "Update PHP Runtime to latest version"
``` ```
@ -36,6 +36,7 @@ them back over in the ANTLR repo:
``` ```
cd runtime cd runtime
rm -rf PHP
mkdir PHP mkdir PHP
cp ~/antlr/code/antlr-php-runtime/LICENSE PHP cp ~/antlr/code/antlr-php-runtime/LICENSE PHP
cp ~/antlr/code/antlr-php-runtime/README.md PHP cp ~/antlr/code/antlr-php-runtime/README.md PHP
@ -54,10 +55,11 @@ Edit the repository looking for 4.5 or whatever and update it. Bump version in t
* runtime/Python2/src/antlr4/Recognizer.py * runtime/Python2/src/antlr4/Recognizer.py
* runtime/Python3/setup.py * runtime/Python3/setup.py
* runtime/Python3/src/antlr4/Recognizer.py * runtime/Python3/src/antlr4/Recognizer.py
* runtime/CSharp/Antlr4.csproj * runtime/CSharp/src/Antlr4.csproj
* runtime/PHP/src/RuntimeMetaData.php * runtime/PHP/src/RuntimeMetaData.php
* runtime/JavaScript/package.json * runtime/JavaScript/package.json
* runtime/JavaScript/src/antlr4/Recognizer.js * runtime/JavaScript/src/antlr4/Recognizer.js
* runtime/JavaScript/package-lock.json
* runtime/Cpp/VERSION * runtime/Cpp/VERSION
* runtime/Cpp/runtime/src/RuntimeMetaData.cpp * runtime/Cpp/runtime/src/RuntimeMetaData.cpp
* runtime/Cpp/cmake/ExternalAntlr4Cpp.cmake * runtime/Cpp/cmake/ExternalAntlr4Cpp.cmake
@ -66,6 +68,11 @@ Edit the repository looking for 4.5 or whatever and update it. Bump version in t
* runtime/Swift/Antlr4/org/antlr/v4/runtime/RuntimeMetaData.swift * runtime/Swift/Antlr4/org/antlr/v4/runtime/RuntimeMetaData.swift
* runtime/Dart/lib/src/runtime_meta_data.dart * runtime/Dart/lib/src/runtime_meta_data.dart
* runtime/Dart/pubspec.yaml * runtime/Dart/pubspec.yaml
* runtime/Swift/Tests/Antlr4Tests/RuntimeMetaDataTests.swift
* runtime/Swift/Sources/Antlr4/RuntimeMetaData.swift
* runtime/CSharp/src/Tree/Xpath/XPathLexer.cs
* runtime/CSharp/src/README.md
* runtime/CSharp/src/Properties/AssemblyInfo.cs
* tool/src/org/antlr/v4/codegen/target/GoTarget.java * tool/src/org/antlr/v4/codegen/target/GoTarget.java
* tool/src/org/antlr/v4/codegen/target/CppTarget.java * tool/src/org/antlr/v4/codegen/target/CppTarget.java
* tool/src/org/antlr/v4/codegen/target/CSharpTarget.java * tool/src/org/antlr/v4/codegen/target/CSharpTarget.java
@ -73,6 +80,7 @@ Edit the repository looking for 4.5 or whatever and update it. Bump version in t
* tool/src/org/antlr/v4/codegen/target/Python2Target.java * tool/src/org/antlr/v4/codegen/target/Python2Target.java
* tool/src/org/antlr/v4/codegen/target/Python3Target.java * tool/src/org/antlr/v4/codegen/target/Python3Target.java
* tool/src/org/antlr/v4/codegen/target/SwiftTarget.java * tool/src/org/antlr/v4/codegen/target/SwiftTarget.java
* tool/src/org/antlr/v4/codegen/target/PHPTarget.java
* tool/src/org/antlr/v4/codegen/Target.java * tool/src/org/antlr/v4/codegen/Target.java
* tool/resources/org/antlr/v4/tool/templates/codegen/Swift/Swift.stg * tool/resources/org/antlr/v4/tool/templates/codegen/Swift/Swift.stg
@ -80,11 +88,12 @@ Here is a simple script to display any line from the critical files with, say, `
```bash ```bash
mvn clean mvn clean
rm -rf runtime/CSharp/bin rm -rf runtime/CSharp/src/bin
rm -rf runtime/CSharp/obj rm -rf runtime/CSharp/src/obj
rm -rf runtime/Cpp/runtime/build
rm -rf runtime/gen rm -rf runtime/gen
rm -rf runtime/JavaScript/dist
find tool runtime -type f -exec grep -l '4\.9' {} \; find tool runtime -type f -exec grep -l '4\.9' {} \;
find runtime runtime -type f -exec grep -l '4\.9' {} \;
``` ```
Commit to repository. Commit to repository.
@ -322,10 +331,10 @@ Of course you need Mono and `nuget` to be installed. On mac:
From @kvanTTT: Install `dotnet` on any platform (see https://dotnet.microsoft.com/download) and run the following command on any OS (Win, Linux, macOS): From @kvanTTT: Install `dotnet` on any platform (see https://dotnet.microsoft.com/download) and run the following command on any OS (Win, Linux, macOS):
* building: `dotnet build runtime/CSharp/Antlr4.csproj -c Release` * building: `dotnet build runtime/CSharp/src/Antlr4.csproj -c Release`
Output `.dll` will be in `runtime/CSharp/bin/Release/netstandard2.0` or in `runtime/CSharp/bin/Release/netstandard2.1` Output `.dll` will be in `runtime/CSharp/src/bin/Release/netstandard2.0` or in `runtime/CSharp/src/bin/Release/netstandard2.1`
* packing: `dotnet pack runtime/CSharp/Antlr4.csproj -c Release` * packing: `dotnet pack runtime/CSharp/src/Antlr4.csproj -c Release`
Output `.nupkg` will be in `runtime/CSharp/bin/Release/Antlr4.Runtime.Standard.4.9.0.nupkg` Output `.nupkg` will be in `runtime/CSharp/src/bin/Release/Antlr4.Runtime.Standard.4.9.1.nupkg`
Alternatively, you can install Visual Studio 2017 and make sure to check boxes with .NET Core SDK. Alternatively, you can install Visual Studio 2017 and make sure to check boxes with .NET Core SDK.
@ -476,7 +485,13 @@ Otherwise enter `N` to ignore the warning.
## Update javadoc for runtime and tool ## Update javadoc for runtime and tool
First, gen javadoc: Above build should make latest in
```
~/.m2/repository/org/antlr/antlr4-runtime/4.9/antlr4-runtime-4.9
```
but you can regen (watch pom version!):
```bash ```bash
$ cd antlr4 $ cd antlr4

View File

@ -13,7 +13,7 @@
</parent> </parent>
<groupId>org.antlr</groupId> <groupId>org.antlr</groupId>
<artifactId>antlr4-master</artifactId> <artifactId>antlr4-master</artifactId>
<version>4.9.2-SNAPSHOT</version> <version>4.9.3-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>ANTLR 4</name> <name>ANTLR 4</name>

View File

@ -9,7 +9,7 @@
<parent> <parent>
<groupId>org.antlr</groupId> <groupId>org.antlr</groupId>
<artifactId>antlr4-master</artifactId> <artifactId>antlr4-master</artifactId>
<version>4.9.2-SNAPSHOT</version> <version>4.9.3-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<artifactId>antlr4-runtime-test-annotations</artifactId> <artifactId>antlr4-runtime-test-annotations</artifactId>

View File

@ -10,7 +10,7 @@
<parent> <parent>
<groupId>org.antlr</groupId> <groupId>org.antlr</groupId>
<artifactId>antlr4-master</artifactId> <artifactId>antlr4-master</artifactId>
<version>4.9.2-SNAPSHOT</version> <version>4.9.3-SNAPSHOT</version>
</parent> </parent>
<artifactId>antlr4-runtime-testsuite</artifactId> <artifactId>antlr4-runtime-testsuite</artifactId>
<name>ANTLR 4 Runtime Tests (2nd generation)</name> <name>ANTLR 4 Runtime Tests (2nd generation)</name>

View File

@ -9,7 +9,7 @@
<parent> <parent>
<groupId>org.antlr</groupId> <groupId>org.antlr</groupId>
<artifactId>antlr4-master</artifactId> <artifactId>antlr4-master</artifactId>
<version>4.9.2-SNAPSHOT</version> <version>4.9.3-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<artifactId>antlr4-runtime-test-annotation-processors</artifactId> <artifactId>antlr4-runtime-test-annotation-processors</artifactId>

View File

@ -87,13 +87,13 @@ public abstract class BaseRuntimeTest {
public void run() { public void run() {
heartbeat = true; heartbeat = true;
while (heartbeat) { while (heartbeat) {
System.out.print('.');
try { try {
//noinspection BusyWait //noinspection BusyWait
Thread.sleep(5000); Thread.sleep(10000);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
System.out.print('.');
} }
} }
}; };

View File

@ -14,11 +14,16 @@ import org.junit.rules.TestWatcher;
import org.junit.runner.Description; import org.junit.runner.Description;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.util.Locale; import java.util.Locale;
import java.util.logging.Logger; import java.util.logging.Logger;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@SuppressWarnings("ResultOfMethodCallIgnored")
public abstract class BaseRuntimeTestSupport implements RuntimeTestSupport { public abstract class BaseRuntimeTestSupport implements RuntimeTestSupport {
// -J-Dorg.antlr.v4.test.BaseTest.level=FINE // -J-Dorg.antlr.v4.test.BaseTest.level=FINE
@ -102,8 +107,7 @@ public abstract class BaseRuntimeTestSupport implements RuntimeTestSupport {
String prop = System.getProperty(propName); String prop = System.getProperty(propName);
if(prop!=null && prop.length()>0) { if(prop!=null && prop.length()>0) {
tempTestDir = new File(prop); tempTestDir = new File(prop);
} } else {
else {
String dirName = getClass().getSimpleName() + "-" + Thread.currentThread().getName() + "-" + System.currentTimeMillis(); String dirName = getClass().getSimpleName() + "-" + Thread.currentThread().getName() + "-" + System.currentTimeMillis();
tempTestDir = new File(System.getProperty("java.io.tmpdir"), dirName); tempTestDir = new File(System.getProperty("java.io.tmpdir"), dirName);
} }
@ -149,22 +153,41 @@ public abstract class BaseRuntimeTestSupport implements RuntimeTestSupport {
public static void eraseFilesInDir(File dir) { public static void eraseFilesInDir(File dir) {
String[] files = dir.list(); String[] files = dir.list();
for(int i = 0; files!=null && i < files.length; i++) { for(int i = 0; files!=null && i < files.length; i++) {
new File(dir,files[i]).delete(); try {
eraseFile(dir, files[i]);
} catch(IOException e) {
logger.info(e.getMessage());
}
} }
} }
private static void eraseFile(File dir, String name) throws IOException {
File file = new File(dir,name);
if(Files.isSymbolicLink((file.toPath())))
Files.delete(file.toPath());
else if(file.isDirectory()) {
// work around issue where Files.isSymbolicLink returns false on Windows for node/antlr4 linked package
if("antlr4".equals(name))
; // logger.warning("antlr4 not seen as a symlink");
else
eraseDirectory(file);
} else
file.delete();
}
private static String detectedOS; private static String detectedOS;
public static String getOS() { public static String getOS() {
if (detectedOS == null) { if (detectedOS == null) {
String os = System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH); String os = System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH);
if ((os.indexOf("mac") >= 0) || (os.indexOf("darwin") >= 0)) { if (os.contains("mac") || os.contains("darwin")) {
detectedOS = "mac"; detectedOS = "mac";
} }
else if (os.indexOf("win") >= 0) { else if (os.contains("win")) {
detectedOS = "windows"; detectedOS = "windows";
} }
else if (os.indexOf("nux") >= 0) { else if (os.contains("nux")) {
detectedOS = "linux"; detectedOS = "linux";
} }
else { else {

View File

@ -6,6 +6,10 @@ public abstract class TestContext {
return "true".equals(String.valueOf(System.getenv("TRAVIS")).toLowerCase()); return "true".equals(String.valueOf(System.getenv("TRAVIS")).toLowerCase());
} }
public static boolean isGitHubCI() {
return "true".equals(String.valueOf(System.getenv("CI")).toLowerCase());
}
public static boolean isAppVeyorCI() { public static boolean isAppVeyorCI() {
return "true".equals(String.valueOf(System.getenv("APPVEYOR")).toLowerCase()); return "true".equals(String.valueOf(System.getenv("APPVEYOR")).toLowerCase());
} }
@ -14,9 +18,14 @@ public abstract class TestContext {
return "true".equals(String.valueOf(System.getenv("CIRCLECI")).toLowerCase()); return "true".equals(String.valueOf(System.getenv("CIRCLECI")).toLowerCase());
} }
public static boolean isCI() {
return isAppVeyorCI() || isCircleCI() || isGitHubCI() || isTravisCI();
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public static boolean isSupportedTarget(String target) { public static boolean isSupportedTarget(String target) {
if(isAppVeyorCI()) if(isAppVeyorCI())
return !target.matches("Swift|Node"); return !target.matches("Swift");
else else
return true; return true;
} }

View File

@ -394,7 +394,8 @@ public class BaseCppTest extends BaseRuntimeTestSupport implements RuntimeTestSu
+ "\n" + "\n"
+ "\n" + "\n"
+ "int main(int argc, const char* argv[]) {\n" + "int main(int argc, const char* argv[]) {\n"
+ " ANTLRFileStream input(argv[1]);\n" + " ANTLRFileStream input;\n"
+ " input.loadFromFile(argv[1]);\n"
+ " <lexerName> lexer(&input);\n" + " <lexerName> lexer(&input);\n"
+ " CommonTokenStream tokens(&lexer);\n" + " CommonTokenStream tokens(&lexer);\n"
+ "<createParser>" + "<createParser>"
@ -436,7 +437,8 @@ public class BaseCppTest extends BaseRuntimeTestSupport implements RuntimeTestSu
+ "using namespace antlr4;\n" + "using namespace antlr4;\n"
+ "\n" + "\n"
+ "int main(int argc, const char* argv[]) {\n" + "int main(int argc, const char* argv[]) {\n"
+ " ANTLRFileStream input(argv[1]);\n" + " ANTLRFileStream input;\n"
+ " input.loadFromFile(argv[1]);\n"
+ " <lexerName> lexer(&input);\n" + " <lexerName> lexer(&input);\n"
+ " CommonTokenStream tokens(&lexer);\n" + " CommonTokenStream tokens(&lexer);\n"
+ " tokens.fill();\n" + " tokens.fill();\n"

View File

@ -195,7 +195,7 @@ public class BaseCSharpTest extends BaseRuntimeTestSupport implements RuntimeTes
// find runtime package // find runtime package
final ClassLoader loader = Thread.currentThread().getContextClassLoader(); final ClassLoader loader = Thread.currentThread().getContextClassLoader();
final URL runtimeProj = loader.getResource("CSharp/Antlr4.csproj"); final URL runtimeProj = loader.getResource("CSharp/src/Antlr4.csproj");
if (runtimeProj == null) { if (runtimeProj == null) {
throw new RuntimeException("C# runtime project file not found!"); throw new RuntimeException("C# runtime project file not found!");
} }

View File

@ -5,6 +5,7 @@
*/ */
package org.antlr.v4.test.runtime.javascript; package org.antlr.v4.test.runtime.javascript;
import org.antlr.v4.runtime.misc.Utils;
import org.antlr.v4.test.runtime.*; import org.antlr.v4.test.runtime.*;
import org.stringtemplate.v4.ST; import org.stringtemplate.v4.ST;
@ -121,7 +122,7 @@ public class BaseNodeTest extends BaseRuntimeTestSupport implements RuntimeTestS
public String execModule(String fileName) { public String execModule(String fileName) {
try { try {
String npmPath = locateNpm(); String npmPath = locateNpm();
if(!TestContext.isTravisCI() && !TestContext.isCircleCI()) { if(!TestContext.isCI()) {
installRuntime(npmPath); installRuntime(npmPath);
registerRuntime(npmPath); registerRuntime(npmPath);
} }
@ -203,7 +204,8 @@ public class BaseNodeTest extends BaseRuntimeTestSupport implements RuntimeTestS
args.addAll(Arrays.asList(npmPath, "link", "antlr4")); args.addAll(Arrays.asList(npmPath, "link", "antlr4"));
ProcessBuilder builder = new ProcessBuilder(args.toArray(new String[0])); ProcessBuilder builder = new ProcessBuilder(args.toArray(new String[0]));
builder.directory(getTempTestDir()); builder.directory(getTempTestDir());
builder.redirectError(new File(getTempTestDir(), "error.txt")); File errorFile = new File(getTempTestDir(), "error.txt");
builder.redirectError(errorFile);
builder.redirectOutput(new File(getTempTestDir(), "output.txt")); builder.redirectOutput(new File(getTempTestDir(), "output.txt"));
Process process = builder.start(); Process process = builder.start();
// TODO switch to jdk 8 // TODO switch to jdk 8
@ -211,8 +213,10 @@ public class BaseNodeTest extends BaseRuntimeTestSupport implements RuntimeTestS
// if(!process.waitFor(30L, TimeUnit.SECONDS)) // if(!process.waitFor(30L, TimeUnit.SECONDS))
// process.destroyForcibly(); // process.destroyForcibly();
int error = process.exitValue(); int error = process.exitValue();
if(error!=0) if(error!=0) {
throw new IOException("'npm link antlr4' failed"); char[] errors = Utils.readFile(errorFile.getAbsolutePath());
throw new IOException("'npm link antlr4' failed: " + new String(errors));
}
} }
private boolean canExecute(String tool) { private boolean canExecute(String tool) {
@ -237,6 +241,8 @@ public class BaseNodeTest extends BaseRuntimeTestSupport implements RuntimeTestS
// typically /usr/local/bin/npm // typically /usr/local/bin/npm
String prop = System.getProperty("antlr-javascript-npm"); String prop = System.getProperty("antlr-javascript-npm");
if ( prop!=null && prop.length()!=0 ) { if ( prop!=null && prop.length()!=0 ) {
if(prop.contains(" "))
prop = "\"" + prop + "\"";
return prop; return prop;
} }
return "npm"; // everywhere return "npm"; // everywhere
@ -246,6 +252,8 @@ public class BaseNodeTest extends BaseRuntimeTestSupport implements RuntimeTestS
// typically /usr/local/bin/node // typically /usr/local/bin/node
String prop = System.getProperty("antlr-javascript-nodejs"); String prop = System.getProperty("antlr-javascript-nodejs");
if ( prop!=null && prop.length()!=0 ) { if ( prop!=null && prop.length()!=0 ) {
if(prop.contains(" "))
prop = "\"" + prop + "\"";
return prop; return prop;
} }
if (canExecute("nodejs")) { if (canExecute("nodejs")) {

View File

@ -195,7 +195,8 @@ public abstract class BasePythonTest extends BaseRuntimeTestSupport implements R
private String locateTool(List<String> tools) { private String locateTool(List<String> tools) {
String[] roots = { String[] roots = {
"/opt/local/bin", "/usr/bin/", "/usr/local/bin/", "/opt/local/bin", "/usr/bin/", "/usr/local/bin/",
"/Users/"+System.getProperty("user.name")+"/anaconda3/bin/" "/Users/"+System.getProperty("user.name")+"/anaconda3/bin/",
"/Users/"+System.getProperty("user.name")+"/opt/anaconda3/bin/"
}; };
for(String root : roots) { for(String root : roots) {
for (String tool : tools) { for (String tool : tools) {

View File

@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<Company>The ANTLR Organization</Company> <Company>The ANTLR Organization</Company>
<Version>4.9.1</Version> <Version>4.9.2</Version>
<NeutralLanguage>en-US</NeutralLanguage> <NeutralLanguage>en-US</NeutralLanguage>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks> <TargetFramework>netstandard2.0</TargetFramework>
<NoWarn>$(NoWarn);CS1591;CS1574;CS1580</NoWarn> <NoWarn>$(NoWarn);CS1591;CS1574;CS1580</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>Antlr4.Runtime.Standard</AssemblyName> <AssemblyName>Antlr4.Runtime.Standard</AssemblyName>

View File

@ -41,6 +41,9 @@ namespace Antlr4.Runtime.Atn
/// <since>4.3</since> /// <since>4.3</since>
public class AmbiguityInfo : DecisionEventInfo public class AmbiguityInfo : DecisionEventInfo
{ {
/** The set of alternative numbers for this decision event that lead to a valid parse. */
public BitSet ambigAlts;
/// <summary> /// <summary>
/// Constructs a new instance of the /// Constructs a new instance of the
/// <see cref="AmbiguityInfo"/> /// <see cref="AmbiguityInfo"/>
@ -48,19 +51,30 @@ namespace Antlr4.Runtime.Atn
/// specified detailed ambiguity information. /// specified detailed ambiguity information.
/// </summary> /// </summary>
/// <param name="decision">The decision number</param> /// <param name="decision">The decision number</param>
/// <param name="state"> /// <param name="configs">The final configuration set identifying the ambiguous
/// The final simulator state identifying the ambiguous
/// alternatives for the current input /// alternatives for the current input
/// </param> /// </param>
/// <param name="ambigAlts">The set of alternatives in the decision that lead to a valid parse.
/// The predicted alt is the min(ambigAlts)
/// </param>
/// <param name="input">The input token stream</param> /// <param name="input">The input token stream</param>
/// <param name="startIndex">The start index for the current prediction</param> /// <param name="startIndex">The start index for the current prediction</param>
/// <param name="stopIndex"> /// <param name="stopIndex">
/// The index at which the ambiguity was identified during /// The index at which the ambiguity was identified during
/// prediction /// prediction
/// </param> /// </param>
public AmbiguityInfo(int decision, SimulatorState state, ITokenStream input, int startIndex, int stopIndex) /// <param name="fullCtx">@code true} if the ambiguity was identified during LL
: base(decision, state, input, startIndex, stopIndex, state.useContext) /// prediction; otherwise, {@code false} if the ambiguity was identified
/// during SLL prediction
/// </param>
public AmbiguityInfo(int decision,
ATNConfigSet configs,
BitSet ambigAlts,
ITokenStream input, int startIndex, int stopIndex,
bool fullCtx)
: base(decision, configs, input, startIndex, stopIndex, fullCtx)
{ {
this.ambigAlts = ambigAlts;
} }
} }
} }

View File

@ -35,9 +35,8 @@ namespace Antlr4.Runtime.Atn
/// with the specified detailed context sensitivity information. /// with the specified detailed context sensitivity information.
/// </summary> /// </summary>
/// <param name="decision">The decision number</param> /// <param name="decision">The decision number</param>
/// <param name="state"> /// <param name="configs">The final configuration set identifying the ambiguous
/// The final simulator state containing the unique /// alternatives for the current input
/// alternative identified by full-context prediction
/// </param> /// </param>
/// <param name="input">The input token stream</param> /// <param name="input">The input token stream</param>
/// <param name="startIndex">The start index for the current prediction</param> /// <param name="startIndex">The start index for the current prediction</param>
@ -45,8 +44,8 @@ namespace Antlr4.Runtime.Atn
/// The index at which the context sensitivity was /// The index at which the context sensitivity was
/// identified during full-context prediction /// identified during full-context prediction
/// </param> /// </param>
public ContextSensitivityInfo(int decision, SimulatorState state, ITokenStream input, int startIndex, int stopIndex) public ContextSensitivityInfo(int decision, ATNConfigSet configs, ITokenStream input, int startIndex, int stopIndex)
: base(decision, state, input, startIndex, stopIndex, true) : base(decision, configs, input, startIndex, stopIndex, true)
{ {
} }
} }

View File

@ -25,15 +25,13 @@ namespace Antlr4.Runtime.Atn
/// <seealso cref="ATN.decisionToState"/> /// <seealso cref="ATN.decisionToState"/>
public readonly int decision; public readonly int decision;
/// <summary> /// <summary>The configuration set containing additional information relevant to the
/// The simulator state containing additional information relevant to the /// prediction state when the current event occurred, or {@code null} if no
/// prediction state when the current event occurred, or /// additional information is relevant or available.</summary>
/// <see langword="null"/> /// <remarks>The configuration set containing additional information relevant to the
/// if no /// prediction state when the current event occurred, or {@code null} if no
/// additional information is relevant or available. /// additional information is relevant or available.</remarks>
/// </summary> public readonly ATNConfigSet configs;
[Nullable]
public readonly SimulatorState state;
/// <summary>The input token stream which is being parsed.</summary> /// <summary>The input token stream which is being parsed.</summary>
/// <remarks>The input token stream which is being parsed.</remarks> /// <remarks>The input token stream which is being parsed.</remarks>
@ -63,14 +61,17 @@ namespace Antlr4.Runtime.Atn
/// </summary> /// </summary>
public readonly bool fullCtx; public readonly bool fullCtx;
public DecisionEventInfo(int decision, SimulatorState state, ITokenStream input, int startIndex, int stopIndex, bool fullCtx) public DecisionEventInfo(int decision,
ATNConfigSet configs,
ITokenStream input, int startIndex, int stopIndex,
bool fullCtx)
{ {
this.decision = decision; this.decision = decision;
this.fullCtx = fullCtx; this.fullCtx = fullCtx;
this.stopIndex = stopIndex; this.stopIndex = stopIndex;
this.input = input; this.input = input;
this.startIndex = startIndex; this.startIndex = startIndex;
this.state = state; this.configs = configs;
} }
} }
} }

View File

@ -30,17 +30,18 @@ namespace Antlr4.Runtime.Atn
/// specified detailed syntax error information. /// specified detailed syntax error information.
/// </summary> /// </summary>
/// <param name="decision">The decision number</param> /// <param name="decision">The decision number</param>
/// <param name="state"> /// <param name="configs">The final configuration set reached during prediction
/// The final simulator state reached during prediction /// prior to reaching the {@link ATNSimulator#ERROR} state
/// prior to reaching the
/// <see cref="ATNSimulator.ERROR"/>
/// state
/// </param> /// </param>
/// <param name="input">The input token stream</param> /// <param name="input">The input token stream</param>
/// <param name="startIndex">The start index for the current prediction</param> /// <param name="startIndex">The start index for the current prediction</param>
/// <param name="stopIndex">The index at which the syntax error was identified</param> /// <param name="stopIndex">The index at which the syntax error was identified</param>
public ErrorInfo(int decision, SimulatorState state, ITokenStream input, int startIndex, int stopIndex) /// <param name="fullCtx">{@code true} if the syntax error was identified during LL
: base(decision, state, input, startIndex, stopIndex, state.useContext) /// prediction; otherwise, {@code false} if the syntax error was identified
/// during SLL prediction
/// </param>
public ErrorInfo(int decision, ATNConfigSet configs, ITokenStream input, int startIndex, int stopIndex, bool fullCtx)
: base(decision, configs, input, startIndex, stopIndex, fullCtx)
{ {
} }
} }

View File

@ -19,6 +19,13 @@ namespace Antlr4.Runtime.Atn
/// <since>4.3</since> /// <since>4.3</since>
public class LookaheadEventInfo : DecisionEventInfo public class LookaheadEventInfo : DecisionEventInfo
{ {
/// <summary>The alternative chosen by adaptivePredict(), not necessarily
/// the outermost alt shown for a rule; left-recursive rules have
/// user-level alts that differ from the rewritten rule with a (...) block
/// and a (..)* loop.
/// </summary>
public int predictedAlt;
/// <summary> /// <summary>
/// Constructs a new instance of the /// Constructs a new instance of the
/// <see cref="LookaheadEventInfo"/> /// <see cref="LookaheadEventInfo"/>
@ -26,18 +33,15 @@ namespace Antlr4.Runtime.Atn
/// the specified detailed lookahead information. /// the specified detailed lookahead information.
/// </summary> /// </summary>
/// <param name="decision">The decision number</param> /// <param name="decision">The decision number</param>
/// <param name="state"> /// <param name="configs">The final configuration set containing the necessary
/// The final simulator state containing the necessary /// information to determine the result of a prediction, or {@code null} if
/// information to determine the result of a prediction, or /// the final configuration set is not available
/// <see langword="null"/>
/// if
/// the final state is not available
/// </param> /// </param>
/// <param name="predictedAlt"></param>
/// <param name="input">The input token stream</param> /// <param name="input">The input token stream</param>
/// <param name="startIndex">The start index for the current prediction</param> /// <param name="startIndex">The start index for the current prediction</param>
/// <param name="stopIndex">The index at which the prediction was finally made</param> /// <param name="stopIndex">The index at which the prediction was finally made</param>
/// <param name="fullCtx"> /// <param name="fullCtx">
///
/// <see langword="true"/> /// <see langword="true"/>
/// if the current lookahead is part of an LL /// if the current lookahead is part of an LL
/// prediction; otherwise, /// prediction; otherwise,
@ -45,9 +49,10 @@ namespace Antlr4.Runtime.Atn
/// if the current lookahead is part of /// if the current lookahead is part of
/// an SLL prediction /// an SLL prediction
/// </param> /// </param>
public LookaheadEventInfo(int decision, SimulatorState state, ITokenStream input, int startIndex, int stopIndex, bool fullCtx) public LookaheadEventInfo(int decision, ATNConfigSet configs, int predictedAlt, ITokenStream input, int startIndex, int stopIndex, bool fullCtx)
: base(decision, state, input, startIndex, stopIndex, fullCtx) : base(decision, configs, input, startIndex, stopIndex, fullCtx)
{ {
this.predictedAlt = predictedAlt;
} }
} }
} }

View File

@ -49,7 +49,6 @@ namespace Antlr4.Runtime.Atn
/// class with the /// class with the
/// specified detailed predicate evaluation information. /// specified detailed predicate evaluation information.
/// </summary> /// </summary>
/// <param name="state">The simulator state</param>
/// <param name="decision">The decision number</param> /// <param name="decision">The decision number</param>
/// <param name="input">The input token stream</param> /// <param name="input">The input token stream</param>
/// <param name="startIndex">The start index for the current prediction</param> /// <param name="startIndex">The start index for the current prediction</param>
@ -68,10 +67,15 @@ namespace Antlr4.Runtime.Atn
/// <see cref="predictedAlt"/> /// <see cref="predictedAlt"/>
/// for more information. /// for more information.
/// </param> /// </param>
/// <param name="fullCtx">{@code true} if the semantic context was
/// evaluated during LL prediction; otherwise, {@code false} if the semantic
/// context was evaluated during SLL prediction
/// </param>
///
/// <seealso cref="ParserATNSimulator.EvalSemanticContext(SemanticContext, ParserRuleContext, int, bool)"/> /// <seealso cref="ParserATNSimulator.EvalSemanticContext(SemanticContext, ParserRuleContext, int, bool)"/>
/// <seealso cref="SemanticContext.Eval"/> /// <seealso cref="SemanticContext.Eval"/>
public PredicateEvalInfo(SimulatorState state, int decision, ITokenStream input, int startIndex, int stopIndex, SemanticContext semctx, bool evalResult, int predictedAlt) public PredicateEvalInfo(int decision, ITokenStream input, int startIndex, int stopIndex, SemanticContext semctx, bool evalResult, int predictedAlt, bool fullCtx)
: base(decision, state, input, startIndex, stopIndex, state.useContext) : base(decision, new ATNConfigSet(), input, startIndex, stopIndex, fullCtx)
{ {
this.semctx = semctx; this.semctx = semctx;
this.evalResult = evalResult; this.evalResult = evalResult;

View File

@ -71,7 +71,7 @@ namespace Antlr4.Runtime.Atn
{ {
decisions[decision].SLL_MaxLook = SLL_k; decisions[decision].SLL_MaxLook = SLL_k;
decisions[decision].SLL_MaxLookEvent = decisions[decision].SLL_MaxLookEvent =
new LookaheadEventInfo(decision, null/*, alt*/, input, startIndex, sllStopIndex, false); new LookaheadEventInfo(decision, null, alt, input, startIndex, sllStopIndex, false);
} }
if (llStopIndex >= 0) if (llStopIndex >= 0)
@ -83,7 +83,7 @@ namespace Antlr4.Runtime.Atn
{ {
decisions[decision].LL_MaxLook = LL_k; decisions[decision].LL_MaxLook = LL_k;
decisions[decision].LL_MaxLookEvent = decisions[decision].LL_MaxLookEvent =
new LookaheadEventInfo(decision, null/*, alt*/, input, startIndex, llStopIndex, true); new LookaheadEventInfo(decision, null, alt, input, startIndex, llStopIndex, true);
} }
} }
@ -108,7 +108,7 @@ namespace Antlr4.Runtime.Atn
if (existingTargetState == ERROR) if (existingTargetState == ERROR)
{ {
decisions[currentDecision].errors.Add( decisions[currentDecision].errors.Add(
new ErrorInfo(currentDecision, null /*previousD.configs*/, input, startIndex, sllStopIndex) new ErrorInfo(currentDecision, previousD.configSet, input, startIndex, sllStopIndex, false)
); );
} }
} }
@ -143,7 +143,7 @@ namespace Antlr4.Runtime.Atn
else { // no reach on current lookahead symbol. ERROR. else { // no reach on current lookahead symbol. ERROR.
// TODO: does not handle delayed errors per getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule() // TODO: does not handle delayed errors per getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule()
decisions[currentDecision].errors.Add( decisions[currentDecision].errors.Add(
new ErrorInfo(currentDecision, null /*closure*/, input, startIndex, llStopIndex) new ErrorInfo(currentDecision, closure, input, startIndex, llStopIndex, true)
); );
} }
} }
@ -154,7 +154,7 @@ namespace Antlr4.Runtime.Atn
} }
else { // no reach on current lookahead symbol. ERROR. else { // no reach on current lookahead symbol. ERROR.
decisions[currentDecision].errors.Add( decisions[currentDecision].errors.Add(
new ErrorInfo(currentDecision, null /*closure*/, input, startIndex, sllStopIndex) new ErrorInfo(currentDecision, closure, input, startIndex, sllStopIndex, false)
); );
} }
} }
@ -168,7 +168,7 @@ namespace Antlr4.Runtime.Atn
bool fullContext = llStopIndex >= 0; bool fullContext = llStopIndex >= 0;
int stopIndex = fullContext ? llStopIndex : sllStopIndex; int stopIndex = fullContext ? llStopIndex : sllStopIndex;
decisions[currentDecision].predicateEvals.Add( decisions[currentDecision].predicateEvals.Add(
new PredicateEvalInfo(null , currentDecision, input, startIndex, stopIndex, pred, result, alt/*, fullCtx*/) new PredicateEvalInfo(currentDecision, input, startIndex, stopIndex, pred, result, alt, fullCtx)
); );
} }
@ -193,14 +193,14 @@ namespace Antlr4.Runtime.Atn
if (prediction != conflictingAltResolvedBySLL) if (prediction != conflictingAltResolvedBySLL)
{ {
decisions[currentDecision].contextSensitivities.Add( decisions[currentDecision].contextSensitivities.Add(
new ContextSensitivityInfo(currentDecision, null /*configs*/, input, startIndex, stopIndex) new ContextSensitivityInfo(currentDecision, configs, input, startIndex, stopIndex)
); );
} }
base.ReportContextSensitivity(dfa, prediction, configs, startIndex, stopIndex); base.ReportContextSensitivity(dfa, prediction, configs, startIndex, stopIndex);
} }
protected override void ReportAmbiguity(DFA dfa, DFAState D, int startIndex, int stopIndex, bool exact, protected override void ReportAmbiguity(DFA dfa, DFAState D, int startIndex, int stopIndex, bool exact,
BitSet ambigAlts, ATNConfigSet configSet) BitSet ambigAlts, ATNConfigSet configs)
{ {
int prediction; int prediction;
if (ambigAlts != null) if (ambigAlts != null)
@ -208,22 +208,22 @@ namespace Antlr4.Runtime.Atn
prediction = ambigAlts.NextSetBit(0); prediction = ambigAlts.NextSetBit(0);
} }
else { else {
prediction = configSet.GetAlts().NextSetBit(0); prediction = configs.GetAlts().NextSetBit(0);
} }
if (configSet.fullCtx && prediction != conflictingAltResolvedBySLL) if (configs.fullCtx && prediction != conflictingAltResolvedBySLL)
{ {
// Even though this is an ambiguity we are reporting, we can // Even though this is an ambiguity we are reporting, we can
// still detect some context sensitivities. Both SLL and LL // still detect some context sensitivities. Both SLL and LL
// are showing a conflict, hence an ambiguity, but if they resolve // are showing a conflict, hence an ambiguity, but if they resolve
// to different minimum alternatives we have also identified a // to different minimum alternatives we have also identified a
// context sensitivity. // context sensitivity.
decisions[currentDecision].contextSensitivities.Add( new ContextSensitivityInfo(currentDecision, null /*configs*/, input, startIndex, stopIndex) ); decisions[currentDecision].contextSensitivities.Add( new ContextSensitivityInfo(currentDecision, configs, input, startIndex, stopIndex) );
} }
decisions[currentDecision].ambiguities.Add( decisions[currentDecision].ambiguities.Add(
new AmbiguityInfo(currentDecision, null /*configs, ambigAlts*/, new AmbiguityInfo(currentDecision, configs, ambigAlts,
input, startIndex, stopIndex/*, configs.IsFullContext*/) input, startIndex, stopIndex, configs.fullCtx)
); );
base.ReportAmbiguity(dfa, D, startIndex, stopIndex, exact, ambigAlts, configSet); base.ReportAmbiguity(dfa, D, startIndex, stopIndex, exact, ambigAlts, configs);
} }
// --------------------------------------------------------------------- // ---------------------------------------------------------------------

Some files were not shown because too many files have changed in this diff Show More