diff --git a/.circleci/scripts/install-linux-php.sh b/.circleci/scripts/install-linux-php.sh
index 863668f29d..4127d1ce61 100755
--- a/.circleci/scripts/install-linux-php.sh
+++ b/.circleci/scripts/install-linux-php.sh
@@ -2,15 +2,19 @@
set -euo pipefail
-sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
-sudo apt-get update -qq
-
+sudo apt install software-properties-common
+sudo add-apt-repository ppa:ondrej/php
sudo apt update
-sudo apt install php-all-dev
+sudo apt install wget php8.0-cli php8.0-zip unzip
+wget -O composer-setup.php https://getcomposer.org/installer
+sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
+
+sudo apt install php8.0
+sudo apt install php8.0-mbstring
+sudo apt install php8.0-xml
php -v
-sudo apt install composer
git clone https://github.com/antlr/antlr-php-runtime.git runtime/PHP
composer install -d runtime/PHP
diff --git a/.github/scripts-windows/run-tests-csharp.cmd b/.github/scripts-windows/run-tests-csharp.cmd
index 28fd0d3c99..c5e1fb0a77 100644
--- a/.github/scripts-windows/run-tests-csharp.cmd
+++ b/.github/scripts-windows/run-tests-csharp.cmd
@@ -1,6 +1,5 @@
dotnet build runtime/CSharp/src/Antlr4.csproj -c Release
dotnet pack runtime/CSharp/src/Antlr4.csproj -c Release
cd runtime-testsuite
-export MAVEN_OPTS="-Xmx8g"
mvn -Dparallel=classes -DthreadCount=2 -Dtest=csharp.** test
cd ..
diff --git a/.github/scripts-windows/run-tests-dart.cmd b/.github/scripts-windows/run-tests-dart.cmd
index 74fa92b52d..2fd5034ba7 100644
--- a/.github/scripts-windows/run-tests-dart.cmd
+++ b/.github/scripts-windows/run-tests-dart.cmd
@@ -1,6 +1,5 @@
C:\ProgramData\chocolatey\bin\choco.exe -y install dart-sdk
cd runtime-testsuite
-export MAVEN_OPTS="-Xmx8g"
mvn -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"
cd ..
diff --git a/.github/scripts-windows/run-tests-go.cmd b/.github/scripts-windows/run-tests-go.cmd
index d07d7e1ef2..1c15fd1c95 100644
--- a/.github/scripts-windows/run-tests-go.cmd
+++ b/.github/scripts-windows/run-tests-go.cmd
@@ -1,4 +1,3 @@
cd runtime-testsuite
-export MAVEN_OPTS="-Xmx8g"
mvn -Dparallel=classes -DthreadCount=2 -Dtest=go.** test
cd ..
diff --git a/.github/scripts-windows/run-tests-java.cmd b/.github/scripts-windows/run-tests-java.cmd
index 87a72b3c72..55e9ea5621 100755
--- a/.github/scripts-windows/run-tests-java.cmd
+++ b/.github/scripts-windows/run-tests-java.cmd
@@ -1,4 +1,3 @@
cd runtime-testsuite
-export MAVEN_OPTS="-Xmx8g"
mvn -Dparallel=classes -DthreadCount=2 -Dtest=java.** test
cd ..
diff --git a/.github/scripts-windows/run-tests-javascript.cmd b/.github/scripts-windows/run-tests-javascript.cmd
index 81d1eacbde..b8744e8980 100644
--- a/.github/scripts-windows/run-tests-javascript.cmd
+++ b/.github/scripts-windows/run-tests-javascript.cmd
@@ -1,4 +1,3 @@
cd runtime-testsuite
-export MAVEN_OPTS="-Xmx8g"
mvn -Dparallel=classes -DthreadCount=2 -Dtest=javascript.** test
cd ..
diff --git a/.github/scripts-windows/run-tests-php.cmd b/.github/scripts-windows/run-tests-php.cmd
index 60900c234a..155cc0472f 100644
--- a/.github/scripts-windows/run-tests-php.cmd
+++ b/.github/scripts-windows/run-tests-php.cmd
@@ -1,9 +1,8 @@
REM C:\ProgramData\chocolatey\bin\choco.exe install php -y --package-parameters='"/DontAddToPath"'
-git clone https://github.com/antlr/antlr-php-runtime/tree/dev
+git clone https://github.com/antlr/antlr-php-runtime.git
move antlr-php-runtime runtime\PHP
cd runtime-testsuite
-export MAVEN_OPTS="-Xmx8g"
mvn -Dparallel=classes -DthreadCount=2 -Dtest=php.** test -Dantlr-php-php="C:\tools\php81\php.exe"
cd ..
diff --git a/.github/scripts-windows/run-tests-python2.cmd b/.github/scripts-windows/run-tests-python2.cmd
index 6f2defe23c..351355b03a 100644
--- a/.github/scripts-windows/run-tests-python2.cmd
+++ b/.github/scripts-windows/run-tests-python2.cmd
@@ -1,4 +1,3 @@
cd runtime-testsuite
-export MAVEN_OPTS="-Xmx8g"
mvn -Dparallel=classes -DthreadCount=2 -Dantlr-python2-python="C:\Python27\python.exe" -Dtest=python2.** test
cd ..
diff --git a/.github/scripts-windows/run-tests-python3.cmd b/.github/scripts-windows/run-tests-python3.cmd
index f08639c70d..fe448be018 100644
--- a/.github/scripts-windows/run-tests-python3.cmd
+++ b/.github/scripts-windows/run-tests-python3.cmd
@@ -1,4 +1,3 @@
cd runtime-testsuite
-export MAVEN_OPTS="-Xmx8g"
mvn -Dparallel=classes -DthreadCount=2 -Dantlr-python3-python="C:\Python310\python.exe" -Dtest=python3.** test
cd ..
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index c5336e7ca7..ecc2d427ff 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -2,11 +2,22 @@
1. [Fork](https://help.github.com/articles/fork-a-repo) the [antlr/antlr4 repo](https://github.com/antlr/antlr4), which will give you both key branches, `master` and `dev`
2. Make sure to `git checkout dev` in your fork so that you are working from the latest development branch
-2. Install and configure [EditorConfig](http://editorconfig.org/) so your text editor or IDE uses the ANTLR 4 coding style
-3. [Build ANTLR 4](doc/building-antlr.md)
-4. [Run the ANTLR project unit tests](doc/antlr-project-testing.md)
-5. Create a [pull request](https://help.github.com/articles/using-pull-requests/) with your changes and make sure you're comparing the `dev` branch in your fork to the `dev` branch from the `antlr/antlr4` repo:
+3. Create and work from a branch from `dev` such as `git checkout -b
+ your-branch-name`
+4. Install and configure [EditorConfig](http://editorconfig.org/) so your text editor or IDE uses the ANTLR 4 coding style
+5. [Build ANTLR 4](doc/building-antlr.md)
+6. [Run the ANTLR project unit tests](doc/antlr-project-testing.md)
+7. Create a [pull request](https://help.github.com/articles/using-pull-requests/) with your changes and make sure you're comparing the `dev` branch in your fork to the `dev` branch from the `antlr/antlr4` repo:
-**Note:** You must sign the `contributors.txt` certificate of origin with your pull request if you've not done so before.
+**Note:** Each commit requires a "signature", which is simple as using `-s` (not
+`-S`) to the git commit command:
+
+```
+git commit -s -m 'This is my commit message'
+```
+
+Github's pull request process enforces the sig and gives instructions on how to
+fix any commits that lack the sig. See [Github DCO app](https://github.com/apps/dco)
+for more info.
diff --git a/doc/dart-target.md b/doc/dart-target.md
index 58ff668ccc..399379f9f1 100644
--- a/doc/dart-target.md
+++ b/doc/dart-target.md
@@ -1,6 +1,6 @@
# ANTLR4 Runtime for Dart
-From version 4.9.3 onwards antlr's dart generated code is null sound safety compatible and sets the minimum dart sdk version to 2.12.0.
+From version 4.10 onwards antlr's dart generated code is null sound safety compatible and sets the minimum dart sdk version to 2.12.0.
### First steps
diff --git a/doc/getting-started.md b/doc/getting-started.md
index 48726ebc76..02f5b39d05 100644
--- a/doc/getting-started.md
+++ b/doc/getting-started.md
@@ -6,7 +6,7 @@ Hi and welcome to the version 4 release of ANTLR! It's named after the fearless
ANTLR is really two things: a tool that translates your grammar to a parser/lexer in Java (or other target language) and the runtime needed by the generated parsers/lexers. Even if you are using the ANTLR Intellij plug-in or ANTLRWorks to run the ANTLR tool, the generated code will still need the runtime library.
-The first thing you should do is probably download and install a development tool plug-in. Even if you only use such tools for editing, they are great. Then, follow the instructions below to get the runtime environment available to your system to run generated parsers/lexers. In what follows, I talk about antlr-4.9.3-complete.jar, which has the tool and the runtime and any other support libraries (e.g., ANTLR v4 is written in v3).
+The first thing you should do is probably download and install a development tool plug-in. Even if you only use such tools for editing, they are great. Then, follow the instructions below to get the runtime environment available to your system to run generated parsers/lexers. In what follows, I talk about antlr-4.10-complete.jar, which has the tool and the runtime and any other support libraries (e.g., ANTLR v4 is written in v3).
If you are going to integrate ANTLR into your existing build system using mvn, ant, or want to get ANTLR into your IDE such as eclipse or intellij, see [Integrating ANTLR into Development Systems](https://github.com/antlr/antlr4/blob/master/doc/IDEs.md).
@@ -16,22 +16,22 @@ If you are going to integrate ANTLR into your existing build system using mvn, a
1. Download
```
$ cd /usr/local/lib
-$ curl -O https://www.antlr.org/download/antlr-4.9.3-complete.jar
+$ curl -O https://www.antlr.org/download/antlr-4.10-complete.jar
```
Or just download in browser from website:
[https://www.antlr.org/download.html](https://www.antlr.org/download.html)
and put it somewhere rational like `/usr/local/lib`.
-2. Add `antlr-4.9.3-complete.jar` to your `CLASSPATH`:
+2. Add `antlr-4.10-complete.jar` to your `CLASSPATH`:
```
-$ export CLASSPATH=".:/usr/local/lib/antlr-4.9.3-complete.jar:$CLASSPATH"
+$ export CLASSPATH=".:/usr/local/lib/antlr-4.10-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.9.3-complete.jar:$CLASSPATH" org.antlr.v4.Tool'
-$ alias grun='java -Xmx500M -cp "/usr/local/lib/antlr-4.9.3-complete.jar:$CLASSPATH" org.antlr.v4.gui.TestRig'
+$ alias antlr4='java -Xmx500M -cp "/usr/local/lib/antlr-4.10-complete.jar:$CLASSPATH" org.antlr.v4.Tool'
+$ alias grun='java -Xmx500M -cp "/usr/local/lib/antlr-4.10-complete.jar:$CLASSPATH" org.antlr.v4.gui.TestRig'
```
### WINDOWS
@@ -39,13 +39,13 @@ $ alias grun='java -Xmx500M -cp "/usr/local/lib/antlr-4.9.3-complete.jar:$CLASSP
(*Thanks to Graham Wideman*)
0. Install Java (version 1.7 or higher)
-1. Download antlr-4.9.3-complete.jar (or whatever version) from [https://www.antlr.org/download/](https://www.antlr.org/download/)
+1. Download antlr-4.10-complete.jar (or whatever version) from [https://www.antlr.org/download/](https://www.antlr.org/download/)
Save to your directory for 3rd party Java libraries, say `C:\Javalib`
-2. Add `antlr-4.9.3-complete.jar` to CLASSPATH, either:
+2. Add `antlr-4.10-complete.jar` to CLASSPATH, either:
* Permanently: Using System Properties dialog > Environment variables > Create or append to `CLASSPATH` variable
* Temporarily, at command line:
```
-SET CLASSPATH=.;C:\Javalib\antlr-4.9.3-complete.jar;%CLASSPATH%
+SET CLASSPATH=.;C:\Javalib\antlr-4.10-complete.jar;%CLASSPATH%
```
3. Create short convenient commands for the ANTLR Tool, and TestRig, using batch files or doskey commands:
* Batch files (in directory in system PATH) antlr4.bat and grun.bat
@@ -71,7 +71,7 @@ Either launch org.antlr.v4.Tool directly:
```
$ java org.antlr.v4.Tool
-ANTLR Parser Generator Version 4.9.3
+ANTLR Parser Generator Version 4.10
-o ___ specify output directory where all output is generated
-lib ___ specify location of .tokens files
...
@@ -80,8 +80,8 @@ ANTLR Parser Generator Version 4.9.3
or use -jar option on java:
```
-$ java -jar /usr/local/lib/antlr-4.9.3-complete.jar
-ANTLR Parser Generator Version 4.9.3
+$ java -jar /usr/local/lib/antlr-4.10-complete.jar
+ANTLR Parser Generator Version 4.10
-o ___ specify output directory where all output is generated
-lib ___ specify location of .tokens files
...
diff --git a/doc/go-target.md b/doc/go-target.md
index 695f1564fc..6bdac133b3 100644
--- a/doc/go-target.md
+++ b/doc/go-target.md
@@ -20,11 +20,11 @@ go get github.com/antlr/antlr4/runtime/Go/antlr
`go get` has no native way to specify a branch or commit. So, when you run it, you'll download the latest commits. This may or may not be your preference.
-You'll need to use git to set the release. For example, to set the release tag for release 4.6.0:
+You'll need to use git to set the release. For example, to set the release tag for release 4.9.3:
```bash
cd $GOPATH/src/github.com/antlr/antlr4 # enter the antlr4 source directory
-git checkout tags/4.6.0 # the go runtime was added in release 4.6.0
+git checkout tags/4.9.3 # the go runtime was added in release 4.9.3
```
A complete list of releases can be found on [the release page](https://github.com/antlr/antlr4/releases).
diff --git a/doc/java-target.md b/doc/java-target.md
index 2e6c791cfd..1760dccbcb 100644
--- a/doc/java-target.md
+++ b/doc/java-target.md
@@ -134,7 +134,7 @@ Edit the pom.xml file. Now we need to extensively modify the pom.xml file. The f
org.antlr
antlr4-runtime
- 4.5
+ 4.9.3
junit
@@ -164,7 +164,7 @@ Edit the pom.xml file. Now we need to extensively modify the pom.xml file. The f
org.antlr
antlr4-maven-plugin
- 4.5
+ 4.9.3
diff --git a/doc/releasing-antlr.md b/doc/releasing-antlr.md
index cfabd93eea..ccf3ff61d3 100644
--- a/doc/releasing-antlr.md
+++ b/doc/releasing-antlr.md
@@ -2,7 +2,7 @@
## Github
-Create a pre-release or full release at github; [Example 4.5-rc-1](https://github.com/antlr/antlr4/releases/tag/4.5-rc-1).
+Create a pre-release or full release at github; e.g., [tag 4.9](https://github.com/antlr/antlr4/tree/4.9).
### Turn on DCO Enforcement
@@ -10,35 +10,60 @@ As of 4.10, we will be using the Linux DCO not the previous contributors license
See [GitHub App DCO](https://github.com/apps/dco).
-Make sure this has turned on for the `dev` and `master` branch.
+Make sure this feature is turned on for the `dev` and `master` branch upon release.
### Delete existing release tag
Wack any existing tag as mvn will create one and it fails if already there.
```
-$ git tag -d 4.9
-$ git push origin :refs/tags/4.9
-$ git push upstream :refs/tags/4.9
+$ git tag -d 4.10
+$ git push origin :refs/tags/4.10
+$ git push upstream :refs/tags/4.10
```
### Create release candidate tag
```bash
-$ git tag -a 4.9-rc1 -m 'heading towards 4.9'
-$ git push origin 4.9-rc1
-$ git push upstream 4.9-rc1
+$ git tag -a 4.10-rc.1 -m 'heading towards 4.10'
+$ git push origin 4.10-rc.1
+$ git push upstream 4.10-rc1
```
### Go release tags
-It seems that [Go needs a `v` in the release git tag](https://go.dev/ref/mod#glos-version) so make sure that we double up with 4.9.3 and v4.9.3.
+It seems that [Go needs a `v` in the release git tag](https://go.dev/ref/mod#glos-version) so make sure that we double up with 4.10 and v4.10.
-## Copy PHP runtime over
-(Is this only necessary to run the unittests?)
+## Bump version in code and other files
-Bump version to 4.9 in `~/antlr/code/antlr-php-runtime/src/RuntimeMetaData.php` in separate repository and commit plus push.
+There are a number of files that require inversion number be updated.
+
+
+Here is a simple script to display any line from the critical files with, say, `4.10` in it. Here's an example run of the script:
+
+```bash
+~/antlr/code/antlr4 $ python scripts/update_antlr_version.py 4.9.3 4.10
+Updating ANTLR version from 4.9.3 to 4.10
+Set ANTLR repo root (default ~/antlr/code/antlr4):
+Perform antlr4 `mvn clean` and wipe build dirs Y/N? (default no):
+Ok, not cleaning antlr4 dir
+4.9.3 appears on 2 lines so _not_ updating /tmp/antlr4/runtime/JavaScript/package-lock.json
+4.9.3 not in /tmp/antlr4/doc/releasing-antlr.md
+```
+
+It's also worth doing a quick check to see if you find any other references to a version:
+
+```bash
+mvn clean
+find . -type f -exec grep -l '4\.9' {} \; | grep -v -E '\.o|\.a|\.jar|\.dylib|node_modules/|\.class|tests/|CHANGELOG|\.zip|\.gz|.iml|.svg'
+```
+
+Commit to repository.
+
+### PHP runtime
+
+We only have to copy the PHP runtime into the ANTLR repository to run the unittests. But, we still need to bump the version to 4.10 in `~/antlr/code/antlr-php-runtime/src/RuntimeMetaData.php` in the separate repository, commit, and push.
```
cd ~/antlr/code/antlr-php-runtime/src
@@ -46,6 +71,7 @@ cd ~/antlr/code/antlr-php-runtime/src
git commit -a -m "Update PHP Runtime to latest version"
```
+
-## Bump version
-
-Edit the repository looking for 4.5 or whatever and update it. Bump version in the following files:
-
- * runtime/Java/src/org/antlr/v4/runtime/RuntimeMetaData.java
- * runtime/Python2/setup.py
- * runtime/Python2/src/antlr4/Recognizer.py
- * runtime/Python3/setup.py
- * runtime/Python3/src/antlr4/Recognizer.py
- * runtime/CSharp/src/Antlr4.csproj
- * runtime/PHP/src/RuntimeMetaData.php
- * runtime/JavaScript/package.json
- * runtime/JavaScript/src/antlr4/Recognizer.js
- * runtime/JavaScript/package-lock.json
- * runtime/Cpp/VERSION
- * runtime/Cpp/runtime/src/RuntimeMetaData.cpp
- * runtime/Cpp/cmake/ExternalAntlr4Cpp.cmake
- * runtime/Cpp/demo/generate.cmd
- * runtime/Go/antlr/recognizer.go
- * runtime/Swift/Antlr4/org/antlr/v4/runtime/RuntimeMetaData.swift
- * runtime/Dart/lib/src/runtime_meta_data.dart
- * 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/CppTarget.java
- * tool/src/org/antlr/v4/codegen/target/CSharpTarget.java
- * tool/src/org/antlr/v4/codegen/target/JavaScriptTarget.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/SwiftTarget.java
- * tool/src/org/antlr/v4/codegen/target/PHPTarget.java
- * tool/src/org/antlr/v4/codegen/Target.java
- * tool/resources/org/antlr/v4/tool/templates/codegen/Swift/Swift.stg
-
-Here is a simple script to display any line from the critical files with, say, `4.9` in it:
+## Build XPath parsers
-```bash
-mvn clean
-rm -rf runtime/CSharp/src/bin
-rm -rf runtime/CSharp/src/obj
-rm -rf runtime/Cpp/runtime/build
-rm -rf runtime/gen
-rm -rf runtime/JavaScript/dist
-find tool runtime -type f -exec grep -l '4\.9' {} \; | grep -v -E '\.o|\.a|\.jar|\.dylib|node_modules/|\.class|tests/|CHANGELOG|\.zip|\.gz|.iml'
-```
+This section addresses a [circular dependency regarding XPath](https://github.com/antlr/antlr4/issues/3600). In the java target I avoided a circular dependency (gen 4.10 parser for XPath using 4.10 which needs it to build) by hand building the parser: runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPath.java. Probably we won't have to rerun this for the patch releases, just major ones that alter the ATN serialization.
-Commit to repository.
+```
+cd ~/antlr/code/antlr4/runtime/CSharp/src/Tree/Xpath
+java -cp ":/Users/parrt/.m2/repository/org/antlr/antlr4/4.10-SNAPSHOT/antlr4-4.10-SNAPSHOT-complete.jar:$CLASSPATH" org.antlr.v4.Tool -Dlanguage=CSharp XPathLexer.g4
-## Building
+cd ~/antlr/code/antlr4/runtime/Python3/tests/expr
+java -cp ":/Users/parrt/.m2/repository/org/antlr/antlr4/4.10-SNAPSHOT/antlr4-4.10-SNAPSHOT-complete.jar:$CLASSPATH" org.antlr.v4.Tool -Dlanguage=Python2 Expr.g4
+java -cp ":/Users/parrt/.m2/repository/org/antlr/antlr4/4.10-SNAPSHOT/antlr4-4.10-SNAPSHOT-complete.jar:$CLASSPATH" org.antlr.v4.Tool -Dlanguage=Python2 XPathLexer.g4
-ugh. apparently you have to `mvn install` and then `mvn compile` or some such or subdir pom.xml's won't see the latest runtime build.
+cd ~/antlr/code/antlr4/runtime/Python3/tests/expr
+java -cp ":/Users/parrt/.m2/repository/org/antlr/antlr4/4.10-SNAPSHOT/antlr4-4.10-SNAPSHOT-complete.jar:$CLASSPATH" org.antlr.v4.Tool -Dlanguage=Python3 Expr.g4
+java -cp ":/Users/parrt/.m2/repository/org/antlr/antlr4/4.10-SNAPSHOT/antlr4-4.10-SNAPSHOT-complete.jar:$CLASSPATH" org.antlr.v4.Tool -Dlanguage=Python3 XPathLexer.g4
+```
## Maven Repository Settings
+ugh. apparently you have to `mvn install` and then `mvn compile` or some such or subdir pom.xml's won't see the latest runtime build.
+
First, make sure you have maven set up to communicate with staging servers etc... Create file `~/.m2/settings.xml` with appropriate username/password for staging server and gpg.keyname/passphrase for signing. Make sure it has strict visibility privileges to just you. On unix, it looks like:
```bash
@@ -163,7 +153,7 @@ Here is the file template
## Maven deploy snapshot
-The goal is to get a snapshot, such as `4.9-SNAPSHOT`, to the staging server: [antlr4 tool](https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4) and [antlr4 java runtime](https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-runtime).
+The goal is to get a snapshot, such as `4.10-SNAPSHOT`, to the staging server: [antlr4 tool](https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4/4.10-SNAPSHOT/) and [antlr4 java runtime](https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-runtime/4.10-SNAPSHOT/).
Do this:
@@ -172,15 +162,15 @@ $ mvn install -DskipTests # seems required to get the jar files visible to mave
$ mvn deploy -DskipTests
...
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ antlr4-tool-testsuite ---
-Downloading: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.9-SNAPSHOT/maven-metadata.xml
-Uploading: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.9-SNAPSHOT/antlr4-tool-testsuite-4.9-20161211.173752-1.jar
-Uploaded: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.9-SNAPSHOT/antlr4-tool-testsuite-4.9-20161211.173752-1.jar (3 KB at 3.4 KB/sec)
-Uploading: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.9-SNAPSHOT/antlr4-tool-testsuite-4.9-20161211.173752-1.pom
-Uploaded: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.9-SNAPSHOT/antlr4-tool-testsuite-4.9-20161211.173752-1.pom (3 KB at 6.5 KB/sec)
+Downloading: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.10-SNAPSHOT/maven-metadata.xml
+Uploading: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.10-SNAPSHOT/antlr4-tool-testsuite-4.10-20161211.173752-1.jar
+Uploaded: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.10-SNAPSHOT/antlr4-tool-testsuite-4.10-20161211.173752-1.jar (3 KB at 3.4 KB/sec)
+Uploading: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.10-SNAPSHOT/antlr4-tool-testsuite-4.10-20161211.173752-1.pom
+Uploaded: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.10-SNAPSHOT/antlr4-tool-testsuite-4.10-20161211.173752-1.pom (3 KB at 6.5 KB/sec)
Downloading: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/maven-metadata.xml
Downloaded: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/maven-metadata.xml (371 B at 1.4 KB/sec)
-Uploading: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.9-SNAPSHOT/maven-metadata.xml
-Uploaded: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.9-SNAPSHOT/maven-metadata.xml (774 B at 1.8 KB/sec)
+Uploading: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.10-SNAPSHOT/maven-metadata.xml
+Uploaded: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.10-SNAPSHOT/maven-metadata.xml (774 B at 1.8 KB/sec)
Uploading: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/maven-metadata.xml
Uploaded: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/maven-metadata.xml (388 B at 0.9 KB/sec)
[INFO] ------------------------------------------------------------------------
@@ -208,60 +198,47 @@ Uploaded: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antl
The maven deploy lifecycle phased deploys the artifacts and the poms for the ANTLR project to the [sonatype remote staging server](https://oss.sonatype.org/content/repositories/snapshots/).
```bash
-export JAVA_HOME=`/usr/libexec/java_home -v 1.7`; mvn deploy -DskipTests
+mvn deploy -DskipTests
```
-With JDK 1.7 (not 6 or 8), do this:
+Make sure `gpg` is installed (`brew install gpg` on mac). Also must [create a key and publish it](https://blog.sonatype.com/2010/01/how-to-generate-pgp-signatures-with-maven/) then update `.m2/settings` to use that public key.
-```bash
-export JAVA_HOME=`/usr/libexec/java_home -v 1.7`; mvn release:prepare -Darguments="-DskipTests"
-```
-
-Hm...per https://github.com/keybase/keybase-issues/issues/1712 we need this to make gpg work:
+Then:
```bash
-export GPG_TTY=$(tty)
+mvn release:prepare -Darguments="-DskipTests"
```
-Side note to set jdk 1.7 on os x:
+Hmm...per https://github.com/keybase/keybase-issues/issues/1712 we need this to make gpg work:
```bash
-alias java="`/usr/libexec/java_home -v 1.7`/bin/java"
-alias javac="`/usr/libexec/java_home -v 1.7`/bin/javac"
-alias javadoc="`/usr/libexec/java_home -v 1.7`/bin/javadoc"
-alias jar="`/usr/libexec/java_home -v 1.7`/bin/jar"
-export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
-```
-
-But I think just this on front of mvn works:
-
-```
-export JAVA_HOME=`/usr/libexec/java_home -v 1.7`; mvn ...
+export GPG_TTY=$(tty)
```
-You should see 0x33 in generated .class files after 0xCAFEBABE; see [Java SE 7 = 51 (0x33 hex)](https://en.wikipedia.org/wiki/Java_class_file):
+You should see 0x37 in generated .class files after 0xCAFEBABE; see [Java SE 11 = 55 (0x37 hex)](https://en.wikipedia.org/wiki/Java_class_file):
```bash
-beast:/tmp/org/antlr/v4 $ od -h Tool.class |head -1
-0000000 feca beba 0000 3300 fa04 0207 0ab8 0100
+~/antlr/code/antlr4 $ od -h tool/target/classes/org/antlr/v4/Tool.class |head -1
+0000000 feca beba 0000 3700 ed04 0207 0a9d 0100
+ ^^
```
It will start out by asking you the version number:
```
...
-What is the release version for "ANTLR 4"? (org.antlr:antlr4-master) 4.9: : 4.9
-What is the release version for "ANTLR 4 Runtime"? (org.antlr:antlr4-runtime) 4.9: :
-What is the release version for "ANTLR 4 Tool"? (org.antlr:antlr4) 4.9: :
-What is the release version for "ANTLR 4 Maven plugin"? (org.antlr:antlr4-maven-plugin) 4.9: :
-What is the release version for "ANTLR 4 Runtime Test Generator"? (org.antlr:antlr4-runtime-testsuite) 4.9: :
-What is the release version for "ANTLR 4 Tool Tests"? (org.antlr:antlr4-tool-testsuite) 4.9: :
-What is SCM release tag or label for "ANTLR 4"? (org.antlr:antlr4-master) antlr4-master-4.9: : 4.9
-What is the new development version for "ANTLR 4"? (org.antlr:antlr4-master) 4.9.1-SNAPSHOT:
+What is the release version for "ANTLR 4"? (org.antlr:antlr4-master) 4.10: : 4.10
+What is the release version for "ANTLR 4 Runtime"? (org.antlr:antlr4-runtime) 4.10: :
+What is the release version for "ANTLR 4 Tool"? (org.antlr:antlr4) 4.10: :
+What is the release version for "ANTLR 4 Maven plugin"? (org.antlr:antlr4-maven-plugin) 4.10: :
+What is the release version for "ANTLR 4 Runtime Test Generator"? (org.antlr:antlr4-runtime-testsuite) 4.10: :
+What is the release version for "ANTLR 4 Tool Tests"? (org.antlr:antlr4-tool-testsuite) 4.10: :
+What is SCM release tag or label for "ANTLR 4"? (org.antlr:antlr4-master) antlr4-master-4.10: : 4.10
+What is the new development version for "ANTLR 4"? (org.antlr:antlr4-master) 4.10.1-SNAPSHOT:
...
```
-Maven will go through your pom.xml files to update versions from 4.9-SNAPSHOT to 4.9 for release and then to 4.9.1-SNAPSHOT after release, which is done with:
+Maven will go through your pom.xml files to update versions from 4.10-SNAPSHOT to 4.10 for release and then to 4.10.1-SNAPSHOT after release, which is done with:
```bash
mvn release:perform -Darguments="-DskipTests"
@@ -275,18 +252,18 @@ Now, go here:
and on the left click "Staging Repositories". You click the staging repo and close it, then you refresh, click it and release it. It's done when you see it here:
- [https://oss.sonatype.org/service/local/repositories/releases/content/org/antlr/antlr4-runtime/4.9-1/antlr4-runtime-4.9-1.jar](https://oss.sonatype.org/service/local/repositories/releases/content/org/antlr/antlr4-runtime/4.9-1/antlr4-runtime-4.9-1.jar)
+ [https://oss.sonatype.org/service/local/repositories/releases/content/org/antlr/antlr4-runtime/4.10/antlr4-runtime-4.10.jar](https://oss.sonatype.org/service/local/repositories/releases/content/org/antlr/antlr4-runtime/4.10/antlr4-runtime-4.10.jar)
-All releases should be here: https://repo1.maven.org/maven2/org/antlr/antlr4-runtime/
+All releases should be here: [https://repo1.maven.org/maven2/org/antlr/antlr4-runtime](https://repo1.maven.org/maven2/org/antlr/antlr4-runtime).
Copy the jars to antlr.org site and update download/index.html
```bash
-cp ~/.m2/repository/org/antlr/antlr4-runtime/4.9/antlr4-runtime-4.9.jar ~/antlr/sites/website-antlr4/download/antlr-runtime-4.9.jar
-cp ~/.m2/repository/org/antlr/antlr4/4.9/antlr4-4.9-complete.jar ~/antlr/sites/website-antlr4/download/antlr-4.9-complete.jar
+cp ~/.m2/repository/org/antlr/antlr4-runtime/4.10/antlr4-runtime-4.10.jar ~/antlr/sites/website-antlr4/download/antlr-runtime-4.10.jar
+cp ~/.m2/repository/org/antlr/antlr4/4.10/antlr4-4.10-complete.jar ~/antlr/sites/website-antlr4/download/antlr-4.10-complete.jar
cd ~/antlr/sites/website-antlr4/download
-git add antlr-4.9-complete.jar
-git add antlr-runtime-4.9.jar
+git add antlr-4.10-complete.jar
+git add antlr-runtime-4.10.jar
```
Update on site:
@@ -298,7 +275,7 @@ Update on site:
* scripts/topnav.js
```
-git commit -a -m 'add 4.9 jars'
+git commit -a -m 'add 4.10 jars'
git push origin gh-pages
```
@@ -306,11 +283,6 @@ git push origin gh-pages
### JavaScript
-```bash
-cd runtime/JavaScript
-# git add, commit, push
-```
-
**Push to npm**
```bash
@@ -318,7 +290,7 @@ cd runtime/JavaScript
npm update
npm install
npm run build
-npm login
+npm login # asks for username/password/2FA (npmjs.com)
npm publish # don't put antlr4 on there or it will try to push the old version for some reason
```
@@ -326,55 +298,65 @@ Move (and zip) target to website:
```bash
cd src
-zip -r ~/antlr/sites/website-antlr4/download/antlr-javascript-runtime-4.9.zip .
+zip -r ~/antlr/sites/website-antlr4/download/antlr-javascript-runtime-4.10.zip .
```
### CSharp
-Now we have [appveyor create artifact](https://ci.appveyor.com/project/parrt/antlr4/build/artifacts). Go to [nuget](https://www.nuget.org/packages/manage/upload) to upload the `.nupkg`.
-
-### Publishing to Nuget from Windows
-
**Install the pre-requisites**
-Of course you need Mono and `nuget` to be installed. On mac:
+You need Mono and `nuget` to be installed. On mac:
- .NET build tools - can be loaded from [here](https://www.visualstudio.com/downloads/) (I need dotnet 5 and 3.1 versions)
- nuget - download [nuget.exe](https://www.nuget.org/downloads)
- dotnet - follow [the instructions here](https://www.microsoft.com/net/core)
-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/src/Antlr4.csproj -c Release`
- 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/src/Antlr4.csproj -c Release`
- 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.
You also need to enable .NET Framework 3.5 support in Windows "Programs and Features".
-If everything is ok, the following command will restore nuget packages, build Antlr for .NET Standard and .NET 3.5 and create nuget package:
+**Creating the signed assembly**
-```PS
-msbuild /target:restore /target:rebuild /target:pack /property:Configuration=Release .\Antlr4.dotnet.sln /verbosity:minimal
-```
+From Mac:
+
+```bash
+critter:~ $ cd ~/antlr/code/antlr4/runtime/CSharp/src
+critter:~/antlr/code/antlr4/runtime/CSharp/src $ dotnet build -c Release Antlr4.csproj
+Microsoft (R) Build Engine version 16.7.2+b60ddb6f4 for .NET
+Copyright (C) Microsoft Corporation. All rights reserved.
-This should display something like this:
+ Determining projects to restore...
+ Restored /Users/parrt/antlr/code/antlr4/runtime/CSharp/src/Antlr4.csproj (in 340 ms).
+ Antlr4 -> /Users/parrt/antlr/code/antlr4/runtime/CSharp/src/bin/Release/netstandard2.0/Antlr4.Runtime.Standard.dll
+ Successfully created package '/Users/parrt/antlr/code/antlr4/runtime/CSharp/src/bin/Release/Antlr4.Runtime.Standard.4.10.0.nupkg'.
-**Creating and packaging the assembly**
+Build succeeded.
+ 0 Warning(s)
+ 0 Error(s)
-```
-Microsoft (R) Build Engine version 15.4.8.50001 for .NET Framework
-Copyright (C) Microsoft Corporation. All rights reserved.
+Time Elapsed 00:00:06.77
+critter:~/antlr/code/antlr4/runtime/CSharp/src $ /Library/Frameworks/Mono.framework/Versions/Current/Commands/sn -R bin/Release/netstandard2.0/Antlr4.Runtime.Standard.dll Antlr4.snk
+Mono StrongName - version 6.12.0.0
+StrongName utility for signing assemblies
+Copyright 2002, 2003 Motus Technologies. Copyright 2004-2008 Novell. BSD licensed.
- Restoring packages for C:\Code\antlr4-fork\runtime\CSharp\runtime\CSharp\Antlr4.Runtime\Antlr4.Runtime.dotnet.csproj...
- Generating MSBuild file C:\Code\antlr4-fork\runtime\CSharp\runtime\CSharp\Antlr4.Runtime\obj\Antlr4.Runtime.dotnet.csproj.nuget.g.props.
- Generating MSBuild file C:\Code\antlr4-fork\runtime\CSharp\runtime\CSharp\Antlr4.Runtime\obj\Antlr4.Runtime.dotnet.csproj.nuget.g.targets.
- Restore completed in 427.62 ms for C:\Code\antlr4-fork\runtime\CSharp\runtime\CSharp\Antlr4.Runtime\Antlr4.Runtime.dotnet.csproj.
- Antlr4.Runtime.dotnet -> C:\Code\antlr4-fork\runtime\CSharp\runtime\CSharp\Antlr4.Runtime\lib\Release\netstandard1.3\Antlr4.Runtime.Standard.dll
- Antlr4.Runtime.dotnet -> C:\Code\antlr4-fork\runtime\CSharp\runtime\CSharp\Antlr4.Runtime\lib\Release\net35\Antlr4.Runtime.Standard.dll
- Successfully created package 'C:\Code\antlr4-fork\runtime\CSharp\runtime\CSharp\Antlr4.Runtime\lib\Release\Antlr4.Runtime.Standard.4.9.3.nupkg'.
+Assembly bin/Release/netstandard2.0/Antlr4.Runtime.Standard.dll signed.
+critter:~/antlr/code/antlr4/runtime/CSharp/src $ /Library/Frameworks/Mono.framework/Versions/Current/Commands/sn -v bin/Release/netstandard2.0/Antlr4.Runtime.Standard.dll
+Mono StrongName - version 6.12.0.0
+StrongName utility for signing assemblies
+Copyright 2002, 2003 Motus Technologies. Copyright 2004-2008 Novell. BSD licensed.
+
+Assembly bin/Release/netstandard2.0/Antlr4.Runtime.Standard.dll is strongnamed.
+$ tree /Users/parrt/antlr/code/antlr4/runtime/CSharp/src/bin/Release/
+/Users/parrt/antlr/code/antlr4/runtime/CSharp/src/bin/Release/
+├── Antlr4.Runtime.Standard.4.10.0.nupkg
+└── netstandard2.0
+ ├── Antlr4.Runtime.Standard.deps.json
+ ├── Antlr4.Runtime.Standard.dll
+ ├── Antlr4.Runtime.Standard.pdb
+ └── Antlr4.Runtime.Standard.xml
+
+1 directory, 5 files
```
**Publishing to NuGet**
@@ -390,6 +372,7 @@ nuget push Antlr4.Runtime.Standard..nupkg -Source https://ww
Nuget packages are also accessible as artifacts of [AppVeyor builds](https://ci.appveyor.com/project/parrt/antlr4/build/artifacts).
+
### Python
The Python targets get deployed with `setup.py`. First, set up `~/.pypirc` with tight privileges:
@@ -450,7 +433,7 @@ On a Mac (with XCode 7+ installed):
```bash
cd runtime/Cpp
./deploy-macos.sh
-cp antlr4-cpp-runtime-macos.zip ~/antlr/sites/website-antlr4/download/antlr4-cpp-runtime-4.9-macos.zip
+cp antlr4-cpp-runtime-macos.zip ~/antlr/sites/website-antlr4/download/antlr4-cpp-runtime-4.10-macos.zip
```
On any Mac or Linux machine:
@@ -458,7 +441,7 @@ On any Mac or Linux machine:
```bash
cd runtime/Cpp
./deploy-source.sh
-cp antlr4-cpp-runtime-source.zip ~/antlr/sites/website-antlr4/download/antlr4-cpp-runtime-4.9-source.zip
+cp antlr4-cpp-runtime-source.zip ~/antlr/sites/website-antlr4/download/antlr4-cpp-runtime-4.10-source.zip
```
On a Windows machine the build scripts checks if VS 2017 and/or VS 2019 are installed and builds binaries for each, if found. This script requires 7z to be installed (http://7-zip.org then do `set PATH=%PATH%;C:\Program Files\7-Zip\` from DOS not powershell).
@@ -466,7 +449,7 @@ On a Windows machine the build scripts checks if VS 2017 and/or VS 2019 are inst
```bash
cd runtime/Cpp
deploy-windows.cmd Community
-cp antlr4-cpp-runtime-vs2019.zip ~/antlr/sites/website-antlr4/download/antlr4-cpp-runtime-4.9-vs2019.zip
+cp antlr4-cpp-runtime-vs2019.zip ~/antlr/sites/website-antlr4/download/antlr4-cpp-runtime-4.10-vs2019.zip
```
Move target to website (**_rename to a specific ANTLR version first if needed_**):
@@ -474,9 +457,9 @@ Move target to website (**_rename to a specific ANTLR version first if needed_**
```bash
pushd ~/antlr/sites/website-antlr4/download
# vi index.html
-git add antlr4-cpp-runtime-4.9-macos.zip
-git add antlr4-cpp-runtime-4.9-windows.zip
-git add antlr4-cpp-runtime-4.9-source.zip
+git add antlr4-cpp-runtime-4.10-macos.zip
+git add antlr4-cpp-runtime-4.10-windows.zip
+git add antlr4-cpp-runtime-4.10-source.zip
git commit -a -m 'update C++ runtime'
git push origin gh-pages
popd
@@ -502,7 +485,7 @@ Otherwise enter `N` to ignore the warning.
Above build should make latest in
```
-~/.m2/repository/org/antlr/antlr4-runtime/4.9/antlr4-runtime-4.9
+~/.m2/repository/org/antlr/antlr4-runtime/4.10/antlr4-runtime-4.10
```
but you can regen (watch pom version!):
@@ -519,9 +502,9 @@ cd ~/antlr/sites/website-antlr4/api
git checkout gh-pages
git pull origin gh-pages
cd Java
-jar xvf ~/.m2/repository/org/antlr/antlr4-runtime/4.9/antlr4-runtime-4.9-javadoc.jar
+jar xvf ~/.m2/repository/org/antlr/antlr4-runtime/4.10/antlr4-runtime-4.10-javadoc.jar
cd ../JavaTool
-jar xvf ~/.m2/repository/org/antlr/antlr4/4.9/antlr4-4.9-javadoc.jar
+jar xvf ~/.m2/repository/org/antlr/antlr4/4.10/antlr4-4.10-javadoc.jar
git commit -a -m 'freshen api doc'
git push origin gh-pages
```
diff --git a/doc/swift-target.md b/doc/swift-target.md
index 6355924490..21313deef9 100644
--- a/doc/swift-target.md
+++ b/doc/swift-target.md
@@ -131,7 +131,7 @@ Add Antlr4 as a dependency to your `Package.swift` file. For more information, p
```swift
-.package(name: "Antlr4", url: "https://github.com/antlr/antlr4", from: "4.9.3"
+.package(name: "Antlr4", url: "https://github.com/antlr/antlr4", from: "4.10"
```
## Swift access levels
diff --git a/runtime/CSharp/src/Antlr4.csproj b/runtime/CSharp/src/Antlr4.csproj
index 6ad2e31425..aac3a5804f 100644
--- a/runtime/CSharp/src/Antlr4.csproj
+++ b/runtime/CSharp/src/Antlr4.csproj
@@ -1,7 +1,7 @@
The ANTLR Organization
- 4.9.3
+ 4.10
en-US
netstandard2.0
net45;netstandard2.0
diff --git a/runtime/CSharp/src/Properties/AssemblyInfo.cs b/runtime/CSharp/src/Properties/AssemblyInfo.cs
index 352e2ce17a..6666031698 100644
--- a/runtime/CSharp/src/Properties/AssemblyInfo.cs
+++ b/runtime/CSharp/src/Properties/AssemblyInfo.cs
@@ -6,4 +6,4 @@
using System.Reflection;
[assembly: CLSCompliant(true)]
-[assembly: AssemblyVersion("4.9.3")]
+[assembly: AssemblyVersion("4.10")]
diff --git a/runtime/CSharp/src/README.md b/runtime/CSharp/src/README.md
index 47aff0cd97..771253596f 100644
--- a/runtime/CSharp/src/README.md
+++ b/runtime/CSharp/src/README.md
@@ -41,7 +41,7 @@ See the docs and the book to learn about writing lexer and parser grammars.
### Step 4: Generate the C# code
This can be done either from the cmd line, or by adding a custom pre-build command in your project.
-At minimal, the cmd line should look as follows: ``java -jar antlr4-4.9.3.jar -Dlanguage=CSharp grammar.g4``
+At minimal, the cmd line should look as follows: ``java -jar antlr4-4.10.jar -Dlanguage=CSharp grammar.g4``
This will generate the files, which you can then integrate in your project.
This is just a quick start. The tool has many useful options to control generation, please refer to its documentation.
diff --git a/runtime/CSharp/src/Tree/Xpath/XPathLexer.cs b/runtime/CSharp/src/Tree/Xpath/XPathLexer.cs
index 225cd43275..43619f3164 100644
--- a/runtime/CSharp/src/Tree/Xpath/XPathLexer.cs
+++ b/runtime/CSharp/src/Tree/Xpath/XPathLexer.cs
@@ -109,23 +109,23 @@ private void ID_action(RuleContext _localctx, int actionIndex) {
}
private static int[] _serializedATN = {
- 4,0,8,50,6,65535,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,
- 6,2,7,7,7,1,0,1,0,1,0,1,1,1,1,1,2,1,2,1,3,1,3,1,4,1,4,5,4,29,8,4,10,4,
- 12,4,32,9,4,1,4,1,4,1,5,1,5,3,5,38,8,5,1,6,1,6,1,7,1,7,5,7,44,8,7,10,7,
- 12,7,47,9,7,1,7,1,7,1,45,0,8,1,3,3,4,5,5,7,6,9,7,11,0,13,0,15,8,1,0,2,
- 5,0,48,57,95,95,183,183,768,879,8255,8256,13,0,65,90,97,122,192,214,216,
- 246,248,767,880,893,895,8191,8204,8205,8304,8591,11264,12271,12289,55295,
- 63744,64975,65008,65533,0,50,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,
- 0,0,0,0,9,1,0,0,0,0,15,1,0,0,0,1,17,1,0,0,0,3,20,1,0,0,0,5,22,1,0,0,0,
- 7,24,1,0,0,0,9,26,1,0,0,0,11,37,1,0,0,0,13,39,1,0,0,0,15,41,1,0,0,0,17,
- 18,5,47,0,0,18,19,5,47,0,0,19,2,1,0,0,0,20,21,5,47,0,0,21,4,1,0,0,0,22,
- 23,5,42,0,0,23,6,1,0,0,0,24,25,5,33,0,0,25,8,1,0,0,0,26,30,3,13,6,0,27,
- 29,3,11,5,0,28,27,1,0,0,0,29,32,1,0,0,0,30,28,1,0,0,0,30,31,1,0,0,0,31,
- 33,1,0,0,0,32,30,1,0,0,0,33,34,6,4,0,0,34,10,1,0,0,0,35,38,3,13,6,0,36,
- 38,7,0,0,0,37,35,1,0,0,0,37,36,1,0,0,0,38,12,1,0,0,0,39,40,7,1,0,0,40,
- 14,1,0,0,0,41,45,5,39,0,0,42,44,9,0,0,0,43,42,1,0,0,0,44,47,1,0,0,0,45,
- 46,1,0,0,0,45,43,1,0,0,0,46,48,1,0,0,0,47,45,1,0,0,0,48,49,5,39,0,0,49,
- 16,1,0,0,0,4,0,30,37,45,1,1,4,0
+ 4,0,8,50,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,
+ 2,7,7,7,1,0,1,0,1,0,1,1,1,1,1,2,1,2,1,3,1,3,1,4,1,4,5,4,29,8,4,10,4,12,
+ 4,32,9,4,1,4,1,4,1,5,1,5,3,5,38,8,5,1,6,1,6,1,7,1,7,5,7,44,8,7,10,7,12,
+ 7,47,9,7,1,7,1,7,1,45,0,8,1,3,3,4,5,5,7,6,9,7,11,0,13,0,15,8,1,0,2,5,0,
+ 48,57,95,95,183,183,768,879,8255,8256,13,0,65,90,97,122,192,214,216,246,
+ 248,767,880,893,895,8191,8204,8205,8304,8591,11264,12271,12289,55295,63744,
+ 64975,65008,65533,50,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,0,0,0,0,
+ 9,1,0,0,0,0,15,1,0,0,0,1,17,1,0,0,0,3,20,1,0,0,0,5,22,1,0,0,0,7,24,1,0,
+ 0,0,9,26,1,0,0,0,11,37,1,0,0,0,13,39,1,0,0,0,15,41,1,0,0,0,17,18,5,47,
+ 0,0,18,19,5,47,0,0,19,2,1,0,0,0,20,21,5,47,0,0,21,4,1,0,0,0,22,23,5,42,
+ 0,0,23,6,1,0,0,0,24,25,5,33,0,0,25,8,1,0,0,0,26,30,3,13,6,0,27,29,3,11,
+ 5,0,28,27,1,0,0,0,29,32,1,0,0,0,30,28,1,0,0,0,30,31,1,0,0,0,31,33,1,0,
+ 0,0,32,30,1,0,0,0,33,34,6,4,0,0,34,10,1,0,0,0,35,38,3,13,6,0,36,38,7,0,
+ 0,0,37,35,1,0,0,0,37,36,1,0,0,0,38,12,1,0,0,0,39,40,7,1,0,0,40,14,1,0,
+ 0,0,41,45,5,39,0,0,42,44,9,0,0,0,43,42,1,0,0,0,44,47,1,0,0,0,45,46,1,0,
+ 0,0,45,43,1,0,0,0,46,48,1,0,0,0,47,45,1,0,0,0,48,49,5,39,0,0,49,16,1,0,
+ 0,0,4,0,30,37,45,1,1,4,0
};
public static readonly ATN _ATN =
diff --git a/runtime/Cpp/VERSION b/runtime/Cpp/VERSION
index c01c413359..8d39259a80 100644
--- a/runtime/Cpp/VERSION
+++ b/runtime/Cpp/VERSION
@@ -1 +1 @@
-4.9.3
+4.10
diff --git a/runtime/Cpp/cmake/Antlr4Package.md b/runtime/Cpp/cmake/Antlr4Package.md
index 10e7752856..9b4d8584c3 100644
--- a/runtime/Cpp/cmake/Antlr4Package.md
+++ b/runtime/Cpp/cmake/Antlr4Package.md
@@ -96,7 +96,7 @@ target_link_libraries( Parsertest PRIVATE
find_package(antlr4-generator REQUIRED)
# Set path to generator
- set(ANTLR4_JAR_LOCATION ${PROJECT_SOURCE_DIR}/thirdparty/antlr/antlr-4.9.3-complete.jar)
+ set(ANTLR4_JAR_LOCATION ${PROJECT_SOURCE_DIR}/thirdparty/antlr/antlr-4.10-complete.jar)
# generate lexer
antlr4_generate(
diff --git a/runtime/Cpp/cmake/ExternalAntlr4Cpp.cmake b/runtime/Cpp/cmake/ExternalAntlr4Cpp.cmake
index 2acc610ef0..6d07ba16cb 100644
--- a/runtime/Cpp/cmake/ExternalAntlr4Cpp.cmake
+++ b/runtime/Cpp/cmake/ExternalAntlr4Cpp.cmake
@@ -38,7 +38,7 @@ else()
set(ANTLR4_SHARED_LIBRARIES
${ANTLR4_OUTPUT_DIR}/libantlr4-runtime.dll.a)
set(ANTLR4_RUNTIME_LIBRARIES
- ${ANTLR4_OUTPUT_DIR}/cygantlr4-runtime-4.9.3.dll)
+ ${ANTLR4_OUTPUT_DIR}/cygantlr4-runtime-4.10.dll)
elseif(APPLE)
set(ANTLR4_RUNTIME_LIBRARIES
${ANTLR4_OUTPUT_DIR}/libantlr4-runtime.dylib)
diff --git a/runtime/Cpp/cmake/FindANTLR.cmake b/runtime/Cpp/cmake/FindANTLR.cmake
index 2d204d7e9d..4a34d730d1 100644
--- a/runtime/Cpp/cmake/FindANTLR.cmake
+++ b/runtime/Cpp/cmake/FindANTLR.cmake
@@ -2,7 +2,7 @@ find_package(Java QUIET COMPONENTS Runtime)
if(NOT ANTLR_EXECUTABLE)
find_program(ANTLR_EXECUTABLE
- NAMES antlr.jar antlr4.jar antlr-4.jar antlr-4.9.3-complete.jar)
+ NAMES antlr.jar antlr4.jar antlr-4.jar antlr-4.10-complete.jar)
endif()
if(ANTLR_EXECUTABLE AND Java_JAVA_EXECUTABLE)
diff --git a/runtime/Cpp/cmake/README.md b/runtime/Cpp/cmake/README.md
index f43de44d39..2ca41a0d4c 100644
--- a/runtime/Cpp/cmake/README.md
+++ b/runtime/Cpp/cmake/README.md
@@ -39,7 +39,7 @@ include_directories(${ANTLR4_INCLUDE_DIRS})
# set variable pointing to the antlr tool that supports C++
# this is not required if the jar file can be found under PATH environment
-set(ANTLR_EXECUTABLE /home/user/antlr-4.9.3-complete.jar)
+set(ANTLR_EXECUTABLE /home/user/antlr-4.10-complete.jar)
# add macros to generate ANTLR Cpp code from grammar
find_package(ANTLR REQUIRED)
diff --git a/runtime/Cpp/demo/generate.cmd b/runtime/Cpp/demo/generate.cmd
index 5d74466a90..53619c742f 100644
--- a/runtime/Cpp/demo/generate.cmd
+++ b/runtime/Cpp/demo/generate.cmd
@@ -6,7 +6,7 @@
:: Download the ANLTR jar and place it in the same folder as this script (or adjust the LOCATION var accordingly).
-set LOCATION=antlr-4.9.3-complete.jar
+set LOCATION=antlr-4.10-complete.jar
java -jar %LOCATION% -Dlanguage=Cpp -listener -visitor -o generated/ -package antlrcpptest TLexer.g4 TParser.g4
::java -jar %LOCATION% -Dlanguage=Cpp -listener -visitor -o generated/ -package antlrcpptest -XdbgST TLexer.g4 TParser.g4
::java -jar %LOCATION% -Dlanguage=Java -listener -visitor -o generated/ -package antlrcpptest TLexer.g4 TParser.g4
diff --git a/runtime/Dart/CHANGELOG.md b/runtime/Dart/CHANGELOG.md
deleted file mode 100644
index 1ba1db8d3f..0000000000
--- a/runtime/Dart/CHANGELOG.md
+++ /dev/null
@@ -1,9 +0,0 @@
-
-## 4.9.0
-
-* Initial release
-
-## 4.9.3
-
-* Support web platform.
-
diff --git a/runtime/Dart/lib/src/runtime_meta_data.dart b/runtime/Dart/lib/src/runtime_meta_data.dart
index 8008b7d374..f0af12f3dc 100644
--- a/runtime/Dart/lib/src/runtime_meta_data.dart
+++ b/runtime/Dart/lib/src/runtime_meta_data.dart
@@ -66,7 +66,7 @@ class RuntimeMetaData {
/// omitted, the {@code -} (hyphen-minus) appearing before it is also
/// omitted.
///
- static final String VERSION = '4.9.3';
+ static final String VERSION = '4.10';
/// Gets the currently executing version of the ANTLR 4 runtime library.
///
diff --git a/runtime/Dart/pubspec.yaml b/runtime/Dart/pubspec.yaml
index 39ebadb8b0..f59fd1f8ef 100644
--- a/runtime/Dart/pubspec.yaml
+++ b/runtime/Dart/pubspec.yaml
@@ -1,5 +1,5 @@
name: "antlr4"
-version: "4.9.3"
+version: "4.10.0"
description: "New Dart runtime for ANTLR4."
homepage: "https://github.com/antlr/antlr4"
license: "BSD-3-Clause"
diff --git a/runtime/Go/antlr/recognizer.go b/runtime/Go/antlr/recognizer.go
index 12578cfb37..d7c1079b1e 100644
--- a/runtime/Go/antlr/recognizer.go
+++ b/runtime/Go/antlr/recognizer.go
@@ -49,7 +49,7 @@ var tokenTypeMapCache = make(map[string]int)
var ruleIndexMapCache = make(map[string]int)
func (b *BaseRecognizer) checkVersion(toolVersion string) {
- runtimeVersion := "4.9.3"
+ runtimeVersion := "4.10"
if runtimeVersion != toolVersion {
fmt.Println("ANTLR runtime and generated code versions disagree: " + runtimeVersion + "!=" + toolVersion)
}
diff --git a/runtime/Java/src/org/antlr/v4/runtime/RuntimeMetaData.java b/runtime/Java/src/org/antlr/v4/runtime/RuntimeMetaData.java
index b634a35072..3b18a98de7 100644
--- a/runtime/Java/src/org/antlr/v4/runtime/RuntimeMetaData.java
+++ b/runtime/Java/src/org/antlr/v4/runtime/RuntimeMetaData.java
@@ -67,7 +67,7 @@ public class RuntimeMetaData {
* omitted.
*
*/
- public static final String VERSION = "4.9.3";
+ public static final String VERSION = "4.10";
/**
* Gets the currently executing version of the ANTLR 4 runtime library.
diff --git a/runtime/JavaScript/package-lock.json b/runtime/JavaScript/package-lock.json
index 5a62693281..d97248f90e 100644
--- a/runtime/JavaScript/package-lock.json
+++ b/runtime/JavaScript/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "antlr4",
- "version": "4.9.3",
+ "version": "4.10.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "antlr4",
- "version": "4.9.3",
+ "version": "4.10",
"license": "BSD-3-Clause",
"devDependencies": {
"@babel/preset-env": "^7.16.11",
diff --git a/runtime/JavaScript/package.json b/runtime/JavaScript/package.json
index d320a2ae29..51cb034aeb 100644
--- a/runtime/JavaScript/package.json
+++ b/runtime/JavaScript/package.json
@@ -1,6 +1,6 @@
{
"name": "antlr4",
- "version": "4.9.3",
+ "version": "4.10.0",
"type": "module",
"description": "JavaScript runtime for ANTLR4",
"main": "src/antlr4/index.js",
diff --git a/runtime/JavaScript/src/antlr4/Recognizer.js b/runtime/JavaScript/src/antlr4/Recognizer.js
index d29bcf7b39..e28a321cb1 100644
--- a/runtime/JavaScript/src/antlr4/Recognizer.js
+++ b/runtime/JavaScript/src/antlr4/Recognizer.js
@@ -15,7 +15,7 @@ export default class Recognizer {
}
checkVersion(toolVersion) {
- const runtimeVersion = "4.9.3";
+ const runtimeVersion = "4.10";
if (runtimeVersion!==toolVersion) {
console.log("ANTLR runtime and generated code versions disagree: "+runtimeVersion+"!="+toolVersion);
}
diff --git a/runtime/Python2/setup.py b/runtime/Python2/setup.py
index ba20e7986e..e8bab93aba 100644
--- a/runtime/Python2/setup.py
+++ b/runtime/Python2/setup.py
@@ -1,6 +1,6 @@
from setuptools import setup
-v = '4.9.3'
+v = '4.10'
setup(
name='antlr4-python2-runtime',
version=v,
diff --git a/runtime/Python2/src/antlr4/Recognizer.py b/runtime/Python2/src/antlr4/Recognizer.py
index ea9a8739fd..99462d409b 100644
--- a/runtime/Python2/src/antlr4/Recognizer.py
+++ b/runtime/Python2/src/antlr4/Recognizer.py
@@ -30,7 +30,7 @@ def extractVersion(self, version):
return major, minor
def checkVersion(self, toolVersion):
- runtimeVersion = "4.9.3"
+ runtimeVersion = "4.10"
rvmajor, rvminor = self.extractVersion(runtimeVersion)
tvmajor, tvminor = self.extractVersion(toolVersion)
if rvmajor!=tvmajor or rvminor!=tvminor:
diff --git a/runtime/Python2/src/antlr4/xpath/XPath.py b/runtime/Python2/src/antlr4/xpath/XPath.py
index 87da0af80e..92f5e0dac3 100644
--- a/runtime/Python2/src/antlr4/xpath/XPath.py
+++ b/runtime/Python2/src/antlr4/xpath/XPath.py
@@ -48,110 +48,30 @@
# Whitespace is not allowed.
#
from antlr4 import CommonTokenStream, DFA, PredictionContextCache, Lexer, LexerATNSimulator, ParserRuleContext, TerminalNode
-from antlr4.atn.ATNDeserializer import ATNDeserializer
from antlr4.InputStream import InputStream
+from antlr4.Parser import Parser
+from antlr4.RuleContext import RuleContext
from antlr4.Token import Token
+from antlr4.atn.ATNDeserializer import ATNDeserializer
from antlr4.error.ErrorListener import ErrorListener
from antlr4.error.Errors import LexerNoViableAltException
+from antlr4.tree.Tree import ParseTree
from antlr4.tree.Trees import Trees
-
from io import StringIO
+from antlr4.xpath.XPathLexer import XPathLexer
-def serializedATN():
- with StringIO() as buf:
- buf.write(u"\4\0\b\62\6\uffff\2\0\7\0\2\1\7\1\2\2\7\2\2\3\7\3\2\4")
- buf.write(u"\7\4\2\5\7\5\2\6\7\6\2\7\7\7\1\0\1\0\1\0\1\1\1\1\1\2")
- buf.write(u"\1\2\1\3\1\3\1\4\1\4\5\4\35\b\4\n\4\f\4 \t\4\1\4\1\4")
- buf.write(u"\1\5\1\5\3\5&\b\5\1\6\1\6\1\7\1\7\5\7,\b\7\n\7\f\7/\t")
- buf.write(u"\7\1\7\1\7\1-\0\b\1\3\3\4\5\5\7\6\t\7\13\0\r\0\17\b\1")
- buf.write(u"\0\2\5\0\609__\u00b7\u00b7\u0300\u036f\u203f\u2040\r")
- buf.write(u"\0AZaz\u00c0\u00d6\u00d8\u00f6\u00f8\u02ff\u0370\u037d")
- buf.write(u"\u037f\u1fff\u200c\u200d\u2070\u218f\u2c00\u2fef\u3001")
- buf.write(u"\ud7ff\uf900\ufdcf\ufdf0\uffff\0\62\0\1\1\0\0\0\0\3\1")
- buf.write(u"\0\0\0\0\5\1\0\0\0\0\7\1\0\0\0\0\t\1\0\0\0\0\17\1\0\0")
- buf.write(u"\0\1\21\1\0\0\0\3\24\1\0\0\0\5\26\1\0\0\0\7\30\1\0\0")
- buf.write(u"\0\t\32\1\0\0\0\13%\1\0\0\0\r\'\1\0\0\0\17)\1\0\0\0\21")
- buf.write(u"\22\5/\0\0\22\23\5/\0\0\23\2\1\0\0\0\24\25\5/\0\0\25")
- buf.write(u"\4\1\0\0\0\26\27\5*\0\0\27\6\1\0\0\0\30\31\5!\0\0\31")
- buf.write(u"\b\1\0\0\0\32\36\3\r\6\0\33\35\3\13\5\0\34\33\1\0\0\0")
- buf.write(u"\35 \1\0\0\0\36\34\1\0\0\0\36\37\1\0\0\0\37!\1\0\0\0")
- buf.write(u" \36\1\0\0\0!\"\6\4\0\0\"\n\1\0\0\0#&\3\r\6\0$&\7\0\0")
- buf.write(u"\0%#\1\0\0\0%$\1\0\0\0&\f\1\0\0\0\'(\7\1\0\0(\16\1\0")
- buf.write(u"\0\0)-\5\'\0\0*,\t\0\0\0+*\1\0\0\0,/\1\0\0\0-.\1\0\0")
- buf.write(u"\0-+\1\0\0\0.\60\1\0\0\0/-\1\0\0\0\60\61\5\'\0\0\61\20")
- buf.write(u"\1\0\0\0\4\0\36%-\1\1\4\0")
- return buf.getvalue()
-
-
-class XPathLexer(Lexer):
-
- atn = ATNDeserializer().deserialize(serializedATN())
-
- decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ]
-
-
- TOKEN_REF = 1
- RULE_REF = 2
- ANYWHERE = 3
- ROOT = 4
- WILDCARD = 5
- BANG = 6
- ID = 7
- STRING = 8
-
- modeNames = [ u"DEFAULT_MODE" ]
-
- literalNames = [ u"",
- u"'//'", u"'/'", u"'*'", u"'!'" ]
-
- symbolicNames = [ u"",
- u"TOKEN_REF", u"RULE_REF", u"ANYWHERE", u"ROOT", u"WILDCARD",
- u"BANG", u"ID", u"STRING" ]
-
- ruleNames = [ u"ANYWHERE", u"ROOT", u"WILDCARD", u"BANG", u"ID", u"NameChar",
- u"NameStartChar", u"STRING" ]
-
- grammarFileName = u"XPathLexer.g4"
-
- def __init__(self, input=None):
- super(XPathLexer, self).__init__(input)
- self.checkVersion("4.5")
- self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache())
- self._actions = None
- self._predicates = None
-
-
- def action(self, localctx, ruleIndex, actionIndex):
- if self._actions is None:
- actions = dict()
- actions[4] = self.ID_action
- self._actions = actions
- action = self._actions.get(ruleIndex, None)
- if action is not None:
- action(localctx, actionIndex)
- else:
- raise Exception("No registered action for:" + str(ruleIndex))
-
- def ID_action(self, localctx , actionIndex):
- if actionIndex == 0:
- char = self.text[0]
- if char.isupper():
- self.type = XPathLexer.TOKEN_REF
- else:
- self.type = XPathLexer.RULE_REF
-
class XPath(object):
WILDCARD = "*" # word not operator/separator
NOT = "!" # word for invert operator
- def __init__(self, parser, path):
+ def __init__(self, parser:Parser, path:str):
self.parser = parser
self.path = path
self.elements = self.split(path)
- def split(self, path):
+ def split(self, path:str):
input = InputStream(path)
lexer = XPathLexer(input)
def recover(self, e):
@@ -163,40 +83,40 @@ def recover(self, e):
try:
tokenStream.fill()
except LexerNoViableAltException as e:
- pos = lexer.getColumn()
- msg = "Invalid tokens or characters at index " + str(pos) + " in path '" + path + "'"
+ pos = lexer.column
+ msg = "Invalid tokens or characters at index %d in path '%s'" % (pos, path)
raise Exception(msg, e)
- tokens = tokenStream.getTokens()
+ tokens = iter(tokenStream.tokens)
elements = list()
- n = len(tokens)
- i=0
- while i < n :
- el = tokens[i]
- next = None
+ for el in tokens:
+ invert = False
+ anywhere = False
+ # Check for path separators, if none assume root
if el.type in [XPathLexer.ROOT, XPathLexer.ANYWHERE]:
- anywhere = el.type == XPathLexer.ANYWHERE
- i += 1
- next = tokens[i]
- invert = next.type==XPathLexer.BANG
- if invert:
- i += 1
- next = tokens[i]
- pathElement = self.getXPathElement(next, anywhere)
- pathElement.invert = invert
- elements.append(pathElement)
- i += 1
-
- elif el.type in [XPathLexer.TOKEN_REF, XPathLexer.RULE_REF, XPathLexer.WILDCARD] :
- elements.append( self.getXPathElement(el, False) )
- i += 1
-
- elif el.type==Token.EOF :
- break
-
+ anywhere = el.type == XPathLexer.ANYWHERE
+ next_el = next(tokens, None)
+ if not next_el:
+ raise Exception('Missing element after %s' % el.getText())
+ else:
+ el = next_el
+ # Check for bangs
+ if el.type == XPathLexer.BANG:
+ invert = True
+ next_el = next(tokens, None)
+ if not next_el:
+ raise Exception('Missing element after %s' % el.getText())
+ else:
+ el = next_el
+ # Add searched element
+ if el.type in [XPathLexer.TOKEN_REF, XPathLexer.RULE_REF, XPathLexer.WILDCARD, XPathLexer.STRING]:
+ element = self.getXPathElement(el, anywhere)
+ element.invert = invert
+ elements.append(element)
+ elif el.type==Token.EOF:
+ break
else:
- raise Exception("Unknown path element " + str(el))
-
+ raise Exception("Unknown path element %s" % lexer.symbolicNames[el.type])
return elements
#
@@ -204,31 +124,39 @@ def recover(self, e):
# element. {@code anywhere} is {@code true} if {@code //} precedes the
# word.
#
- def getXPathElement(self, wordToken, anywhere):
+ def getXPathElement(self, wordToken:Token, anywhere:bool):
if wordToken.type==Token.EOF:
raise Exception("Missing path element at end of path")
- word = wordToken.text
- ttype = self.parser.getTokenType(word)
- ruleIndex = self.parser.getRuleIndex(word)
+ word = wordToken.text
if wordToken.type==XPathLexer.WILDCARD :
-
return XPathWildcardAnywhereElement() if anywhere else XPathWildcardElement()
elif wordToken.type in [XPathLexer.TOKEN_REF, XPathLexer.STRING]:
+ tsource = self.parser.getTokenStream().tokenSource
- if ttype==Token.INVALID_TYPE:
- raise Exception( word + " at index " + str(wordToken.startIndex) + " isn't a valid token name")
+ ttype = Token.INVALID_TYPE
+ if wordToken.type == XPathLexer.TOKEN_REF:
+ if word in tsource.ruleNames:
+ ttype = tsource.ruleNames.index(word) + 1
+ else:
+ if word in tsource.literalNames:
+ ttype = tsource.literalNames.index(word)
+
+ if ttype == Token.INVALID_TYPE:
+ raise Exception("%s at index %d isn't a valid token name" % (word, wordToken.tokenIndex))
return XPathTokenAnywhereElement(word, ttype) if anywhere else XPathTokenElement(word, ttype)
else:
+ ruleIndex = self.parser.ruleNames.index(word) if word in self.parser.ruleNames else -1
- if ruleIndex==-1:
- raise Exception( word + " at index " + str(wordToken.getStartIndex()) + " isn't a valid rule name")
+ if ruleIndex == -1:
+ raise Exception("%s at index %d isn't a valid rule name" % (word, wordToken.tokenIndex))
return XPathRuleAnywhereElement(word, ruleIndex) if anywhere else XPathRuleElement(word, ruleIndex)
- def findAll(self, tree, xpath, parser):
+ @staticmethod
+ def findAll(tree:ParseTree, xpath:str, parser:Parser):
p = XPath(parser, xpath)
return p.evaluate(tree)
@@ -237,37 +165,37 @@ def findAll(self, tree, xpath, parser):
# path. The root {@code /} is relative to the node passed to
# {@link #evaluate}.
#
- def evaluate(self, t):
+ def evaluate(self, t:ParseTree):
dummyRoot = ParserRuleContext()
dummyRoot.children = [t] # don't set t's parent.
work = [dummyRoot]
-
- for i in range(0, len(self.elements)):
- next = set()
+ for element in self.elements:
+ work_next = list()
for node in work:
- if len( node.children) > 0 :
+ if not isinstance(node, TerminalNode) and node.children:
# only try to match next element if it has children
# e.g., //func/*/stat might have a token node for which
# we can't go looking for stat nodes.
- matching = self.elements[i].evaluate(node)
- next |= matching
- i += 1
- work = next
+ matching = element.evaluate(node)
+
+ # See issue antlr#370 - Prevents XPath from returning the
+ # same node multiple times
+ matching = filter(lambda m: m not in work_next, matching)
+
+ work_next.extend(matching)
+ work = work_next
return work
class XPathElement(object):
- def __init__(self, nodeName):
+ def __init__(self, nodeName:str):
self.nodeName = nodeName
self.invert = False
def __str__(self):
- return unicode(self)
-
- def __unicode__(self):
return type(self).__name__ + "[" + ("!" if self.invert else "") + self.nodeName + "]"
@@ -277,51 +205,51 @@ def __unicode__(self):
#
class XPathRuleAnywhereElement(XPathElement):
- def __init__(self, ruleName, ruleIndex):
- super(XPathRuleAnywhereElement, self).__init__(ruleName)
+ def __init__(self, ruleName:str, ruleIndex:int):
+ super().__init__(ruleName)
self.ruleIndex = ruleIndex
- def evaluate(self, t):
- return Trees.findAllRuleNodes(t, self.ruleIndex)
-
+ def evaluate(self, t:ParseTree):
+ # return all ParserRuleContext descendants of t that match ruleIndex (or do not match if inverted)
+ return filter(lambda c: isinstance(c, ParserRuleContext) and (self.invert ^ (c.getRuleIndex() == self.ruleIndex)), Trees.descendants(t))
class XPathRuleElement(XPathElement):
- def __init__(self, ruleName, ruleIndex):
- super(XPathRuleElement, self).__init__(ruleName)
+ def __init__(self, ruleName:str, ruleIndex:int):
+ super().__init__(ruleName)
self.ruleIndex = ruleIndex
- def evaluate(self, t):
- # return all children of t that match nodeName
- return [c for c in Trees.getChildren(t) if isinstance(c, ParserRuleContext) and (c.ruleIndex == self.ruleIndex) == (not self.invert)]
+ def evaluate(self, t:ParseTree):
+ # return all ParserRuleContext children of t that match ruleIndex (or do not match if inverted)
+ return filter(lambda c: isinstance(c, ParserRuleContext) and (self.invert ^ (c.getRuleIndex() == self.ruleIndex)), Trees.getChildren(t))
class XPathTokenAnywhereElement(XPathElement):
- def __init__(self, ruleName, tokenType):
- super(XPathTokenAnywhereElement, self).__init__(ruleName)
+ def __init__(self, ruleName:str, tokenType:int):
+ super().__init__(ruleName)
self.tokenType = tokenType
- def evaluate(self, t):
- return Trees.findAllTokenNodes(t, self.tokenType)
-
+ def evaluate(self, t:ParseTree):
+ # return all TerminalNode descendants of t that match tokenType (or do not match if inverted)
+ return filter(lambda c: isinstance(c, TerminalNode) and (self.invert ^ (c.symbol.type == self.tokenType)), Trees.descendants(t))
class XPathTokenElement(XPathElement):
- def __init__(self, ruleName, tokenType):
- super(XPathTokenElement, self).__init__(ruleName)
+ def __init__(self, ruleName:str, tokenType:int):
+ super().__init__(ruleName)
self.tokenType = tokenType
- def evaluate(self, t):
- # return all children of t that match nodeName
- return [c for c in Trees.getChildren(t) if isinstance(c, TerminalNode) and (c.symbol.type == self.tokenType) == (not self.invert)]
+ def evaluate(self, t:ParseTree):
+ # return all TerminalNode children of t that match tokenType (or do not match if inverted)
+ return filter(lambda c: isinstance(c, TerminalNode) and (self.invert ^ (c.symbol.type == self.tokenType)), Trees.getChildren(t))
class XPathWildcardAnywhereElement(XPathElement):
def __init__(self):
- super(XPathWildcardAnywhereElement, self).__init__(XPath.WILDCARD)
+ super().__init__(XPath.WILDCARD)
- def evaluate(self, t):
+ def evaluate(self, t:ParseTree):
if self.invert:
return list() # !* is weird but valid (empty)
else:
@@ -331,10 +259,10 @@ def evaluate(self, t):
class XPathWildcardElement(XPathElement):
def __init__(self):
- super(XPathWildcardElement, self).__init__(XPath.WILDCARD)
+ super().__init__(XPath.WILDCARD)
- def evaluate(self, t):
+ def evaluate(self, t:ParseTree):
if self.invert:
return list() # !* is weird but valid (empty)
else:
diff --git a/runtime/Python2/src/antlr4/xpath/XPathLexer.g4 b/runtime/Python2/src/antlr4/xpath/XPathLexer.g4
new file mode 100644
index 0000000000..c4b1e173df
--- /dev/null
+++ b/runtime/Python2/src/antlr4/xpath/XPathLexer.g4
@@ -0,0 +1,45 @@
+lexer grammar XPathLexer;
+
+tokens { TOKEN_REF, RULE_REF }
+
+ANYWHERE : '//' ;
+ROOT : '/' ;
+WILDCARD : '*' ;
+BANG : '!' ;
+
+ID : NameStartChar NameChar*
+ {
+ char = self.text[0]
+ if char.isupper():
+ self.type = XPathLexer.TOKEN_REF
+ else:
+ self.type = XPathLexer.RULE_REF
+ }
+ ;
+
+fragment
+NameChar : NameStartChar
+ | '0'..'9'
+ | '_'
+ | '\u00B7'
+ | '\u0300'..'\u036F'
+ | '\u203F'..'\u2040'
+ ;
+
+fragment
+NameStartChar
+ : 'A'..'Z' | 'a'..'z'
+ | '\u00C0'..'\u00D6'
+ | '\u00D8'..'\u00F6'
+ | '\u00F8'..'\u02FF'
+ | '\u0370'..'\u037D'
+ | '\u037F'..'\u1FFF'
+ | '\u200C'..'\u200D'
+ | '\u2070'..'\u218F'
+ | '\u2C00'..'\u2FEF'
+ | '\u3001'..'\uD7FF'
+ | '\uF900'..'\uFDCF'
+ | '\uFDF0'..'\uFFFD'
+ ; // ignores | ['\u10000-'\uEFFFF] ;
+
+STRING : '\'' .*? '\'' ;
diff --git a/runtime/Python2/src/antlr4/xpath/XPathLexer.py b/runtime/Python2/src/antlr4/xpath/XPathLexer.py
new file mode 100644
index 0000000000..cbf3bb9827
--- /dev/null
+++ b/runtime/Python2/src/antlr4/xpath/XPathLexer.py
@@ -0,0 +1,95 @@
+# Generated from XPathLexer.g4 by ANTLR 4.9.3
+from antlr4 import *
+from io import StringIO
+import sys
+if sys.version_info[1] > 5:
+ from typing import TextIO
+else:
+ from typing.io import TextIO
+
+
+def serializedATN():
+ return [
+ 4,0,8,50,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,
+ 6,7,6,2,7,7,7,1,0,1,0,1,0,1,1,1,1,1,2,1,2,1,3,1,3,1,4,1,4,5,4,29,
+ 8,4,10,4,12,4,32,9,4,1,4,1,4,1,5,1,5,3,5,38,8,5,1,6,1,6,1,7,1,7,
+ 5,7,44,8,7,10,7,12,7,47,9,7,1,7,1,7,1,45,0,8,1,3,3,4,5,5,7,6,9,7,
+ 11,0,13,0,15,8,1,0,2,5,0,48,57,95,95,183,183,768,879,8255,8256,13,
+ 0,65,90,97,122,192,214,216,246,248,767,880,893,895,8191,8204,8205,
+ 8304,8591,11264,12271,12289,55295,63744,64975,65008,65533,50,0,1,
+ 1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,15,1,0,
+ 0,0,1,17,1,0,0,0,3,20,1,0,0,0,5,22,1,0,0,0,7,24,1,0,0,0,9,26,1,0,
+ 0,0,11,37,1,0,0,0,13,39,1,0,0,0,15,41,1,0,0,0,17,18,5,47,0,0,18,
+ 19,5,47,0,0,19,2,1,0,0,0,20,21,5,47,0,0,21,4,1,0,0,0,22,23,5,42,
+ 0,0,23,6,1,0,0,0,24,25,5,33,0,0,25,8,1,0,0,0,26,30,3,13,6,0,27,29,
+ 3,11,5,0,28,27,1,0,0,0,29,32,1,0,0,0,30,28,1,0,0,0,30,31,1,0,0,0,
+ 31,33,1,0,0,0,32,30,1,0,0,0,33,34,6,4,0,0,34,10,1,0,0,0,35,38,3,
+ 13,6,0,36,38,7,0,0,0,37,35,1,0,0,0,37,36,1,0,0,0,38,12,1,0,0,0,39,
+ 40,7,1,0,0,40,14,1,0,0,0,41,45,5,39,0,0,42,44,9,0,0,0,43,42,1,0,
+ 0,0,44,47,1,0,0,0,45,46,1,0,0,0,45,43,1,0,0,0,46,48,1,0,0,0,47,45,
+ 1,0,0,0,48,49,5,39,0,0,49,16,1,0,0,0,4,0,30,37,45,1,1,4,0
+ ]
+
+class XPathLexer(Lexer):
+
+ atn = ATNDeserializer().deserialize(serializedATN())
+
+ decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ]
+
+ TOKEN_REF = 1
+ RULE_REF = 2
+ ANYWHERE = 3
+ ROOT = 4
+ WILDCARD = 5
+ BANG = 6
+ ID = 7
+ STRING = 8
+
+ channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ]
+
+ modeNames = [ "DEFAULT_MODE" ]
+
+ literalNames = [ "",
+ "'//'", "'/'", "'*'", "'!'" ]
+
+ symbolicNames = [ "",
+ "TOKEN_REF", "RULE_REF", "ANYWHERE", "ROOT", "WILDCARD", "BANG",
+ "ID", "STRING" ]
+
+ ruleNames = [ "ANYWHERE", "ROOT", "WILDCARD", "BANG", "ID", "NameChar",
+ "NameStartChar", "STRING" ]
+
+ grammarFileName = "XPathLexer.g4"
+
+ def __init__(self, input=None, output:TextIO = sys.stdout):
+ super().__init__(input, output)
+ self.checkVersion("4.9.3")
+ self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache())
+ self._actions = None
+ self._predicates = None
+
+
+ def action(self, localctx:RuleContext, ruleIndex:int, actionIndex:int):
+ if self._actions is None:
+ actions = dict()
+ actions[4] = self.ID_action
+ self._actions = actions
+ action = self._actions.get(ruleIndex, None)
+ if action is not None:
+ action(localctx, actionIndex)
+ else:
+ raise Exception("No registered action for:" + str(ruleIndex))
+
+
+ def ID_action(self, localctx:RuleContext , actionIndex:int):
+ if actionIndex == 0:
+
+ char = self.text[0]
+ if char.isupper():
+ self.type = XPathLexer.TOKEN_REF
+ else:
+ self.type = XPathLexer.RULE_REF
+
+
+
+
diff --git a/runtime/Python3/setup.py b/runtime/Python3/setup.py
index b13bd2a703..a9af2bb557 100644
--- a/runtime/Python3/setup.py
+++ b/runtime/Python3/setup.py
@@ -1,6 +1,6 @@
from setuptools import setup
-v = '4.9.3'
+v = '4.10'
setup(
name='antlr4-python3-runtime',
diff --git a/runtime/Python3/src/antlr4/Recognizer.py b/runtime/Python3/src/antlr4/Recognizer.py
index d87738be57..371d9aaa43 100644
--- a/runtime/Python3/src/antlr4/Recognizer.py
+++ b/runtime/Python3/src/antlr4/Recognizer.py
@@ -34,7 +34,7 @@ def extractVersion(self, version):
return major, minor
def checkVersion(self, toolVersion):
- runtimeVersion = "4.9.3"
+ runtimeVersion = "4.10"
rvmajor, rvminor = self.extractVersion(runtimeVersion)
tvmajor, tvminor = self.extractVersion(toolVersion)
if rvmajor!=tvmajor or rvminor!=tvminor:
diff --git a/runtime/Python3/src/antlr4/tree/ParseTreePattern.py b/runtime/Python3/src/antlr4/tree/ParseTreePattern.py
index 37fd0bf09f..b09bf1a542 100644
--- a/runtime/Python3/src/antlr4/tree/ParseTreePattern.py
+++ b/runtime/Python3/src/antlr4/tree/ParseTreePattern.py
@@ -10,7 +10,7 @@
#
from antlr4.tree.ParseTreePatternMatcher import ParseTreePatternMatcher
from antlr4.tree.Tree import ParseTree
-from antlr4.xpath.XPath import XPath
+from antlr4.xpath.XPathLexer import XPathLexer
class ParseTreePattern(object):
diff --git a/runtime/Python3/src/antlr4/xpath/XPath.py b/runtime/Python3/src/antlr4/xpath/XPath.py
index bae18dd18a..92f5e0dac3 100644
--- a/runtime/Python3/src/antlr4/xpath/XPath.py
+++ b/runtime/Python3/src/antlr4/xpath/XPath.py
@@ -58,91 +58,9 @@
from antlr4.tree.Tree import ParseTree
from antlr4.tree.Trees import Trees
from io import StringIO
+from antlr4.xpath.XPathLexer import XPathLexer
-def serializedATN():
- with StringIO() as buf:
- buf.write("\4\0\b\62\6\uffff\2\0\7\0\2\1\7\1\2\2\7\2\2\3\7\3\2\4")
- buf.write("\7\4\2\5\7\5\2\6\7\6\2\7\7\7\1\0\1\0\1\0\1\1\1\1\1\2\1")
- buf.write("\2\1\3\1\3\1\4\1\4\5\4\35\b\4\n\4\f\4 \t\4\1\4\1\4\1\5")
- buf.write("\1\5\3\5&\b\5\1\6\1\6\1\7\1\7\5\7,\b\7\n\7\f\7/\t\7\1")
- buf.write("\7\1\7\1-\0\b\1\3\3\4\5\5\7\6\t\7\13\0\r\0\17\b\1\0\2")
- buf.write("\5\0\609__\u00b7\u00b7\u0300\u036f\u203f\u2040\r\0AZa")
- buf.write("z\u00c0\u00d6\u00d8\u00f6\u00f8\u02ff\u0370\u037d\u037f")
- buf.write("\u1fff\u200c\u200d\u2070\u218f\u2c00\u2fef\u3001\ud7ff")
- buf.write("\uf900\ufdcf\ufdf0\uffff\0\62\0\1\1\0\0\0\0\3\1\0\0\0")
- buf.write("\0\5\1\0\0\0\0\7\1\0\0\0\0\t\1\0\0\0\0\17\1\0\0\0\1\21")
- buf.write("\1\0\0\0\3\24\1\0\0\0\5\26\1\0\0\0\7\30\1\0\0\0\t\32\1")
- buf.write("\0\0\0\13%\1\0\0\0\r\'\1\0\0\0\17)\1\0\0\0\21\22\5/\0")
- buf.write("\0\22\23\5/\0\0\23\2\1\0\0\0\24\25\5/\0\0\25\4\1\0\0\0")
- buf.write("\26\27\5*\0\0\27\6\1\0\0\0\30\31\5!\0\0\31\b\1\0\0\0\32")
- buf.write("\36\3\r\6\0\33\35\3\13\5\0\34\33\1\0\0\0\35 \1\0\0\0\36")
- buf.write("\34\1\0\0\0\36\37\1\0\0\0\37!\1\0\0\0 \36\1\0\0\0!\"\6")
- buf.write("\4\0\0\"\n\1\0\0\0#&\3\r\6\0$&\7\0\0\0%#\1\0\0\0%$\1\0")
- buf.write("\0\0&\f\1\0\0\0\'(\7\1\0\0(\16\1\0\0\0)-\5\'\0\0*,\t\0")
- buf.write("\0\0+*\1\0\0\0,/\1\0\0\0-.\1\0\0\0-+\1\0\0\0.\60\1\0\0")
- buf.write("\0/-\1\0\0\0\60\61\5\'\0\0\61\20\1\0\0\0\4\0\36%-\1\1")
- buf.write("\4\0")
- return buf.getvalue()
-
-
-class XPathLexer(Lexer):
-
- atn = ATNDeserializer().deserialize(serializedATN())
-
- decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ]
-
-
- TOKEN_REF = 1
- RULE_REF = 2
- ANYWHERE = 3
- ROOT = 4
- WILDCARD = 5
- BANG = 6
- ID = 7
- STRING = 8
-
- modeNames = [ "DEFAULT_MODE" ]
-
- literalNames = [ "",
- "'//'", "'/'", "'*'", "'!'" ]
-
- symbolicNames = [ "",
- "TOKEN_REF", "RULE_REF", "ANYWHERE", "ROOT", "WILDCARD", "BANG",
- "ID", "STRING" ]
-
- ruleNames = [ "ANYWHERE", "ROOT", "WILDCARD", "BANG", "ID", "NameChar",
- "NameStartChar", "STRING" ]
-
- grammarFileName = "XPathLexer.g4"
-
- def __init__(self, input=None):
- super().__init__(input)
- self.checkVersion("4.9.1")
- self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache())
- self._actions = None
- self._predicates = None
-
-
- def action(self, localctx:RuleContext, ruleIndex:int, actionIndex:int):
- if self._actions is None:
- actions = dict()
- actions[4] = self.ID_action
- self._actions = actions
- _action = self._actions.get(ruleIndex, None)
- if _action is not None:
- _action(localctx, actionIndex)
- else:
- raise Exception("No registered action for: %d" % ruleIndex)
-
- def ID_action(self, localctx:RuleContext , actionIndex:int):
- if actionIndex == 0:
- char = self.text[0]
- if char.isupper():
- self.type = XPathLexer.TOKEN_REF
- else:
- self.type = XPathLexer.RULE_REF
-
class XPath(object):
WILDCARD = "*" # word not operator/separator
diff --git a/runtime/Python3/src/antlr4/xpath/XPathLexer.g4 b/runtime/Python3/src/antlr4/xpath/XPathLexer.g4
new file mode 100644
index 0000000000..c4b1e173df
--- /dev/null
+++ b/runtime/Python3/src/antlr4/xpath/XPathLexer.g4
@@ -0,0 +1,45 @@
+lexer grammar XPathLexer;
+
+tokens { TOKEN_REF, RULE_REF }
+
+ANYWHERE : '//' ;
+ROOT : '/' ;
+WILDCARD : '*' ;
+BANG : '!' ;
+
+ID : NameStartChar NameChar*
+ {
+ char = self.text[0]
+ if char.isupper():
+ self.type = XPathLexer.TOKEN_REF
+ else:
+ self.type = XPathLexer.RULE_REF
+ }
+ ;
+
+fragment
+NameChar : NameStartChar
+ | '0'..'9'
+ | '_'
+ | '\u00B7'
+ | '\u0300'..'\u036F'
+ | '\u203F'..'\u2040'
+ ;
+
+fragment
+NameStartChar
+ : 'A'..'Z' | 'a'..'z'
+ | '\u00C0'..'\u00D6'
+ | '\u00D8'..'\u00F6'
+ | '\u00F8'..'\u02FF'
+ | '\u0370'..'\u037D'
+ | '\u037F'..'\u1FFF'
+ | '\u200C'..'\u200D'
+ | '\u2070'..'\u218F'
+ | '\u2C00'..'\u2FEF'
+ | '\u3001'..'\uD7FF'
+ | '\uF900'..'\uFDCF'
+ | '\uFDF0'..'\uFFFD'
+ ; // ignores | ['\u10000-'\uEFFFF] ;
+
+STRING : '\'' .*? '\'' ;
diff --git a/runtime/Python3/src/antlr4/xpath/XPathLexer.py b/runtime/Python3/src/antlr4/xpath/XPathLexer.py
new file mode 100644
index 0000000000..cbf3bb9827
--- /dev/null
+++ b/runtime/Python3/src/antlr4/xpath/XPathLexer.py
@@ -0,0 +1,95 @@
+# Generated from XPathLexer.g4 by ANTLR 4.9.3
+from antlr4 import *
+from io import StringIO
+import sys
+if sys.version_info[1] > 5:
+ from typing import TextIO
+else:
+ from typing.io import TextIO
+
+
+def serializedATN():
+ return [
+ 4,0,8,50,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,
+ 6,7,6,2,7,7,7,1,0,1,0,1,0,1,1,1,1,1,2,1,2,1,3,1,3,1,4,1,4,5,4,29,
+ 8,4,10,4,12,4,32,9,4,1,4,1,4,1,5,1,5,3,5,38,8,5,1,6,1,6,1,7,1,7,
+ 5,7,44,8,7,10,7,12,7,47,9,7,1,7,1,7,1,45,0,8,1,3,3,4,5,5,7,6,9,7,
+ 11,0,13,0,15,8,1,0,2,5,0,48,57,95,95,183,183,768,879,8255,8256,13,
+ 0,65,90,97,122,192,214,216,246,248,767,880,893,895,8191,8204,8205,
+ 8304,8591,11264,12271,12289,55295,63744,64975,65008,65533,50,0,1,
+ 1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,15,1,0,
+ 0,0,1,17,1,0,0,0,3,20,1,0,0,0,5,22,1,0,0,0,7,24,1,0,0,0,9,26,1,0,
+ 0,0,11,37,1,0,0,0,13,39,1,0,0,0,15,41,1,0,0,0,17,18,5,47,0,0,18,
+ 19,5,47,0,0,19,2,1,0,0,0,20,21,5,47,0,0,21,4,1,0,0,0,22,23,5,42,
+ 0,0,23,6,1,0,0,0,24,25,5,33,0,0,25,8,1,0,0,0,26,30,3,13,6,0,27,29,
+ 3,11,5,0,28,27,1,0,0,0,29,32,1,0,0,0,30,28,1,0,0,0,30,31,1,0,0,0,
+ 31,33,1,0,0,0,32,30,1,0,0,0,33,34,6,4,0,0,34,10,1,0,0,0,35,38,3,
+ 13,6,0,36,38,7,0,0,0,37,35,1,0,0,0,37,36,1,0,0,0,38,12,1,0,0,0,39,
+ 40,7,1,0,0,40,14,1,0,0,0,41,45,5,39,0,0,42,44,9,0,0,0,43,42,1,0,
+ 0,0,44,47,1,0,0,0,45,46,1,0,0,0,45,43,1,0,0,0,46,48,1,0,0,0,47,45,
+ 1,0,0,0,48,49,5,39,0,0,49,16,1,0,0,0,4,0,30,37,45,1,1,4,0
+ ]
+
+class XPathLexer(Lexer):
+
+ atn = ATNDeserializer().deserialize(serializedATN())
+
+ decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ]
+
+ TOKEN_REF = 1
+ RULE_REF = 2
+ ANYWHERE = 3
+ ROOT = 4
+ WILDCARD = 5
+ BANG = 6
+ ID = 7
+ STRING = 8
+
+ channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ]
+
+ modeNames = [ "DEFAULT_MODE" ]
+
+ literalNames = [ "",
+ "'//'", "'/'", "'*'", "'!'" ]
+
+ symbolicNames = [ "",
+ "TOKEN_REF", "RULE_REF", "ANYWHERE", "ROOT", "WILDCARD", "BANG",
+ "ID", "STRING" ]
+
+ ruleNames = [ "ANYWHERE", "ROOT", "WILDCARD", "BANG", "ID", "NameChar",
+ "NameStartChar", "STRING" ]
+
+ grammarFileName = "XPathLexer.g4"
+
+ def __init__(self, input=None, output:TextIO = sys.stdout):
+ super().__init__(input, output)
+ self.checkVersion("4.9.3")
+ self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache())
+ self._actions = None
+ self._predicates = None
+
+
+ def action(self, localctx:RuleContext, ruleIndex:int, actionIndex:int):
+ if self._actions is None:
+ actions = dict()
+ actions[4] = self.ID_action
+ self._actions = actions
+ action = self._actions.get(ruleIndex, None)
+ if action is not None:
+ action(localctx, actionIndex)
+ else:
+ raise Exception("No registered action for:" + str(ruleIndex))
+
+
+ def ID_action(self, localctx:RuleContext , actionIndex:int):
+ if actionIndex == 0:
+
+ char = self.text[0]
+ if char.isupper():
+ self.type = XPathLexer.TOKEN_REF
+ else:
+ self.type = XPathLexer.RULE_REF
+
+
+
+
diff --git a/runtime/Python3/tests/expr/ExprLexer.py b/runtime/Python3/tests/expr/ExprLexer.py
index e909c5f540..e71a5123d7 100644
--- a/runtime/Python3/tests/expr/ExprLexer.py
+++ b/runtime/Python3/tests/expr/ExprLexer.py
@@ -1,46 +1,47 @@
-# Generated from expr/Expr.g4 by ANTLR 4.7.2
+# Generated from Expr.g4 by ANTLR 4.9.3
from antlr4 import *
from io import StringIO
-from typing.io import TextIO
import sys
+if sys.version_info[1] > 5:
+ from typing import TextIO
+else:
+ from typing.io import TextIO
def serializedATN():
- with StringIO() as buf:
- buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\23")
- buf.write("^\b\1\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7")
- buf.write("\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r\4\16")
- buf.write("\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22\3\2\3\2")
- buf.write("\3\2\3\2\3\3\3\3\3\4\3\4\3\5\3\5\3\6\3\6\3\7\3\7\3\b\3")
- buf.write("\b\3\t\3\t\3\n\3\n\3\13\3\13\3\f\3\f\3\r\3\r\3\16\3\16")
- buf.write("\3\16\3\16\3\16\3\16\3\16\3\17\6\17H\n\17\r\17\16\17I")
- buf.write("\3\20\6\20M\n\20\r\20\16\20N\3\21\5\21R\n\21\3\21\3\21")
- buf.write("\3\21\3\21\3\22\6\22Y\n\22\r\22\16\22Z\3\22\3\22\2\2\23")
- buf.write("\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31")
- buf.write("\16\33\17\35\20\37\21!\22#\23\3\2\5\4\2C\\c|\3\2\62;\4")
- buf.write("\2\13\13\"\"\2a\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2")
- buf.write("\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21")
- buf.write("\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3")
- buf.write("\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2")
- buf.write("\2\2#\3\2\2\2\3%\3\2\2\2\5)\3\2\2\2\7+\3\2\2\2\t-\3\2")
- buf.write("\2\2\13/\3\2\2\2\r\61\3\2\2\2\17\63\3\2\2\2\21\65\3\2")
- buf.write("\2\2\23\67\3\2\2\2\259\3\2\2\2\27;\3\2\2\2\31=\3\2\2\2")
- buf.write("\33?\3\2\2\2\35G\3\2\2\2\37L\3\2\2\2!Q\3\2\2\2#X\3\2\2")
- buf.write("\2%&\7f\2\2&\'\7g\2\2\'(\7h\2\2(\4\3\2\2\2)*\7*\2\2*\6")
- buf.write("\3\2\2\2+,\7.\2\2,\b\3\2\2\2-.\7+\2\2.\n\3\2\2\2/\60\7")
- buf.write("}\2\2\60\f\3\2\2\2\61\62\7\177\2\2\62\16\3\2\2\2\63\64")
- buf.write("\7=\2\2\64\20\3\2\2\2\65\66\7?\2\2\66\22\3\2\2\2\678\7")
- buf.write(",\2\28\24\3\2\2\29:\7\61\2\2:\26\3\2\2\2;<\7-\2\2<\30")
- buf.write("\3\2\2\2=>\7/\2\2>\32\3\2\2\2?@\7t\2\2@A\7g\2\2AB\7v\2")
- buf.write("\2BC\7w\2\2CD\7t\2\2DE\7p\2\2E\34\3\2\2\2FH\t\2\2\2GF")
- buf.write("\3\2\2\2HI\3\2\2\2IG\3\2\2\2IJ\3\2\2\2J\36\3\2\2\2KM\t")
- buf.write("\3\2\2LK\3\2\2\2MN\3\2\2\2NL\3\2\2\2NO\3\2\2\2O \3\2\2")
- buf.write("\2PR\7\17\2\2QP\3\2\2\2QR\3\2\2\2RS\3\2\2\2ST\7\f\2\2")
- buf.write("TU\3\2\2\2UV\b\21\2\2V\"\3\2\2\2WY\t\4\2\2XW\3\2\2\2Y")
- buf.write("Z\3\2\2\2ZX\3\2\2\2Z[\3\2\2\2[\\\3\2\2\2\\]\b\22\2\2]")
- buf.write("$\3\2\2\2\7\2INQZ\3\b\2\2")
- return buf.getvalue()
-
+ return [
+ 4,0,17,92,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,
+ 6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,
+ 7,13,2,14,7,14,2,15,7,15,2,16,7,16,1,0,1,0,1,0,1,0,1,1,1,1,1,2,1,
+ 2,1,3,1,3,1,4,1,4,1,5,1,5,1,6,1,6,1,7,1,7,1,8,1,8,1,9,1,9,1,10,1,
+ 10,1,11,1,11,1,12,1,12,1,12,1,12,1,12,1,12,1,12,1,13,4,13,70,8,13,
+ 11,13,12,13,71,1,14,4,14,75,8,14,11,14,12,14,76,1,15,3,15,80,8,15,
+ 1,15,1,15,1,15,1,15,1,16,4,16,87,8,16,11,16,12,16,88,1,16,1,16,0,
+ 0,17,1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,8,17,9,19,10,21,11,23,12,25,
+ 13,27,14,29,15,31,16,33,17,1,0,3,2,0,65,90,97,122,1,0,48,57,2,0,
+ 9,9,32,32,95,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,0,0,0,0,9,
+ 1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,15,1,0,0,0,0,17,1,0,0,0,0,19,
+ 1,0,0,0,0,21,1,0,0,0,0,23,1,0,0,0,0,25,1,0,0,0,0,27,1,0,0,0,0,29,
+ 1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,0,1,35,1,0,0,0,3,39,1,0,0,0,5,41,
+ 1,0,0,0,7,43,1,0,0,0,9,45,1,0,0,0,11,47,1,0,0,0,13,49,1,0,0,0,15,
+ 51,1,0,0,0,17,53,1,0,0,0,19,55,1,0,0,0,21,57,1,0,0,0,23,59,1,0,0,
+ 0,25,61,1,0,0,0,27,69,1,0,0,0,29,74,1,0,0,0,31,79,1,0,0,0,33,86,
+ 1,0,0,0,35,36,5,100,0,0,36,37,5,101,0,0,37,38,5,102,0,0,38,2,1,0,
+ 0,0,39,40,5,40,0,0,40,4,1,0,0,0,41,42,5,44,0,0,42,6,1,0,0,0,43,44,
+ 5,41,0,0,44,8,1,0,0,0,45,46,5,123,0,0,46,10,1,0,0,0,47,48,5,125,
+ 0,0,48,12,1,0,0,0,49,50,5,59,0,0,50,14,1,0,0,0,51,52,5,61,0,0,52,
+ 16,1,0,0,0,53,54,5,42,0,0,54,18,1,0,0,0,55,56,5,47,0,0,56,20,1,0,
+ 0,0,57,58,5,43,0,0,58,22,1,0,0,0,59,60,5,45,0,0,60,24,1,0,0,0,61,
+ 62,5,114,0,0,62,63,5,101,0,0,63,64,5,116,0,0,64,65,5,117,0,0,65,
+ 66,5,114,0,0,66,67,5,110,0,0,67,26,1,0,0,0,68,70,7,0,0,0,69,68,1,
+ 0,0,0,70,71,1,0,0,0,71,69,1,0,0,0,71,72,1,0,0,0,72,28,1,0,0,0,73,
+ 75,7,1,0,0,74,73,1,0,0,0,75,76,1,0,0,0,76,74,1,0,0,0,76,77,1,0,0,
+ 0,77,30,1,0,0,0,78,80,5,13,0,0,79,78,1,0,0,0,79,80,1,0,0,0,80,81,
+ 1,0,0,0,81,82,5,10,0,0,82,83,1,0,0,0,83,84,6,15,0,0,84,32,1,0,0,
+ 0,85,87,7,2,0,0,86,85,1,0,0,0,87,88,1,0,0,0,88,86,1,0,0,0,88,89,
+ 1,0,0,0,89,90,1,0,0,0,90,91,6,16,0,0,91,34,1,0,0,0,5,0,71,76,79,
+ 88,1,6,0,0
+ ]
class ExprLexer(Lexer):
@@ -86,7 +87,7 @@ class ExprLexer(Lexer):
def __init__(self, input=None, output:TextIO = sys.stdout):
super().__init__(input, output)
- self.checkVersion("4.9")
+ self.checkVersion("4.9.3")
self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache())
self._actions = None
self._predicates = None
diff --git a/runtime/Python3/tests/expr/ExprParser.py b/runtime/Python3/tests/expr/ExprParser.py
index 30ab327a6f..9e025b076c 100644
--- a/runtime/Python3/tests/expr/ExprParser.py
+++ b/runtime/Python3/tests/expr/ExprParser.py
@@ -1,41 +1,41 @@
-# Generated from expr/Expr.g4 by ANTLR 4.7.2
+# Generated from Expr.g4 by ANTLR 4.9.3
# encoding: utf-8
from antlr4 import *
from io import StringIO
-from typing.io import TextIO
import sys
+if sys.version_info[1] > 5:
+ from typing import TextIO
+else:
+ from typing.io import TextIO
def serializedATN():
- with StringIO() as buf:
- buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\23")
- buf.write("S\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b")
- buf.write("\t\b\3\2\6\2\22\n\2\r\2\16\2\23\3\3\3\3\3\3\3\3\3\3\3")
- buf.write("\3\7\3\34\n\3\f\3\16\3\37\13\3\3\3\3\3\3\3\3\4\3\4\6\4")
- buf.write("&\n\4\r\4\16\4\'\3\4\3\4\3\5\3\5\3\6\3\6\3\6\3\6\3\6\3")
- buf.write("\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\5\6;\n\6\3\7\3\7\3\7\3")
- buf.write("\7\3\7\3\7\3\7\3\7\3\7\7\7F\n\7\f\7\16\7I\13\7\3\b\3\b")
- buf.write("\3\b\3\b\3\b\3\b\5\bQ\n\b\3\b\2\3\f\t\2\4\6\b\n\f\16\2")
- buf.write("\4\3\2\13\f\3\2\r\16\2U\2\21\3\2\2\2\4\25\3\2\2\2\6#\3")
- buf.write("\2\2\2\b+\3\2\2\2\n:\3\2\2\2\f<\3\2\2\2\16P\3\2\2\2\20")
- buf.write("\22\5\4\3\2\21\20\3\2\2\2\22\23\3\2\2\2\23\21\3\2\2\2")
- buf.write("\23\24\3\2\2\2\24\3\3\2\2\2\25\26\7\3\2\2\26\27\7\20\2")
- buf.write("\2\27\30\7\4\2\2\30\35\5\b\5\2\31\32\7\5\2\2\32\34\5\b")
- buf.write("\5\2\33\31\3\2\2\2\34\37\3\2\2\2\35\33\3\2\2\2\35\36\3")
- buf.write("\2\2\2\36 \3\2\2\2\37\35\3\2\2\2 !\7\6\2\2!\"\5\6\4\2")
- buf.write("\"\5\3\2\2\2#%\7\7\2\2$&\5\n\6\2%$\3\2\2\2&\'\3\2\2\2")
- buf.write("\'%\3\2\2\2\'(\3\2\2\2()\3\2\2\2)*\7\b\2\2*\7\3\2\2\2")
- buf.write("+,\7\20\2\2,\t\3\2\2\2-.\5\f\7\2./\7\t\2\2/;\3\2\2\2\60")
- buf.write("\61\7\20\2\2\61\62\7\n\2\2\62\63\5\f\7\2\63\64\7\t\2\2")
- buf.write("\64;\3\2\2\2\65\66\7\17\2\2\66\67\5\f\7\2\678\7\t\2\2")
- buf.write("8;\3\2\2\29;\7\t\2\2:-\3\2\2\2:\60\3\2\2\2:\65\3\2\2\2")
- buf.write(":9\3\2\2\2;\13\3\2\2\2<=\b\7\1\2=>\5\16\b\2>G\3\2\2\2")
- buf.write("?@\f\5\2\2@A\t\2\2\2AF\5\f\7\6BC\f\4\2\2CD\t\3\2\2DF\5")
- buf.write("\f\7\5E?\3\2\2\2EB\3\2\2\2FI\3\2\2\2GE\3\2\2\2GH\3\2\2")
- buf.write("\2H\r\3\2\2\2IG\3\2\2\2JQ\7\21\2\2KQ\7\20\2\2LM\7\4\2")
- buf.write("\2MN\5\f\7\2NO\7\6\2\2OQ\3\2\2\2PJ\3\2\2\2PK\3\2\2\2P")
- buf.write("L\3\2\2\2Q\17\3\2\2\2\t\23\35\':EGP")
- return buf.getvalue()
-
+ return [
+ 4,1,17,81,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,
+ 6,1,0,4,0,16,8,0,11,0,12,0,17,1,1,1,1,1,1,1,1,1,1,1,1,5,1,26,8,1,
+ 10,1,12,1,29,9,1,1,1,1,1,1,1,1,2,1,2,4,2,36,8,2,11,2,12,2,37,1,2,
+ 1,2,1,3,1,3,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,
+ 3,4,57,8,4,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,5,5,68,8,5,10,5,12,
+ 5,71,9,5,1,6,1,6,1,6,1,6,1,6,1,6,3,6,79,8,6,1,6,0,1,10,7,0,2,4,6,
+ 8,10,12,0,2,1,0,9,10,1,0,11,12,83,0,15,1,0,0,0,2,19,1,0,0,0,4,33,
+ 1,0,0,0,6,41,1,0,0,0,8,56,1,0,0,0,10,58,1,0,0,0,12,78,1,0,0,0,14,
+ 16,3,2,1,0,15,14,1,0,0,0,16,17,1,0,0,0,17,15,1,0,0,0,17,18,1,0,0,
+ 0,18,1,1,0,0,0,19,20,5,1,0,0,20,21,5,14,0,0,21,22,5,2,0,0,22,27,
+ 3,6,3,0,23,24,5,3,0,0,24,26,3,6,3,0,25,23,1,0,0,0,26,29,1,0,0,0,
+ 27,25,1,0,0,0,27,28,1,0,0,0,28,30,1,0,0,0,29,27,1,0,0,0,30,31,5,
+ 4,0,0,31,32,3,4,2,0,32,3,1,0,0,0,33,35,5,5,0,0,34,36,3,8,4,0,35,
+ 34,1,0,0,0,36,37,1,0,0,0,37,35,1,0,0,0,37,38,1,0,0,0,38,39,1,0,0,
+ 0,39,40,5,6,0,0,40,5,1,0,0,0,41,42,5,14,0,0,42,7,1,0,0,0,43,44,3,
+ 10,5,0,44,45,5,7,0,0,45,57,1,0,0,0,46,47,5,14,0,0,47,48,5,8,0,0,
+ 48,49,3,10,5,0,49,50,5,7,0,0,50,57,1,0,0,0,51,52,5,13,0,0,52,53,
+ 3,10,5,0,53,54,5,7,0,0,54,57,1,0,0,0,55,57,5,7,0,0,56,43,1,0,0,0,
+ 56,46,1,0,0,0,56,51,1,0,0,0,56,55,1,0,0,0,57,9,1,0,0,0,58,59,6,5,
+ -1,0,59,60,3,12,6,0,60,69,1,0,0,0,61,62,10,3,0,0,62,63,7,0,0,0,63,
+ 68,3,10,5,4,64,65,10,2,0,0,65,66,7,1,0,0,66,68,3,10,5,3,67,61,1,
+ 0,0,0,67,64,1,0,0,0,68,71,1,0,0,0,69,67,1,0,0,0,69,70,1,0,0,0,70,
+ 11,1,0,0,0,71,69,1,0,0,0,72,79,5,15,0,0,73,79,5,14,0,0,74,75,5,2,
+ 0,0,75,76,3,10,5,0,76,77,5,4,0,0,77,79,1,0,0,0,78,72,1,0,0,0,78,
+ 73,1,0,0,0,78,74,1,0,0,0,79,13,1,0,0,0,7,17,27,37,56,67,69,78
+ ]
class ExprParser ( Parser ):
@@ -86,13 +86,15 @@ class ExprParser ( Parser ):
def __init__(self, input:TokenStream, output:TextIO = sys.stdout):
super().__init__(input, output)
- self.checkVersion("4.9")
+ self.checkVersion("4.9.3")
self._interp = ParserATNSimulator(self, self.atn, self.decisionsToDFA, self.sharedContextCache)
self._predicates = None
+
class ProgContext(ParserRuleContext):
+ __slots__ = 'parser'
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
super().__init__(parent, invokingState)
@@ -108,6 +110,14 @@ def func(self, i:int=None):
def getRuleIndex(self):
return ExprParser.RULE_prog
+ def enterRule(self, listener:ParseTreeListener):
+ if hasattr( listener, "enterProg" ):
+ listener.enterProg(self)
+
+ def exitRule(self, listener:ParseTreeListener):
+ if hasattr( listener, "exitProg" ):
+ listener.exitProg(self)
+
@@ -138,7 +148,9 @@ def prog(self):
self.exitRule()
return localctx
+
class FuncContext(ParserRuleContext):
+ __slots__ = 'parser'
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
super().__init__(parent, invokingState)
@@ -161,6 +173,14 @@ def body(self):
def getRuleIndex(self):
return ExprParser.RULE_func
+ def enterRule(self, listener:ParseTreeListener):
+ if hasattr( listener, "enterFunc" ):
+ listener.enterFunc(self)
+
+ def exitRule(self, listener:ParseTreeListener):
+ if hasattr( listener, "exitFunc" ):
+ listener.exitFunc(self)
+
@@ -203,7 +223,9 @@ def func(self):
self.exitRule()
return localctx
+
class BodyContext(ParserRuleContext):
+ __slots__ = 'parser'
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
super().__init__(parent, invokingState)
@@ -219,6 +241,14 @@ def stat(self, i:int=None):
def getRuleIndex(self):
return ExprParser.RULE_body
+ def enterRule(self, listener:ParseTreeListener):
+ if hasattr( listener, "enterBody" ):
+ listener.enterBody(self)
+
+ def exitRule(self, listener:ParseTreeListener):
+ if hasattr( listener, "exitBody" ):
+ listener.exitBody(self)
+
@@ -253,7 +283,9 @@ def body(self):
self.exitRule()
return localctx
+
class ArgContext(ParserRuleContext):
+ __slots__ = 'parser'
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
super().__init__(parent, invokingState)
@@ -265,6 +297,14 @@ def ID(self):
def getRuleIndex(self):
return ExprParser.RULE_arg
+ def enterRule(self, listener:ParseTreeListener):
+ if hasattr( listener, "enterArg" ):
+ listener.enterArg(self)
+
+ def exitRule(self, listener:ParseTreeListener):
+ if hasattr( listener, "exitArg" ):
+ listener.exitArg(self)
+
@@ -284,7 +324,9 @@ def arg(self):
self.exitRule()
return localctx
+
class StatContext(ParserRuleContext):
+ __slots__ = 'parser'
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
super().__init__(parent, invokingState)
@@ -312,6 +354,14 @@ def expr(self):
return self.getTypedRuleContext(ExprParser.ExprContext,0)
+ def enterRule(self, listener:ParseTreeListener):
+ if hasattr( listener, "enterRet" ):
+ listener.enterRet(self)
+
+ def exitRule(self, listener:ParseTreeListener):
+ if hasattr( listener, "exitRet" ):
+ listener.exitRet(self)
+
class BlankContext(StatContext):
@@ -320,6 +370,14 @@ def __init__(self, parser, ctx:ParserRuleContext): # actually a ExprParser.StatC
self.copyFrom(ctx)
+ def enterRule(self, listener:ParseTreeListener):
+ if hasattr( listener, "enterBlank" ):
+ listener.enterBlank(self)
+
+ def exitRule(self, listener:ParseTreeListener):
+ if hasattr( listener, "exitBlank" ):
+ listener.exitBlank(self)
+
class PrintExprContext(StatContext):
@@ -331,6 +389,14 @@ def expr(self):
return self.getTypedRuleContext(ExprParser.ExprContext,0)
+ def enterRule(self, listener:ParseTreeListener):
+ if hasattr( listener, "enterPrintExpr" ):
+ listener.enterPrintExpr(self)
+
+ def exitRule(self, listener:ParseTreeListener):
+ if hasattr( listener, "exitPrintExpr" ):
+ listener.exitPrintExpr(self)
+
class AssignContext(StatContext):
@@ -344,6 +410,14 @@ def expr(self):
return self.getTypedRuleContext(ExprParser.ExprContext,0)
+ def enterRule(self, listener:ParseTreeListener):
+ if hasattr( listener, "enterAssign" ):
+ listener.enterAssign(self)
+
+ def exitRule(self, listener:ParseTreeListener):
+ if hasattr( listener, "exitAssign" ):
+ listener.exitAssign(self)
+
def stat(self):
@@ -403,7 +477,9 @@ def stat(self):
self.exitRule()
return localctx
+
class ExprContext(ParserRuleContext):
+ __slots__ = 'parser'
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
super().__init__(parent, invokingState)
@@ -428,6 +504,14 @@ def primary(self):
return self.getTypedRuleContext(ExprParser.PrimaryContext,0)
+ def enterRule(self, listener:ParseTreeListener):
+ if hasattr( listener, "enterPrim" ):
+ listener.enterPrim(self)
+
+ def exitRule(self, listener:ParseTreeListener):
+ if hasattr( listener, "exitPrim" ):
+ listener.exitPrim(self)
+
class MulDivContext(ExprContext):
@@ -446,6 +530,14 @@ def MUL(self):
def DIV(self):
return self.getToken(ExprParser.DIV, 0)
+ def enterRule(self, listener:ParseTreeListener):
+ if hasattr( listener, "enterMulDiv" ):
+ listener.enterMulDiv(self)
+
+ def exitRule(self, listener:ParseTreeListener):
+ if hasattr( listener, "exitMulDiv" ):
+ listener.exitMulDiv(self)
+
class AddSubContext(ExprContext):
@@ -464,6 +556,14 @@ def ADD(self):
def SUB(self):
return self.getToken(ExprParser.SUB, 0)
+ def enterRule(self, listener:ParseTreeListener):
+ if hasattr( listener, "enterAddSub" ):
+ listener.enterAddSub(self)
+
+ def exitRule(self, listener:ParseTreeListener):
+ if hasattr( listener, "exitAddSub" ):
+ listener.exitAddSub(self)
+
def expr(self, _p:int=0):
@@ -543,7 +643,9 @@ def expr(self, _p:int=0):
self.unrollRecursionContexts(_parentctx)
return localctx
+
class PrimaryContext(ParserRuleContext):
+ __slots__ = 'parser'
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
super().__init__(parent, invokingState)
@@ -569,6 +671,14 @@ def expr(self):
return self.getTypedRuleContext(ExprParser.ExprContext,0)
+ def enterRule(self, listener:ParseTreeListener):
+ if hasattr( listener, "enterParens" ):
+ listener.enterParens(self)
+
+ def exitRule(self, listener:ParseTreeListener):
+ if hasattr( listener, "exitParens" ):
+ listener.exitParens(self)
+
class IdContext(PrimaryContext):
@@ -579,6 +689,14 @@ def __init__(self, parser, ctx:ParserRuleContext): # actually a ExprParser.Prima
def ID(self):
return self.getToken(ExprParser.ID, 0)
+ def enterRule(self, listener:ParseTreeListener):
+ if hasattr( listener, "enterId" ):
+ listener.enterId(self)
+
+ def exitRule(self, listener:ParseTreeListener):
+ if hasattr( listener, "exitId" ):
+ listener.exitId(self)
+
class IntContext(PrimaryContext):
@@ -589,6 +707,14 @@ def __init__(self, parser, ctx:ParserRuleContext): # actually a ExprParser.Prima
def INT(self):
return self.getToken(ExprParser.INT, 0)
+ def enterRule(self, listener:ParseTreeListener):
+ if hasattr( listener, "enterInt" ):
+ listener.enterInt(self)
+
+ def exitRule(self, listener:ParseTreeListener):
+ if hasattr( listener, "exitInt" ):
+ listener.exitInt(self)
+
def primary(self):
diff --git a/runtime/Python3/tests/run.py b/runtime/Python3/tests/run.py
index 5f842044fe..8eb442ce31 100644
--- a/runtime/Python3/tests/run.py
+++ b/runtime/Python3/tests/run.py
@@ -2,8 +2,8 @@
import os
src_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'src')
sys.path.insert(0,src_path)
-from TestTokenStreamRewriter import TestTokenStreamRewriter
from xpathtest import XPathTest
+#from TestTokenStreamRewriter import TestTokenStreamRewriter
from TestFileStream import TestFileStream
from TestInputStream import TestInputStream
from TestIntervalSet import TestIntervalSet
diff --git a/runtime/Swift/Sources/Antlr4/RuntimeMetaData.swift b/runtime/Swift/Sources/Antlr4/RuntimeMetaData.swift
index 8607ed2147..eb7afa44d5 100644
--- a/runtime/Swift/Sources/Antlr4/RuntimeMetaData.swift
+++ b/runtime/Swift/Sources/Antlr4/RuntimeMetaData.swift
@@ -63,7 +63,7 @@ public class RuntimeMetaData {
/// omitted, the `-` (hyphen-minus) appearing before it is also
/// omitted.
///
- public static let VERSION: String = "4.9.3"
+ public static let VERSION: String = "4.10"
///
/// Gets the currently executing version of the ANTLR 4 runtime library.
diff --git a/scripts/deploy.py b/scripts/deploy.py
new file mode 100644
index 0000000000..db6c18c10d
--- /dev/null
+++ b/scripts/deploy.py
@@ -0,0 +1,49 @@
+# Deploy targets, update version number at website, update Javadoc
+
+import sys
+
+WEBSITE_ROOT = '/Users/parrt/antlr/sites/website-antlr4'
+
+website_files_to_update = ['download.html',
+ 'index.html',
+ 'api/index.html',
+ 'scripts/topnav.js']
+
+def update_file(qfname, multi, before, after):
+ with open(qfname, "r", encoding="UTF-8") as f:
+ text = f.read()
+
+ if before not in text:
+ print(f"{before} not in {qfname}")
+ return
+
+ # Don't update if on > 1 line; too complex for tool
+ lines = text.split('\n')
+ count = sum(before in line for line in lines)
+ if count>1 and not multi:
+ print(f"{before} appears on {count} lines so _not_ updating {qfname}")
+
+ # print(f"{before} => {after} in {qfname}")
+ text = text.replace(before, after)
+ with open(qfname, "w", encoding="UTF-8") as f:
+ f.write(text)
+
+
+if __name__ == '__main__':
+ before = sys.argv[1]
+ after = sys.argv[2]
+ print(f"Updating ANTLR version from {before} to {after}")
+
+ root = input(f"Set ANTLR repo root (default {WEBSITE_ROOT}): ")
+ if len(root.strip())>0:
+ WEBSITE_ROOT = root
+
+ for fname in website_files_to_update:
+ qfname = WEBSITE_ROOT + "/" + fname
+ update_file(qfname, True, before, after)
+
+ print(f"WARNING: Manually update '{WEBSITE_ROOT}/download/index.html'")
+ print("THEN, run:")
+ print(f"cd {WEBSITE_ROOT}")
+ print(f"git commit -a -m 'add {after} jars'")
+ print("git push origin gh-pages")
diff --git a/scripts/files-to-update.txt b/scripts/files-to-update.txt
new file mode 100644
index 0000000000..6266712c85
--- /dev/null
+++ b/scripts/files-to-update.txt
@@ -0,0 +1,47 @@
+# The list of files with an antlr version number to update
+# generated initially from:
+# $ mvn clean
+# $ find tool runtime -type f -exec grep -l '4\.9' {} \; | grep -v -E '\.o|\.a|\.jar|\.dylib|node_modules/|\.class|tests/|CHANGELOG|\.zip|\.gz|.iml|.svg'
+#
+# Lines starting with '*' allow multiple changes in single file
+
+runtime/Go/antlr/recognizer.go
+runtime/Python3/setup.py
+runtime/Python3/src/antlr4/Recognizer.py
+runtime/Python2/setup.py
+runtime/Python2/src/antlr4/Recognizer.py
+runtime/Dart/pubspec.yaml
+runtime/Dart/lib/src/runtime_meta_data.dart
+runtime/Java/src/org/antlr/v4/runtime/RuntimeMetaData.java
+runtime/Cpp/demo/generate.cmd
+runtime/Cpp/cmake/Antlr4Package.md
+runtime/Cpp/cmake/README.md
+runtime/Cpp/cmake/ExternalAntlr4Cpp.cmake
+runtime/Cpp/cmake/FindANTLR.cmake
+runtime/Cpp/runtime/src/RuntimeMetaData.cpp
+runtime/Cpp/VERSION
+runtime/Swift/Sources/Antlr4/RuntimeMetaData.swift
+runtime/CSharp/src/README.md
+runtime/CSharp/src/Properties/AssemblyInfo.cs
+runtime/CSharp/src/Antlr4.csproj
+runtime/JavaScript/package-lock.json
+runtime/JavaScript/package.json
+runtime/JavaScript/src/antlr4/Recognizer.js
+
+# Allow doc files to have multiple values updated
+* doc/swift-target.md
+* doc/dart-target.md
+# doc/releasing-antlr.md # Do this one manually
+* doc/getting-started.md
+* doc/swift-target.md
+* doc/getting-started.md
+
+#runtime/Swift/Tests/Antlr4Tests/RuntimeMetaDataTests.swift This is special so must manually edit
+
+# Just documenting that these are generated...
+
+# runtime/Python3/src/antlr4/xpath/XPathLexer.py
+# runtime/Python2/src/antlr4/xpath/XPathLexer.py
+# runtime/Cpp/runtime/src/tree/xpath/XPathLexer.cpp
+# runtime/Cpp/runtime/src/tree/xpath/XPathLexer.h
+# runtime/CSharp/src/Tree/Xpath/XPathLexer.cs
diff --git a/scripts/update_antlr_version.py b/scripts/update_antlr_version.py
new file mode 100644
index 0000000000..2f0400b100
--- /dev/null
+++ b/scripts/update_antlr_version.py
@@ -0,0 +1,90 @@
+"""
+$ python update_antlr_version.py 4.9.3 4.10
+
+Read file
+"""
+import sys
+import os
+import subprocess
+
+
+def runme(cmd):
+ return subprocess.check_output(cmd.split(' '))
+
+
+def freshen(ROOT):
+ ok = input("Perform antlr4 `mvn clean` and wipe build dirs Y/N? (default no): ")
+ ok = ok.lower()
+ if ok.lower() != 'y' and ok !='yes':
+ print("Ok, not cleaning antlr4 dir")
+ return
+ # runme("mvn clean")
+ runme(f"rm -rf {ROOT}/runtime/CSharp/src/bin")
+ runme(f"rm -rf {ROOT}/runtime/CSharp/src/obj")
+ runme(f"rm -rf {ROOT}/runtime/Cpp/runtime/build")
+ runme(f"rm -rf {ROOT}/runtime/gen")
+ runme(f"rm -rf {ROOT}/runtime/JavaScript/dist")
+
+
+def get_change_list(fname):
+ files = {}
+ with open(fname, "r") as f:
+ for line in f.readlines():
+ line = line.strip()
+ if len(line)>0 and not line.startswith("#"):
+ if line.startswith('*'): # '*' implies change multiple lines
+ files[line[1:].strip()] = True
+ else:
+ files[line] = False
+
+ return files
+
+
+def update_file(qfname, multi, before, after):
+ with open(qfname, "r", encoding="UTF-8") as f:
+ text = f.read()
+
+ if before not in text:
+ print(f"{before} not in {qfname}")
+ return
+
+ # Don't update if on > 1 line; too complex for tool
+ lines = text.split('\n')
+ count = sum(before in line for line in lines)
+ if count>1 and not multi:
+ print(f"{before} appears on {count} lines so _not_ updating {qfname}")
+
+ # print(f"{before} => {after} in {qfname}")
+ text = text.replace(before, after)
+ with open(qfname, "w", encoding="UTF-8") as f:
+ f.write(text)
+
+
+def update_files(ROOT, before, after):
+ files = get_change_list(f"{ROOT}/scripts/files-to-update.txt")
+ for fname,multi in files.items():
+ update_file(f"{ROOT}/{fname}", multi, before, after)
+
+
+def find_remaining(ROOT, before):
+ return
+
+
+if __name__ == '__main__':
+ # This is where parrt puts antlr
+ ROOT = f"{os.path.expanduser('~')}/antlr/code/antlr4"
+ # ROOT = f"/tmp/antlr4" # for testing, it's nice to have diff target
+
+ before = sys.argv[1]
+ after = sys.argv[2]
+ print(f"Updating ANTLR version from {before} to {after}")
+
+ root = input(f"Set ANTLR repo root (default {ROOT}): ")
+ if len(root.strip())>0:
+ ROOT = root
+
+ freshen(ROOT)
+
+ update_files(ROOT, before, after)
+
+ find_remaining(ROOT, before)
diff --git a/tool/pom.xml b/tool/pom.xml
index 09489aedcd..6d69f3c013 100644
--- a/tool/pom.xml
+++ b/tool/pom.xml
@@ -29,12 +29,12 @@
org.antlr
antlr-runtime
- 3.5.2
+ 3.5.3-SNAPSHOT
org.antlr
ST4
- 4.3.1
+ 4.3.2
org.abego.treelayout
@@ -147,7 +147,7 @@
org.antlr
antlr3-maven-plugin
- 3.5.2
+ 3.5.3-SNAPSHOT
src
true
diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/Swift/Swift.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/Swift/Swift.stg
index fdfeb0477f..861348a330 100755
--- a/tool/resources/org/antlr/v4/tool/templates/codegen/Swift/Swift.stg
+++ b/tool/resources/org/antlr/v4/tool/templates/codegen/Swift/Swift.stg
@@ -353,7 +353,7 @@ func getVocabulary() -> Vocabulary {
override
init(_ input:TokenStream) throws {
- RuntimeMetaData.checkVersion("4.9.3", RuntimeMetaData.VERSION)
+ RuntimeMetaData.checkVersion("", RuntimeMetaData.VERSION)
try super.init(input)
_interp = ParserATNSimulator(self,._ATN,._decisionToDFA, ._sharedContextCache)
}