Merge branch 'master' into add/docker

This commit is contained in:
ericvergnaud 2021-01-29 10:01:30 +08:00 committed by GitHub
commit 9e4036fd89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
572 changed files with 27958 additions and 9464 deletions

66
.circleci/config.yml Normal file
View File

@ -0,0 +1,66 @@
version: 2.1
jobs:
test_tool_and_runtime_java:
docker:
- image: cimg/openjdk:8.0
steps:
- checkout
- run:
name: build tool
command: mvn -B -V -DskipTests=true -Dmaven.javadoc.skip=true install
- run:
name: test runtime
command: |
cd runtime-testsuite
mvn -q -Dparallel=methods -DthreadCount=4 -Dtest=java.* test
cd ..
- run:
name: test tool
command: |
cd tool-testsuite
mvn -q -Dparallel=methods -DthreadCount=4 test
cd ..
test_runtime:
parameters:
test-group:
description: The section
type: string
default: ALL
target:
description: The target
type: string
default: java
docker:
- image: cimg/openjdk:8.0
environment:
TARGET: << parameters.target >>
GROUP: << parameters.test-group >>
steps:
- checkout
- run:
name: Install << parameters.target >> pre-requisites
command: |
f=".circleci/scripts/install-linux-<< parameters.target >>.sh"; ! [ -x "$f" ] || "$f"
- run:
name: Build ANTLR4 tool
command: mvn -B -V -DskipTests=true -Dmaven.javadoc.skip=true install
- run:
name: Test << parameters.target >> runtime
command: |
.circleci/scripts/run-tests-<< parameters.target >>.sh
workflows:
build:
jobs:
- test_tool_and_runtime_java
- test_runtime:
matrix:
parameters:
target: [ dart, go, python2, python3, javascript ]
- test_runtime:
matrix:
parameters:
# target: [ cpp, dotnet, swift ]
target: [ cpp, dotnet ]
test-group: [ LEXER, PARSER, RECURSION ]

View File

@ -0,0 +1,35 @@
#!/bin/bash
set -euo pipefail
echo "installing cpp SDK..."
sudo apt-get update -y
sudo apt-get install -y clang
sudo apt-get install -y cmake
sudo apt-get install -y pkg-config
sudo apt-get install -y uuid-dev
echo "done installing cpp SDK"
clang++ --version
cmake --version
echo "building cpp runtime..."
pushd "runtime/Cpp/"
echo $PWD
rc=0
if [ $rc == 0 ]; then
cmake . -DCMAKE_BUILD_TYPE=release
rc=$?
fi
if [ $rc == 0 ]; then
make -j 8
rc=$?
fi
popd
echo "done building cpp runtime"

View File

@ -0,0 +1,14 @@
#!/bin/bash
set -euo pipefail
echo "installing dart SDK..."
sudo apt-get update
sudo apt-get install apt-transport-https
sudo sh -c 'wget -qO- https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -'
sudo sh -c 'wget -qO- https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list'
sudo apt-get update
sudo apt-get install dart=2.8.4-1
export PATH="$PATH:/usr/lib/dart/bin"
echo "done installing dart SDK"
sudo apt-get install -f

View File

@ -0,0 +1,19 @@
#!/bin/bash
set -euo pipefail
echo "installing .Net SDK..."
wget https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update; \
sudo apt-get install -y apt-transport-https && \
sudo apt-get update && \
sudo apt-get install -y dotnet-sdk-3.1
export PATH=$PATH:~/.dotnet
echo "done installing .Net SDK"
# we need to build the runtime before test run, since we used "--no-dependencies"
# when we call dotnet cli for restore and build, in order to speed up
echo "building runtime..."
dotnet build -c Release -f netstandard2.0 runtime/CSharp/Antlr4.csproj
echo "done building runtime"

View File

@ -0,0 +1,9 @@
#!/bin/bash
set -euo pipefail
echo "installing go SDK..."
sudo apt update
sudo apt install golang-go
go version
echo "done installing go SDK"

View File

@ -0,0 +1,17 @@
#!/bin/bash
set -euo pipefail
# use v14 and check
echo "installing nodejs..."
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
echo node version: $(node --version)
echo "done installing nodejs..."
echo "packaging javascript runtime..."
pushd runtime/JavaScript
sudo npm install
sudo npm link
popd
echo "done packaging javascript runtime"

View File

@ -0,0 +1,24 @@
#!/bin/bash
echo "before patching"
ls -all /lib/x86_64-linux-gnu/ | grep libcurl
# This would fix missing CURL_OPENSSL_3
# use a dedicated temp dir in the user space
mkdir ~/libcurl3
cd ~/libcurl3
# fetch latest libcurl3
wget http://archive.ubuntu.com/ubuntu/pool/main/c/curl/libcurl3_7.47.0-1ubuntu2_amd64.deb
# extract data.tar.xz
ar x libcurl3* data.tar.xz
# extract all from data.tar.xz
tar xf data.tar.xz
# copy libcurl.so.3 where required
sudo cp -L ~/libcurl3/usr/lib/x86_64-linux-gnu/libcurl.so.4.4.0 /lib/x86_64-linux-gnu/libcurl.so.4.4.0
sudo ln -sf libcurl.so.4.4.0 /lib/x86_64-linux-gnu/libcurl.so.4
cd ..
# drop dedicated temp dir
sudo rm -rf ~/libcurl3
echo "after patching"
ls -all /lib/x86_64-linux-gnu/ | grep libcurl

View File

@ -3,6 +3,9 @@
set -euo pipefail
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/debian xenial main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update -qq
sudo apt-get install -qq mono-complete
php -v
git clone https://github.com/antlr/antlr-php-runtime.git
mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V

View File

@ -0,0 +1,8 @@
#!/bin/bash
set -euo pipefail
echo "installing python 2..."
sudo apt-get update -y
sudo apt-get install python2
echo "done installing python 2"

View File

@ -0,0 +1,8 @@
#!/bin/bash
set -euo pipefail
echo "installing python 3..."
sudo apt-get update -y
sudo apt-get install python3
echo "done installing python 3"

View File

@ -0,0 +1,36 @@
#!/bin/bash
set -euo pipefail
echo "installing swift SDK..."
.circleci/scripts/install-linux-libcurl3.sh
# see https://tecadmin.net/install-swift-ubuntu-1604-xenial/
sudo apt-get update -y
sudo apt-get install clang libicu-dev
sudo apt-get install libpython2.7 libpython2.7-dev
export SWIFT_VERSION=swift-5.3.2
echo "installing gpg key..."
wget -q -O - https://swift.org/keys/all-keys.asc | sudo gpg --import -
echo "downloading SDK gpg key..."
SWIFT_SDK=https://swift.org/builds/$SWIFT_VERSION-release/ubuntu1604/$SWIFT_VERSION-RELEASE/$SWIFT_VERSION-RELEASE-ubuntu16.04.tar.gz
echo $SWIFT_SDK
wget -q $SWIFT_SDK
sudo tar xzf $SWIFT_VERSION-RELEASE-ubuntu16.04.tar.gz
mv $SWIFT_VERSION-RELEASE-ubuntu16.04 $PWD/swift
export SWIFT_HOME=$PWD/swift/$SWIFT_VERSION-RELEASE-ubuntu16.04/usr/bin/
export PATH=$PWD/swift/usr/bin:$PATH
# This would fix a know linker issue mentioned in: # https://bugs.swift.org/browse/SR-2299
sudo ln -sf ld.gold /usr/bin/ld
# This would fix missing libtinfo.so.5
sudo apt install libncurses5
echo "done installing swift SDK..."
# check swift
swift --version
swift build --version

View File

@ -0,0 +1,17 @@
#!/bin/bash
set -euo pipefail
pushd runtime-testsuite
echo "running maven tests..."
if [ $GROUP == "LEXER" ]; then
mvn -q -Dgroups="org.antlr.v4.test.runtime.category.LexerTests" -Dtest=cpp.* test
elif [ $GROUP == "PARSER" ]; then
mvn -q -Dgroups="org.antlr.v4.test.runtime.category.ParserTests" -Dtest=cpp.* test
elif [ $GROUP == "RECURSION" ]; then
mvn -q -Dgroups="org.antlr.v4.test.runtime.category.LeftRecursionTests" -Dtest=cpp.* test
else
mvn -q -Dtest=cpp.* test
fi
popd

View File

@ -0,0 +1,11 @@
#!/bin/bash
set -euo pipefail
dart --version
pushd runtime-testsuite
echo "running maven tests..."
# mvn -q -Dparallel=classes -DthreadCount=4 -Dtest=dart.* test
mvn -q -Dtest=dart.* test
popd

View File

@ -0,0 +1,16 @@
#!/bin/bash
set -euo pipefail
pushd runtime-testsuite/
echo "running maven tests..."
if [ $GROUP == "LEXER" ]; then
mvn -q -Dgroups="org.antlr.v4.test.runtime.category.LexerTests" -Dtest=csharp.* test
elif [ $GROUP == "PARSER" ]; then
mvn -q -Dgroups="org.antlr.v4.test.runtime.category.ParserTests" -Dtest=csharp.* test
elif [ $GROUP == "RECURSION" ]; then
mvn -q -Dgroups="org.antlr.v4.test.runtime.category.LeftRecursionTests" -Dtest=csharp.* test
else
mvn -q -Dtest=csharp.* test
fi
popd

View File

@ -0,0 +1,10 @@
#!/bin/bash
set -euo pipefail
go version
pushd runtime-testsuite
echo "running maven tests..."
mvn -q -Dparallel=methods -DthreadCount=4 -Dtest=go.* test
popd

View File

@ -0,0 +1,8 @@
#!/bin/bash
set -euo pipefail
pushd runtime-testsuite
echo "running maven tests..."
mvn -q -Dtest=javascript.* test
popd

View File

@ -0,0 +1,9 @@
#!/bin/bash
set -euo pipefail
php_path=$(which php)
composer install -d ../runtime/PHP
mvn -q -DPHP_PATH="${php_path}" -Dparallel=methods -DthreadCount=4 -Dtest=php.* test

View File

@ -0,0 +1,24 @@
#!/bin/bash
set -euo pipefail
python2 --version
pushd runtime/Python2/tests
echo "running native tests..."
python2 run.py
rc=$?
if [ $rc != 0 ]; then
echo "failed running native tests"
fi
popd
if [ $rc == 0 ]; then
pushd runtime-testsuite
echo "running maven tests..."
mvn -q -Dtest=python2.* test
rc=$?
popd
fi
# return $rc

View File

@ -0,0 +1,24 @@
#!/bin/bash
set -euo pipefail
python3 --version
pushd runtime/Python3/tests
echo "running native tests..."
python3 run.py
rc=$?
if [ $rc != 0 ]; then
echo "failed running native tests"
fi
popd
if [ $rc == 0 ]; then
pushd runtime-testsuite
echo "running maven tests..."
mvn -q -Dtest=python3.* test
rc=$?
popd
fi
# return $rc

View File

@ -0,0 +1,27 @@
#!/bin/bash
set -euo pipefail
pushd runtime/Swift
echo "running native tests..."
./boot.py --test
rc=$?
if [ $rc != 0 ]; then
echo "failed running native tests"
fi
popd
if [ $rc == 0 ]; then
pushd runtime-testsuite
echo "running maven tests..."
if [ $GROUP == "LEXER" ]; then
mvn -q -Dgroups="org.antlr.v4.test.runtime.category.LexerTests" -Dtest=swift.* test
elif [ $GROUP == "PARSER" ]; then
mvn -q -Dgroups="org.antlr.v4.test.runtime.category.ParserTests" -Dtest=swift.* test
elif [ $GROUP == "RECURSION" ]; then
mvn -q -Dgroups="org.antlr.v4.test.runtime.category.LeftRecursionTests" -Dtest=swift.* test
else
mvn -q -Dtest=swift.* test
fi
popd
fi

1112
.github/scripts/install-dotnet-on-osx.sh vendored Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,30 @@
Sharing the trouble of getting github action runners to work on a mac coming straight out of the factory, running Big Sur
XCode (you need XCode to build the Swift runtime):
- install XCode from the Mac App Store
- Launch it, this will force installation of components
- Go to Preferences -> Locations and select XCode as Command Line Tools
Brew (you need Brew to install maven):
- get the script from https://brew.sh
- once installed, run the following:
echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> /Users/{user-account}/.zprofile
eval $(/opt/homebrew/bin/brew shellenv)
(you need to repeat these last steps for each user account)
Maven (supposedly installed by the github workflow, but it's convenient to have a global install for troubleshooting):
- brew install maven
JDK (we need a specific JDK):
- download openjdk8 from Oracle (later versions break the build due to some packages having disappeared)
- install it -> this will mess up your JAVA_HOME completely, pointing to /Library/Internet...
- fix the JAVA_HOME mess as follows:
sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefpane
C++:
- brew install cmake
C#:
- .github/scripts/install-dotnet-on-osx.sh
(you need to repeat this step for each user account)

15
.github/scripts/run-tests-cpp.sh vendored Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
set -euo pipefail
cd runtime-testsuite/
if [ $GROUP == "LEXER" ]; then
mvn -q -Dgroups="org.antlr.v4.test.runtime.category.LexerTests" -Dtest=cpp.* test
elif [ $GROUP == "PARSER" ]; then
mvn -q -Dgroups="org.antlr.v4.test.runtime.category.ParserTests" -Dtest=cpp.* test
elif [ $GROUP == "RECURSION" ]; then
mvn -q -Dgroups="org.antlr.v4.test.runtime.category.LeftRecursionTests" -Dtest=cpp.* test
else
mvn -q -Dtest=cpp.* test
fi

23
.github/scripts/run-tests-dotnet.sh vendored Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash
set -euo pipefail
export PATH=$PATH:~/.dotnet
# we need to build the runtime before test run, since we used "--no-dependencies"
# when we call dotnet cli for restore and build, in order to speed up
dotnet build -c Release -f netstandard2.0 runtime/CSharp/Antlr4.csproj
# run tests
cd runtime-testsuite/
if [ $GROUP == "LEXER" ]; then
mvn -q -Dgroups="org.antlr.v4.test.runtime.category.LexerTests" -Dtest=csharp.* test
elif [ $GROUP == "PARSER" ]; then
mvn -q -Dgroups="org.antlr.v4.test.runtime.category.ParserTests" -Dtest=csharp.* test
elif [ $GROUP == "RECURSION" ]; then
mvn -q -Dgroups="org.antlr.v4.test.runtime.category.LeftRecursionTests" -Dtest=csharp.* test
else
mvn -q -Dtest=csharp.* test
fi

50
.github/scripts/run-tests-swift.sh vendored Executable file
View File

@ -0,0 +1,50 @@
#!/bin/bash
set -euo pipefail
# linux specific setup, those setup have to be
# here since environment variables doesn't pass
# across scripts
if [ $RUNNER_OS == "Linux" ]; then
export SWIFT_VERSION=swift-5.0.1
export SWIFT_HOME=$(pwd)/swift/$SWIFT_VERSION-RELEASE-ubuntu16.04/usr/bin/
export PATH=$SWIFT_HOME:$PATH
# download swift
mkdir swift
curl https://swift.org/builds/$SWIFT_VERSION-release/ubuntu1604/$SWIFT_VERSION-RELEASE/$SWIFT_VERSION-RELEASE-ubuntu16.04.tar.gz -s | tar xz -C swift &> /dev/null
fi
if [ -z "${JAVA_HOME}" ]
then
export JAVA_HOME="$(java -XshowSettings:properties -version 2>&1 |
grep 'java\.home' | awk '{ print $3 }')"
fi
echo "export JAVA_HOME=$JAVA_HOME"
# check swift
swift --version
swift build --version
# run swift tests
pushd runtime/Swift
./boot.py --test
rc=$?
popd
if [ $rc == 0 ]; then
# run java tests
cd runtime-testsuite/
if [ $GROUP == "LEXER" ]; then
mvn -e -q -Dgroups="org.antlr.v4.test.runtime.category.LexerTests" -Dtest="swift.*" test
elif [ $GROUP == "PARSER" ]; then
mvn -e -q -Dgroups="org.antlr.v4.test.runtime.category.ParserTests" -Dtest="swift.*" test
elif [ $GROUP == "RECURSION" ]; then
mvn -e -q -Dgroups="org.antlr.v4.test.runtime.category.LeftRecursionTests" -Dtest="swift.*" test
else
mvn -e -q -Dtest=swift.* test
fi
rc=$?
cat target/surefire-reports/*.dumpstream || true
fi
exit $rc

34
.github/workflows/macosx.yml vendored Normal file
View File

@ -0,0 +1,34 @@
name: MacOSX
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: [self-hosted, macOS, x64]
strategy:
fail-fast: false
matrix:
# TARGET: [swift, cpp, dotnet] disabling dotnet which is unstable on M1
TARGET: [swift, cpp]
GROUP: [LEXER, PARSER, RECURSION]
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Set up Maven
uses: stCarolas/setup-maven@v4
with:
maven-version: 3.5.4
- name: Build tool with Maven
run: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
- name: Test with Maven
run: arch -x86_64 .github/scripts/run-tests-${{ matrix.TARGET }}.sh
env:
TARGET: ${{ matrix.TARGET }}
GROUP: ${{ matrix.GROUP }}

7
.gitignore vendored
View File

@ -3,7 +3,7 @@ target/
# ... but not code generation targets
!tool/src/org/antlr/v4/codegen/target/
# Node.js (npm and typings) cached dependencies
# Node.js (npm and typings) cached dependencies
node_modules/
typings/
@ -97,4 +97,7 @@ xcuserdata
# VSCode Java plugin temporary files
javac-services.0.log
javac-services.0.log.lck
test/
# Don't ignore python tests
!runtime/Python3/test/
Antlr4.sln

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "runtime/PHP"]
path = runtime/PHP
url = https://github.com/antlr/antlr-php-runtime.git

View File

@ -12,108 +12,12 @@ cache:
- $HOME/Library/Caches/Homebrew
stages:
- smoke-test
- main-test
# - smoke-test
# - main-test
- extended-test
matrix:
include:
- os: linux
dist: trusty
compiler: clang
jdk: openjdk8
env:
- TARGET=cpp
- CXX=g++-5
- GROUP=LEXER
stage: main-test
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.7
packages:
- g++-5
- uuid-dev
- clang-3.7
- os: linux
dist: trusty
compiler: clang
jdk: openjdk8
env:
- TARGET=cpp
- CXX=g++-5
- GROUP=PARSER
stage: main-test
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.7
packages:
- g++-5
- uuid-dev
- clang-3.7
- os: linux
dist: trusty
compiler: clang
jdk: openjdk8
env:
- TARGET=cpp
- CXX=g++-5
- GROUP=RECURSION
stage: main-test
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.7
packages:
- g++-5
- uuid-dev
- clang-3.7
- os: osx
compiler: clang
osx_image: xcode10.2
env:
- TARGET=cpp
- GROUP=LEXER
stage: extended-test
- os: osx
compiler: clang
osx_image: xcode10.2
env:
- TARGET=cpp
- GROUP=PARSER
stage: extended-test
- os: osx
compiler: clang
osx_image: xcode10.2
env:
- TARGET=cpp
- GROUP=RECURSION
stage: extended-test
- os: osx
compiler: clang
osx_image: xcode10.2
env:
- TARGET=swift
- GROUP=LEXER
stage: main-test
- os: osx
compiler: clang
osx_image: xcode10.2
env:
- TARGET=swift
- GROUP=PARSER
stage: main-test
- os: osx
compiler: clang
osx_image: xcode10.2
env:
- TARGET=swift
- GROUP=RECURSION
stage: main-test
- os: linux
dist: xenial
compiler: clang
@ -121,89 +25,6 @@ matrix:
- TARGET=swift
- GROUP=ALL
stage: extended-test
- os: osx
osx_image: xcode10.2
env:
- TARGET=dotnet
- GROUP=LEXER
stage: extended-test
- os: osx
osx_image: xcode10.2
env:
- TARGET=dotnet
- GROUP=PARSER
stage: extended-test
- os: osx
osx_image: xcode10.2
env:
- TARGET=dotnet
- GROUP=RECURSION
stage: extended-test
- os: linux
dist: trusty
jdk: openjdk7
env: TARGET=java
stage: extended-test
- os: linux
jdk: openjdk8
env: TARGET=java
stage: smoke-test
- os: linux
jdk: openjdk8
env: TARGET=csharp
stage: main-test
- os: linux
language: php
php:
- 7.2
jdk: openjdk8
env: TARGET=php
stage: main-test
- os: linux
jdk: openjdk8
dist: trusty
env:
- TARGET=dotnet
- GROUP=LEXER
stage: extended-test
- os: linux
jdk: openjdk8
dist: trusty
env:
- TARGET=dotnet
- GROUP=PARSER
stage: extended-test
- os: linux
jdk: openjdk8
dist: trusty
env:
- TARGET=dotnet
- GROUP=RECURSION
stage: extended-test
- os: linux
jdk: openjdk8
env: TARGET=python2
stage: main-test
- os: linux
jdk: openjdk8
env: TARGET=python3
addons:
apt:
sources:
- deadsnakes # source required so it finds the package definition below
packages:
- python3.7
stage: main-test
- os: linux
dist: trusty
jdk: openjdk8
env: TARGET=javascript
stage: main-test
- os: linux
dist: trusty
jdk: openjdk8
env: TARGET=go
stage: main-test
before_install:
- f="./.travis/before-install-$TRAVIS_OS_NAME-$TARGET.sh"; ! [ -x "$f" ] || "$f"
@ -211,7 +32,7 @@ before_install:
script:
- |
cd runtime-testsuite;
travis_wait 40 ../.travis/run-tests-$TARGET.sh;
rc=$?;
cat target/surefire-reports/*.dumpstream || true;
travis_wait 40 ../.travis/run-tests-$TARGET.sh
rc=$?
cat target/surefire-reports/*.dumpstream || true
exit $rc

View File

@ -0,0 +1,7 @@
#!/bin/bash
set -euo pipefail
wget https://storage.googleapis.com/dart-archive/channels/stable/release/2.8.4/linux_packages/dart_2.8.4-1_amd64.deb
sudo dpkg -i ./dart_2.8.4-1_amd64.deb
sudo rm ./dart_2.8.4-1_amd64.deb
sudo apt-get install -f

View File

@ -2,9 +2,9 @@
set -euo pipefail
# install dotnet
sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 417A0893
sudo apt-get update
sudo apt-get --allow-unauthenticated install dotnet-dev-1.0.4
wget https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update; \
sudo apt-get install -y apt-transport-https && \
sudo apt-get update && \
sudo apt-get install -y dotnet-sdk-3.1

View File

@ -2,7 +2,6 @@
set -euo pipefail
sudo apt-get update -qq
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -qq nodejs
node --version
# use v14 and check
echo node version: $(node --version)

View File

@ -7,4 +7,5 @@ sudo apt-get update -qq
php -v
git clone https://github.com/antlr/antlr-php-runtime.git
mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +0,0 @@
#!/bin/bash
set -euo pipefail
mvn -q -Dparallel=methods -DthreadCount=4 -Dtest=csharp.* test

4
.travis/run-tests-dart.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
set -euo pipefail
mvn -q -Dparallel=classes -DthreadCount=4 -Dtest=dart.* test

View File

@ -2,20 +2,21 @@
set -euo pipefail
export PATH=$PATH:/Users/travis/.dotnet
# we need to build the runtime before test run, since we used "--no-dependencies"
# when we call dotnet cli for restore and build, in order to speed up
dotnet restore ../runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.dotnet.csproj
dotnet build -c Release -f netstandard1.3 ../runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.dotnet.csproj
dotnet build -c Release -f netstandard2.0 ../runtime/CSharp/Antlr4.csproj
# call test
if [ $GROUP == "LEXER" ]; then
mvn -q -Dgroups="org.antlr.v4.test.runtime.category.LexerTests" -Dparallel=classes -DthreadCount=4 -Dtest=csharp.* -Dantlr-csharp-netstandard=true test
mvn -q -Dgroups="org.antlr.v4.test.runtime.category.LexerTests" -Dparallel=classes -DthreadCount=4 -Dtest=csharp.* test
elif [ $GROUP == "PARSER" ]; then
mvn -q -Dgroups="org.antlr.v4.test.runtime.category.ParserTests" -Dparallel=classes -DthreadCount=4 -Dtest=csharp.* -Dantlr-csharp-netstandard=true test
mvn -q -Dgroups="org.antlr.v4.test.runtime.category.ParserTests" -Dparallel=classes -DthreadCount=4 -Dtest=csharp.* test
elif [ $GROUP == "RECURSION" ]; then
mvn -q -Dgroups="org.antlr.v4.test.runtime.category.LeftRecursionTests" -Dparallel=classes -DthreadCount=4 -Dtest=csharp.* -Dantlr-csharp-netstandard=true test
mvn -q -Dgroups="org.antlr.v4.test.runtime.category.LeftRecursionTests" -Dparallel=classes -DthreadCount=4 -Dtest=csharp.* test
else
mvn -q -Dparallel=classes -DthreadCount=4 -Dtest=csharp.* -Dantlr-csharp-netstandard=true test
mvn -q -Dparallel=methods -DthreadCount=4 -Dtest=csharp.* test
fi

View File

@ -2,4 +2,8 @@
set -euo pipefail
mvn -q -Dparallel=methods -DthreadCount=4 -Dtest=javascript.* test
cd ../runtime/JavaScript
npm install
npm link
cd ../../runtime-testsuite
mvn -q -Dparallel=methods -DthreadCount=1 -Dtest=javascript.* test

View File

@ -1,6 +1,14 @@
# ANTLR v4
[![Build Travis-CI Status](https://travis-ci.org/antlr/antlr4.svg?branch=master)](https://travis-ci.org/antlr/antlr4) [![Build AppVeyor Status](https://ci.appveyor.com/api/projects/status/5acpbx1pg7bhgh8v/branch/master?svg=true)](https://ci.appveyor.com/project/parrt/antlr4) [![Java 7+](https://img.shields.io/badge/java-7+-4c7e9f.svg)](http://java.oracle.com) [![License](https://img.shields.io/badge/license-BSD-blue.svg)](https://raw.githubusercontent.com/antlr/antlr4/master/LICENSE.txt)
[![Java 7+](https://img.shields.io/badge/java-7+-4c7e9f.svg)](http://java.oracle.com)
[![License](https://img.shields.io/badge/license-BSD-blue.svg)](https://raw.githubusercontent.com/antlr/antlr4/master/LICENSE.txt)
**Build status**
[![Github CI Build Status (MacOSX)](https://img.shields.io/github/workflow/status/antlr/antlr4/MacOSX?label=MacOSX)](https://github.com/antlr/antlr4/actions)
[![AppVeyor CI Build Status (Windows)](https://img.shields.io/appveyor/build/parrt/antlr4?label=Windows)](https://ci.appveyor.com/project/parrt/antlr4)
[![Circle CI Build Status (Linux)](https://img.shields.io/circleci/build/gh/antlr/antlr4/master?label=Linux)](https://app.circleci.com/pipelines/github/antlr/antlr4)
[![Travis-CI Build Status (Swift-Linux)](https://img.shields.io/travis/antlr/antlr4.svg?label=Linux-Swift&branch=master)](https://travis-ci.com/github/antlr/antlr4)
**ANTLR** (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files. It's widely used to build languages, tools, and frameworks. From a grammar, ANTLR generates a parser that can build parse trees and also generates a listener interface (or visitor) that makes it easy to respond to the recognition of phrases of interest.
@ -13,8 +21,8 @@
* [Terence Parr](http://www.cs.usfca.edu/~parrt/), parrt@cs.usfca.edu
ANTLR project lead and supreme dictator for life
[University of San Francisco](http://www.usfca.edu/)
* [Sam Harwell](http://tunnelvisionlabs.com/) (Tool co-author, Java and C# target)
* Eric Vergnaud (Javascript, Python2, Python3 targets and significant work on C# target)
* [Sam Harwell](http://tunnelvisionlabs.com/) (Tool co-author, Java and original C# target)
* [Eric Vergnaud](https://github.com/ericvergnaud) (Javascript, Python2, Python3 targets and maintenance of C# target)
* [Peter Boyer](https://github.com/pboyer) (Go target)
* [Mike Lischke](http://www.soft-gems.net/) (C++ completed target)
* Dan McLaughlin (C++ initial target)
@ -23,6 +31,7 @@ ANTLR project lead and supreme dictator for life
* [Ewan Mellor](https://github.com/ewanmellor), [Hanzhou Shi](https://github.com/hanjoes) (Swift target merging)
* [Ben Hamilton](https://github.com/bhamiltoncx) (Full Unicode support in serialized ATN and all languages' runtimes for code points > U+FFFF)
* [Marcos Passos](https://github.com/marcospassos) (PHP target)
* [Lingyu Li](https://github.com/lingyv-li) (Dart target)
## Useful information

View File

@ -8,7 +8,7 @@
<parent>
<groupId>org.antlr</groupId>
<artifactId>antlr4-master</artifactId>
<version>4.8-2-SNAPSHOT</version>
<version>4.9.2-SNAPSHOT</version>
</parent>
<artifactId>antlr4-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
@ -64,7 +64,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
<dependency>
@ -120,7 +120,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.3</version>
<version>3.6.0</version>
<configuration>
<!-- see http://jira.codehaus.org/browse/MNG-5346 -->
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>

View File

@ -17,7 +17,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
</dependencies>

View File

@ -17,7 +17,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
</dependencies>

View File

@ -17,7 +17,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
</dependencies>

View File

@ -17,7 +17,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
</dependencies>

View File

@ -1,21 +1,22 @@
version: '4.7.1-SNAPSHOT+AppVeyor.{build}'
version: '4.9.1-SNAPSHOT+AppVeyor.{build}'
cache:
- '%USERPROFILE%\.m2'
- '%USERPROFILE%\.nuget\packages -> **\project.json'
image: Visual Studio 2017
image: Visual Studio 2019
build: off
install:
- git submodule update --init --recursive
- git clone https://github.com/antlr/antlr-php-runtime.git
- mv antlr-php-runtime runtime/PHP
- cinst -y php --params "/InstallDir:C:\tools\php"
- cinst -y composer
- cinst -y dart-sdk --version=2.8.4
build_script:
- mvn -DskipTests install --batch-mode
- msbuild /target:restore /target:rebuild /property:Configuration=Release /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /verbosity:detailed runtime/CSharp/runtime/CSharp/Antlr4.dotnet.sln
- msbuild ./runtime-testsuite/target/classes/CSharp/runtime/CSharp/Antlr4.vs2013.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /verbosity:detailed
after_build:
- msbuild /target:pack /property:Configuration=Release /verbosity:detailed runtime/CSharp/runtime/CSharp/Antlr4.dotnet.sln
- dotnet build runtime/CSharp/Antlr4.csproj -c Release
after_build:
- dotnet pack runtime/CSharp/Antlr4.csproj -c Release
test_script:
- mvn install -Dantlr-php-php="C:\tools\php\php.exe" -Dantlr-python2-python="C:\Python27\python.exe" -Dantlr-python3-python="C:\Python35\python.exe" -Dantlr-javascript-nodejs="C:\Program Files (x86)\nodejs\node.exe" --batch-mode
- mvn install -Dantlr-php-php="C:\tools\php\php.exe" -Dantlr-dart-dart="C:\tools\dart-sdk\bin\dart.exe" -Dantlr-dart-pub="C:\tools\dart-sdk\bin\pub.bat" -Dantlr-dart-dart2native="C:\tools\dart-sdk\bin\dart2native.bat" -Dantlr-python2-python="C:\Python27\python.exe" -Dantlr-python3-python="C:\Python35\python.exe" --batch-mode
artifacts:
- path: 'runtime\**\*.nupkg'
name: NuGet
- path: 'runtime\**\*.nupkg'
name: NuGet

View File

@ -1,64 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Antlr4.Runtime</id>
<version>0.0.0</version>
<authors>Sam Harwell, Terence Parr</authors>
<owners>Sam Harwell</owners>
<description>The runtime library for parsers generated by the C# target of ANTLR 4. This package supports projects targeting .NET 2.0 or newer, and built using Visual Studio 2008 or newer.</description>
<language>en-us</language>
<projectUrl>https://github.com/sharwell/antlr4cs</projectUrl>
<licenseUrl>https://raw.github.com/sharwell/antlr4cs/master/LICENSE.txt</licenseUrl>
<iconUrl>https://raw.github.com/antlr/website-antlr4/master/images/icons/antlr.png</iconUrl>
<copyright>Copyright © Sam Harwell 2014</copyright>
<releaseNotes>https://github.com/sharwell/antlr4cs/releases/v$version$</releaseNotes>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<tags>antlr antlr4 parsing</tags>
<title>ANTLR 4 Runtime</title>
<summary>The runtime library for parsers generated by the C# target of ANTLR 4.</summary>
</metadata>
<files>
<!-- Runtime Libraries -->
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\net20\$Configuration$\Antlr4.Runtime.dll" target="lib\net20"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\net20\$Configuration$\Antlr4.Runtime.pdb" target="lib\net20"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\net20\$Configuration$\Antlr4.Runtime.xml" target="lib\net20"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\net30\$Configuration$\Antlr4.Runtime.dll" target="lib\net30"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\net30\$Configuration$\Antlr4.Runtime.pdb" target="lib\net30"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\net30\$Configuration$\Antlr4.Runtime.xml" target="lib\net30"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\net35-client\$Configuration$\Antlr4.Runtime.dll" target="lib\net35-client"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\net35-client\$Configuration$\Antlr4.Runtime.pdb" target="lib\net35-client"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\net35-client\$Configuration$\Antlr4.Runtime.xml" target="lib\net35-client"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\net40-client\$Configuration$\Antlr4.Runtime.dll" target="lib\net40-client"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\net40-client\$Configuration$\Antlr4.Runtime.pdb" target="lib\net40-client"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\net40-client\$Configuration$\Antlr4.Runtime.xml" target="lib\net40-client"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\net45\$Configuration$\Antlr4.Runtime.dll" target="lib\net45"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\net45\$Configuration$\Antlr4.Runtime.pdb" target="lib\net45"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\net45\$Configuration$\Antlr4.Runtime.xml" target="lib\net45"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\net35-cf\$Configuration$\Antlr4.Runtime.dll" target="lib\net35-cf"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\net35-cf\$Configuration$\Antlr4.Runtime.pdb" target="lib\net35-cf"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\net35-cf\$Configuration$\Antlr4.Runtime.xml" target="lib\net35-cf"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\portable-net40\$Configuration$\Antlr4.Runtime.dll" target="lib\portable-net4+sl5+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\portable-net40\$Configuration$\Antlr4.Runtime.pdb" target="lib\portable-net4+sl5+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\portable-net40\$Configuration$\Antlr4.Runtime.xml" target="lib\portable-net4+sl5+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\portable-net45\$Configuration$\Antlr4.Runtime.dll" target="lib\portable-net45+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\portable-net45\$Configuration$\Antlr4.Runtime.pdb" target="lib\portable-net45+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\portable-net45\$Configuration$\Antlr4.Runtime.xml" target="lib\portable-net45+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\netcore45\$Configuration$\Antlr4.Runtime.dll" target="lib\netcore45"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\netcore45\$Configuration$\Antlr4.Runtime.pdb" target="lib\netcore45"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\bin\netcore45\$Configuration$\Antlr4.Runtime.xml" target="lib\netcore45"/>
<!-- Source Code -->
<file exclude="..\runtime\CSharp\Antlr4.Runtime\obj\**\*.cs" src="..\runtime\CSharp\Antlr4.Runtime\**\*.cs" target="src"/>
<file src="..\runtime\CSharp\Antlr4.Runtime\**\$Configuration$\*Lexer.cs" target="src"/>
</files>
</package>

View File

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata minClientVersion="2.7">
<id>Antlr4.VS2008</id>
<version>0.0.0</version>
<authors>Sam Harwell, Terence Parr</authors>
<owners>Sam Harwell</owners>
<description>The C# target of the ANTLR 4 parser generator for Visual Studio 2008 projects. This package supports projects targeting .NET 2.0 or newer, and built using Visual Studio 2008.</description>
<language>en-us</language>
<projectUrl>https://github.com/sharwell/antlr4cs</projectUrl>
<licenseUrl>https://raw.github.com/sharwell/antlr4cs/master/LICENSE.txt</licenseUrl>
<iconUrl>https://raw.github.com/antlr/website-antlr4/master/images/icons/antlr.png</iconUrl>
<copyright>Copyright © Sam Harwell 2014</copyright>
<releaseNotes>https://github.com/sharwell/antlr4cs/releases/v$version$</releaseNotes>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<developmentDependency>true</developmentDependency>
<tags>antlr antlr4 parsing</tags>
<title>ANTLR 4 (Visual Studio 2008)</title>
<summary>The C# target of the ANTLR 4 parser generator for Visual Studio 2008 projects.</summary>
<dependencies>
<dependency id="Antlr4.Runtime" version="$version$" />
</dependencies>
</metadata>
<files>
<!-- Tools -->
<file src="..\tool\target\antlr4-csharp-$CSharpToolVersion$-complete.jar" target="tools"/>
<!-- Build Configuration -->
<file src="..\runtime\CSharp\Antlr4BuildTasks\bin\net35\$Configuration$\Antlr4.net35.props" target="build\Antlr4.props"/>
<file src="..\runtime\CSharp\Antlr4BuildTasks\bin\net35\$Configuration$\Antlr4.net35.targets" target="build\Antlr4.targets"/>
<file src="..\runtime\CSharp\Antlr4BuildTasks\bin\net35\$Configuration$\Antlr4BuildTasks.net35.dll" target="build"/>
</files>
</package>

View File

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata minClientVersion="2.7">
<id>Antlr4</id>
<version>0.0.0</version>
<authors>Sam Harwell, Terence Parr</authors>
<owners>Sam Harwell</owners>
<description>The C# target of the ANTLR 4 parser generator for Visual Studio 2010+ projects. This package supports projects targeting .NET 2.0 or newer, and built using Visual Studio 2010 or newer.</description>
<language>en-us</language>
<projectUrl>https://github.com/sharwell/antlr4cs</projectUrl>
<licenseUrl>https://raw.github.com/sharwell/antlr4cs/master/LICENSE.txt</licenseUrl>
<iconUrl>https://raw.github.com/antlr/website-antlr4/master/images/icons/antlr.png</iconUrl>
<copyright>Copyright © Sam Harwell 2014</copyright>
<releaseNotes>https://github.com/sharwell/antlr4cs/releases/v$version$</releaseNotes>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<developmentDependency>true</developmentDependency>
<tags>antlr antlr4 parsing</tags>
<title>ANTLR 4</title>
<summary>The C# target of the ANTLR 4 parser generator for Visual Studio 2010+ projects.</summary>
<dependencies>
<dependency id="Antlr4.Runtime" version="$version$" />
</dependencies>
</metadata>
<files>
<!-- Tools -->
<file src="..\tool\target\antlr4-csharp-$CSharpToolVersion$-complete.jar" target="tools"/>
<!-- Build Configuration -->
<file src="..\runtime\CSharp\Antlr4BuildTasks\bin\net40\$Configuration$\Antlr4.net40.props" target="build\Antlr4.props"/>
<file src="..\runtime\CSharp\Antlr4BuildTasks\bin\net40\$Configuration$\Antlr4.net40.targets" target="build\Antlr4.targets"/>
<file src="..\runtime\CSharp\Antlr4BuildTasks\bin\net40\$Configuration$\Antlr4BuildTasks.net40.dll" target="build"/>
</files>
</package>

View File

@ -1,139 +0,0 @@
param (
[switch]$Debug,
[string]$VisualStudioVersion = "12.0",
[switch]$NoClean,
[string]$Java6Home,
[string]$MavenHome,
[string]$MavenRepo = "$($env:USERPROFILE)\.m2",
[switch]$SkipMaven,
[switch]$SkipKeyCheck
)
# build the solutions
$SolutionPath = "..\Runtime\CSharp\Antlr4.sln"
$CF35SolutionPath = "..\Runtime\CSharp\Antlr4.VS2008.sln"
# make sure the script was run from the expected path
if (!(Test-Path $SolutionPath)) {
echo "The script was run from an invalid working directory."
exit 1
}
. .\version.ps1
If ($Debug) {
$BuildConfig = 'Debug'
} Else {
$BuildConfig = 'Release'
}
If ($NoClean) {
$Target = 'build'
} Else {
$Target = 'rebuild'
}
If (-not $MavenHome) {
$MavenHome = $env:M2_HOME
}
$Java6RegKey = 'HKLM:\SOFTWARE\JavaSoft\Java Runtime Environment\1.6'
$Java6RegValue = 'JavaHome'
If (-not $Java6Home -and (Test-Path $Java6RegKey)) {
$JavaHomeKey = Get-Item -LiteralPath $Java6RegKey
If ($JavaHomeKey.GetValue($Java6RegValue, $null) -ne $null) {
$JavaHomeProperty = Get-ItemProperty $Java6RegKey $Java6RegValue
$Java6Home = $JavaHomeProperty.$Java6RegValue
}
}
# this is configured here for path checking, but also in the .props and .targets files
[xml]$pom = Get-Content "..\tool\pom.xml"
$CSharpToolVersionNodeInfo = Select-Xml "/mvn:project/mvn:version" -Namespace @{mvn='http://maven.apache.org/POM/4.0.0'} $pom
$CSharpToolVersion = $CSharpToolVersionNodeInfo.Node.InnerText.trim()
# build the main project
$msbuild = "$env:windir\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe"
&$msbuild '/nologo' '/m' '/nr:false' "/t:$Target" "/p:Configuration=$BuildConfig" "/p:VisualStudioVersion=$VisualStudioVersion" $SolutionPath
if ($LASTEXITCODE -ne 0) {
$host.ui.WriteErrorLine('Build failed, aborting!')
exit $p.ExitCode
}
# build the compact framework project
$msbuild = "$env:windir\Microsoft.NET\Framework\v4.0.30319\msbuild.exe"
&$msbuild '/nologo' '/m' '/nr:false' '/t:rebuild' "/p:Configuration=$BuildConfig" $CF35SolutionPath
if ($LASTEXITCODE -ne 0) {
$host.ui.WriteErrorLine('.NET 3.5 Compact Framework Build failed, aborting!')
exit $p.ExitCode
}
if (-not (Test-Path 'nuget')) {
mkdir "nuget"
}
# Build the Java library using Maven
If (-not $SkipMaven) {
$OriginalPath = $PWD
cd '..\tool'
$MavenPath = "$MavenHome\bin\mvn.bat"
If (-not (Test-Path $MavenPath)) {
$host.ui.WriteErrorLine("Couldn't locate Maven binary: $MavenPath")
cd $OriginalPath
exit 1
}
If (-not (Test-Path $Java6Home)) {
$host.ui.WriteErrorLine("Couldn't locate Java 6 installation: $Java6Home")
cd $OriginalPath
exit 1
}
$MavenGoal = 'package'
&$MavenPath '-DskipTests=true' '--errors' '-e' '-Dgpg.useagent=true' "-Djava6.home=$Java6Home" '-Psonatype-oss-release' $MavenGoal
if ($LASTEXITCODE -ne 0) {
$host.ui.WriteErrorLine('Maven build of the C# Target custom Tool failed, aborting!')
cd $OriginalPath
exit $p.ExitCode
}
cd $OriginalPath
}
$JarPath = "..\tool\target\antlr4-csharp-$CSharpToolVersion-complete.jar"
if (!(Test-Path $JarPath)) {
$host.ui.WriteErrorLine("Couldn't locate the complete jar used for building C# parsers: $JarPath")
exit 1
}
# By default, do not create a NuGet package unless the expected strong name key files were used
if (-not $SkipKeyCheck) {
. .\keys.ps1
foreach ($pair in $Keys.GetEnumerator()) {
$assembly = Resolve-FullPath -Path "..\runtime\CSharp\Antlr4.Runtime\bin\$($pair.Key)\$BuildConfig\Antlr4.Runtime.dll"
# Run the actual check in a separate process or the current process will keep the assembly file locked
powershell -Command ".\check-key.ps1 -Assembly '$assembly' -ExpectedKey '$($pair.Value)' -Build '$($pair.Key)'"
if ($LASTEXITCODE -ne 0) {
Exit $p.ExitCode
}
}
}
$packages = @(
'Antlr4.Runtime'
'Antlr4'
'Antlr4.VS2008')
$nuget = '..\runtime\CSharp\.nuget\NuGet.exe'
ForEach ($package in $packages) {
If (-not (Test-Path ".\$package.nuspec")) {
$host.ui.WriteErrorLine("Couldn't locate NuGet package specification: $package")
exit 1
}
&$nuget 'pack' ".\$package.nuspec" '-OutputDirectory' 'nuget' '-Prop' "Configuration=$BuildConfig" '-Version' "$AntlrVersion" '-Prop' "M2_REPO=$M2_REPO" '-Prop' "CSharpToolVersion=$CSharpToolVersion" '-Symbols'
}

View File

@ -1,31 +0,0 @@
param(
[string]$Assembly,
[string]$ExpectedKey,
[string]$Build = $null
)
function Get-PublicKeyToken() {
param([string]$assembly = $null)
if ($assembly) {
$bytes = $null
$bytes = [System.Reflection.Assembly]::ReflectionOnlyLoadFrom($assembly).GetName().GetPublicKeyToken()
if ($bytes) {
$key = ""
for ($i=0; $i -lt $bytes.Length; $i++) {
$key += "{0:x2}" -f $bytes[$i]
}
$key
}
}
}
if (-not $Build) {
$Build = $Assembly
}
$actual = Get-PublicKeyToken -assembly $Assembly
if ($actual -ne $ExpectedKey) {
$host.ui.WriteErrorLine("Invalid publicKeyToken for '$Build'; expected '$ExpectedKey' but found '$actual'")
exit 1
}

View File

@ -1,17 +0,0 @@
# Note: these values may only change during minor release
$Keys = @{
'net20' = '7983ae52036899ac'
'net30' = '7671200403f6656a'
'net35-cf' = '770a97458f51159e'
'net35-client' = '4307381ae04f9aa7'
'net40-client' = 'bb1075973a9370c4'
'net45' = 'edc21c04cf562012'
'netcore45' = 'e4e9019902d0b6e2'
'portable-net40' = '90bf14da8e1462b4'
'portable-net45' = '3d23c8e77559f391'
}
function Resolve-FullPath() {
param([string]$Path)
[System.IO.Path]::GetFullPath((Join-Path (pwd) $Path))
}

View File

@ -1,29 +0,0 @@
. .\version.ps1
If ($AntlrVersion.EndsWith('-dev')) {
$host.ui.WriteErrorLine("Cannot push development version '$AntlrVersion' to NuGet.")
Exit 1
}
$packages = @(
'Antlr4.Runtime'
'Antlr4'
'Antlr4.VS2008')
# Make sure all packages exist before pushing any packages
ForEach ($package in $packages) {
If (-not (Test-Path ".\nuget\$package.$AntlrVersion.nupkg")) {
$host.ui.WriteErrorLine("Couldn't locate NuGet package: $JarPath")
exit 1
}
If (-not (Test-Path ".\nuget\$package.$AntlrVersion.symbols.nupkg")) {
$host.ui.WriteErrorLine("Couldn't locate NuGet symbols package: $JarPath")
exit 1
}
}
$nuget = '..\runtime\CSharp\.nuget\NuGet.exe'
ForEach ($package in $packages) {
&$nuget 'push' ".\nuget\$package.$AntlrVersion.nupkg"
}

View File

@ -1 +0,0 @@
$AntlrVersion = "4.5.1"

View File

@ -208,6 +208,7 @@ YYYY/MM/DD, github id, Full name, email
2018/07/03, jgoppert, James Goppert, james.goppert@gmail.com
2018/07/27, Maksim Novikov, mnovikov.work@gmail.com
2018/08/03, ENDOH takanao, djmchl@gmail.com
2018/10/08, xsIceman, Andreas Skaar, andreas.skaar@gmail.com
2018/10/18, edirgarcia, Edir García Lazo, edirgl@hotmail.com
2018/07/31, Lucas Henrqiue, lucashenrique580@gmail.com
2018/08/03, ENDOH takanao, djmchl@gmail.com
@ -218,34 +219,70 @@ YYYY/MM/DD, github id, Full name, email
2018/11/29, hannemann-tamas, Ralf Hannemann-Tamas, ralf.ht@gmail.com
2018/12/20, WalterCouto, Walter Couto, WalterCouto@users.noreply.github.com
2018/12/23, youkaichao, Kaichao You, youkaichao@gmail.com
2019/01/01, khoroshilov, Alexey Khoroshilov, khoroshilov@ispras.ru
2019/01/02, wkhemir, Wail Khemir, khemirwail@gmail.com
2019/01/16, kuegi, Markus Zancolo, markus.zancolo@roomle.com
2019/02/06, ralucado, Cristina Raluca Vijulie, ralucris.v[at]gmail[dot]com
2019/02/23, gedimitr, Gerasimos Dimitriadis, gedimitr@gmail.com
2019/03/13, base698, Justin Thomas, justin.thomas1@gmail.com
2019/03/18, carlodri, Carlo Dri, carlo.dri@gmail.com
2019/05/02, askingalot, Andy Collins, askingalot@gmail.com
2019/05/13, mapio, Massimo Santini, massimo.santini@gmail.com
2019/07/11, olowo726, Olof Wolgast, olof@baah.se
2019/07/16, abhijithneilabraham, Abhijith Neil Abraham, abhijithneilabrahampk@gmail.com
2019/07/26, Braavos96, Eric Hettiaratchi, erichettiaratchi@gmail.com
2019/08/02, thron7, Thomas Herchenroeder, thron7[at]users[dot]sourceforge[dot]net
2019/08/12, easonlin404, Eason Lin, easonlin404@gmail.com
2019/08/23, akaJes, Oleksandr Mamchyts, akaJes@gmail.com
2019/08/27, wurzelpeter, Markus Franke, markus[hyphen]franke[at]web[dot]de
2019/09/10, ImanHosseini, Iman Hosseini, hosseini.iman@yahoo.com
2019/09/03, João Henrique, johnnyonflame@hotmail.com
2019/09/10, neko1235, Ihar Mokharau, igor.mohorev@gmail.com
2019/09/10, yar3333, Yaroslav Sivakov, yar3333@gmail.com
2019/09/10, marcospassos, Marcos Passos, marcospassos.com@gmail.com
2019/09/10, amorimjuliana, Juliana Amorim, juu.amorim@gmail.com
2019/09/15, sullis, Sean Sullivan, github@seansullivan.com
2019/09/17, kaz, Kazuki Sawada, kazuki@6715.jp
2019/09/28, lmy269, Mingyang Liu, lmy040758@gmail.com
2019/10/29, tehbone, Tabari Alexander, tehbone@gmail.com
2019/10/31, a-square, Alexei Averchenko, lex.aver@gmail.com
2019/11/05, listba, Ben List, ben.list89@gmail.com
2019/11/11, foxeverl, Liu Xinfeng, liuxf1986[at]gmail[dot]com
2019/11/17, felixn, Felix Nieuwenhuizhen, felix@tdlrali.com
2019/11/18, mlilback, Mark Lilback, mark@lilback.com
2020/01/19, lingyv-li, Lingyu Li, lingyv.li@gmail.com
2020/02/02, carocad, Camilo Roca, carocad@unal.edu.co
2020/02/10, julibert, Julián Bermúdez Ortega, julibert.dev@gmail.com
2020/02/17, quantumsheep, Nathanael Demacon, nathanael.dmc@outlook.fr
2020/02/21, StochasticTinkr, Daniel Pitts, github@coloraura.com
2020/03/17, XsongyangX, Song Yang, songyang1218@gmail.com
2020/04/07, deniskyashif, Denis Kyashif, denis.kyashif@gmail.com
2020/04/08, lwehmeier, Leon Wehmeier, wehmeier@st.ovgu.de
2020/04/10, agrabski, Adam Grabski, adam.gr@outlook.com
2020/04/23, martinvw, Martin van Wingerden, martin@martinvw.nl
2020/04/23, kaczmarj, Jakub Kaczmarzyk, jakub.kaczmarzyk@stonybrookmedicine.edu
2020/04/30, TristonianJones, Tristan Swadell, tswadell@google.com
2020/05/06, iammosespaulr, Moses Paul R, iammosespaulr@gmail.com
2020/05/10, gomerser, Erik Gomersbach, gomerser@gomersba.ch
2020/05/22, keywan-ghadami-oxid, Keywan Ghadami, keywan.ghadami@oxid-esales.com
2020/05/25, graknol, Sindre van der Linden, graknol@gmail.com
2020/05/31, d-markey, David Markey, dmarkey@free.fr
2020/06/02, cohomology, Kilian Kilger, kkilger AT gmail.com
2020/06/04, IohannRabeson, Iohann Rabeson, iotaka6@gmail.com
2020/06/04, sigmasoldi3r, Pablo Blanco, pablobc.1995@gmail.com
2020/07/01, sha-N, Shan M Mathews, admin@bluestarqatar.com
2020/08/22, stevenjohnstone, Steven Johnstone, steven.james.johnstone@gmail.com
2020/09/06, ArthurSonzogni, Sonzogni Arthur, arthursonzogni@gmail.com
2020/09/10, Khailian, Arunav Sanyal, arunav.sanyal91@gmail.com
2020/09/12, Clcanny, Charles Ruan, a837940593@gmail.com
2020/09/15, rmcgregor1990, Robert McGregor, rmcgregor1990@gmail.com
2020/09/16, trenki2, Markus Trenkwalder, trenki2[at]gmx[dot]net
2020/10/08, Marti2203, Martin Mirchev, mirchevmartin2203@gmail.com
2020/10/16, adarshbhat, Adarsh Bhat, adarshbhat@users.noreply.github.com
2020/10/20, adamwojs, Adam Wójs, adam[at]wojs.pl
2020/10/24, cliid, Jiwu Jang, jiwujang@naver.com
2020/11/05, MichelHartmann, Michel Hartmann, MichelHartmann@users.noreply.github.com
2020/11/26, mr-c, Michael R. Crusoe, 1330696+mr-c@users.noreply.github.com
2020/12/01, maxence-lefebvre, Maxence Lefebvre, maxence-lefebvre@users.noreply.github.com
2020/12/03, electrum, David Phillips, david@acz.org
2021/01/25, l215884529, Qiheng Liu, 13607681+l215884529@users.noreply.github.com

View File

@ -84,7 +84,7 @@ Using a rule label looks like this:
returnStat : 'return' e=expr {System.out.println("matched "+e.text);} ;
```
You can also use `$ followed by the name of the attribute to access the value associated with the currently executing rule. For example, `$start` is the starting token of the current rule.
You can also use `$` followed by the name of the attribute to access the value associated with the currently executing rule. For example, `$start` is the starting token of the current rule.
```
returnStat : 'return' expr {System.out.println("first token "+$start.getText());} ;

View File

@ -1,6 +1,6 @@
# C++
The C++ target supports all platforms that can either run MS Visual Studio 2013 (or newer), XCode 7 (or newer) or CMake (C++11 required). All build tools can either create static or dynamic libraries, both as 64bit or 32bit arch. Additionally, XCode can create an iOS library. Also see [Antlr4 for C++ with CMake: A practical example](http://blorente.me//Antlr-,-C++-and-CMake-Wait-what.html).
The C++ target supports all platforms that can either run MS Visual Studio 2013 (or newer), XCode 7 (or newer) or CMake (C++11 required). All build tools can either create static or dynamic libraries, both as 64bit or 32bit arch. Additionally, XCode can create an iOS library. Also see [Antlr4 for C++ with CMake: A practical example](http://blorente.me/beyond-the-loop/Antlr-cpp-cmake/).
## How to create a C++ lexer or parser?
This is pretty much the same as creating a Java lexer or parser, except you need to specify the language target, for example:
@ -65,7 +65,7 @@ int main(int argc, const char* argv[]) {
tree::ParseTree *tree = parser.key();
TreeShapeListener listener;
tree::ParseTreeWalker::DEFAULT->walk(&listener, tree);
tree::ParseTreeWalker::DEFAULT.walk(&listener, tree);
return 0;
}
@ -74,7 +74,7 @@ int main(int argc, const char* argv[]) {
This example assumes your grammar contains a parser rule named `key` for which the enterKey function was generated.
## Specialities of this ANTLR target
## Special cases for this ANTLR target
There are a couple of things that only the C++ ANTLR target has to deal with. They are described here.

View File

@ -10,6 +10,8 @@ Creating a new target involves the following key elements:
1. Create *X*.stg in directory tool/resources/org/antlr/v4/tool/templates/codegen/*X*/*X*.stg. This is a [StringTemplate](http://www.stringtemplate.org/) group file (`.stg`) that tells ANTLR how to express all of the parsing elements needed to generate code. You will see templates called `ParserFile`, `Parser`, `Lexer`, `CodeBlockForAlt`, `AltBlock`, etc... Each of these must be described how to build the indicated chunk of code. Your best bet is to find the closest existing target, copy that template file, and tweak to suit.
1. Create a runtime library to support the parsers generated by ANTLR. Under directory runtime/*X*, you are in complete control of the directory structure as dictated by common usage of that target language. For example, Java has: `runtime/Java/lib` and `runtime/Java/src` directories. Under `src`, you will find a directory structure for package `org.antlr.v4.runtime` and below.
1. Create a template file for runtime tests. All you have to do is provide a few templates that indicate how to print values and declare variables. Our runtime test mechanism in dir `runtime-testsuite` will automatically generate code using these templates for each target and check the test results. It needs to know how to define various class fields, compare members and so on. You must create a *X*.test.stg file underneath [runtime-testsuite/resources/org/antlr/v4/test/runtime](https://github.com/antlr/antlr4/tree/master/runtime-testsuite/resources/org/antlr/v4/test/runtime). Again, your best bet is to copy the templates from the closest language to your target and tweak it to suit.
1. Create test files under [/runtime-testsuite/test/org/antlr/v4/test/runtime](https://github.com/antlr/antlr4/tree/master/runtime-testsuite/test/org/antlr/v4/test/runtime). They will load defined test cases in each test descriptor. Also add the `/runtime-testsuite/test/org/antlr/v4/test/runtime/X/BaseXTest.java` which defines how test cases will execute and output.
1. Create/edit shell scripts in [/.travis](https://github.com/antlr/antlr4/blob/master/.travis) and [/appveyor.yml](https://github.com/antlr/antlr4/blob/master/appveyor.yml) to run tests in CI pipelines.
## Getting started

View File

@ -86,7 +86,7 @@ In order to execute this listener, you would simply add the following lines to t
...
IParseTree tree = parser.StartRule() - only repeated here for reference
KeyPrinter printer = new KeyPrinter();
ParseTreeWalker.DEFAULT.walk(printer, tree);
ParseTreeWalker.Default.Walk(printer, tree);
```
Further information can be found from The Definitive ANTLR Reference book.

117
doc/dart-target.md Normal file
View File

@ -0,0 +1,117 @@
# ANTLR4 Runtime for Dart
Notice: Dart target may generate code incompatible with Dart 2.9 sound null safety. Please set the minimum SDK constraint to 2.8.4 or lower if such violation is found. Contributions are welcomed.
### First steps
#### 1. Install ANTLR4
[The getting started guide](https://github.com/antlr/antlr4/blob/master/doc/getting-started.md)
should get you started.
#### 2. Install the Dart ANTLR runtime
Each target language for ANTLR has a runtime package for running parser
generated by ANTLR4. The runtime provides a common set of tools for using your parser.
Install the runtime with the same version as the main ANTLR tool:
Add this to your package's pubspec.yaml file:
```yaml
...
dependencies:
antlr4: <ANTLR version>
...
```
#### 3. Generate your parser
You use the ANTLR4 "tool" to generate a parser. These will reference the ANTLR
runtime, installed above.
Suppose you're using a UNIX system and have set up an alias for the ANTLR4 tool
as described in [the getting started guide](https://github.com/antlr/antlr4/blob/master/doc/getting-started.md).
To generate your Dart parser, run the following command:
```shell script
antlr4 -Dlanguage=Dart MyGrammar.g4
```
For a full list of antlr4 tool options, please visit the
[tool documentation page](https://github.com/antlr/antlr4/blob/master/doc/tool-options.md).
### Complete example
Suppose you're using the JSON grammar from https://github.com/antlr/grammars-v4/tree/master/json.
Then, invoke `antlr4 -Dlanguage=Dart JSON.g4`. The result of this is a
collection of `.dart` including:
* JsonLexer.dart
* JsonParser.dart
* JsonBaseListener.dart
* JsonListener.dart (if you have not activated the -no-listener option)
* JsonVisitor.dart (if you have activated the -visitor option)
We'll write a small main func to call the generated parser/lexer
(assuming they are separate). This one writes out the encountered
`ParseTreeContext`'s:
```dart
import 'package:antlr4/antlr4.dart';
import 'package:my_project/JSONParser.dart';
import 'package:my_project/JSONLexer.dart';
class TreeShapeListener implements ParseTreeListener {
@override
void enterEveryRule(ParserRuleContext ctx) {
print(ctx.text);
}
@override
void exitEveryRule(ParserRuleContext node) {
}
@override
void visitErrorNode(ErrorNode node) {
}
@override
void visitTerminal(TerminalNode node) {
}
}
void main(List<String> args) async {
JSONLexer.checkVersion();
JSONParser.checkVersion();
final input = await InputStream.fromPath(args[0]);
final lexer = JSONLexer(input);
final tokens = CommonTokenStream(lexer);
final parser = JSONParser(tokens);
parser.addErrorListener(DiagnosticErrorListener());
parser.buildParseTree = true;
final tree = parser.json();
ParseTreeWalker.DEFAULT.walk(TreeShapeListener(), tree);
}
```
Create a `example.json` file:
```json
{"a":1}
```
Parse the input file:
```shell script
dart bin/main.dart example.json
```
The expected output is:
```
{"a":1}
{"a":1}
{"a":1}
"a":1
1
```

View File

@ -38,8 +38,8 @@ This is the main landing page for the ANTLR 4 FAQ. The links below will take you
## Translation
* [ASTs vs parse trees](parse-trees.md)
* [Decoupling input walking from output generation](parse-trees.md)
* [ASTs vs parse trees](translation.md)
* [Decoupling input walking from output generation](translation.md)
## Actions and semantic predicates

View File

@ -50,7 +50,7 @@ For writing a compiler, either generate [LLVM-type static-single-assignment](htt
### XPath
XPath works great when you need to find specific nodes, possibly in certain contexts. The context is limited to the parents on the way to the root of the tree. For example, if you want to find all ID nodes, use path `//ID`. If you want all variable declarations, you might use path `//vardecl`. If you only want fields declarations, then you can use some context information via path `/classdef/vardecl`, which would only find vardecls that our children of class definitions. You can merge the results of multiple XPath `findAll()`s simulating a set union for XPath. The only caveat is that the order from the original tree is not preserved when you union multiple `findAll()` sets.
XPath works great when you need to find specific nodes, possibly in certain contexts. The context is limited to the parents on the way to the root of the tree. For example, if you want to find all ID nodes, use path `//ID`. If you want all variable declarations, you might use path `//vardecl`. If you only want fields declarations, then you can use some context information via path `/classdef/vardecl`, which would only find vardecls that are children of class definitions. You can merge the results of multiple XPath `findAll()`s simulating a set union for XPath. The only caveat is that the order from the original tree is not preserved when you union multiple `findAll()` sets.
### Tree pattern matching
@ -70,4 +70,4 @@ scopeStack.peek().define(new VariableSymbol("foo"))
That way each listener function does not have to compute its appropriate scope.
Examples: [DefScopesAndSymbols.java](https://github.com/mantra/compiler/blob/master/src/java/mantra/semantics/DefScopesAndSymbols.java) and [SetScopeListener.java](https://github.com/mantra/compiler/blob/master/src/java/mantra/semantics/SetScopeListener.java) and [VerifyListener.java](https://github.com/mantra/compiler/blob/master/src/java/mantra/semantics/VerifyListener.java)
Examples: [DefScopesAndSymbols.java](https://github.com/mantra/compiler/blob/master/src/java/mantra/semantics/DefScopesAndSymbols.java) and [SetScopeListener.java](https://github.com/mantra/compiler/blob/master/src/java/mantra/semantics/SetScopeListener.java) and [VerifyListener.java](https://github.com/mantra/compiler/blob/master/src/java/mantra/semantics/VerifyListener.java)

View File

@ -6,46 +6,46 @@ 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.7.1-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.9-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.
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).
### UNIX
0. Install Java (version 1.6 or higher)
0. Install Java (version 1.7 or higher)
1. Download
```
$ cd /usr/local/lib
$ curl -O https://www.antlr.org/download/antlr-4.7.1-complete.jar
$ curl -O https://www.antlr.org/download/antlr-4.9-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.7.1-complete.jar` to your `CLASSPATH`:
2. Add `antlr-4.9-complete.jar` to your `CLASSPATH`:
```
$ export CLASSPATH=".:/usr/local/lib/antlr-4.7.1-complete.jar:$CLASSPATH"
$ export CLASSPATH=".:/usr/local/lib/antlr-4.9-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.7.1-complete.jar:$CLASSPATH" org.antlr.v4.Tool'
$ alias grun='java -Xmx500M -cp "/usr/local/lib/antlr-4.7.1-complete.jar:$CLASSPATH" org.antlr.v4.gui.TestRig'
$ alias antlr4='java -Xmx500M -cp "/usr/local/lib/antlr-4.9-complete.jar:$CLASSPATH" org.antlr.v4.Tool'
$ alias grun='java -Xmx500M -cp "/usr/local/lib/antlr-4.9-complete.jar:$CLASSPATH" org.antlr.v4.gui.TestRig'
```
### WINDOWS
(*Thanks to Graham Wideman*)
0. Install Java (version 1.6 or higher)
1. Download antlr-4.7.1-complete.jar (or whatever version) from [https://www.antlr.org/download/](https://www.antlr.org/download/)
0. Install Java (version 1.7 or higher)
1. Download antlr-4.9-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.7.1-complete.jar` to CLASSPATH, either:
2. Add `antlr-4.9-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.7.1-complete.jar;%CLASSPATH%
SET CLASSPATH=.;C:\Javalib\antlr-4.9-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.7.1
ANTLR Parser Generator Version 4.9
-o ___ specify output directory where all output is generated
-lib ___ specify location of .tokens files
...
@ -80,8 +80,8 @@ ANTLR Parser Generator Version 4.7.1
or use -jar option on java:
```
$ java -jar /usr/local/lib/antlr-4.7.1-complete.jar
ANTLR Parser Generator Version 4.7.1
$ java -jar /usr/local/lib/antlr-4.9-complete.jar
ANTLR Parser Generator Version 4.9
-o ___ specify output directory where all output is generated
-lib ___ specify location of .tokens files
...
@ -138,3 +138,4 @@ The book has lots and lots of examples that should be useful too. You can downlo
Also, there is a large collection of grammars for v4 at github:
[https://github.com/antlr/grammars-v4](https://github.com/antlr/grammars-v4)
/

View File

@ -65,7 +65,7 @@ Another common option to the ANTLR tool is `-visitor`, which generates a parse t
We'll write a small main func to call the generated parser/lexer (assuming they are separate). This one writes out the encountered `ParseTreeContext`'s. Suppose the gen'ed parser code is in the `parser` directory relative to this code:
```
```golang
package main
import (

View File

@ -139,7 +139,7 @@ Edit the pom.xml file. Now we need to extensively modify the pom.xml file. The f
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<version>4.13.1</version>
</dependency>
</dependencies>
<build>

View File

@ -11,11 +11,18 @@ In practice, this target has been extensively tested against:
* Chrome 39.0.2171
* Explorer 11.0.3
The tests were conducted using Selenium. No issue was found, so you should find that the runtime works pretty much against any recent JavaScript engine.
The above tests were conducted using Selenium. No issue was found, so you should find that the runtime works pretty much against any recent JavaScript engine.
## Is NodeJS supported?
The runtime has also been extensively tested against Node.js 10 LTS. No issue was found.
The runtime has also been extensively tested against Node.js 14 LTS. No issue was found.
NodeJS together with a packaging tool is now the preferred development path, developers are encouraged to follow it.
## What about modules?
Starting with version 8.1, Antlr4 JavaScript runtime follows esm semantics (see https://tc39.es/ecma262/#sec-modules for details)
Generated lexers, parsers, listeners and visitors also follow this new standard.
If you have used previous versions of the runtime, you will need to migrate and make your parser a module.
## How to create a JavaScript lexer or parser?
@ -61,7 +68,10 @@ The steps to create your parsing code are the following:
You are now ready to bundle your parsing code as follows:
- following webpack specs, create a webpack.config file
- in the `webpack.config` file, exclude node.js only modules using: `node: { module: "empty", net: "empty", fs: "empty" }`
- For Webpack version 5,
- in the `webpack.config` file, exclude node.js only modules using: `resolve: { fallback: { fs: false } }`
- For older versions of Webpack,
- in the `webpack.config` file, exclude node.js only modules using: `node: { module: "empty", net: "empty", fs: "empty" }`
- from the cmd line, navigate to the directory containing webpack.config and type: webpack
This will produce a single js file containing all your parsing code. Easy to include in your web pages!
@ -80,18 +90,18 @@ Let's suppose that your grammar is named, as above, "MyGrammar". Let's suppose t
Now a fully functioning script might look like the following:
```javascript
var antlr4 = require('antlr4');
var MyGrammarLexer = require('./MyGrammarLexer').MyGrammarLexer;
var MyGrammarParser = require('./MyGrammarParser').MyGrammarParser;
var MyGrammarListener = require('./MyGrammarListener').MyGrammarListener;
import antlr4 from 'antlr4';
import MyGrammarLexer from './MyGrammarLexer.js');
import MyGrammarParser from './MyGrammarParser.js';
import MyGrammarListener from './MyGrammarListener.js';
var input = "your text to parse here"
var chars = new antlr4.InputStream(input);
var lexer = new MyGrammarLexer(chars);
var tokens = new antlr4.CommonTokenStream(lexer);
var parser = new MyGrammarParser(tokens);
const input = "your text to parse here"
const chars = new antlr4.InputStream(input);
const lexer = new MyGrammarLexer(chars);
const tokens = new antlr4.CommonTokenStream(lexer);
const parser = new MyGrammarParser(tokens);
parser.buildParseTrees = true;
var tree = parser.MyStartRule();
const tree = parser.MyStartRule();
```
This program will work. But it won't be useful unless you do one of the following:
@ -105,19 +115,19 @@ This program will work. But it won't be useful unless you do one of the followin
## How do I create and run a visitor?
```javascript
// test.js
var antlr4 = require('antlr4');
var MyGrammarLexer = require('./QueryLexer').QueryLexer;
var MyGrammarParser = require('./QueryParser').QueryParser;
var MyGrammarListener = require('./QueryListener').QueryListener;
import antlr4 from 'antlr4';
import MyGrammarLexer from './QueryLexer.js';
import MyGrammarParser from './QueryParser.js';
import MyGrammarListener from './QueryListener.js';
var input = "field = 123 AND items in (1,2,3)"
var chars = new antlr4.InputStream(input);
var lexer = new MyGrammarLexer(chars);
var tokens = new antlr4.CommonTokenStream(lexer);
var parser = new MyGrammarParser(tokens);
const input = "field = 123 AND items in (1,2,3)"
const chars = new antlr4.InputStream(input);
const lexer = new MyGrammarLexer(chars);
const tokens = new antlr4.CommonTokenStream(lexer);
const parser = new MyGrammarParser(tokens);
parser.buildParseTrees = true;
var tree = parser.query();
const tree = parser.query();
class Visitor {
visitChildren(ctx) {
@ -145,40 +155,37 @@ tree.accept(new Visitor());
Let's suppose your MyGrammar grammar comprises 2 rules: "key" and "value". The antlr4 tool will have generated the following listener:
```javascript
MyGrammarListener = function(ParseTreeListener) {
// some code here
}
// some code here
MyGrammarListener.prototype.enterKey = function(ctx) {};
MyGrammarListener.prototype.exitKey = function(ctx) {};
MyGrammarListener.prototype.enterValue = function(ctx) {};
MyGrammarListener.prototype.exitValue = function(ctx) {};
class MyGrammarListener extends ParseTreeListener {
constructor() {
super();
}
enterKey(ctx) {}
exitKey(ctx) {}
enterValue(ctx) {}
exitValue(ctx) {}
}
```
In order to provide custom behavior, you might want to create the following class:
```javascript
var KeyPrinter = function() {
MyGrammarListener.call(this); // inherit default listener
return this;
};
class KeyPrinter extends MyGrammarListener {
// continue inheriting default listener
KeyPrinter.prototype = Object.create(MyGrammarListener.prototype);
KeyPrinter.prototype.constructor = KeyPrinter;
// override default listener behavior
KeyPrinter.prototype.exitKey = function(ctx) {
console.log("Oh, a key!");
};
// override default listener behavior
exitKey(ctx) {
console.log("Oh, a key!");
}
}
```
In order to execute this listener, you would simply add the following lines to the above code:
```javascript
...
tree = parser.StartRule() // only repeated here for reference
var printer = new KeyPrinter();
...
tree = parser.StartRule() // only repeated here for reference
const printer = new KeyPrinter();
antlr4.tree.ParseTreeWalker.DEFAULT.walk(printer, tree);
```

View File

@ -25,7 +25,7 @@ fragment DIGIT : [0-9] ; // not a token by itself
## Lexical Modes
Modes allow you to group lexical rules by context, such as inside and outside of XML tags. Its like having multiple sublexers, one for context. The lexer can only return tokens matched by entering a rule in the current mode. Lexers start out in the so-called default mode. All rules are considered to be within the default mode unless you specify a mode command. Modes are not allowed within combined grammars, just lexer grammars. (See grammar `XMLLexer` from [Tokenizing XML](http://pragprog.com/book/tpantlr2/the-definitive-antlr-4-reference).)
Modes allow you to group lexical rules by context, such as inside and outside of XML tags. Its like having multiple sublexers, one for each context. The lexer can only return tokens matched by entering a rule in the current mode. Lexers start out in the so-called default mode. All rules are considered to be within the default mode unless you specify a mode command. Modes are not allowed within combined grammars, just lexer grammars. (See grammar `XMLLexer` from [Tokenizing XML](http://pragprog.com/book/tpantlr2/the-definitive-antlr-4-reference).)
```
rules in default mode
@ -58,7 +58,7 @@ Match that character or sequence of characters. E.g., while or =.</t
<tr>
<td>[char set]</td><td>
<p>Match one of the characters specified in the character set. Interpret <tt>x-y</tt> as the set of characters between range <tt>x</tt> and <tt>y</tt>, inclusively. The following escaped characters are interpreted as single special characters: <tt>\n</tt>, <tt>\r</tt>, <tt>\b</tt>, <tt>\t</tt>, <tt>\f</tt>, <tt>\uXXXX</tt>, and <tt>\u{XXXXXX}</tt>. To get <tt>]</tt>, <tt>\</tt>, or <tt>-</tt> you must escape them with <tt>\</tt>.</p>
<p>Match one of the characters specified in the character set. Interpret <tt>x-y</tt> as the set of characters between range <tt>x</tt> and <tt>y</tt>, inclusively. The following escaped characters are interpreted as single special characters: <tt>\n</tt>, <tt>\r</tt>, <tt>\b</tt>, <tt>\t</tt>, <tt>\f</tt>, <tt>\uXXXX</tt>, and <tt>\u{XXXXXX}</tt>. To get <tt>]</tt> or <tt>\</tt> you must escape them with <tt>\</tt>. To get <tt>-</tt> you must escape it with <tt>\</tt> too, except for the case when <tt>-</tt> is the first or last character in the set.</p>
<p>You can also include all characters matching Unicode properties (general category, boolean, or enumerated including scripts and blocks) with <tt>\p{PropertyName}</tt> or <tt>\p{EnumProperty=Value}</tt>. (You can invert the test with <tt>\P{PropertyName}</tt> or <tt>\P{EnumProperty=Value}</tt>).</p>
@ -90,6 +90,8 @@ UNICODE_ID : [\p{Alpha}\p{General_Category=Other_Letter}] [\p{Alnum}\p{General_C
EMOJI : [\u{1F4A9}\u{1F926}] ; // note Unicode code points > U+FFFF
DASHBRACK : [\-\]]+ ; // match - or ] one or more times
DASH : [---] ; // match a single -, i.e., "any character" between - and - (note first and last - not escaped)
</pre>
</td>
</tr>
@ -123,7 +125,7 @@ ESC : '\\' . ; // match any escaped \x character
<tr>
<td>{«action»}</td><td>
Lexer actions can appear anywhere as of 4.2, not just at the end of the outermost alternative. The lexer executes the actions at the appropriate input position, according to the placement of the action within the rule. To execute a single action for a role that has multiple alternatives, you can enclose the alts in parentheses and put the action afterwards:
Lexer actions can appear anywhere as of 4.2, not just at the end of the outermost alternative. The lexer executes the actions at the appropriate input position, according to the placement of the action within the rule. To execute a single action for a rule that has multiple alternatives, you can enclose the alts in parentheses and put the action afterwards:
<pre>
END : ('endif'|'end') {System.out.println("found an end");} ;
@ -244,7 +246,8 @@ The mode commands alter the mode stack and hence the mode of the lexer. The 'mor
```
// Default "mode": Everything OUTSIDE of a tag
COMMENT : '<!--' .*? '-->' ;
CDATA : '<![CDATA[' .*? ']]>' ;OPEN : '<' -> pushMode(INSIDE) ;
CDATA : '<![CDATA[' .*? ']]>' ;
OPEN : '<' -> pushMode(INSIDE) ;
...
XMLDeclOpen : '<?xml' S -> pushMode(INSIDE) ;
SPECIAL_OPEN: '<?' Name -> more, pushMode(PROC_INSTR) ;

View File

@ -26,8 +26,8 @@ The Javadoc comments are hidden from the parser and are ignored at the moment.
Token names always start with a capital letter and so do lexer rules as defined by Javas `Character.isUpperCase` method. Parser rule names always start with a lowercase letter (those that fail `Character.isUpperCase`). The initial character can be followed by uppercase and lowercase letters, digits, and underscores. Here are some sample names:
```
ID, LPAREN, RIGHT_CURLY // token names/rules
expr, simpleDeclarator, d2, header_file // rule names
ID, LPAREN, RIGHT_CURLY // token names/lexer rules
expr, simpleDeclarator, d2, header_file // parser rule names
```
Like Java, ANTLR accepts Unicode characters in ANTLR names:
@ -96,7 +96,7 @@ The recognizers that ANTLR generates assume a character vocabulary containing al
## Actions
Actions are code blocks written in the target language. You can use actions in a number of places within a grammar, but the syntax is always the same: arbitrary text surrounded by curly braces. You dont need to escape a closing curly character if its in a string or comment: `"}"` or `/*}*/`. If the curlies are balanced, you also dont need to escape }: `{...}`. Otherwise, escape extra curlies with a backslash: `\{` or `\}`. The action text should conform to the target language as specified with thelanguage option.
Actions are code blocks written in the target language. You can use actions in a number of places within a grammar, but the syntax is always the same: arbitrary text surrounded by curly braces. You dont need to escape a closing curly character if its in a string or comment: `"}"` or `/*}*/`. If the curlies are balanced, you also dont need to escape }: `{...}`. Otherwise, escape extra curlies with a backslash: `\{` or `\}`. The action text should conform to the target language as specified with the language option.
Embedded code can appear in: `@header` and `@members` named actions, parser and lexer rules, exception catching specifications, attribute sections for parser rules (return values, arguments, and locals), and some rule element options (currently predicates).

View File

@ -15,7 +15,7 @@ generated by ANTLR4. The runtime provides a common set of tools for using your p
Install the runtime with Composer:
```bash
composer install antlr/antlr4
composer require antlr/antlr4-php-runtime
```
#### 3. Generate your parser
@ -108,4 +108,4 @@ The expected output is:
{"a":1}
"a":1
1
```
```

View File

@ -9,41 +9,40 @@ Create a pre-release or full release at github; [Example 4.5-rc-1](https://githu
Wack any existing tag as mvn will create one and it fails if already there.
```
$ git tag -d 4.8
$ git push origin :refs/tags/4.8
$ git push upstream :refs/tags/4.8
$ git tag -d 4.9
$ git push origin :refs/tags/4.9
$ git push upstream :refs/tags/4.9
```
### Create release candidate tag
```bash
$ git tag -a 4.8-rc1 -m 'heading towards 4.8'
$ git push origin 4.8-rc1
$ git push upstream 4.8-rc1
$ git tag -a 4.9-rc1 -m 'heading towards 4.9'
$ git push origin 4.9-rc1
$ git push upstream 4.9-rc1
```
## Update submodules
## Copy PHP runtime over
Make sure you tell git to pull in the submodule (for every clone you do of antlr4):
Bump version to 4.9 in `runtime/PHP/src/RuntimeMetaData.php` in separate repository and commit plus push.
```bash
git submodule init
```
cd ~/antlr/code/antlr-php-runtime
... vi src/RuntimeMetaData.php ...
git commit -a -m "Update PHP Runtime to latest version"
```
Also bump version to 4.8 in `runtime/PHP/src/RuntimeMetaData.php`.
them back over in the ANTLR repo:
Update the runtime submodules by running the following command:
```bash
git submodule update --recursive
git submodule update --remote --merge # might only need this last one but do both
```
Make sure these changes go back to antlr4 repo:
```bash
git add runtime/PHP
git commit -m "Update PHP Runtime to latest version"
cd runtime
mkdir PHP
cp ~/antlr/code/antlr-php-runtime/LICENSE PHP
cp ~/antlr/code/antlr-php-runtime/README.md PHP
cp ~/antlr/code/antlr-php-runtime/composer.json PHP
cp ~/antlr/code/antlr-php-runtime/phpcs.xml.dist PHP
cp ~/antlr/code/antlr-php-runtime/phpstan.neon.dist PHP
cp -r ~/antlr/code/antlr-php-runtime/src PHP
```
## Bump version
@ -55,8 +54,8 @@ Edit the repository looking for 4.5 or whatever and update it. Bump version in t
* runtime/Python2/src/antlr4/Recognizer.py
* runtime/Python3/setup.py
* runtime/Python3/src/antlr4/Recognizer.py
* runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Properties/AssemblyInfo.cs
* runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.dotnet.csproj
* runtime/CSharp/Antlr4.csproj
* runtime/PHP/src/RuntimeMetaData.php
* runtime/JavaScript/package.json
* runtime/JavaScript/src/antlr4/Recognizer.js
* runtime/Cpp/VERSION
@ -65,6 +64,8 @@ Edit the repository looking for 4.5 or whatever and update it. Bump version in t
* 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
* 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
@ -75,10 +76,15 @@ Edit the repository looking for 4.5 or whatever and update it. Bump version in t
* 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.5` in it:
Here is a simple script to display any line from the critical files with, say, `4.9` in it:
```bash
find tool runtime -type f -exec grep -l '4\.6' {} \;
mvn clean
rm -rf runtime/CSharp/bin
rm -rf runtime/CSharp/obj
rm -rf runtime/gen
find tool runtime -type f -exec grep -l '4\.9' {} \;
find runtime runtime -type f -exec grep -l '4\.9' {} \;
```
Commit to repository.
@ -134,23 +140,24 @@ Here is the file template
## Maven deploy snapshot
The goal is to get a snapshot, such as `4.8-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.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).
Do this:
```bash
$ mvn install -DskipTests # seems required to get the jar files visible to maven
$ 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.8-SNAPSHOT/maven-metadata.xml
Uploading: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.8-SNAPSHOT/antlr4-tool-testsuite-4.8-20161211.173752-1.jar
Uploaded: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.8-SNAPSHOT/antlr4-tool-testsuite-4.8-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.8-SNAPSHOT/antlr4-tool-testsuite-4.8-20161211.173752-1.pom
Uploaded: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.8-SNAPSHOT/antlr4-tool-testsuite-4.8-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.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/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.8-SNAPSHOT/maven-metadata.xml
Uploaded: https://oss.sonatype.org/content/repositories/snapshots/org/antlr/antlr4-tool-testsuite/4.8-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.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/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] ------------------------------------------------------------------------
@ -196,10 +203,10 @@ export GPG_TTY=$(tty)
Side note to set jdk 1.7 on os x:
```bash
alias java='/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/bin/java'
alias javac='/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/bin/javac'
alias javadoc='/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/bin/javadoc'
alias jar='/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/bin/jar'
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`
```
@ -220,18 +227,18 @@ It will start out by asking you the version number:
```
...
What is the release version for "ANTLR 4"? (org.antlr:antlr4-master) 4.8: : 4.8
What is the release version for "ANTLR 4 Runtime"? (org.antlr:antlr4-runtime) 4.8: :
What is the release version for "ANTLR 4 Tool"? (org.antlr:antlr4) 4.8: :
What is the release version for "ANTLR 4 Maven plugin"? (org.antlr:antlr4-maven-plugin) 4.8: :
What is the release version for "ANTLR 4 Runtime Test Generator"? (org.antlr:antlr4-runtime-testsuite) 4.8: :
What is the release version for "ANTLR 4 Tool Tests"? (org.antlr:antlr4-tool-testsuite) 4.8: :
What is SCM release tag or label for "ANTLR 4"? (org.antlr:antlr4-master) antlr4-master-4.8: : 4.8
What is the new development version for "ANTLR 4"? (org.antlr:antlr4-master) 4.8.1-SNAPSHOT:
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:
...
```
Maven will go through your pom.xml files to update versions from 4.8-SNAPSHOT to 4.8 for release and then to 4.8.1-SNAPSHOT after release, which is done with:
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:
```bash
mvn release:perform -Darguments="-DskipTests"
@ -245,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:
&nbsp;&nbsp;&nbsp;&nbsp;[https://oss.sonatype.org/service/local/repositories/releases/content/org/antlr/antlr4-runtime/4.8-1/antlr4-runtime-4.8-1.jar](https://oss.sonatype.org/service/local/repositories/releases/content/org/antlr/antlr4-runtime/4.8-1/antlr4-runtime-4.8-1.jar)
&nbsp;&nbsp;&nbsp;&nbsp;[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)
All releases should be here: 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.8/antlr4-runtime-4.8.jar ~/antlr/sites/website-antlr4/download/antlr-runtime-4.8.jar
cp ~/.m2/repository/org/antlr/antlr4/4.8/antlr4-4.8-complete.jar ~/antlr/sites/website-antlr4/download/antlr-4.8-complete.jar
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
cd ~/antlr/sites/website-antlr4/download
git add antlr-4.8-complete.jar
git add antlr-runtime-4.8.jar
git add antlr-4.9-complete.jar
git add antlr-runtime-4.9.jar
```
Update on site:
@ -268,7 +275,7 @@ Update on site:
* scripts/topnav.js
```
git commit -a -m 'add 4.8 jars'
git commit -a -m 'add 4.9 jars'
git push origin gh-pages
```
@ -285,15 +292,18 @@ cd runtime/JavaScript
```bash
cd runtime/JavaScript
npm update
npm install
npm run build
npm login
npm publish antlr4
npm publish # don't put antlr4 on there or it will try to push the old version for some reason
```
Move target to website
Move (and zip) target to website:
```bash
npm run build
cp /dist/antlr4.js ~/antlr/sites/website-antlr4/download
cd src
zip -r ~/antlr/sites/website-antlr4/download/antlr-javascript-runtime-4.9.zip .
```
### CSharp
@ -306,10 +316,17 @@ Now we have [appveyor create artifact](https://ci.appveyor.com/project/parrt/ant
Of course you need Mono and `nuget` to be installed. On mac:
- .NET build tools - can be loaded from [here](https://www.visualstudio.com/downloads/)
- .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/Antlr4.csproj -c Release`
Output `.dll` will be in `runtime/CSharp/bin/Release/netstandard2.0` or in `runtime/CSharp/bin/Release/netstandard2.1`
* packing: `dotnet pack runtime/CSharp/Antlr4.csproj -c Release`
Output `.nupkg` will be in `runtime/CSharp/bin/Release/Antlr4.Runtime.Standard.4.9.0.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".
@ -334,7 +351,7 @@ Copyright (C) Microsoft Corporation. All rights reserved.
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.8.2.nupkg'.
Successfully created package 'C:\Code\antlr4-fork\runtime\CSharp\runtime\CSharp\Antlr4.Runtime\lib\Release\Antlr4.Runtime.Standard.4.9.2.nupkg'.
```
**Publishing to NuGet**
@ -410,7 +427,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.8-macos.zip
cp antlr4-cpp-runtime-macos.zip ~/antlr/sites/website-antlr4/download/antlr4-cpp-runtime-4.9-macos.zip
```
On any Mac or Linux machine:
@ -418,7 +435,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.8-source.zip
cp antlr4-cpp-runtime-source.zip ~/antlr/sites/website-antlr4/download/antlr4-cpp-runtime-4.9-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).
@ -426,7 +443,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.8-vs2019.zip
cp antlr4-cpp-runtime-vs2019.zip ~/antlr/sites/website-antlr4/download/antlr4-cpp-runtime-4.9-vs2019.zip
```
Move target to website (**_rename to a specific ANTLR version first if needed_**):
@ -434,14 +451,29 @@ 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 antlr4cpp-runtime-4.8-macos.zip
git add antlr4cpp-runtime-4.8-windows.zip
git add antlr4cpp-runtime-4.8-source.zip
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 commit -a -m 'update C++ runtime'
git push origin gh-pages
popd
```
### Dart
Install Dart SDK from https://dart.dev/get-dart
Push to pub.dev
```bash
cd runtime/Dart
pub publish
```
It will warn that no change log found for the new version.
If there are changes relevant to dart in this release, edit [CHANGELOG.md](https://github.com/antlr/antlr4/blob/master/runtime/Dart/CHANGELOG.md) to describe the changes.
Otherwise enter `N` to ignore the warning.
## Update javadoc for runtime and tool
First, gen javadoc:
@ -458,9 +490,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.8/antlr4-runtime-4.8-javadoc.jar
jar xvf ~/.m2/repository/org/antlr/antlr4-runtime/4.9/antlr4-runtime-4.9-javadoc.jar
cd ../JavaTool
jar xvf ~/.m2/repository/org/antlr/antlr4/4.8/antlr4-4.8-javadoc.jar
jar xvf ~/.m2/repository/org/antlr/antlr4/4.9/antlr4-4.9-javadoc.jar
git commit -a -m 'freshen api doc'
git push origin gh-pages
```

View File

@ -10,12 +10,13 @@ This page lists the available and upcoming ANTLR runtimes. Please note that you
* [C++](cpp-target.md)
* [Swift](swift-target.md)
* [PHP](php-target.md)
* [Dart](dart-target.md)
## Target feature parity
New features generally appear in the Java target and then migrate to the other targets, but these other targets don't always get updated in the same overall tool release. This section tries to identify features added to Java that have not been added to the other targets.
|Feature|Java|C&sharp;|Python2|Python3|JavaScript|Go|C++|Swift|PHP
|---|---|---|---|---|---|---|---|---|---|
|Ambiguous tree construction|4.5.1|-|-|-|-|-|-|-|-|
|Feature|Java|C&sharp;|Python2|Python3|JavaScript|Go|C++|Swift|PHP|Dart
|---|---|---|---|---|---|---|---|---|---|---|
|Ambiguous tree construction|4.5.1|-|-|-|-|-|-|-|-|-|

View File

@ -52,15 +52,6 @@ m.setDelimiters("<<", ">>", "$"); // $ is the escape character
This would allow pattern `<<ID>> = <<expr>> ;$<< ick $>>` to be interpreted as elements: `ID`, ` = `, `expr`, and ` ;<< ick >>`.
```java
String xpath = "//blockStatement/*";
String treePattern = "int <Identifier> = <expression>;";
ParseTreePattern p =
parser.compileParseTreePattern(treePattern,
JavaParser.RULE_localVariableDeclarationStatement);
List<ParseTreeMatch> matches = p.findAll(tree, xpath);
```
### Pattern labels
The tree pattern matcher tracks the nodes in the tree at matches against the tags in a tree pattern. That way we can use the `get()` and `getAll()` methods to retrieve components of the matched subtree. For example, for pattern `<ID>`, `get("ID")` returns the node matched for that `ID`. If more than one node matched the specified token or rule tag, only the first match is returned. If there is no node associated with the label, this returns null.

View File

@ -13,7 +13,7 @@
</parent>
<groupId>org.antlr</groupId>
<artifactId>antlr4-master</artifactId>
<version>4.8-2-SNAPSHOT</version>
<version>4.9.2-SNAPSHOT</version>
<packaging>pom</packaging>
<name>ANTLR 4</name>
@ -151,7 +151,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<version>3.8.1</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>

View File

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

View File

@ -10,7 +10,7 @@
<parent>
<groupId>org.antlr</groupId>
<artifactId>antlr4-master</artifactId>
<version>4.8-2-SNAPSHOT</version>
<version>4.9.2-SNAPSHOT</version>
</parent>
<artifactId>antlr4-runtime-testsuite</artifactId>
<name>ANTLR 4 Runtime Tests (2nd generation)</name>
@ -56,7 +56,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
<dependency>
@ -103,6 +103,7 @@
<include>**/python2/Test*.java</include>
<include>**/python3/Test*.java</include>
<include>**/php/Test*.java</include>
<include>**/dart/Test*.java</include>
<include>${antlr.tests.swift}</include>
</includes>
</configuration>

View File

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

View File

@ -6,10 +6,11 @@
package org.antlr.v4.test.runtime;
import com.sun.tools.javac.main.JavaCompiler;
import com.sun.tools.javac.model.JavacElements;
import com.sun.tools.javac.processing.JavacProcessingEnvironment;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.TreeMaker;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.List;
import javax.annotation.processing.AbstractProcessor;
@ -20,6 +21,7 @@ import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import java.lang.reflect.Field;
import java.util.Set;
/**
@ -38,6 +40,7 @@ import java.util.Set;
@SupportedAnnotationTypes({"org.antlr.v4.test.runtime.CommentHasStringValue"})
@SupportedSourceVersion(SourceVersion.RELEASE_7)
public class CommentHasStringValueProcessor extends AbstractProcessor {
protected JavacElements utilities;
protected TreeMaker treeMaker;
@ -46,9 +49,21 @@ public class CommentHasStringValueProcessor extends AbstractProcessor {
super.init(processingEnv);
// Messager messager = processingEnv.getMessager();
// messager.printMessage(Diagnostic.Kind.NOTE, "WOW INIT--------------------");
JavacProcessingEnvironment javacProcessingEnv = (JavacProcessingEnvironment) processingEnv;
utilities = javacProcessingEnv.getElementUtils();
treeMaker = TreeMaker.instance(javacProcessingEnv.getContext());
utilities = (JavacElements)processingEnv.getElementUtils();
treeMaker = TreeMaker.instance(extractContext(utilities));
}
private static Context extractContext(JavacElements utilities) {
try {
Field compilerField = JavacElements.class.getDeclaredField("javaCompiler");
compilerField.setAccessible(true);
JavaCompiler compiler = (JavaCompiler)compilerField.get(utilities);
Field contextField = JavaCompiler.class.getDeclaredField("context");
contextField.setAccessible(true);
return (Context)contextField.get(compiler);
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new IllegalStateException(e);
}
}
@Override
@ -66,8 +81,7 @@ public class CommentHasStringValueProcessor extends AbstractProcessor {
else if ( elementTree instanceof JCTree.JCMethodDecl ) {
JCTree.JCStatement[] statements = new JCTree.JCStatement[1];
statements[0] = treeMaker.Return(literal);
JCTree.JCBlock body = treeMaker.Block(0, List.from(statements));
((JCTree.JCMethodDecl)elementTree).body = body;
((JCTree.JCMethodDecl)elementTree).body = treeMaker.Block(0, List.from(statements));
}
}
return true;

View File

@ -74,7 +74,7 @@ LANotEquals(i, v) ::= <%this._input.LA(<i>)!=<v>%>
TokenStartColumnEquals(i) ::= <%this._tokenStartColumn===<i>%>
ImportListener(X) ::= <<var <X>Listener = require('./<X>Listener').<X>Listener;>>
ImportListener(X) ::= ""
GetExpectedTokenNames() ::= "this.getExpectedTokens().toString(this.literalNames)"

View File

@ -0,0 +1,318 @@
writeln(s) ::= <<print(<s>);>>
write(s) ::= <<stdout.write(<s>);>>
writeList(s) ::= <<print(<s; separator="+">);>>
False() ::= "false"
True() ::= "true"
Not(v) ::= "!<v>"
Assert(s) ::= <<assert(<s>);>>
Cast(t,v) ::= "(<v> as <t>)"
Append(a,b) ::= "<a>.toString() + <b>.toString()"
AppendStr(a,b) ::= <%<Append(a,b)>%>
Concat(a,b) ::= "<a><b>"
AssertIsList(v) ::= "assert (<v> is List);" // just use static type system
AssignLocal(s,v) ::= "<s> = <v>;"
InitIntMember(n,v) ::= <%int <n> = <v>;%>
InitBooleanMember(n,v) ::= <%bool <n> = <v>;%>
InitIntVar(n,v) ::= <%<InitIntMember(n,v)>%>
IntArg(n) ::= "int <n>"
VarRef(n) ::= "<n>"
GetMember(n) ::= <%this.<n>%>
SetMember(n,v) ::= <%this.<n> = <v>;%>
AddMember(n,v) ::= <%this.<n> += <v>;%>
MemberEquals(n,v) ::= <%this.<n> == <v>%>
ModMemberEquals(n,m,v) ::= <%this.<n> % <m> == <v>%>
ModMemberNotEquals(n,m,v) ::= <%this.<n> % <m> != <v>%>
DumpDFA() ::= "this.dumpDFA();"
Pass() ::= ""
StringList() ::= "List\<String>"
BuildParseTrees() ::= "buildParseTree = true;"
BailErrorStrategy() ::= <%errorHandler = new BailErrorStrategy();%>
ToStringTree(s) ::= <%<s>.toStringTree(parser: this)%>
Column() ::= "this.charPositionInLine"
Text() ::= "this.text"
ValEquals(a,b) ::= <%<a>==<b>%>
TextEquals(a) ::= <%this.text == "<a>"%>
PlusText(a) ::= <%"<a>" + this.text%>
InputText() ::= "tokenStream.text"
LTEquals(i, v) ::= <%tokenStream.LT(<i>).text == <v>%>
LANotEquals(i, v) ::= <%tokenStream.LA(<i>)!=<v>%>
TokenStartColumnEquals(i) ::= <%this.tokenStartCharPositionInLine==<i>%>
ImportListener(X) ::= ""
GetExpectedTokenNames() ::= "this.expectedTokens.toString(vocabulary: this.vocabulary)"
RuleInvocationStack() ::= "ruleInvocationStack"
LL_EXACT_AMBIG_DETECTION() ::= <<interpreter.predictionMode = PredictionMode.LL_EXACT_AMBIG_DETECTION;>>
ParserToken(parser, token) ::= <%<parser>.TOKEN_<token>%>
Production(p) ::= <%<p>%>
Result(r) ::= <%<r>%>
ParserPropertyMember() ::= <<
@members {
bool Property() {
return true;
}
}
>>
ParserPropertyCall(p, call) ::= "<p>.<call>"
PositionAdjustingLexerDef() ::= <<
class PositionAdjustingLexerATNSimulator extends LexerATNSimulator {
PositionAdjustingLexerATNSimulator(Lexer recog, ATN atn,
List\<DFA> decisionToDFA, PredictionContextCache sharedContextCache)
: super(atn, decisionToDFA, sharedContextCache, recog: recog);
void resetAcceptPosition(CharStream input, int index, int line,
int charPositionInLine) {
input.seek(index);
this.line = line;
this.charPositionInLine = charPositionInLine;
consume(input);
}
}
>>
PositionAdjustingLexer() ::= <<
@override
Token nextToken() {
if (!(super.interpreter is PositionAdjustingLexerATNSimulator)) {
interpreter = new PositionAdjustingLexerATNSimulator(
this, _ATN, _decisionToDFA, _sharedContextCache);
}
return super.nextToken();
}
@override
Token emit() {
switch (type) {
case TOKEN_TOKENS:
handleAcceptPositionForKeyword("tokens");
break;
case TOKEN_LABEL:
handleAcceptPositionForIdentifier();
break;
default:
break;
}
return super.emit();
}
bool handleAcceptPositionForIdentifier() {
String tokenText = text;
int identifierLength = 0;
while (identifierLength \< tokenText.length &&
isIdentifierChar(tokenText[identifierLength])) {
identifierLength++;
}
if (inputStream.index > tokenStartCharIndex + identifierLength) {
int offset = identifierLength - 1;
interpreter.resetAcceptPosition(inputStream, tokenStartCharIndex + offset,
tokenStartLine, tokenStartCharPositionInLine + offset);
return true;
}
return false;
}
bool handleAcceptPositionForKeyword(String keyword) {
if (inputStream.index > tokenStartCharIndex + keyword.length) {
int offset = keyword.length - 1;
interpreter.resetAcceptPosition(inputStream, tokenStartCharIndex + offset,
tokenStartLine, tokenStartCharPositionInLine + offset);
return true;
}
return false;
}
@override
PositionAdjustingLexerATNSimulator get interpreter {
return super.interpreter as PositionAdjustingLexerATNSimulator;
}
static bool isIdentifierChar(String c) {
return isLetterOrDigit(c) || c == '_';
}
static const ZERO = 48;
static const LOWER_A = 97;
static const LOWER_Z = 122;
static const UPPER_A = 65;
static const UPPER_Z = 90;
static bool isLetterOrDigit(String char) => isLetter(char) || isDigit(char);
// Note: this is intentially ASCII only
static bool isLetter(String char) {
if (char == null) return false;
var cc = char.codeUnitAt(0);
return cc >= LOWER_A && cc \<= LOWER_Z || cc >= UPPER_A && cc \<= UPPER_Z;
}
static bool isDigit(String char) {
if (char == null) return false;
var cc = char.codeUnitAt(0);
return cc >= ZERO && cc \< ZERO + 10;
}
>>
BasicListener(X) ::= <<
@parser::definitions {
class LeafListener extends TBaseListener {
void visitTerminal(TerminalNode node) {
print(node.symbol.text);
}
}
}
>>
WalkListener(s) ::= <<
ParseTreeWalker walker = new ParseTreeWalker();
walker.walk(new LeafListener(), <s>);
>>
TreeNodeWithAltNumField(X) ::= <<
@parser::definitions {
class MyRuleNode extends ParserRuleContext {
int altNum;
MyRuleNode(ParserRuleContext parent, int invokingStateNumber)
: super(parent, invokingStateNumber);
@override int get altNumber {
return altNum;
}
@override void set altNumber(int altNum) {
this.altNum = altNum;
}
}
}
>>
TokenGetterListener(X) ::= <<
@parser::definitions {
class LeafListener extends TBaseListener {
void exitA(AContext ctx) {
if (ctx.childCount==2)
stdout.write("${ctx.INT(0).symbol.text} ${ctx.INT(1).symbol.text} ${ctx.INTs()}");
else
print(ctx.ID().symbol);
}
}
}
>>
RuleGetterListener(X) ::= <<
@parser::definitions {
class LeafListener extends TBaseListener {
void exitA(AContext ctx) {
if (ctx.childCount==2) {
stdout.write("${ctx.b(0).start.text} ${ctx.b(1).start.text} ${ctx.bs()[0].start.text}");
} else
print(ctx.b(0).start.text);
}
}
}
>>
LRListener(X) ::= <<
@parser::definitions {
class LeafListener extends TBaseListener {
void exitE(EContext ctx) {
if (ctx.childCount==3) {
stdout.write("${ctx.e(0).start.text} ${ctx.e(1).start.text} ${ctx.es()[0].start.text}\n");
} else
print(ctx.INT().symbol.text);
}
}
}
>>
LRWithLabelsListener(X) ::= <<
@parser::definitions {
class LeafListener extends TBaseListener {
void exitCall(CallContext ctx) {
stdout.write("${ctx.e().start.text} ${ctx.eList()}");
}
void exitInt(IntContext ctx) {
print(ctx.INT().symbol.text);
}
}
}
>>
DeclareContextListGettersFunction() ::= <<
void foo() {
SContext s = null;
List\<AContext> a = s.as();
List\<BContext> b = s.bs();
}
>>
Declare_foo() ::= <<
void foo() {print("foo");}
>>
Invoke_foo() ::= "foo();"
Declare_pred() ::= <<bool pred(bool v) {
print("eval=\$v");
return v;
}
>>
Invoke_pred(v) ::= <<this.pred(<v>)>>
ParserTokenType(t) ::= "Parser.<t>"
ContextRuleFunction(ctx, rule) ::= "<ctx>.<rule>"
StringType() ::= "String"
ContextMember(ctx, subctx, member) ::= "<ctx>.<subctx>.<member>"

View File

@ -76,11 +76,7 @@ LANotEquals(i, v) ::= <%this._input.LA(<i>)!=<v>%>
TokenStartColumnEquals(i) ::= <%this._tokenStartColumn===<i>%>
ImportListener(X) ::= <<
@parser::header {
var <X>Listener = require('./<X>Listener').<X>Listener;
}
>>
ImportListener(X) ::= ""
GetExpectedTokenNames() ::= "this.getExpectedTokens().toString(this.literalNames)"

View File

@ -74,11 +74,7 @@ LANotEquals(i, v) ::= <%this._input.LA(<i>)!=<v>%>
TokenStartColumnEquals(i) ::= <%this._tokenStartColumn===<i>%>
ImportListener(X) ::= <<
@parser::header {
var <X>Listener = require('./<X>Listener').<X>Listener;
}
>>
ImportListener(X) ::= ""
GetExpectedTokenNames() ::= "this.getExpectedTokens().toString(this.literalNames)"

View File

@ -74,11 +74,7 @@ LANotEquals(i, v) ::= <%this._input.LA(<i>)!=<v>%>
TokenStartColumnEquals(i) ::= <%this._tokenStartColumn===<i>%>
ImportListener(X) ::= <<
@parser::header {
var <X>Listener = require('./<X>Listener').<X>Listener;
}
>>
ImportListener(X) ::= ""
GetExpectedTokenNames() ::= "this.getExpectedTokens().toString(this.literalNames)"

View File

@ -11,9 +11,7 @@ import org.antlr.v4.runtime.misc.Pair;
import org.antlr.v4.runtime.misc.Utils;
import org.antlr.v4.tool.ANTLRMessage;
import org.antlr.v4.tool.DefaultToolListener;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.*;
import org.junit.rules.TestRule;
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;
@ -44,28 +42,56 @@ import static org.junit.Assume.assumeFalse;
* @since 4.6.
*/
public abstract class BaseRuntimeTest {
public final static String[] Targets = {
"Cpp",
"Java",
"Go",
"CSharp",
"Python2", "Python3",
"Dart",
"Go",
"Java",
"Node",
"PHP",
"Node"
"Python2", "Python3",
"Swift"
};
static {
// Add heartbeat thread to gen minimal output for travis, appveyor to
// avoid timeout.
@BeforeClass
public static void startHeartbeatToAvoidTimeout() {
if (isTravisCI() || isAppVeyorCI())
startHeartbeat();
}
@AfterClass
public static void stopHeartbeat() {
heartbeat = false;
}
private static boolean isAppVeyorCI() {
// see https://www.appveyor.com/docs/environment-variables/
String s = System.getenv("APPVEYOR");
return s!=null && "true".equals(s.toLowerCase());
}
private static boolean isTravisCI() {
// see https://docs.travis-ci.com/user/environment-variables/#default-environment-variables
String s = System.getenv("TRAVIS");
return s!=null && "true".equals(s.toLowerCase());
}
static boolean heartbeat = false;
private static void startHeartbeat() {
// Add heartbeat thread to gen minimal output for travis, appveyor to avoid timeout.
Thread t = new Thread("heartbeat") {
@Override
public void run() {
while (true) {
heartbeat = true;
while (heartbeat) {
System.out.print('.');
try {
//noinspection BusyWait
Thread.sleep(5000);
}
catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
}
@ -94,10 +120,17 @@ public abstract class BaseRuntimeTest {
public void setUp() throws Exception {
// From http://junit.sourceforge.net/javadoc/org/junit/Assume.html
// "The default JUnit runner treats tests with failing assumptions as ignored"
assumeFalse(descriptor.ignore(descriptor.getTarget()));
assumeFalse(checkIgnored());
delegate.testSetUp();
}
public boolean checkIgnored() {
boolean ignored = !TestContext.isSupportedTarget(descriptor.getTarget()) || descriptor.ignore(descriptor.getTarget());
if(ignored)
System.out.println("Ignore " + descriptor);
return ignored;
}
@Rule
public final TestRule testWatcher = new TestWatcher() {
@Override
@ -109,18 +142,20 @@ public abstract class BaseRuntimeTest {
@Test
public void testOne() throws Exception {
// System.out.println(descriptor.getTestName());
// System.out.println(delegate.getTmpDir());
if ( descriptor.ignore(descriptor.getTarget()) ) {
System.out.printf("Ignore "+descriptor);
if (descriptor.ignore(descriptor.getTarget()) ) {
System.out.println("Ignore " + descriptor);
return;
}
if ( descriptor.getTestType().contains("Parser") ) {
delegate.beforeTest(descriptor);
if (descriptor.getTestType().contains("Parser") ) {
testParser(descriptor);
}
else {
testLexer(descriptor);
}
delegate.afterTest(descriptor);
}
public void testParser(RuntimeTestDescriptor descriptor) throws Exception {
@ -272,6 +307,8 @@ public abstract class BaseRuntimeTest {
// ---- support ----
public static RuntimeTestDescriptor[] getRuntimeTestDescriptors(Class<?> clazz, String targetName) {
if(!TestContext.isSupportedTarget(targetName))
return new RuntimeTestDescriptor[0];
Class<?>[] nestedClasses = clazz.getClasses();
List<RuntimeTestDescriptor> descriptors = new ArrayList<RuntimeTestDescriptor>();
for (Class<?> nestedClass : nestedClasses) {
@ -279,8 +316,10 @@ public abstract class BaseRuntimeTest {
if ( RuntimeTestDescriptor.class.isAssignableFrom(nestedClass) && !Modifier.isAbstract(modifiers) ) {
try {
RuntimeTestDescriptor d = (RuntimeTestDescriptor) nestedClass.newInstance();
d.setTarget(targetName);
descriptors.add(d);
if(!d.ignore(targetName)) {
d.setTarget(targetName);
descriptors.add(d);
}
} catch (Exception e) {
e.printStackTrace(System.err);
}
@ -299,6 +338,16 @@ public abstract class BaseRuntimeTest {
}
}
public static String readFile(String dir, String fileName) {
try {
return String.copyValueOf(Utils.readFile(dir+"/"+fileName, "UTF-8"));
}
catch (IOException ioe) {
System.err.println("can't read file");
ioe.printStackTrace(System.err);
}
return null;
}
protected static void assertCorrectOutput(RuntimeTestDescriptor descriptor, RuntimeTestSupport delegate, String actualOutput) {
String actualParseErrors = delegate.getParseErrors();

View File

@ -39,4 +39,7 @@ public interface RuntimeTestSupport {
String startRuleName,
String input,
boolean showDiagnosticErrors);
void beforeTest(RuntimeTestDescriptor descriptor);
void afterTest(RuntimeTestDescriptor descriptor);
}

View File

@ -0,0 +1,24 @@
package org.antlr.v4.test.runtime;
public abstract class TestContext {
public static boolean isTravisCI() {
return "true".equals(String.valueOf(System.getenv("TRAVIS")).toLowerCase());
}
public static boolean isAppVeyorCI() {
return "true".equals(String.valueOf(System.getenv("APPVEYOR")).toLowerCase());
}
public static boolean isCircleCI() {
return "true".equals(String.valueOf(System.getenv("CIRCLECI")).toLowerCase());
}
public static boolean isSupportedTarget(String target) {
if(isAppVeyorCI())
return !target.matches("Swift|Node");
else
return true;
}
}

View File

@ -35,6 +35,7 @@ import org.antlr.v4.runtime.misc.Interval;
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.semantics.SemanticPipeline;
import org.antlr.v4.test.runtime.ErrorQueue;
import org.antlr.v4.test.runtime.RuntimeTestDescriptor;
import org.antlr.v4.test.runtime.RuntimeTestSupport;
import org.antlr.v4.test.runtime.StreamVacuum;
import org.antlr.v4.tool.ANTLRMessage;
@ -43,6 +44,9 @@ import org.antlr.v4.tool.Grammar;
import org.antlr.v4.tool.GrammarSemanticsMessage;
import org.antlr.v4.tool.LexerGrammar;
import org.antlr.v4.tool.Rule;
import org.junit.rules.TestRule;
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;
import org.stringtemplate.v4.ST;
import org.stringtemplate.v4.STGroup;
import org.stringtemplate.v4.STGroupString;
@ -88,6 +92,17 @@ public class BaseCppTest implements RuntimeTestSupport {
/** Errors found while running antlr */
protected StringBuilder antlrToolErrors;
@org.junit.Rule
public final TestRule testWatcher = new TestWatcher() {
@Override
protected void succeeded(Description description) {
// remove tmpdir if no error.
eraseTempDir();
}
};
private String getPropertyPrefix() {
return "antlr-" + getLanguage().toLowerCase();
}
@ -111,6 +126,15 @@ public class BaseCppTest implements RuntimeTestSupport {
public void testTearDown() throws Exception {
}
@Override
public void beforeTest(RuntimeTestDescriptor descriptor) {
System.out.println(descriptor.getTestName());
}
@Override
public void afterTest(RuntimeTestDescriptor descriptor) {
}
@Override
public String getTmpDir() {
return tmpdir;
@ -510,7 +534,7 @@ public class BaseCppTest implements RuntimeTestSupport {
}
private String runProcess(ProcessBuilder builder, String description, boolean showStderr) throws Exception {
// System.out.println("BUILDER: "+builder.command());
// System.out.println("BUILDER: " + builder.command() + " @ " + builder.directory().toString());
Process process = builder.start();
StreamVacuum stdoutVacuum = new StreamVacuum(process.getInputStream());
StreamVacuum stderrVacuum = new StreamVacuum(process.getErrorStream());
@ -688,7 +712,7 @@ public class BaseCppTest implements RuntimeTestSupport {
p = Paths.get(runtimeURL.toURI()).toFile().toString();
}
catch (URISyntaxException use) {
p = "Can't find runtime";
p = "Can't find runtime at " + runtimeURL.toString();
}
return p;
}
@ -963,20 +987,26 @@ public class BaseCppTest implements RuntimeTestSupport {
@Override
public void eraseTempDir() {
boolean doErase = true;
String propName = getPropertyPrefix() + "-erase-test-dir";
String prop = System.getProperty(propName);
if(prop!=null && prop.length()>0)
doErase = Boolean.getBoolean(prop);
if(doErase) {
if (shouldEraseTempDir()) {
File tmpdirF = new File(tmpdir);
if ( tmpdirF.exists() ) {
if (tmpdirF.exists()) {
eraseFiles(tmpdirF);
tmpdirF.delete();
}
}
}
private boolean shouldEraseTempDir() {
if(tmpdir==null)
return false;
String propName = getPropertyPrefix() + "-erase-test-dir";
String prop = System.getProperty(propName);
if (prop != null && prop.length() > 0)
return Boolean.getBoolean(prop);
else
return true;
}
public String getFirstLineOfException() {
if ( this.stderrDuringParse ==null ) {
return null;
@ -1128,3 +1158,4 @@ public class BaseCppTest implements RuntimeTestSupport {
return dup;
}
}

View File

@ -1,13 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp1.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<NoWarn>$(NoWarn);CS3021</NoWarn>
<AssemblyName>Test</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>Antlr4.Test.dotnet</PackageId>
<RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion>
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
<PackageId>Antlr4.Test</PackageId>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>

View File

@ -1,51 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{EDC70A11-C4C1-4209-93A6-CCE2B19E8E95}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Antlr4.Test.mono</RootNamespace>
<AssemblyName>Test</AssemblyName>
<StartupObject>Test</StartupObject>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>true</Externalconsole>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>true</Externalconsole>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="Antlr4.Runtime.mono.csproj">
<Project>{E1A46D9D-66CB-46E8-93B0-7FC87299ABEF}</Project>
<Name>Antlr4.Runtime.mono</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Test.cs" />
<Compile Include="L.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<None Include="App.config">
<LogicalName>Test.exe.config</LogicalName>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@ -1,44 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?><Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{EDC70A11-C4C1-4209-93A6-CCE2B19E8E95}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Antlr4.Test.mono</RootNamespace>
<AssemblyName>Test</AssemblyName>
<StartupObject>Test</StartupObject>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>true</Externalconsole>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>true</Externalconsole>
</PropertyGroup>
<ItemGroup>
<Reference Include="System"/>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs"/>
<Compile Include="Test.cs"/>
<Compile Include="L.cs"/>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets"/>
<ItemGroup>
<ProjectReference Include="Antlr4.Runtime.vs2013.csproj">
<Project>{E1A46D9D-66CB-46E8-93B0-7FC87299ABEF}</Project>
<Name>Antlr4.Runtime.vs2013</Name>
</ProjectReference>
</ItemGroup>
</Project>

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<startup>
<supportedRuntime version="v2.0.50727"/>
<supportedRuntime version="v4.0"/>
</startup>
</configuration>

View File

@ -1,28 +0,0 @@
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle ("Antlr4.Test.mono")]
[assembly: AssemblyDescription ("")]
[assembly: AssemblyConfiguration ("")]
[assembly: AssemblyCompany ("")]
[assembly: AssemblyProduct ("")]
[assembly: AssemblyCopyright ("ericvergnaud")]
[assembly: AssemblyTrademark ("")]
[assembly: AssemblyCulture ("")]
[assembly: CLSCompliant (true)]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion ("1.0.*")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.runtime.dart;
import org.antlr.v4.test.runtime.BaseRuntimeTest;
import org.antlr.v4.test.runtime.RuntimeTestDescriptor;
import org.antlr.v4.test.runtime.descriptors.CompositeLexersDescriptors;
import org.antlr.v4.test.runtime.dart.BaseDartTest;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@RunWith(Parameterized.class)
public class TestCompositeLexers extends BaseRuntimeTest {
public TestCompositeLexers(RuntimeTestDescriptor descriptor) {
super(descriptor,new BaseDartTest());
}
@Parameterized.Parameters(name="{0}")
public static RuntimeTestDescriptor[] getAllTestDescriptors() {
return BaseRuntimeTest.getRuntimeTestDescriptors(CompositeLexersDescriptors.class, "Dart");
}
}

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.runtime.dart;
import org.antlr.v4.test.runtime.BaseRuntimeTest;
import org.antlr.v4.test.runtime.RuntimeTestDescriptor;
import org.antlr.v4.test.runtime.descriptors.CompositeParsersDescriptors;
import org.antlr.v4.test.runtime.dart.BaseDartTest;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@RunWith(Parameterized.class)
public class TestCompositeParsers extends BaseRuntimeTest {
public TestCompositeParsers(RuntimeTestDescriptor descriptor) {
super(descriptor,new BaseDartTest());
}
@Parameterized.Parameters(name="{0}")
public static RuntimeTestDescriptor[] getAllTestDescriptors() {
return BaseRuntimeTest.getRuntimeTestDescriptors(CompositeParsersDescriptors.class, "Dart");
}
}

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.runtime.dart;
import org.antlr.v4.test.runtime.BaseRuntimeTest;
import org.antlr.v4.test.runtime.RuntimeTestDescriptor;
import org.antlr.v4.test.runtime.descriptors.FullContextParsingDescriptors;
import org.antlr.v4.test.runtime.dart.BaseDartTest;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@RunWith(Parameterized.class)
public class TestFullContextParsing extends BaseRuntimeTest {
public TestFullContextParsing(RuntimeTestDescriptor descriptor) {
super(descriptor,new BaseDartTest());
}
@Parameterized.Parameters(name="{0}")
public static RuntimeTestDescriptor[] getAllTestDescriptors() {
return BaseRuntimeTest.getRuntimeTestDescriptors(FullContextParsingDescriptors.class, "Dart");
}
}

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.runtime.dart;
import org.antlr.v4.test.runtime.BaseRuntimeTest;
import org.antlr.v4.test.runtime.RuntimeTestDescriptor;
import org.antlr.v4.test.runtime.descriptors.LeftRecursionDescriptors;
import org.antlr.v4.test.runtime.dart.BaseDartTest;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@RunWith(Parameterized.class)
public class TestLeftRecursion extends BaseRuntimeTest {
public TestLeftRecursion(RuntimeTestDescriptor descriptor) {
super(descriptor,new BaseDartTest());
}
@Parameterized.Parameters(name="{0}")
public static RuntimeTestDescriptor[] getAllTestDescriptors() {
return BaseRuntimeTest.getRuntimeTestDescriptors(LeftRecursionDescriptors.class, "Dart");
}
}

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.runtime.dart;
import org.antlr.v4.test.runtime.BaseRuntimeTest;
import org.antlr.v4.test.runtime.RuntimeTestDescriptor;
import org.antlr.v4.test.runtime.descriptors.LexerErrorsDescriptors;
import org.antlr.v4.test.runtime.dart.BaseDartTest;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@RunWith(Parameterized.class)
public class TestLexerErrors extends BaseRuntimeTest {
public TestLexerErrors(RuntimeTestDescriptor descriptor) {
super(descriptor,new BaseDartTest());
}
@Parameterized.Parameters(name="{0}")
public static RuntimeTestDescriptor[] getAllTestDescriptors() {
return BaseRuntimeTest.getRuntimeTestDescriptors(LexerErrorsDescriptors.class, "Dart");
}
}

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.runtime.dart;
import org.antlr.v4.test.runtime.BaseRuntimeTest;
import org.antlr.v4.test.runtime.RuntimeTestDescriptor;
import org.antlr.v4.test.runtime.descriptors.LexerExecDescriptors;
import org.antlr.v4.test.runtime.dart.BaseDartTest;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@RunWith(Parameterized.class)
public class TestLexerExec extends BaseRuntimeTest {
public TestLexerExec(RuntimeTestDescriptor descriptor) {
super(descriptor,new BaseDartTest());
}
@Parameterized.Parameters(name="{0}")
public static RuntimeTestDescriptor[] getAllTestDescriptors() {
return BaseRuntimeTest.getRuntimeTestDescriptors(LexerExecDescriptors.class, "Dart");
}
}

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.runtime.dart;
import org.antlr.v4.test.runtime.BaseRuntimeTest;
import org.antlr.v4.test.runtime.RuntimeTestDescriptor;
import org.antlr.v4.test.runtime.descriptors.ListenersDescriptors;
import org.antlr.v4.test.runtime.dart.BaseDartTest;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@RunWith(Parameterized.class)
public class TestListeners extends BaseRuntimeTest {
public TestListeners(RuntimeTestDescriptor descriptor) {
super(descriptor,new BaseDartTest());
}
@Parameterized.Parameters(name="{0}")
public static RuntimeTestDescriptor[] getAllTestDescriptors() {
return BaseRuntimeTest.getRuntimeTestDescriptors(ListenersDescriptors.class, "Dart");
}
}

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.runtime.dart;
import org.antlr.v4.test.runtime.BaseRuntimeTest;
import org.antlr.v4.test.runtime.RuntimeTestDescriptor;
import org.antlr.v4.test.runtime.descriptors.ParseTreesDescriptors;
import org.antlr.v4.test.runtime.dart.BaseDartTest;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@RunWith(Parameterized.class)
public class TestParseTrees extends BaseRuntimeTest {
public TestParseTrees(RuntimeTestDescriptor descriptor) {
super(descriptor,new BaseDartTest());
}
@Parameterized.Parameters(name="{0}")
public static RuntimeTestDescriptor[] getAllTestDescriptors() {
return BaseRuntimeTest.getRuntimeTestDescriptors(ParseTreesDescriptors.class, "Dart");
}
}

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