forked from jasder/antlr
Merge branch 'master' into py3runtime_test_dist
This commit is contained in:
commit
d050e38635
|
@ -97,7 +97,6 @@ xcuserdata
|
||||||
# VSCode Java plugin temporary files
|
# VSCode Java plugin temporary files
|
||||||
javac-services.0.log
|
javac-services.0.log
|
||||||
javac-services.0.log.lck
|
javac-services.0.log.lck
|
||||||
test/
|
|
||||||
|
|
||||||
# Don't ignore python tests
|
# Don't ignore python tests
|
||||||
!runtime/Python3/test/
|
!runtime/Python3/test/
|
||||||
|
|
46
.travis.yml
46
.travis.yml
|
@ -19,59 +19,56 @@ stages:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: linux
|
- os: linux
|
||||||
dist: trusty
|
dist: focal
|
||||||
compiler: clang
|
compiler: clang
|
||||||
jdk: openjdk8
|
jdk: openjdk11
|
||||||
env:
|
env:
|
||||||
- TARGET=cpp
|
- TARGET=cpp
|
||||||
- CXX=g++-5
|
- CXX=g++-10
|
||||||
- GROUP=LEXER
|
- GROUP=LEXER
|
||||||
stage: main-test
|
stage: main-test
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- sourceline: 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-10 main'
|
||||||
- llvm-toolchain-precise-3.7
|
|
||||||
packages:
|
packages:
|
||||||
- g++-5
|
- g++-10
|
||||||
- uuid-dev
|
- uuid-dev
|
||||||
- clang-3.7
|
- clang-10
|
||||||
- os: linux
|
- os: linux
|
||||||
dist: trusty
|
dist: focal
|
||||||
compiler: clang
|
compiler: clang
|
||||||
jdk: openjdk8
|
jdk: openjdk11
|
||||||
env:
|
env:
|
||||||
- TARGET=cpp
|
- TARGET=cpp
|
||||||
- CXX=g++-5
|
- CXX=g++-10
|
||||||
- GROUP=PARSER
|
- GROUP=PARSER
|
||||||
stage: main-test
|
stage: main-test
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- sourceline: 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-10 main'
|
||||||
- llvm-toolchain-precise-3.7
|
|
||||||
packages:
|
packages:
|
||||||
- g++-5
|
- g++-10
|
||||||
- uuid-dev
|
- uuid-dev
|
||||||
- clang-3.7
|
- clang-10
|
||||||
- os: linux
|
- os: linux
|
||||||
dist: trusty
|
dist: focal
|
||||||
compiler: clang
|
compiler: clang
|
||||||
jdk: openjdk8
|
jdk: openjdk11
|
||||||
env:
|
env:
|
||||||
- TARGET=cpp
|
- TARGET=cpp
|
||||||
- CXX=g++-5
|
- CXX=g++-10
|
||||||
- GROUP=RECURSION
|
- GROUP=RECURSION
|
||||||
stage: main-test
|
stage: main-test
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- sourceline: 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-10 main'
|
||||||
- llvm-toolchain-precise-3.7
|
|
||||||
packages:
|
packages:
|
||||||
- g++-5
|
- g++-10
|
||||||
- uuid-dev
|
- uuid-dev
|
||||||
- clang-3.7
|
- clang-10
|
||||||
- os: osx
|
- os: osx
|
||||||
compiler: clang
|
compiler: clang
|
||||||
osx_image: xcode10.2
|
osx_image: xcode10.2
|
||||||
|
@ -150,7 +147,9 @@ matrix:
|
||||||
stage: smoke-test
|
stage: smoke-test
|
||||||
- os: linux
|
- os: linux
|
||||||
jdk: openjdk8
|
jdk: openjdk8
|
||||||
env: TARGET=csharp
|
env:
|
||||||
|
- TARGET=dotnet
|
||||||
|
- GROUP=MAIN
|
||||||
stage: main-test
|
stage: main-test
|
||||||
- os: linux
|
- os: linux
|
||||||
jdk: openjdk8
|
jdk: openjdk8
|
||||||
|
@ -165,21 +164,18 @@ matrix:
|
||||||
stage: main-test
|
stage: main-test
|
||||||
- os: linux
|
- os: linux
|
||||||
jdk: openjdk8
|
jdk: openjdk8
|
||||||
dist: trusty
|
|
||||||
env:
|
env:
|
||||||
- TARGET=dotnet
|
- TARGET=dotnet
|
||||||
- GROUP=LEXER
|
- GROUP=LEXER
|
||||||
stage: extended-test
|
stage: extended-test
|
||||||
- os: linux
|
- os: linux
|
||||||
jdk: openjdk8
|
jdk: openjdk8
|
||||||
dist: trusty
|
|
||||||
env:
|
env:
|
||||||
- TARGET=dotnet
|
- TARGET=dotnet
|
||||||
- GROUP=PARSER
|
- GROUP=PARSER
|
||||||
stage: extended-test
|
stage: extended-test
|
||||||
- os: linux
|
- os: linux
|
||||||
jdk: openjdk8
|
jdk: openjdk8
|
||||||
dist: trusty
|
|
||||||
env:
|
env:
|
||||||
- TARGET=dotnet
|
- TARGET=dotnet
|
||||||
- GROUP=RECURSION
|
- GROUP=RECURSION
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
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
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# install dotnet
|
wget https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
|
||||||
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 dpkg -i packages-microsoft-prod.deb
|
||||||
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 417A0893
|
sudo apt-get update; \
|
||||||
sudo apt-get update
|
sudo apt-get install -y apt-transport-https && \
|
||||||
sudo apt-get --allow-unauthenticated install dotnet-dev-1.0.4
|
sudo apt-get update && \
|
||||||
|
sudo apt-get install -y dotnet-sdk-3.1
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
mvn -q -Dparallel=methods -DthreadCount=4 -Dtest=csharp.* test
|
|
|
@ -2,20 +2,21 @@
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
export PATH=$PATH:/Users/travis/.dotnet
|
||||||
|
|
||||||
# we need to build the runtime before test run, since we used "--no-dependencies"
|
# we need to build the runtime before test run, since we used "--no-dependencies"
|
||||||
# when we call dotnet cli for restore and build, in order to speed up
|
# when we call dotnet cli for restore and build, in order to speed up
|
||||||
|
|
||||||
dotnet restore ../runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.dotnet.csproj
|
dotnet build -c Release -f netstandard2.0 ../runtime/CSharp/Antlr4.csproj
|
||||||
dotnet build -c Release -f netstandard1.3 ../runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.dotnet.csproj
|
|
||||||
|
|
||||||
# call test
|
# call test
|
||||||
|
|
||||||
if [ $GROUP == "LEXER" ]; then
|
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
|
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
|
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
|
else
|
||||||
mvn -q -Dparallel=classes -DthreadCount=4 -Dtest=csharp.* -Dantlr-csharp-netstandard=true test
|
mvn -q -Dparallel=methods -DthreadCount=4 -Dtest=csharp.* test
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -64,7 +64,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.12</version>
|
<version>4.13.1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.11</version>
|
<version>4.13.1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.11</version>
|
<version>4.13.1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.11</version>
|
<version>4.13.1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.11</version>
|
<version>4.13.1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -2,7 +2,7 @@ version: '4.9.1-SNAPSHOT+AppVeyor.{build}'
|
||||||
cache:
|
cache:
|
||||||
- '%USERPROFILE%\.m2'
|
- '%USERPROFILE%\.m2'
|
||||||
- '%USERPROFILE%\.nuget\packages -> **\project.json'
|
- '%USERPROFILE%\.nuget\packages -> **\project.json'
|
||||||
image: Visual Studio 2017
|
image: Visual Studio 2019
|
||||||
build: off
|
build: off
|
||||||
install:
|
install:
|
||||||
- git submodule update --init --recursive
|
- git submodule update --init --recursive
|
||||||
|
@ -11,10 +11,9 @@ install:
|
||||||
- cinst -y dart-sdk --version=2.8.4
|
- cinst -y dart-sdk --version=2.8.4
|
||||||
build_script:
|
build_script:
|
||||||
- mvn -DskipTests install --batch-mode
|
- 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
|
- dotnet build runtime/CSharp/Antlr4.csproj -c Release
|
||||||
- msbuild ./runtime-testsuite/target/classes/CSharp/runtime/CSharp/Antlr4.vs2013.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /verbosity:detailed
|
|
||||||
after_build:
|
after_build:
|
||||||
- msbuild /target:pack /property:Configuration=Release /verbosity:detailed runtime/CSharp/runtime/CSharp/Antlr4.dotnet.sln
|
- dotnet pack runtime/CSharp/Antlr4.csproj -c Release
|
||||||
test_script:
|
test_script:
|
||||||
- mvn install -Dantlr-php-php="C:\tools\php\php.exe" -Dantlr-dart-dart="C:\tools\dart-sdk\bin\dart.exe" -Dantlr-dart-pub="C:\tools\dart-sdk\bin\pub.bat" -Dantlr-dart-dart2native="C:\tools\dart-sdk\bin\dart2native.bat" -Dantlr-python2-python="C:\Python27\python.exe" -Dantlr-python3-python="C:\Python35\python.exe" --batch-mode
|
- 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:
|
artifacts:
|
||||||
|
|
|
@ -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>
|
|
|
@ -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>
|
|
|
@ -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>
|
|
139
build/build.ps1
139
build/build.ps1
|
@ -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'
|
|
||||||
}
|
|
|
@ -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
|
|
||||||
}
|
|
|
@ -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))
|
|
||||||
}
|
|
|
@ -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"
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
$AntlrVersion = "4.5.1"
|
|
|
@ -219,6 +219,7 @@ YYYY/MM/DD, github id, Full name, email
|
||||||
2018/11/29, hannemann-tamas, Ralf Hannemann-Tamas, ralf.ht@gmail.com
|
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/20, WalterCouto, Walter Couto, WalterCouto@users.noreply.github.com
|
||||||
2018/12/23, youkaichao, Kaichao You, youkaichao@gmail.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/02, wkhemir, Wail Khemir, khemirwail@gmail.com
|
||||||
2019/01/16, kuegi, Markus Zancolo, markus.zancolo@roomle.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/06, ralucado, Cristina Raluca Vijulie, ralucris.v[at]gmail[dot]com
|
||||||
|
@ -281,3 +282,5 @@ YYYY/MM/DD, github id, Full name, email
|
||||||
2020/10/24, cliid, Jiwu Jang, jiwujang@naver.com
|
2020/10/24, cliid, Jiwu Jang, jiwujang@naver.com
|
||||||
2020/11/05, MichelHartmann, Michel Hartmann, MichelHartmann@users.noreply.github.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/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
|
||||||
|
|
|
@ -24,14 +24,14 @@ and put it somewhere rational like `/usr/local/lib`.
|
||||||
|
|
||||||
2. Add `antlr-4.9-complete.jar` to your `CLASSPATH`:
|
2. Add `antlr-4.9-complete.jar` to your `CLASSPATH`:
|
||||||
```
|
```
|
||||||
$ export CLASSPATH=".:/usr/local/lib/antlr-4.9-complete.jar.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.
|
It's also a good idea to put this in your `.bash_profile` or whatever your startup script is.
|
||||||
|
|
||||||
3. Create aliases for the ANTLR Tool, and `TestRig`.
|
3. Create aliases for the ANTLR Tool, and `TestRig`.
|
||||||
```
|
```
|
||||||
$ alias antlr4='java -Xmx500M -cp "/usr/local/lib/antlr-4.9-complete.jar.jar:$CLASSPATH" org.antlr.v4.Tool'
|
$ 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.jar:$CLASSPATH" org.antlr.v4.gui.TestRig'
|
$ alias grun='java -Xmx500M -cp "/usr/local/lib/antlr-4.9-complete.jar:$CLASSPATH" org.antlr.v4.gui.TestRig'
|
||||||
```
|
```
|
||||||
|
|
||||||
### WINDOWS
|
### WINDOWS
|
||||||
|
@ -41,7 +41,7 @@ $ alias grun='java -Xmx500M -cp "/usr/local/lib/antlr-4.9-complete.jar.jar:$CLAS
|
||||||
0. Install Java (version 1.7 or higher)
|
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/)
|
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`
|
Save to your directory for 3rd party Java libraries, say `C:\Javalib`
|
||||||
2. Add `antlr-4.9-complete.jar.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
|
* Permanently: Using System Properties dialog > Environment variables > Create or append to `CLASSPATH` variable
|
||||||
* Temporarily, at command line:
|
* Temporarily, at command line:
|
||||||
```
|
```
|
||||||
|
|
|
@ -139,7 +139,7 @@ Edit the pom.xml file. Now we need to extensively modify the pom.xml file. The f
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>3.8.1</version>
|
<version>4.13.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -55,8 +55,7 @@ Edit the repository looking for 4.5 or whatever and update it. Bump version in t
|
||||||
* runtime/Python2/src/antlr4/Recognizer.py
|
* runtime/Python2/src/antlr4/Recognizer.py
|
||||||
* runtime/Python3/setup.py
|
* runtime/Python3/setup.py
|
||||||
* runtime/Python3/src/antlr4/Recognizer.py
|
* runtime/Python3/src/antlr4/Recognizer.py
|
||||||
* runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Properties/AssemblyInfo.cs
|
* runtime/CSharp/Antlr4.csproj
|
||||||
* runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.dotnet.csproj
|
|
||||||
* runtime/PHP/src/RuntimeMetaData.php
|
* runtime/PHP/src/RuntimeMetaData.php
|
||||||
* runtime/JavaScript/package.json
|
* runtime/JavaScript/package.json
|
||||||
* runtime/JavaScript/src/antlr4/Recognizer.js
|
* runtime/JavaScript/src/antlr4/Recognizer.js
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.12</version>
|
<version>4.13.1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -119,12 +119,12 @@ public abstract class BaseRuntimeTest {
|
||||||
@Test
|
@Test
|
||||||
public void testOne() throws Exception {
|
public void testOne() throws Exception {
|
||||||
// System.out.println(delegate.getTmpDir());
|
// System.out.println(delegate.getTmpDir());
|
||||||
if ( descriptor.ignore(descriptor.getTarget()) ) {
|
if (descriptor.ignore(descriptor.getTarget()) ) {
|
||||||
System.out.println("Ignore " + descriptor);
|
System.out.println("Ignore " + descriptor);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( descriptor.getTestType().contains("Parser") ) {
|
if (descriptor.getTestType().contains("Parser") ) {
|
||||||
testParser(descriptor);
|
testParser(descriptor);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp1.0</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<NoWarn>$(NoWarn);CS3021</NoWarn>
|
<NoWarn>$(NoWarn);CS3021</NoWarn>
|
||||||
<AssemblyName>Test</AssemblyName>
|
<AssemblyName>Test</AssemblyName>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<PackageId>Antlr4.Test.dotnet</PackageId>
|
<PackageId>Antlr4.Test</PackageId>
|
||||||
<RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion>
|
|
||||||
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
|
|
||||||
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
|
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
|
||||||
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
|
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
|
||||||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
|
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
|
|
@ -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>
|
|
|
@ -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>
|
|
|
@ -1,7 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<configuration>
|
|
||||||
<startup>
|
|
||||||
<supportedRuntime version="v2.0.50727"/>
|
|
||||||
<supportedRuntime version="v4.0"/>
|
|
||||||
</startup>
|
|
||||||
</configuration>
|
|
|
@ -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("")]
|
|
||||||
|
|
|
@ -58,13 +58,6 @@ import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class BaseCSharpTest implements RuntimeTestSupport {
|
public class BaseCSharpTest implements RuntimeTestSupport {
|
||||||
public static final String newline = System.getProperty("line.separator");
|
public static final String newline = System.getProperty("line.separator");
|
||||||
public static final String pathSep = System.getProperty("path.separator");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* When {@code true}, on Linux will call dotnet cli toolchain, otherwise
|
|
||||||
* will continue to use mono
|
|
||||||
*/
|
|
||||||
public static final boolean NETSTANDARD = Boolean.parseBoolean(System.getProperty("antlr-csharp-netstandard"));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When the {@code antlr.preserve-test-dir} runtime property is set to
|
* When the {@code antlr.preserve-test-dir} runtime property is set to
|
||||||
|
@ -120,22 +113,24 @@ public class BaseCSharpTest implements RuntimeTestSupport {
|
||||||
|
|
||||||
public String tmpdir = null;
|
public String tmpdir = null;
|
||||||
|
|
||||||
/** If error during parser execution, store stderr here; can't return
|
/**
|
||||||
* stdout and stderr. This doesn't trap errors from running antlr.
|
* If error during parser execution, store stderr here; can't return
|
||||||
|
* stdout and stderr. This doesn't trap errors from running antlr.
|
||||||
*/
|
*/
|
||||||
protected String stderrDuringParse;
|
protected String stderrDuringParse;
|
||||||
|
|
||||||
/** Errors found while running antlr */
|
/**
|
||||||
|
* Errors found while running antlr
|
||||||
|
*/
|
||||||
protected StringBuilder antlrToolErrors;
|
protected StringBuilder antlrToolErrors;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void testSetUp() throws Exception {
|
public void testSetUp() throws Exception {
|
||||||
if (CREATE_PER_TEST_DIRECTORIES) {
|
if (CREATE_PER_TEST_DIRECTORIES) {
|
||||||
// new output dir for each test
|
// new output dir for each test
|
||||||
String testDirectory = getClass().getSimpleName() + "-"+Thread.currentThread().getName()+ "-" + System.currentTimeMillis();
|
String testDirectory = getClass().getSimpleName() + "-" + Thread.currentThread().getName() + "-" + System.currentTimeMillis();
|
||||||
tmpdir = new File(BASE_TEST_DIR, testDirectory).getAbsolutePath();
|
tmpdir = new File(BASE_TEST_DIR, testDirectory).getAbsolutePath();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
tmpdir = new File(BASE_TEST_DIR).getAbsolutePath();
|
tmpdir = new File(BASE_TEST_DIR).getAbsolutePath();
|
||||||
if (!PRESERVE_TEST_DIR && new File(tmpdir).exists()) {
|
if (!PRESERVE_TEST_DIR && new File(tmpdir).exists()) {
|
||||||
eraseDirectory(new File(tmpdir));
|
eraseDirectory(new File(tmpdir));
|
||||||
|
@ -165,152 +160,114 @@ public class BaseCSharpTest implements RuntimeTestSupport {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getANTLRToolErrors() {
|
public String getANTLRToolErrors() {
|
||||||
if ( antlrToolErrors.length()==0 ) {
|
if (antlrToolErrors.length() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return antlrToolErrors.toString();
|
return antlrToolErrors.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected org.antlr.v4.Tool newTool(String[] args) {
|
|
||||||
Tool tool = new Tool(args);
|
|
||||||
return tool;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Tool newTool() {
|
|
||||||
org.antlr.v4.Tool tool = new Tool(new String[] {"-o", tmpdir});
|
|
||||||
return tool;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String load(String fileName, String encoding)
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
if ( fileName==null ) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String fullFileName = getClass().getPackage().getName().replace('.', '/') + '/' + fileName;
|
|
||||||
int size = 65000;
|
|
||||||
InputStreamReader isr;
|
|
||||||
InputStream fis = getClass().getClassLoader().getResourceAsStream(fullFileName);
|
|
||||||
if ( encoding!=null ) {
|
|
||||||
isr = new InputStreamReader(fis, encoding);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
isr = new InputStreamReader(fis);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
char[] data = new char[size];
|
|
||||||
int n = isr.read(data);
|
|
||||||
return new String(data, 0, n);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
isr.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String execLexer(String grammarFileName,
|
protected String execLexer(String grammarFileName,
|
||||||
String grammarStr,
|
String grammarStr,
|
||||||
String lexerName,
|
String lexerName,
|
||||||
String input)
|
String input) {
|
||||||
{
|
|
||||||
return execLexer(grammarFileName, grammarStr, lexerName, input, false);
|
return execLexer(grammarFileName, grammarStr, lexerName, input, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String execLexer(String grammarFileName,
|
public String execLexer(String grammarFileName,
|
||||||
String grammarStr,
|
String grammarStr,
|
||||||
String lexerName,
|
String lexerName,
|
||||||
String input,
|
String input,
|
||||||
boolean showDFA)
|
boolean showDFA) {
|
||||||
{
|
|
||||||
boolean success = rawGenerateRecognizer(grammarFileName,
|
boolean success = rawGenerateRecognizer(grammarFileName,
|
||||||
grammarStr,
|
grammarStr,
|
||||||
null,
|
null,
|
||||||
lexerName);
|
lexerName);
|
||||||
assertTrue(success);
|
assertTrue(success);
|
||||||
writeFile(tmpdir, "input", input);
|
writeFile(tmpdir, "input", input);
|
||||||
writeLexerTestFile(lexerName, showDFA);
|
writeLexerTestFile(lexerName, showDFA);
|
||||||
addSourceFiles("Test.cs");
|
addSourceFiles("Test.cs");
|
||||||
if(!compile()) {
|
if (!compile()) {
|
||||||
System.err.println("Failed to compile!");
|
System.err.println("Failed to compile!");
|
||||||
return stderrDuringParse;
|
return stderrDuringParse;
|
||||||
}
|
}
|
||||||
String output = execTest();
|
String output = execTest();
|
||||||
if ( output!=null && output.length()==0 ) {
|
if (output != null && output.length() == 0) {
|
||||||
output = null;
|
output = null;
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<String> sourceFiles = new HashSet<String>();
|
Set<String> sourceFiles = new HashSet<>();
|
||||||
|
|
||||||
private void addSourceFiles(String ... files) {
|
private void addSourceFiles(String... files) {
|
||||||
for(String file : files)
|
for (String file : files)
|
||||||
this.sourceFiles.add(file);
|
this.sourceFiles.add(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String execParser(String grammarFileName,
|
public String execParser(String grammarFileName,
|
||||||
String grammarStr,
|
String grammarStr,
|
||||||
String parserName,
|
String parserName,
|
||||||
String lexerName,
|
String lexerName,
|
||||||
String listenerName,
|
String listenerName,
|
||||||
String visitorName,
|
String visitorName,
|
||||||
String startRuleName,
|
String startRuleName,
|
||||||
String input,
|
String input,
|
||||||
boolean showDiagnosticErrors)
|
boolean showDiagnosticErrors) {
|
||||||
{
|
|
||||||
boolean success = rawGenerateRecognizer(grammarFileName,
|
boolean success = rawGenerateRecognizer(grammarFileName,
|
||||||
grammarStr,
|
grammarStr,
|
||||||
parserName,
|
parserName,
|
||||||
lexerName,
|
lexerName,
|
||||||
"-visitor");
|
"-visitor");
|
||||||
assertTrue(success);
|
assertTrue(success);
|
||||||
writeFile(tmpdir, "input", input);
|
writeFile(tmpdir, "input", input);
|
||||||
return rawExecRecognizer(parserName,
|
return rawExecRecognizer(parserName,
|
||||||
lexerName,
|
lexerName,
|
||||||
startRuleName,
|
startRuleName,
|
||||||
showDiagnosticErrors);
|
showDiagnosticErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return true if all is well */
|
/**
|
||||||
|
* Return true if all is well
|
||||||
|
*/
|
||||||
protected boolean rawGenerateRecognizer(String grammarFileName,
|
protected boolean rawGenerateRecognizer(String grammarFileName,
|
||||||
String grammarStr,
|
String grammarStr,
|
||||||
String parserName,
|
String parserName,
|
||||||
String lexerName,
|
String lexerName,
|
||||||
String... extraOptions)
|
String... extraOptions) {
|
||||||
{
|
|
||||||
return rawGenerateRecognizer(grammarFileName, grammarStr, parserName, lexerName, false, extraOptions);
|
return rawGenerateRecognizer(grammarFileName, grammarStr, parserName, lexerName, false, extraOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return true if all is well */
|
/**
|
||||||
|
* Return true if all is well
|
||||||
|
*/
|
||||||
protected boolean rawGenerateRecognizer(String grammarFileName,
|
protected boolean rawGenerateRecognizer(String grammarFileName,
|
||||||
String grammarStr,
|
String grammarStr,
|
||||||
String parserName,
|
String parserName,
|
||||||
String lexerName,
|
String lexerName,
|
||||||
boolean defaultListener,
|
boolean defaultListener,
|
||||||
String... extraOptions)
|
String... extraOptions) {
|
||||||
{
|
|
||||||
ErrorQueue equeue = antlrOnString(getTmpDir(), "CSharp", grammarFileName, grammarStr, defaultListener, extraOptions);
|
ErrorQueue equeue = antlrOnString(getTmpDir(), "CSharp", grammarFileName, grammarStr, defaultListener, extraOptions);
|
||||||
if (!equeue.errors.isEmpty()) {
|
if (!equeue.errors.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> files = new ArrayList<String>();
|
List<String> files = new ArrayList<String>();
|
||||||
if ( lexerName!=null ) {
|
if (lexerName != null) {
|
||||||
files.add(lexerName+".cs");
|
files.add(lexerName + ".cs");
|
||||||
}
|
}
|
||||||
if ( parserName!=null ) {
|
if (parserName != null) {
|
||||||
files.add(parserName+".cs");
|
files.add(parserName + ".cs");
|
||||||
Set<String> optionsSet = new HashSet<String>(Arrays.asList(extraOptions));
|
Set<String> optionsSet = new HashSet<String>(Arrays.asList(extraOptions));
|
||||||
String grammarName = grammarFileName.substring(0, grammarFileName.lastIndexOf('.'));
|
String grammarName = grammarFileName.substring(0, grammarFileName.lastIndexOf('.'));
|
||||||
if (!optionsSet.contains("-no-listener")) {
|
if (!optionsSet.contains("-no-listener")) {
|
||||||
files.add(grammarName+"Listener.cs");
|
files.add(grammarName + "Listener.cs");
|
||||||
files.add(grammarName+"BaseListener.cs");
|
files.add(grammarName + "BaseListener.cs");
|
||||||
}
|
}
|
||||||
if (optionsSet.contains("-visitor")) {
|
if (optionsSet.contains("-visitor")) {
|
||||||
files.add(grammarName+"Visitor.cs");
|
files.add(grammarName + "Visitor.cs");
|
||||||
files.add(grammarName+"BaseVisitor.cs");
|
files.add(grammarName + "BaseVisitor.cs");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addSourceFiles(files.toArray(new String[files.size()]));
|
addSourceFiles(files.toArray(new String[files.size()]));
|
||||||
|
@ -318,19 +275,17 @@ public class BaseCSharpTest implements RuntimeTestSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String rawExecRecognizer(String parserName,
|
protected String rawExecRecognizer(String parserName,
|
||||||
String lexerName,
|
String lexerName,
|
||||||
String parserStartRuleName,
|
String parserStartRuleName,
|
||||||
boolean debug)
|
boolean debug) {
|
||||||
{
|
|
||||||
this.stderrDuringParse = null;
|
this.stderrDuringParse = null;
|
||||||
if ( parserName==null ) {
|
if (parserName == null) {
|
||||||
writeLexerTestFile(lexerName, false);
|
writeLexerTestFile(lexerName, false);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
writeParserTestFile(parserName,
|
writeParserTestFile(parserName,
|
||||||
lexerName,
|
lexerName,
|
||||||
parserStartRuleName,
|
parserStartRuleName,
|
||||||
debug);
|
debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
addSourceFiles("Test.cs");
|
addSourceFiles("Test.cs");
|
||||||
|
@ -342,50 +297,76 @@ public class BaseCSharpTest implements RuntimeTestSupport {
|
||||||
assertTrue(success);
|
assertTrue(success);
|
||||||
|
|
||||||
String output = execTest();
|
String output = execTest();
|
||||||
if ( output!=null && output.length()==0 ) {
|
if (output != null && output.length() == 0) {
|
||||||
output = null;
|
output = null;
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean compile() {
|
public boolean compile() {
|
||||||
if(!NETSTANDARD) {
|
try {
|
||||||
try {
|
return buildProject();
|
||||||
if(!createProject())
|
} catch (Exception e) {
|
||||||
return false;
|
e.printStackTrace(System.err);
|
||||||
if(!buildProject())
|
return false;
|
||||||
return false;
|
}
|
||||||
return true;
|
|
||||||
} catch(Exception e) {
|
|
||||||
e.printStackTrace(System.err);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return buildDotnetProject();
|
|
||||||
} catch(Exception e) {
|
|
||||||
e.printStackTrace(System.err);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private File getTestProjectFile() {
|
private String locateExec() {
|
||||||
return new File(tmpdir, "Antlr4.Test.mono.csproj");
|
return new File(tmpdir, "bin/Release/netcoreapp3.1/Test.dll").getAbsolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean buildProject() throws Exception {
|
public boolean buildProject() {
|
||||||
String msbuild = locateMSBuild();
|
try {
|
||||||
String[] args = {
|
// save auxiliary files
|
||||||
msbuild,
|
String pack = BaseCSharpTest.class.getPackage().getName().replace(".", "/") + "/";
|
||||||
"/p:Configuration=Release",
|
saveResourceAsFile(pack + "Antlr4.Test.csproj", new File(tmpdir, "Antlr4.Test.csproj"));
|
||||||
getTestProjectFile().getAbsolutePath()
|
|
||||||
};
|
// find runtime package
|
||||||
// System.err.println("Starting build "+ Utils.join(args, " "));
|
final ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
||||||
|
final URL runtimeProj = loader.getResource("CSharp/Antlr4.csproj");
|
||||||
|
if (runtimeProj == null) {
|
||||||
|
throw new RuntimeException("C# runtime project file not found!");
|
||||||
|
}
|
||||||
|
File runtimeProjFile = new File(runtimeProj.getFile());
|
||||||
|
String runtimeProjPath = runtimeProjFile.getPath();
|
||||||
|
|
||||||
|
// add Runtime project reference
|
||||||
|
String[] args = new String[]{
|
||||||
|
"dotnet",
|
||||||
|
"add",
|
||||||
|
"Antlr4.Test.csproj",
|
||||||
|
"reference",
|
||||||
|
runtimeProjPath
|
||||||
|
};
|
||||||
|
boolean success = runProcess(args, tmpdir);
|
||||||
|
assertTrue(success);
|
||||||
|
|
||||||
|
// build test
|
||||||
|
args = new String[]{
|
||||||
|
"dotnet",
|
||||||
|
"build",
|
||||||
|
"Antlr4.Test.csproj",
|
||||||
|
"-c",
|
||||||
|
"Release"
|
||||||
|
};
|
||||||
|
success = runProcess(args, tmpdir);
|
||||||
|
assertTrue(success);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace(System.err);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean runProcess(String[] args, String path) throws Exception {
|
||||||
|
return runProcess(args, path, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean runProcess(String[] args, String path, int retries) throws Exception {
|
||||||
ProcessBuilder pb = new ProcessBuilder(args);
|
ProcessBuilder pb = new ProcessBuilder(args);
|
||||||
pb.directory(new File(tmpdir));
|
pb.directory(new File(path));
|
||||||
Process process = pb.start();
|
Process process = pb.start();
|
||||||
StreamVacuum stdoutVacuum = new StreamVacuum(process.getInputStream());
|
StreamVacuum stdoutVacuum = new StreamVacuum(process.getInputStream());
|
||||||
StreamVacuum stderrVacuum = new StreamVacuum(process.getErrorStream());
|
StreamVacuum stderrVacuum = new StreamVacuum(process.getErrorStream());
|
||||||
|
@ -394,208 +375,39 @@ public class BaseCSharpTest implements RuntimeTestSupport {
|
||||||
process.waitFor();
|
process.waitFor();
|
||||||
stdoutVacuum.join();
|
stdoutVacuum.join();
|
||||||
stderrVacuum.join();
|
stderrVacuum.join();
|
||||||
// xbuild sends errors to output, so check exit code
|
|
||||||
int exitValue = process.exitValue();
|
int exitValue = process.exitValue();
|
||||||
boolean success = (exitValue == 0);
|
boolean success = (exitValue == 0);
|
||||||
if ( !success ) {
|
if (!success) {
|
||||||
this.stderrDuringParse = stdoutVacuum.toString();
|
this.stderrDuringParse = stderrVacuum.toString();
|
||||||
String stderrString = stderrVacuum.toString();
|
System.err.println("runProcess command: " + Utils.join(args, " "));
|
||||||
System.err.println("buildProject command: " + Utils.join(args, " "));
|
System.err.println("runProcess exitValue: " + exitValue);
|
||||||
System.err.println("buildProject exitValue: " + exitValue);
|
System.err.println("runProcess stdoutVacuum: " + stdoutVacuum.toString());
|
||||||
System.err.println("buildProject stdout: " + stderrDuringParse);
|
System.err.println("runProcess stderrVacuum: " + stderrDuringParse);
|
||||||
System.err.println("buildProject stderr: " + stderrString);
|
}
|
||||||
|
if (exitValue == 132) {
|
||||||
|
// Retry after SIGILL. We are seeing this intermittently on
|
||||||
|
// macOS (issue #2078).
|
||||||
|
if (retries < 3) {
|
||||||
|
System.err.println("runProcess retrying; " + retries +
|
||||||
|
" retries so far");
|
||||||
|
return runProcess(args, path, retries + 1);
|
||||||
|
} else {
|
||||||
|
System.err.println("runProcess giving up after " + retries +
|
||||||
|
" retries");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String locateMSBuild() {
|
|
||||||
if(isWindows())
|
|
||||||
return "\"C:\\Program Files (x86)\\MSBuild\\12.0\\Bin\\MSBuild.exe\"";
|
|
||||||
else
|
|
||||||
return locateTool("xbuild");
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isWindows() {
|
|
||||||
return System.getProperty("os.name").toLowerCase().contains("windows");
|
|
||||||
}
|
|
||||||
|
|
||||||
private String locateExec() {
|
|
||||||
if (!NETSTANDARD)
|
|
||||||
return new File(tmpdir, "bin/Release/Test.exe").getAbsolutePath();
|
|
||||||
|
|
||||||
return new File(tmpdir, "bin/Release/netcoreapp1.0/Test.dll").getAbsolutePath();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String locateTool(String tool) {
|
|
||||||
String[] roots = { "/opt/local/bin/", "/usr/local/bin/", "/usr/bin/" };
|
|
||||||
for(String root : roots) {
|
|
||||||
if(new File(root + tool).exists())
|
|
||||||
return root + tool;
|
|
||||||
}
|
|
||||||
throw new RuntimeException("Could not locate " + tool);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean createProject() {
|
|
||||||
try {
|
|
||||||
String pack = BaseCSharpTest.class.getPackage().getName().replace(".", "/") + "/";
|
|
||||||
// save auxiliary files
|
|
||||||
saveResourceAsFile(pack + "AssemblyInfo.cs", new File(tmpdir, "AssemblyInfo.cs"));
|
|
||||||
saveResourceAsFile(pack + "App.config", new File(tmpdir, "App.config"));
|
|
||||||
// update project
|
|
||||||
String projectName = isWindows() ? "Antlr4.Test.vs2013.csproj" : "Antlr4.Test.mono.csproj";
|
|
||||||
final ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
|
||||||
InputStream input = loader.getResourceAsStream(pack + projectName);
|
|
||||||
Document prjXml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(input);
|
|
||||||
// update runtime project reference
|
|
||||||
// find project file as a resource not relative pathname (now that we've merged repos)
|
|
||||||
String runtimeName = isWindows() ? "Antlr4.Runtime.vs2013.csproj" : "Antlr4.Runtime.mono.csproj";
|
|
||||||
final URL runtimeProj = loader.getResource("CSharp/runtime/CSharp/Antlr4.Runtime/"+runtimeName);
|
|
||||||
if ( runtimeProj==null ) {
|
|
||||||
throw new RuntimeException("C# runtime project file not found!");
|
|
||||||
}
|
|
||||||
String runtimeProjPath = runtimeProj.getPath();
|
|
||||||
if(isWindows()){
|
|
||||||
runtimeProjPath = runtimeProjPath.replaceFirst("/", "");
|
|
||||||
}
|
|
||||||
XPathExpression exp = XPathFactory.newInstance().newXPath()
|
|
||||||
.compile("/Project/ItemGroup/ProjectReference[@Include='" + runtimeName + "']");
|
|
||||||
Element node = (Element)exp.evaluate(prjXml, XPathConstants.NODE);
|
|
||||||
node.setAttribute("Include", runtimeProjPath.replace("/", "\\"));
|
|
||||||
// update project file list
|
|
||||||
exp = XPathFactory.newInstance().newXPath().compile("/Project/ItemGroup[Compile/@Include='AssemblyInfo.cs']");
|
|
||||||
Element group = (Element)exp.evaluate(prjXml, XPathConstants.NODE);
|
|
||||||
if(group==null)
|
|
||||||
return false;
|
|
||||||
// remove existing children
|
|
||||||
while(group.hasChildNodes())
|
|
||||||
group.removeChild(group.getFirstChild());
|
|
||||||
// add AssemblyInfo.cs, not a generated source
|
|
||||||
sourceFiles.add("AssemblyInfo.cs");
|
|
||||||
// add files to compile
|
|
||||||
for(String file : sourceFiles) {
|
|
||||||
Element elem = group.getOwnerDocument().createElement("Compile");
|
|
||||||
elem.setAttribute("Include", file);
|
|
||||||
group.appendChild(elem);
|
|
||||||
}
|
|
||||||
// save project
|
|
||||||
File prjFile = getTestProjectFile();
|
|
||||||
Transformer transformer = TransformerFactory.newInstance().newTransformer();
|
|
||||||
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
|
||||||
transformer.transform(new DOMSource(prjXml), new StreamResult(prjFile));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace(System.err);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean buildDotnetProject() {
|
|
||||||
try {
|
|
||||||
// save auxiliary files
|
|
||||||
String pack = BaseCSharpTest.class.getPackage().getName().replace(".", "/") + "/";
|
|
||||||
saveResourceAsFile(pack + "Antlr4.Test.dotnet.csproj", new File(tmpdir, "Antlr4.Test.dotnet.csproj"));
|
|
||||||
|
|
||||||
// find runtime package
|
|
||||||
final ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
|
||||||
final URL runtimeProj = loader.getResource("CSharp/runtime/CSharp/Antlr4.Runtime/Antlr4.Runtime.dotnet.csproj");
|
|
||||||
if ( runtimeProj==null ) {
|
|
||||||
throw new RuntimeException("C# runtime project file not found!");
|
|
||||||
}
|
|
||||||
File runtimeProjFile = new File(runtimeProj.getFile());
|
|
||||||
String runtimeProjPath = runtimeProjFile.getPath();
|
|
||||||
|
|
||||||
// add Runtime project reference
|
|
||||||
String dotnetcli = locateTool("dotnet");
|
|
||||||
String[] args = new String[] {
|
|
||||||
dotnetcli,
|
|
||||||
"add",
|
|
||||||
"Antlr4.Test.dotnet.csproj",
|
|
||||||
"reference",
|
|
||||||
runtimeProjPath
|
|
||||||
};
|
|
||||||
boolean success = runProcess(args, tmpdir);
|
|
||||||
assertTrue(success);
|
|
||||||
|
|
||||||
// restore project
|
|
||||||
args = new String[] {
|
|
||||||
dotnetcli,
|
|
||||||
"restore",
|
|
||||||
"Antlr4.Test.dotnet.csproj",
|
|
||||||
"--no-dependencies"
|
|
||||||
};
|
|
||||||
success = runProcess(args, tmpdir);
|
|
||||||
assertTrue(success);
|
|
||||||
|
|
||||||
// build test
|
|
||||||
args = new String[] {
|
|
||||||
dotnetcli,
|
|
||||||
"build",
|
|
||||||
"Antlr4.Test.dotnet.csproj",
|
|
||||||
"-c",
|
|
||||||
"Release",
|
|
||||||
"--no-dependencies"
|
|
||||||
};
|
|
||||||
success = runProcess(args, tmpdir);
|
|
||||||
assertTrue(success);
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace(System.err);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean runProcess(String[] args, String path) throws Exception {
|
|
||||||
return runProcess(args, path, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean runProcess(String[] args, String path, int retries) throws Exception {
|
|
||||||
ProcessBuilder pb = new ProcessBuilder(args);
|
|
||||||
pb.directory(new File(path));
|
|
||||||
Process process = pb.start();
|
|
||||||
StreamVacuum stdoutVacuum = new StreamVacuum(process.getInputStream());
|
|
||||||
StreamVacuum stderrVacuum = new StreamVacuum(process.getErrorStream());
|
|
||||||
stdoutVacuum.start();
|
|
||||||
stderrVacuum.start();
|
|
||||||
process.waitFor();
|
|
||||||
stdoutVacuum.join();
|
|
||||||
stderrVacuum.join();
|
|
||||||
int exitValue = process.exitValue();
|
|
||||||
boolean success = (exitValue == 0);
|
|
||||||
if ( !success ) {
|
|
||||||
this.stderrDuringParse = stderrVacuum.toString();
|
|
||||||
System.err.println("runProcess command: " + Utils.join(args, " "));
|
|
||||||
System.err.println("runProcess exitValue: " + exitValue);
|
|
||||||
System.err.println("runProcess stdoutVacuum: " + stdoutVacuum.toString());
|
|
||||||
System.err.println("runProcess stderrVacuum: " + stderrDuringParse);
|
|
||||||
}
|
|
||||||
if (exitValue == 132) {
|
|
||||||
// Retry after SIGILL. We are seeing this intermittently on
|
|
||||||
// macOS (issue #2078).
|
|
||||||
if (retries < 3) {
|
|
||||||
System.err.println("runProcess retrying; " + retries +
|
|
||||||
" retries so far");
|
|
||||||
return runProcess(args, path, retries + 1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
System.err.println("runProcess giving up after " + retries +
|
|
||||||
" retries");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveResourceAsFile(String resourceName, File file) throws IOException {
|
private void saveResourceAsFile(String resourceName, File file) throws IOException {
|
||||||
InputStream input = Thread.currentThread().getContextClassLoader().getResourceAsStream(resourceName);
|
InputStream input = Thread.currentThread().getContextClassLoader().getResourceAsStream(resourceName);
|
||||||
if ( input==null ) {
|
if (input == null) {
|
||||||
System.err.println("Can't find " + resourceName + " as resource");
|
System.err.println("Can't find " + resourceName + " as resource");
|
||||||
throw new IOException("Missing resource:" + resourceName);
|
throw new IOException("Missing resource:" + resourceName);
|
||||||
}
|
}
|
||||||
OutputStream output = new FileOutputStream(file.getAbsolutePath());
|
OutputStream output = new FileOutputStream(file.getAbsolutePath());
|
||||||
while(input.available()>0) {
|
while (input.available() > 0) {
|
||||||
output.write(input.read());
|
output.write(input.read());
|
||||||
}
|
}
|
||||||
output.close();
|
output.close();
|
||||||
|
@ -635,8 +447,7 @@ public class BaseCSharpTest implements RuntimeTestSupport {
|
||||||
System.err.println("execTest stderrVacuum: " + stderrString);
|
System.err.println("execTest stderrVacuum: " + stderrString);
|
||||||
}
|
}
|
||||||
return writtenOutput;
|
return writtenOutput;
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
System.err.println("can't exec recognizer");
|
System.err.println("can't exec recognizer");
|
||||||
e.printStackTrace(System.err);
|
e.printStackTrace(System.err);
|
||||||
}
|
}
|
||||||
|
@ -644,138 +455,62 @@ public class BaseCSharpTest implements RuntimeTestSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] getExecTestArgs(String exec, Path output, Path errorOutput) {
|
private String[] getExecTestArgs(String exec, Path output, Path errorOutput) {
|
||||||
if ( isWindows() ) {
|
return new String[]{
|
||||||
return new String[]{
|
"dotnet", exec, new File(tmpdir, "input").getAbsolutePath(),
|
||||||
exec, new File(tmpdir, "input").getAbsolutePath(),
|
|
||||||
output.toAbsolutePath().toString(),
|
output.toAbsolutePath().toString(),
|
||||||
errorOutput.toAbsolutePath().toString()
|
errorOutput.toAbsolutePath().toString()
|
||||||
};
|
};
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (!NETSTANDARD) {
|
|
||||||
String mono = locateTool("mono");
|
|
||||||
return new String[] {
|
|
||||||
mono, exec, new File(tmpdir, "input").getAbsolutePath(),
|
|
||||||
output.toAbsolutePath().toString(),
|
|
||||||
errorOutput.toAbsolutePath().toString()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
String dotnet = locateTool("dotnet");
|
|
||||||
return new String[] {
|
|
||||||
dotnet, exec, new File(tmpdir, "input").getAbsolutePath(),
|
|
||||||
output.toAbsolutePath().toString(),
|
|
||||||
errorOutput.toAbsolutePath().toString()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ANTLRMessage> getMessagesOfType(List<ANTLRMessage> msgs, Class<? extends ANTLRMessage> c) {
|
|
||||||
List<ANTLRMessage> filtered = new ArrayList<ANTLRMessage>();
|
|
||||||
for (ANTLRMessage m : msgs) {
|
|
||||||
if ( m.getClass() == c ) filtered.add(m);
|
|
||||||
}
|
|
||||||
return filtered;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected void checkGrammarSemanticsError(ErrorQueue equeue,
|
|
||||||
GrammarSemanticsMessage expectedMessage)
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
ANTLRMessage foundMsg = null;
|
|
||||||
for (int i = 0; i < equeue.errors.size(); i++) {
|
|
||||||
ANTLRMessage m = equeue.errors.get(i);
|
|
||||||
if (m.getErrorType()==expectedMessage.getErrorType() ) {
|
|
||||||
foundMsg = m;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assertNotNull("no error; "+expectedMessage.getErrorType()+" expected", foundMsg);
|
|
||||||
assertTrue("error is not a GrammarSemanticsMessage",
|
|
||||||
foundMsg instanceof GrammarSemanticsMessage);
|
|
||||||
assertEquals(Arrays.toString(expectedMessage.getArgs()), Arrays.toString(foundMsg.getArgs()));
|
|
||||||
if ( equeue.size()!=1 ) {
|
|
||||||
System.err.println(equeue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static class FilteringTokenStream extends CommonTokenStream {
|
|
||||||
public FilteringTokenStream(TokenSource src) { super(src); }
|
|
||||||
Set<Integer> hide = new HashSet<Integer>();
|
|
||||||
@Override
|
|
||||||
protected boolean sync(int i) {
|
|
||||||
if (!super.sync(i)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Token t = get(i);
|
|
||||||
if ( hide.contains(t.getType()) ) {
|
|
||||||
((WritableToken)t).setChannel(Token.HIDDEN_CHANNEL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public void setTokenTypeChannel(int ttype, int channel) {
|
|
||||||
hide.add(ttype);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void mkdir(String dir) {
|
|
||||||
File f = new File(dir);
|
|
||||||
f.mkdirs();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void writeParserTestFile(String parserName,
|
protected void writeParserTestFile(String parserName,
|
||||||
String lexerName,
|
String lexerName,
|
||||||
String parserStartRuleName,
|
String parserStartRuleName,
|
||||||
boolean debug)
|
boolean debug) {
|
||||||
{
|
|
||||||
ST outputFileST = new ST(
|
ST outputFileST = new ST(
|
||||||
"using System;\n" +
|
"using System;\n" +
|
||||||
"using Antlr4.Runtime;\n" +
|
"using Antlr4.Runtime;\n" +
|
||||||
"using Antlr4.Runtime.Tree;\n" +
|
"using Antlr4.Runtime.Tree;\n" +
|
||||||
"using System.IO;\n" +
|
"using System.IO;\n" +
|
||||||
"using System.Text;\n" +
|
"using System.Text;\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"public class Test {\n" +
|
"public class Test {\n" +
|
||||||
" public static void Main(string[] args) {\n" +
|
" public static void Main(string[] args) {\n" +
|
||||||
" var input = CharStreams.fromPath(args[0]);\n" +
|
" var input = CharStreams.fromPath(args[0]);\n" +
|
||||||
" using (FileStream fsOut = new FileStream(args[1], FileMode.Create, FileAccess.Write))\n" +
|
" using (FileStream fsOut = new FileStream(args[1], FileMode.Create, FileAccess.Write))\n" +
|
||||||
" using (FileStream fsErr = new FileStream(args[2], FileMode.Create, FileAccess.Write))\n" +
|
" using (FileStream fsErr = new FileStream(args[2], FileMode.Create, FileAccess.Write))\n" +
|
||||||
" using (TextWriter output = new StreamWriter(fsOut),\n" +
|
" using (TextWriter output = new StreamWriter(fsOut),\n" +
|
||||||
" errorOutput = new StreamWriter(fsErr)) {\n" +
|
" errorOutput = new StreamWriter(fsErr)) {\n" +
|
||||||
" <lexerName> lex = new <lexerName>(input, output, errorOutput);\n" +
|
" <lexerName> lex = new <lexerName>(input, output, errorOutput);\n" +
|
||||||
" CommonTokenStream tokens = new CommonTokenStream(lex);\n" +
|
" CommonTokenStream tokens = new CommonTokenStream(lex);\n" +
|
||||||
" <createParser>\n"+
|
" <createParser>\n" +
|
||||||
" parser.BuildParseTree = true;\n" +
|
" parser.BuildParseTree = true;\n" +
|
||||||
" ParserRuleContext tree = parser.<parserStartRuleName>();\n" +
|
" ParserRuleContext tree = parser.<parserStartRuleName>();\n" +
|
||||||
" ParseTreeWalker.Default.Walk(new TreeShapeListener(), tree);\n" +
|
" ParseTreeWalker.Default.Walk(new TreeShapeListener(), tree);\n" +
|
||||||
" }\n" +
|
" }\n" +
|
||||||
" }\n" +
|
" }\n" +
|
||||||
"}\n" +
|
"}\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"class TreeShapeListener : IParseTreeListener {\n" +
|
"class TreeShapeListener : IParseTreeListener {\n" +
|
||||||
" public void VisitTerminal(ITerminalNode node) { }\n" +
|
" public void VisitTerminal(ITerminalNode node) { }\n" +
|
||||||
" public void VisitErrorNode(IErrorNode node) { }\n" +
|
" public void VisitErrorNode(IErrorNode node) { }\n" +
|
||||||
" public void ExitEveryRule(ParserRuleContext ctx) { }\n" +
|
" public void ExitEveryRule(ParserRuleContext ctx) { }\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
" public void EnterEveryRule(ParserRuleContext ctx) {\n" +
|
" public void EnterEveryRule(ParserRuleContext ctx) {\n" +
|
||||||
" for (int i = 0; i \\< ctx.ChildCount; i++) {\n" +
|
" for (int i = 0; i \\< ctx.ChildCount; i++) {\n" +
|
||||||
" IParseTree parent = ctx.GetChild(i).Parent;\n" +
|
" IParseTree parent = ctx.GetChild(i).Parent;\n" +
|
||||||
" if (!(parent is IRuleNode) || ((IRuleNode)parent).RuleContext != ctx) {\n" +
|
" if (!(parent is IRuleNode) || ((IRuleNode)parent).RuleContext != ctx) {\n" +
|
||||||
" throw new Exception(\"Invalid parse tree shape detected.\");\n" +
|
" throw new Exception(\"Invalid parse tree shape detected.\");\n" +
|
||||||
" }\n" +
|
" }\n" +
|
||||||
" }\n" +
|
" }\n" +
|
||||||
" }\n" +
|
" }\n" +
|
||||||
"}"
|
"}"
|
||||||
);
|
);
|
||||||
ST createParserST = new ST(" <parserName> parser = new <parserName>(tokens, output, errorOutput);\n");
|
ST createParserST = new ST(" <parserName> parser = new <parserName>(tokens, output, errorOutput);\n");
|
||||||
if ( debug ) {
|
if (debug) {
|
||||||
createParserST =
|
createParserST =
|
||||||
new ST(
|
new ST(
|
||||||
" <parserName> parser = new <parserName>(tokens, output, errorOutput);\n" +
|
" <parserName> parser = new <parserName>(tokens, output, errorOutput);\n" +
|
||||||
" parser.AddErrorListener(new DiagnosticErrorListener());\n");
|
" parser.AddErrorListener(new DiagnosticErrorListener());\n");
|
||||||
}
|
}
|
||||||
outputFileST.add("createParser", createParserST);
|
outputFileST.add("createParser", createParserST);
|
||||||
outputFileST.add("parserName", parserName);
|
outputFileST.add("parserName", parserName);
|
||||||
|
@ -786,113 +521,63 @@ public class BaseCSharpTest implements RuntimeTestSupport {
|
||||||
|
|
||||||
protected void writeLexerTestFile(String lexerName, boolean showDFA) {
|
protected void writeLexerTestFile(String lexerName, boolean showDFA) {
|
||||||
ST outputFileST = new ST(
|
ST outputFileST = new ST(
|
||||||
"using System;\n" +
|
"using System;\n" +
|
||||||
"using Antlr4.Runtime;\n" +
|
"using Antlr4.Runtime;\n" +
|
||||||
"using System.IO;\n" +
|
"using System.IO;\n" +
|
||||||
"using System.Text;\n" +
|
"using System.Text;\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"public class Test {\n" +
|
"public class Test {\n" +
|
||||||
" public static void Main(string[] args) {\n" +
|
" public static void Main(string[] args) {\n" +
|
||||||
" var input = CharStreams.fromPath(args[0]);\n" +
|
" var input = CharStreams.fromPath(args[0]);\n" +
|
||||||
" using (FileStream fsOut = new FileStream(args[1], FileMode.Create, FileAccess.Write))\n" +
|
" using (FileStream fsOut = new FileStream(args[1], FileMode.Create, FileAccess.Write))\n" +
|
||||||
" using (FileStream fsErr = new FileStream(args[2], FileMode.Create, FileAccess.Write))\n" +
|
" using (FileStream fsErr = new FileStream(args[2], FileMode.Create, FileAccess.Write))\n" +
|
||||||
" using (TextWriter output = new StreamWriter(fsOut),\n" +
|
" using (TextWriter output = new StreamWriter(fsOut),\n" +
|
||||||
" errorOutput = new StreamWriter(fsErr)) {\n" +
|
" errorOutput = new StreamWriter(fsErr)) {\n" +
|
||||||
" <lexerName> lex = new <lexerName>(input, output, errorOutput);\n" +
|
" <lexerName> lex = new <lexerName>(input, output, errorOutput);\n" +
|
||||||
" CommonTokenStream tokens = new CommonTokenStream(lex);\n" +
|
" CommonTokenStream tokens = new CommonTokenStream(lex);\n" +
|
||||||
" tokens.Fill();\n" +
|
" tokens.Fill();\n" +
|
||||||
" foreach (object t in tokens.GetTokens())\n" +
|
" foreach (object t in tokens.GetTokens())\n" +
|
||||||
" output.WriteLine(t);\n" +
|
" output.WriteLine(t);\n" +
|
||||||
(showDFA?" output.Write(lex.Interpreter.GetDFA(Lexer.DEFAULT_MODE).ToLexerString());\n":"")+
|
(showDFA ? " output.Write(lex.Interpreter.GetDFA(Lexer.DEFAULT_MODE).ToLexerString());\n" : "") +
|
||||||
" }\n" +
|
" }\n" +
|
||||||
"}\n" +
|
"}\n" +
|
||||||
"}"
|
"}"
|
||||||
);
|
);
|
||||||
|
|
||||||
outputFileST.add("lexerName", lexerName);
|
outputFileST.add("lexerName", lexerName);
|
||||||
writeFile(tmpdir, "Test.cs", outputFileST.render());
|
writeFile(tmpdir, "Test.cs", outputFileST.render());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeRecognizerAndCompile(String parserName, String lexerName,
|
|
||||||
String parserStartRuleName,
|
|
||||||
boolean debug) {
|
|
||||||
if ( parserName==null ) {
|
|
||||||
writeLexerTestFile(lexerName, debug);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
writeParserTestFile(parserName,
|
|
||||||
lexerName,
|
|
||||||
parserStartRuleName,
|
|
||||||
debug);
|
|
||||||
}
|
|
||||||
|
|
||||||
addSourceFiles("Test.cs");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected void eraseFiles(final String filesEndingWith) {
|
|
||||||
File tmpdirF = new File(tmpdir);
|
|
||||||
String[] files = tmpdirF.list();
|
|
||||||
for(int i = 0; files!=null && i < files.length; i++) {
|
|
||||||
if ( files[i].endsWith(filesEndingWith) ) {
|
|
||||||
new File(tmpdir+"/"+files[i]).delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void eraseDirectory(File dir) {
|
protected void eraseDirectory(File dir) {
|
||||||
File[] files = dir.listFiles();
|
File[] files = dir.listFiles();
|
||||||
if (files != null) {
|
if (files != null) {
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
if (file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
eraseDirectory(file);
|
eraseDirectory(file);
|
||||||
}
|
} else {
|
||||||
else {
|
file.delete();
|
||||||
file.delete();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
dir.delete();
|
||||||
dir.delete();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void eraseTempDir() {
|
public void eraseTempDir() {
|
||||||
if (!PRESERVE_TEST_DIR) {
|
if (!PRESERVE_TEST_DIR) {
|
||||||
File tmpdirF = new File(tmpdir);
|
File tmpdirF = new File(tmpdir);
|
||||||
if ( tmpdirF.exists() ) {
|
if (tmpdirF.exists()) {
|
||||||
eraseDirectory(tmpdirF);
|
eraseDirectory(tmpdirF);
|
||||||
tmpdirF.delete();
|
tmpdirF.delete();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFirstLineOfException() {
|
|
||||||
if ( this.stderrDuringParse ==null ) {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
String[] lines = this.stderrDuringParse.split("\n");
|
|
||||||
String prefix="Exception in thread \"main\" ";
|
|
||||||
return lines[0].substring(prefix.length(),lines[0].length());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> realElements(List<String> elements) {
|
/**
|
||||||
return elements.subList(Token.MIN_USER_TOKEN_TYPE, elements.size());
|
* Return map sorted by key
|
||||||
}
|
*/
|
||||||
|
public <K extends Comparable<? super K>, V> LinkedHashMap<K, V> sort(Map<K, V> data) {
|
||||||
public void assertNotNullOrEmpty(String message, String text) {
|
LinkedHashMap<K, V> dup = new LinkedHashMap<K, V>();
|
||||||
assertNotNull(message, text);
|
|
||||||
assertFalse(message, text.isEmpty());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void assertNotNullOrEmpty(String text) {
|
|
||||||
assertNotNull(text);
|
|
||||||
assertFalse(text.isEmpty());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** Return map sorted by key */
|
|
||||||
public <K extends Comparable<? super K>,V> LinkedHashMap<K,V> sort(Map<K,V> data) {
|
|
||||||
LinkedHashMap<K,V> dup = new LinkedHashMap<K, V>();
|
|
||||||
List<K> keys = new ArrayList<K>();
|
List<K> keys = new ArrayList<K>();
|
||||||
keys.addAll(data.keySet());
|
keys.addAll(data.keySet());
|
||||||
Collections.sort(keys);
|
Collections.sort(keys);
|
||||||
|
@ -909,5 +594,4 @@ public class BaseCSharpTest implements RuntimeTestSupport {
|
||||||
protected static void assertEquals(String a, String b) {
|
protected static void assertEquals(String a, String b) {
|
||||||
org.junit.Assert.assertEquals(a, b);
|
org.junit.Assert.assertEquals(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
*/
|
*/
|
||||||
package org.antlr.v4.test.runtime.python;
|
package org.antlr.v4.test.runtime.python;
|
||||||
|
|
||||||
import com.sun.codemodel.internal.JForEach;
|
|
||||||
import org.antlr.v4.Tool;
|
import org.antlr.v4.Tool;
|
||||||
import org.antlr.v4.automata.ATNFactory;
|
import org.antlr.v4.automata.ATNFactory;
|
||||||
import org.antlr.v4.automata.ATNPrinter;
|
import org.antlr.v4.automata.ATNPrinter;
|
||||||
|
|
|
@ -2,27 +2,26 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Company>The ANTLR Organization</Company>
|
<Company>The ANTLR Organization</Company>
|
||||||
<Version>4.9</Version>
|
<Version>4.9</Version>
|
||||||
<NeutralLanguage>en-US</NeutralLanguage>
|
<NeutralLanguage>en-US</NeutralLanguage>
|
||||||
<TargetFrameworks>netstandard1.3;net35</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
|
||||||
<NoWarn>$(NoWarn);CS1591;CS1574;CS1580</NoWarn>
|
<NoWarn>$(NoWarn);CS1591;CS1574;CS1580</NoWarn>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<AssemblyName>Antlr4.Runtime.Standard</AssemblyName>
|
<AssemblyName>Antlr4.Runtime.Standard</AssemblyName>
|
||||||
<AssemblyOriginatorKeyFile>../../Antlr4.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>Antlr4.snk</AssemblyOriginatorKeyFile>
|
||||||
<SignAssembly>true</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
|
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
|
||||||
<PackageId>Antlr4.Runtime.Standard</PackageId>
|
<PackageId>Antlr4.Runtime.Standard</PackageId>
|
||||||
<Title>ANTLR 4 .NET Standard Runtime</Title>
|
<Title>ANTLR 4 .NET Standard Runtime</Title>
|
||||||
<Authors>Eric Vergnaud, Terence Parr, Sam Harwell</Authors>
|
<Authors>Eric Vergnaud, Terence Parr, Sam Harwell</Authors>
|
||||||
<Description>The .NET Core C# ANTLR 4 runtime from the ANTLR Organization</Description>
|
<Description>The .NET Core C# ANTLR 4 runtime from the ANTLR Organization</Description>
|
||||||
<Summary>The runtime library for parsers generated by the C# target of the standard ANTLR 4 tool.</Summary>
|
<Summary>The runtime library for parsers generated by the C# target of the standard ANTLR 4 tool.</Summary>
|
||||||
<Copyright>Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.</Copyright>
|
<Copyright>Copyright (c) 2012-2020 The ANTLR Project. All rights reserved.</Copyright>
|
||||||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
|
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
|
||||||
<PackageLicenseUrl>https://github.com/antlr/antlr4/blob/master/LICENSE.txt</PackageLicenseUrl>
|
<PackageLicenseExpression>BSD-3-Clause</PackageLicenseExpression>
|
||||||
<PackageProjectUrl>https://github.com/antlr/antlr4</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/antlr/antlr4</PackageProjectUrl>
|
||||||
<PackageIconUrl>https://raw.github.com/antlr/website-antlr4/master/images/icons/antlr.png</PackageIconUrl>
|
<PackageIconUrl>https://raw.github.com/antlr/website-antlr4/master/images/icons/antlr.png</PackageIconUrl>
|
||||||
<PackageReleaseNotes>https://github.com/antlr/antlr4/releases</PackageReleaseNotes>
|
<PackageReleaseNotes>https://github.com/antlr/antlr4/releases</PackageReleaseNotes>
|
||||||
<PackageTags>antlr parsing grammar</PackageTags>
|
<PackageTags>antlr parsing grammar</PackageTags>
|
||||||
<NetStandardImplicitPackageVersion>1.6.1</NetStandardImplicitPackageVersion>
|
|
||||||
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
|
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
|
||||||
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
|
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
|
||||||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
|
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
|
||||||
|
@ -38,16 +37,8 @@
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
<OutputPath>lib\Debug</OutputPath>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<OutputPath>lib\Release</OutputPath>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(TargetFramework)'=='netstandard1.3'">
|
|
||||||
<DefineConstants>DOTNETCORE;NET35PLUS;NET40PLUS;NET45PLUS</DefineConstants>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(TargetFramework)'=='net35'">
|
|
||||||
<DefineConstants>NET35PLUS</DefineConstants>
|
|
||||||
</PropertyGroup>
|
|
||||||
</Project>
|
</Project>
|
|
@ -3,18 +3,11 @@
|
||||||
* can be found in the LICENSE.txt file in the project root.
|
* can be found in the LICENSE.txt file in the project root.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !PORTABLE
|
|
||||||
|
|
||||||
using Antlr4.Runtime.Sharpen;
|
|
||||||
using Encoding = System.Text.Encoding;
|
using Encoding = System.Text.Encoding;
|
||||||
using File = System.IO.File;
|
using File = System.IO.File;
|
||||||
|
|
||||||
namespace Antlr4.Runtime
|
namespace Antlr4.Runtime
|
||||||
{
|
{
|
||||||
#if COMPACT
|
|
||||||
using StreamReader = System.IO.StreamReader;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is an
|
/// This is an
|
||||||
/// <see cref="AntlrInputStream"/>
|
/// <see cref="AntlrInputStream"/>
|
||||||
|
@ -47,17 +40,10 @@ namespace Antlr4.Runtime
|
||||||
}
|
}
|
||||||
|
|
||||||
string text;
|
string text;
|
||||||
#if !COMPACT
|
|
||||||
if (encoding != null)
|
if (encoding != null)
|
||||||
text = File.ReadAllText(fileName, encoding);
|
text = File.ReadAllText(fileName, encoding);
|
||||||
else
|
else
|
||||||
text = File.ReadAllText(fileName);
|
text = File.ReadAllText(fileName);
|
||||||
#else
|
|
||||||
if (encoding != null)
|
|
||||||
text = ReadAllText(fileName, encoding);
|
|
||||||
else
|
|
||||||
text = ReadAllText(fileName);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
data = text.ToCharArray();
|
data = text.ToCharArray();
|
||||||
n = data.Length;
|
n = data.Length;
|
||||||
|
@ -70,25 +56,5 @@ namespace Antlr4.Runtime
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if COMPACT
|
|
||||||
private static string ReadAllText(string path)
|
|
||||||
{
|
|
||||||
using (var reader = new StreamReader(path))
|
|
||||||
{
|
|
||||||
return reader.ReadToEnd();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string ReadAllText(string path, Encoding encoding)
|
|
||||||
{
|
|
||||||
using (var reader = new StreamReader(path, encoding ?? Encoding.Default))
|
|
||||||
{
|
|
||||||
return reader.ReadToEnd();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
|
@ -398,7 +398,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected internal virtual void ReadSets(ATN atn, IList<IntervalSet> sets, Func<int> readUnicode)
|
protected internal virtual void ReadSets(ATN atn, IList<IntervalSet> sets, System.Func<int> readUnicode)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// SETS
|
// SETS
|
|
@ -77,9 +77,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
|
|
||||||
protected void ConsoleWriteLine(string format, params object[] arg)
|
protected void ConsoleWriteLine(string format, params object[] arg)
|
||||||
{
|
{
|
||||||
#if !PORTABLE
|
|
||||||
System.Console.WriteLine(format, arg);
|
System.Console.WriteLine(format, arg);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PredictionContextCache getSharedContextCache()
|
public PredictionContextCache getSharedContextCache()
|
|
@ -95,9 +95,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
{
|
{
|
||||||
if (epsilonOnlyTransitions != e.IsEpsilon)
|
if (epsilonOnlyTransitions != e.IsEpsilon)
|
||||||
{
|
{
|
||||||
#if !PORTABLE
|
|
||||||
System.Console.Error.WriteLine("ATN state {0} has both epsilon and non-epsilon transitions.", stateNumber);
|
System.Console.Error.WriteLine("ATN state {0} has both epsilon and non-epsilon transitions.", stateNumber);
|
||||||
#endif
|
|
||||||
epsilonOnlyTransitions = false;
|
epsilonOnlyTransitions = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2112,9 +2112,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
*/
|
*/
|
||||||
public void DumpDeadEndConfigs(NoViableAltException nvae)
|
public void DumpDeadEndConfigs(NoViableAltException nvae)
|
||||||
{
|
{
|
||||||
#if !PORTABLE
|
|
||||||
System.Console.Error.WriteLine("dead end configs: ");
|
System.Console.Error.WriteLine("dead end configs: ");
|
||||||
#endif
|
|
||||||
foreach (ATNConfig c in nvae.DeadEndConfigs.configs)
|
foreach (ATNConfig c in nvae.DeadEndConfigs.configs)
|
||||||
{
|
{
|
||||||
String trans = "no edges";
|
String trans = "no edges";
|
||||||
|
@ -2133,9 +2131,8 @@ namespace Antlr4.Runtime.Atn
|
||||||
trans = (not ? "~" : "") + "Set " + st.set.ToString();
|
trans = (not ? "~" : "") + "Set " + st.set.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if !PORTABLE
|
|
||||||
System.Console.Error.WriteLine(c.ToString(parser, true) + ":" + trans);
|
System.Console.Error.WriteLine(c.ToString(parser, true) + ":" + trans);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -437,11 +437,7 @@ namespace Antlr4.Runtime.Atn
|
||||||
Collections.EmptyList<PrecedencePredicate>();
|
Collections.EmptyList<PrecedencePredicate>();
|
||||||
|
|
||||||
List<PrecedencePredicate> result = collection.OfType<PrecedencePredicate>().ToList();
|
List<PrecedencePredicate> result = collection.OfType<PrecedencePredicate>().ToList();
|
||||||
#if NET40PLUS
|
|
||||||
collection.ExceptWith(result);
|
collection.ExceptWith(result);
|
||||||
#else
|
|
||||||
collection.ExceptWith(result.Cast<SemanticContext>());
|
|
||||||
#endif
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue