Merge branch 'master' into master
This commit is contained in:
commit
4f86ad5c17
|
@ -97,3 +97,4 @@ xcuserdata
|
|||
# VSCode Java plugin temporary files
|
||||
javac-services.0.log
|
||||
javac-services.0.log.lck
|
||||
test/
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
[submodule "runtime/PHP"]
|
||||
path = runtime/PHP
|
||||
url = https://github.com/antlr/antlr-php-runtime.git
|
31
.travis.yml
31
.travis.yml
|
@ -19,8 +19,9 @@ stages:
|
|||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: clang
|
||||
jdk: openjdk7
|
||||
jdk: openjdk8
|
||||
env:
|
||||
- TARGET=cpp
|
||||
- CXX=g++-5
|
||||
|
@ -36,8 +37,9 @@ matrix:
|
|||
- uuid-dev
|
||||
- clang-3.7
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: clang
|
||||
jdk: openjdk7
|
||||
jdk: openjdk8
|
||||
env:
|
||||
- TARGET=cpp
|
||||
- CXX=g++-5
|
||||
|
@ -53,8 +55,9 @@ matrix:
|
|||
- uuid-dev
|
||||
- clang-3.7
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: clang
|
||||
jdk: openjdk7
|
||||
jdk: openjdk8
|
||||
env:
|
||||
- TARGET=cpp
|
||||
- CXX=g++-5
|
||||
|
@ -137,23 +140,27 @@ matrix:
|
|||
- GROUP=RECURSION
|
||||
stage: extended-test
|
||||
- os: linux
|
||||
dist: trusty
|
||||
jdk: openjdk7
|
||||
env: TARGET=java
|
||||
stage: extended-test
|
||||
- os: linux
|
||||
jdk: openjdk8
|
||||
env: TARGET=java
|
||||
stage: extended-test
|
||||
- os: linux
|
||||
jdk: oraclejdk8
|
||||
env: TARGET=java
|
||||
stage: smoke-test
|
||||
- os: linux
|
||||
jdk: openjdk7
|
||||
jdk: openjdk8
|
||||
env: TARGET=csharp
|
||||
stage: main-test
|
||||
- os: linux
|
||||
jdk: oraclejdk8
|
||||
language: php
|
||||
php:
|
||||
- 7.2
|
||||
jdk: openjdk8
|
||||
env: TARGET=php
|
||||
stage: main-test
|
||||
- os: linux
|
||||
jdk: openjdk8
|
||||
dist: trusty
|
||||
env:
|
||||
- TARGET=dotnet
|
||||
|
@ -167,18 +174,18 @@ matrix:
|
|||
- GROUP=PARSER
|
||||
stage: extended-test
|
||||
- os: linux
|
||||
jdk: oraclejdk8
|
||||
jdk: openjdk8
|
||||
dist: trusty
|
||||
env:
|
||||
- TARGET=dotnet
|
||||
- GROUP=RECURSION
|
||||
stage: extended-test
|
||||
- os: linux
|
||||
jdk: openjdk7
|
||||
jdk: openjdk8
|
||||
env: TARGET=python2
|
||||
stage: main-test
|
||||
- os: linux
|
||||
jdk: openjdk7
|
||||
jdk: openjdk8
|
||||
env: TARGET=python3
|
||||
addons:
|
||||
apt:
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
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
|
||||
echo "deb http://download.mono-project.com/repo/debian wheezy/snapshots/3.12.1 main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
|
||||
sudo apt-get install -qq mono-complete
|
||||
|
|
|
@ -6,5 +6,5 @@ set -euo pipefail
|
|||
sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
|
||||
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 417A0893
|
||||
sudo apt-get update
|
||||
sudo apt-get install dotnet-dev-1.0.4
|
||||
sudo apt-get --allow-unauthenticated install dotnet-dev-1.0.4
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
|
||||
sudo apt-get update -qq
|
||||
|
||||
php -v
|
||||
|
||||
mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
php_path=$(which php)
|
||||
|
||||
composer install -d ../runtime/PHP
|
||||
|
||||
mvn -q -DPHP_PATH="${php_path}" -Dparallel=methods -DthreadCount=4 -Dtest=php.* test
|
|
@ -22,6 +22,7 @@ ANTLR project lead and supreme dictator for life
|
|||
* [Janyou](https://github.com/janyou) (Swift target)
|
||||
* [Ewan Mellor](https://github.com/ewanmellor), [Hanzhou Shi](https://github.com/hanjoes) (Swift target merging)
|
||||
* [Ben Hamilton](https://github.com/bhamiltoncx) (Full Unicode support in serialized ATN and all languages' runtimes for code points > U+FFFF)
|
||||
* [Marcos Passos](https://github.com/marcospassos) (PHP target)
|
||||
|
||||
## Useful information
|
||||
|
||||
|
|
|
@ -4,6 +4,9 @@ cache:
|
|||
- '%USERPROFILE%\.nuget\packages -> **\project.json'
|
||||
image: Visual Studio 2017
|
||||
build: off
|
||||
install:
|
||||
- git submodule update --init --recursive
|
||||
- cinst -y php composer
|
||||
build_script:
|
||||
- mvn -DskipTests install --batch-mode
|
||||
- msbuild /target:restore /target:rebuild /property:Configuration=Release /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /verbosity:detailed runtime/CSharp/runtime/CSharp/Antlr4.dotnet.sln
|
||||
|
@ -11,7 +14,7 @@ build_script:
|
|||
after_build:
|
||||
- msbuild /target:pack /property:Configuration=Release /verbosity:detailed runtime/CSharp/runtime/CSharp/Antlr4.dotnet.sln
|
||||
test_script:
|
||||
- mvn install -Dantlr-python2-python="C:\Python27\python.exe" -Dantlr-python3-python="C:\Python35\python.exe" -Dantlr-javascript-nodejs="C:\Program Files (x86)\nodejs\node.exe" --batch-mode
|
||||
- mvn install -Dantlr-php-php="C:\tools\php73\php.exe" -Dantlr-python2-python="C:\Python27\python.exe" -Dantlr-python3-python="C:\Python35\python.exe" -Dantlr-javascript-nodejs="C:\Program Files (x86)\nodejs\node.exe" --batch-mode
|
||||
artifacts:
|
||||
- path: 'runtime\**\*.nupkg'
|
||||
name: NuGet
|
|
@ -203,6 +203,8 @@ YYYY/MM/DD, github id, Full name, email
|
|||
2018/06/16, EternalPhane, Zongyuan Zuo, eternalphane@gmail.com
|
||||
2018/07/03, jgoppert, James Goppert, james.goppert@gmail.com
|
||||
2018/07/27, Maksim Novikov, mnovikov.work@gmail.com
|
||||
2018/08/03, ENDOH takanao, djmchl@gmail.com
|
||||
2018/10/18, edirgarcia, Edir García Lazo, edirgl@hotmail.com
|
||||
2018/07/31, Lucas Henrqiue, lucashenrique580@gmail.com
|
||||
2018/08/03, ENDOH takanao, djmchl@gmail.com
|
||||
2018/10/29, chrisaycock, Christopher Aycock, chris[at]chrisaycock[dot]com
|
||||
|
@ -215,4 +217,17 @@ YYYY/MM/DD, github id, Full name, email
|
|||
2019/02/06, ralucado, Cristina Raluca Vijulie, ralucris.v[at]gmail[dot]com
|
||||
2019/03/13, base698, Justin Thomas, justin.thomas1@gmail.com
|
||||
2019/03/18, carlodri, Carlo Dri, carlo.dri@gmail.com
|
||||
2019/04/09, a-square, Alexei Averchenko, echo 'bGV4LmF2ZXJAZ21haWwuY29tCg==' | base64 -D
|
||||
2019/05/02, askingalot, Andy Collins, askingalot@gmail.com
|
||||
2019/07/11, olowo726, Olof Wolgast, olof@baah.se
|
||||
2019/07/16, abhijithneilabraham, Abhijith Neil Abraham, abhijithneilabrahampk@gmail.com
|
||||
2019/07/26, Braavos96, Eric Hettiaratchi, erichettiaratchi@gmail.com
|
||||
2019/08/23, akaJes, Oleksandr Mamchyts, akaJes@gmail.com
|
||||
2019/09/10, ImanHosseini, Iman Hosseini, hosseini.iman@yahoo.com
|
||||
2019/09/03, João Henrique, johnnyonflame@hotmail.com
|
||||
2019/09/10, neko1235, Ihar Mokharau, igor.mohorev@gmail.com
|
||||
2019/09/10, yar3333, Yaroslav Sivakov, yar3333@gmail.com
|
||||
2019/09/10, marcospassos, Marcos Passos, marcospassos.com@gmail.com
|
||||
2019/09/10, amorimjuliana, Juliana Amorim, juu.amorim@gmail.com
|
||||
2019/09/17, kaz, Kazuki Sawada, kazuki@6715.jp
|
||||
2019/09/28, lmy269, Mingyang Liu, lmy040758@gmail.com
|
||||
2019/10/31, a-square, Alexei Averchenko, lex.aver@gmail.com
|
|
@ -14,7 +14,7 @@ For the 4.7.1 release, we discussed both approaches in [detail](https://github.c
|
|||
|
||||
## Case-insensitive grammars
|
||||
|
||||
As a prime example of a grammar that specifically describes case insensitive keywords, see the
|
||||
As a prime example of a grammar that specifically describes case insensitive keywords, see the
|
||||
[SQLite grammar](https://github.com/antlr/grammars-v4/blob/master/sqlite/SQLite.g4). To match a case insensitive keyword, there are rules such as
|
||||
|
||||
```
|
||||
|
@ -72,7 +72,8 @@ Lexer lexer = new SomeSQLLexer(upper);
|
|||
|
||||
Here are implementations of `CaseChangingCharStream` in various target languages:
|
||||
|
||||
* [Java](https://github.com/parrt/antlr4/blob/case-insensitivity-doc/doc/resources/CaseChangingCharStream.java)
|
||||
* [JavaScript](https://github.com/parrt/antlr4/blob/case-insensitivity-doc/doc/resources/CaseInsensitiveInputStream.js)
|
||||
* [Go](https://github.com/parrt/antlr4/blob/case-insensitivity-doc/doc/resources/case_changing_stream.go)
|
||||
* [C#](https://github.com/parrt/antlr4/blob/case-insensitivity-doc/doc/resources/CaseChangingCharStream.cs)
|
||||
* [C#](https://github.com/antlr/antlr4/blob/master/doc/resources/CaseChangingCharStream.cs)
|
||||
* [Go](https://github.com/antlr/antlr4/blob/master/doc/resources/case_changing_stream.go)
|
||||
* [Java](https://github.com/antlr/antlr4/blob/master/doc/resources/CaseChangingCharStream.java)
|
||||
* [JavaScript](https://github.com/antlr/antlr4/blob/master/doc/resources/CaseChangingStream.js)
|
||||
* [Python2/3](https://github.com/antlr/antlr4/blob/master/doc/resources/CaseChangingStream.py)
|
||||
|
|
|
@ -45,7 +45,7 @@ The generation step above created a listener and base listener class for you. Th
|
|||
#include "MyGrammarParser.h"
|
||||
#include "MyGrammarBaseListener.h"
|
||||
|
||||
using namespace org::antlr::v4::runtime;
|
||||
using namespace antlr4;
|
||||
|
||||
class TreeShapeListener : public MyGrammarBaseListener {
|
||||
public:
|
||||
|
|
|
@ -30,7 +30,7 @@ Let's suppose that your grammar is named `MyGrammar`. The tool will generate for
|
|||
|
||||
Now a fully functioning code might look like the following for start rule `StartRule`:
|
||||
|
||||
```
|
||||
```csharp
|
||||
using Antlr4.Runtime;
|
||||
using Antlr4.Runtime.Tree;
|
||||
|
||||
|
@ -59,7 +59,7 @@ Let's suppose your MyGrammar grammar comprises 2 rules: "key" and "value".
|
|||
|
||||
The antlr4 tool will have generated the following listener (only partial code shown here):
|
||||
|
||||
```
|
||||
```csharp
|
||||
interface IMyGrammarParserListener : IParseTreeListener {
|
||||
void EnterKey (MyGrammarParser.KeyContext context);
|
||||
void ExitKey (MyGrammarParser.KeyContext context);
|
||||
|
@ -70,7 +70,7 @@ interface IMyGrammarParserListener : IParseTreeListener {
|
|||
|
||||
In order to provide custom behavior, you might want to create the following class:
|
||||
|
||||
```
|
||||
```csharp
|
||||
class KeyPrinter : MyGrammarBaseListener {
|
||||
// override default listener behavior
|
||||
void ExitKey (MyGrammarParser.KeyContext context) {
|
||||
|
@ -82,7 +82,7 @@ class KeyPrinter : MyGrammarBaseListener {
|
|||
In order to execute this listener, you would simply add the following lines to the above code:
|
||||
|
||||
|
||||
```
|
||||
```csharp
|
||||
...
|
||||
IParseTree tree = parser.StartRule() - only repeated here for reference
|
||||
KeyPrinter printer = new KeyPrinter();
|
||||
|
|
|
@ -112,8 +112,11 @@ Now test it:
|
|||
|
||||
```
|
||||
$ grun Hello r -tree
|
||||
(Now enter something like the string below)
|
||||
hello parrt
|
||||
(now,do:)
|
||||
^D
|
||||
(The output:)
|
||||
(r hello parrt)
|
||||
(That ^D means EOF on unix; it's ^Z in Windows.) The -tree option prints the parse tree in LISP notation.
|
||||
It's nicer to look at parse trees visually.
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
# ANTLR4 Runtime for PHP
|
||||
|
||||
### First steps
|
||||
|
||||
#### 1. Install ANTLR4
|
||||
|
||||
[The getting started guide](https://github.com/antlr/antlr4/blob/master/doc/getting-started.md)
|
||||
should get you started.
|
||||
|
||||
#### 2. Install the PHP ANTLR runtime
|
||||
|
||||
Each target language for ANTLR has a runtime package for running parser
|
||||
generated by ANTLR4. The runtime provides a common set of tools for using your parser.
|
||||
|
||||
Install the runtime with Composer:
|
||||
|
||||
```bash
|
||||
composer install antlr/antlr4
|
||||
```
|
||||
|
||||
#### 3. Generate your parser
|
||||
|
||||
You use the ANTLR4 "tool" to generate a parser. These will reference the ANTLR
|
||||
runtime, installed above.
|
||||
|
||||
Suppose you're using a UNIX system and have set up an alias for the ANTLR4 tool
|
||||
as described in [the getting started guide](https://github.com/antlr/antlr4/blob/master/doc/getting-started.md).
|
||||
To generate your PHP parser, run the following command:
|
||||
|
||||
```bash
|
||||
antlr4 -Dlanguage=PHP MyGrammar.g4
|
||||
```
|
||||
|
||||
For a full list of antlr4 tool options, please visit the
|
||||
[tool documentation page](https://github.com/antlr/antlr4/blob/master/doc/tool-options.md).
|
||||
|
||||
### Complete example
|
||||
|
||||
Suppose you're using the JSON grammar from https://github.com/antlr/grammars-v4/tree/master/json.
|
||||
|
||||
Then, invoke `antlr4 -Dlanguage=PHP JSON.g4`. The result of this is a
|
||||
collection of `.php` files in the `parser` directory including:
|
||||
```
|
||||
JsonParser.php
|
||||
JsonBaseListener.php
|
||||
JsonLexer.php
|
||||
JsonListener.php
|
||||
```
|
||||
|
||||
Another common option to the ANTLR tool is `-visitor`, which generates a parse
|
||||
tree visitor, but we won't be doing that here. For a full list of antlr4 tool
|
||||
options, please visit the [tool documentation page](tool-options.md).
|
||||
|
||||
We'll write a small main func to call the generated parser/lexer
|
||||
(assuming they are separate). This one writes out the encountered
|
||||
`ParseTreeContext`'s:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
namespace JsonParser;
|
||||
|
||||
use Antlr\Antlr4\Runtime\CommonTokenStream;
|
||||
use Antlr\Antlr4\Runtime\Error\Listeners\DiagnosticErrorListener;
|
||||
use Antlr\Antlr4\Runtime\InputStream;
|
||||
use Antlr\Antlr4\Runtime\ParserRuleContext;
|
||||
use Antlr\Antlr4\Runtime\Tree\ErrorNode;
|
||||
use Antlr\Antlr4\Runtime\Tree\ParseTreeListener;
|
||||
use Antlr\Antlr4\Runtime\Tree\ParseTreeWalker;
|
||||
use Antlr\Antlr4\Runtime\Tree\TerminalNode;
|
||||
|
||||
final class TreeShapeListener implements ParseTreeListener {
|
||||
public function visitTerminal(TerminalNode $node) : void {}
|
||||
public function visitErrorNode(ErrorNode $node) : void {}
|
||||
public function exitEveryRule(ParserRuleContext $ctx) : void {}
|
||||
|
||||
public function enterEveryRule(ParserRuleContext $ctx) : void {
|
||||
echo $ctx->getText();
|
||||
}
|
||||
}
|
||||
|
||||
$input = InputStream::fromPath($argv[1]);
|
||||
$lexer = new JSONLexer($input);
|
||||
$tokens = new CommonTokenStream($lexer);
|
||||
$parser = new JSONParser($tokens);
|
||||
$parser->addErrorListener(new DiagnosticErrorListener());
|
||||
$parser->setBuildParseTree(true);
|
||||
$tree = $parser->json();
|
||||
|
||||
ParseTreeWalker::default()->walk(new TreeShapeListener(), $tree);
|
||||
```
|
||||
|
||||
Create a `example.json` file:
|
||||
```json
|
||||
{"a":1}
|
||||
```
|
||||
|
||||
Parse the input file:
|
||||
|
||||
```
|
||||
php json.php example.json
|
||||
```
|
||||
|
||||
The expected output is:
|
||||
|
||||
```
|
||||
{"a":1}
|
||||
{"a":1}
|
||||
"a":1
|
||||
1
|
||||
```
|
|
@ -0,0 +1,65 @@
|
|||
//
|
||||
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
//
|
||||
|
||||
function CaseChangingStream(stream, upper) {
|
||||
this._stream = stream;
|
||||
this._upper = upper;
|
||||
}
|
||||
|
||||
CaseChangingStream.prototype.LA = function(offset) {
|
||||
var c = this._stream.LA(offset);
|
||||
if (c <= 0) {
|
||||
return c;
|
||||
}
|
||||
return String.fromCodePoint(c)[this._upper ? "toUpperCase" : "toLowerCase"]().codePointAt(0);
|
||||
};
|
||||
|
||||
CaseChangingStream.prototype.reset = function() {
|
||||
return this._stream.reset();
|
||||
};
|
||||
|
||||
CaseChangingStream.prototype.consume = function() {
|
||||
return this._stream.consume();
|
||||
};
|
||||
|
||||
CaseChangingStream.prototype.LT = function(offset) {
|
||||
return this._stream.LT(offset);
|
||||
};
|
||||
|
||||
CaseChangingStream.prototype.mark = function() {
|
||||
return this._stream.mark();
|
||||
};
|
||||
|
||||
CaseChangingStream.prototype.release = function(marker) {
|
||||
return this._stream.release(marker);
|
||||
};
|
||||
|
||||
CaseChangingStream.prototype.seek = function(_index) {
|
||||
return this._stream.seek(_index);
|
||||
};
|
||||
|
||||
CaseChangingStream.prototype.getText = function(start, stop) {
|
||||
return this._stream.getText(start, stop);
|
||||
};
|
||||
|
||||
CaseChangingStream.prototype.toString = function() {
|
||||
return this._stream.toString();
|
||||
};
|
||||
|
||||
Object.defineProperty(CaseChangingStream.prototype, "index", {
|
||||
get: function() {
|
||||
return this._stream.index;
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(CaseChangingStream.prototype, "size", {
|
||||
get: function() {
|
||||
return this._stream.size;
|
||||
}
|
||||
});
|
||||
|
||||
exports.CaseChangingStream = CaseChangingStream;
|
|
@ -0,0 +1,13 @@
|
|||
class CaseChangingStream():
|
||||
def __init__(self, stream, upper):
|
||||
self._stream = stream
|
||||
self._upper = upper
|
||||
|
||||
def __getattr__(self, name):
|
||||
return self._stream.__getattribute__(name)
|
||||
|
||||
def LA(self, offset):
|
||||
c = self._stream.LA(offset)
|
||||
if c <= 0:
|
||||
return c
|
||||
return ord(chr(c).upper() if self._upper else chr(c).lower())
|
|
@ -1,54 +0,0 @@
|
|||
//
|
||||
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
//
|
||||
|
||||
function CaseInsensitiveInputStream(stream, upper) {
|
||||
this._stream = stream;
|
||||
this._case = upper ? String.toUpperCase : String.toLowerCase;
|
||||
return this;
|
||||
}
|
||||
|
||||
CaseInsensitiveInputStream.prototype.LA = function (offset) {
|
||||
c = this._stream.LA(i);
|
||||
if (c <= 0) {
|
||||
return c;
|
||||
}
|
||||
return this._case.call(String.fromCodePoint(c))
|
||||
};
|
||||
|
||||
CaseInsensitiveInputStream.prototype.reset = function() {
|
||||
return this._stream.reset();
|
||||
};
|
||||
|
||||
CaseInsensitiveInputStream.prototype.consume = function() {
|
||||
return this._stream.consume();
|
||||
};
|
||||
|
||||
CaseInsensitiveInputStream.prototype.LT = function(offset) {
|
||||
return this._stream.LT(offset);
|
||||
};
|
||||
|
||||
CaseInsensitiveInputStream.prototype.mark = function() {
|
||||
return this._stream.mark();
|
||||
};
|
||||
|
||||
CaseInsensitiveInputStream.prototype.release = function(marker) {
|
||||
return this._stream.release(marker);
|
||||
};
|
||||
|
||||
CaseInsensitiveInputStream.prototype.seek = function(_index) {
|
||||
return this._stream.getText(start, stop);
|
||||
};
|
||||
|
||||
CaseInsensitiveInputStream.prototype.getText = function(start, stop) {
|
||||
return this._stream.getText(start, stop);
|
||||
};
|
||||
|
||||
CaseInsensitiveInputStream.prototype.toString = function() {
|
||||
return this._stream.toString();
|
||||
};
|
||||
|
||||
exports.CaseInsensitiveInputStream = CaseInsensitiveInputStream;
|
|
@ -1,13 +1,15 @@
|
|||
package antlr
|
||||
package antlr_resource
|
||||
|
||||
import (
|
||||
"unicode"
|
||||
|
||||
"github.com/antlr/antlr4/runtime/Go/antlr"
|
||||
)
|
||||
|
||||
// CaseChangingStream wraps an existing CharStream, but upper cases, or
|
||||
// lower cases the input before it is tokenized.
|
||||
type CaseChangingStream struct {
|
||||
CharStream
|
||||
antlr.CharStream
|
||||
|
||||
upper bool
|
||||
}
|
||||
|
@ -15,10 +17,8 @@ type CaseChangingStream struct {
|
|||
// NewCaseChangingStream returns a new CaseChangingStream that forces
|
||||
// all tokens read from the underlying stream to be either upper case
|
||||
// or lower case based on the upper argument.
|
||||
func NewCaseChangingStream(in CharStream, upper bool) *CaseChangingStream {
|
||||
return &CaseChangingStream{
|
||||
in, upper,
|
||||
}
|
||||
func NewCaseChangingStream(in antlr.CharStream, upper bool) *CaseChangingStream {
|
||||
return &CaseChangingStream{in, upper}
|
||||
}
|
||||
|
||||
// LA gets the value of the symbol at offset from the current position
|
||||
|
|
|
@ -9,12 +9,13 @@ This page lists the available and upcoming ANTLR runtimes. Please note that you
|
|||
* [Go](go-target.md)
|
||||
* [C++](cpp-target.md)
|
||||
* [Swift](swift-target.md)
|
||||
* [PHP](php-target.md)
|
||||
|
||||
## Target feature parity
|
||||
|
||||
New features generally appear in the Java target and then migrate to the other targets, but these other targets don't always get updated in the same overall tool release. This section tries to identify features added to Java that have not been added to the other targets.
|
||||
|
||||
|Feature|Java|C♯|Python2|Python3|JavaScript|Go|C++|Swift|
|
||||
|---|---|---|---|---|---|---|---|---|
|
||||
|Ambiguous tree construction|4.5.1|-|-|-|-|-|-|-|
|
||||
|Feature|Java|C♯|Python2|Python3|JavaScript|Go|C++|Swift|PHP
|
||||
|---|---|---|---|---|---|---|---|---|---|
|
||||
|Ambiguous tree construction|4.5.1|-|-|-|-|-|-|-|-|
|
||||
|
||||
|
|
|
@ -68,7 +68,8 @@
|
|||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-server</artifactId>
|
||||
<version>[9.3.24.v20180605,)</version>
|
||||
<!-- stick to version 9 for jdk compatibility -->
|
||||
<version>9.4.19.v20190610</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -108,14 +109,15 @@
|
|||
<!-- SUREFIRE-951: file.encoding cannot be set via systemPropertyVariables -->
|
||||
<argLine>-Dfile.encoding=UTF-8</argLine>
|
||||
<includes>
|
||||
<include>**/csharp/Test*.java</include>
|
||||
<include>**/java/Test*.java</include>
|
||||
<include>**/go/Test*.java</include>
|
||||
<include>**/javascript/node/Test*.java</include>
|
||||
<include>**/python2/Test*.java</include>
|
||||
<include>**/python3/Test*.java</include>
|
||||
<include>${antlr.tests.swift}</include>
|
||||
</includes>
|
||||
<include>**/csharp/Test*.java</include>
|
||||
<include>**/java/Test*.java</include>
|
||||
<include>**/go/Test*.java</include>
|
||||
<include>**/javascript/node/Test*.java</include>
|
||||
<include>**/python2/Test*.java</include>
|
||||
<include>**/python3/Test*.java</include>
|
||||
<include>**/php/Test*.java</include>
|
||||
<include>${antlr.tests.swift}</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
|
|
@ -14,6 +14,8 @@ Cast(t,v) ::= "((<t>)<v>)"
|
|||
|
||||
Append(a,b) ::= "<a> + <b>"
|
||||
|
||||
AppendStr(a,b) ::= <%<Append(a,b)>%>
|
||||
|
||||
Concat(a,b) ::= "<a><b>"
|
||||
|
||||
DeclareLocal(s,v) ::= "Object <s> = <v>;"
|
||||
|
@ -26,6 +28,12 @@ InitIntMember(n,v) ::= <%int <n> = <v>;%>
|
|||
|
||||
InitBooleanMember(n,v) ::= <%bool <n> = <v>;%>
|
||||
|
||||
InitIntVar(n,v) ::= <%<InitIntMember(n,v)>%>
|
||||
|
||||
IntArg(n) ::= "int <n>"
|
||||
|
||||
VarRef(n) ::= "<n>"
|
||||
|
||||
GetMember(n) ::= <%this.<n>%>
|
||||
|
||||
SetMember(n,v) ::= <%this.<n> = <v>;%>
|
||||
|
@ -94,6 +102,8 @@ bool Property() {
|
|||
|
||||
ParserPropertyCall(p, call) ::= "<p>.<call>"
|
||||
|
||||
PositionAdjustingLexerDef() ::= ""
|
||||
|
||||
PositionAdjustingLexer() ::= <<
|
||||
|
||||
public override IToken NextToken() {
|
||||
|
|
|
@ -14,6 +14,8 @@ Cast(t,v) ::= "<v>"
|
|||
|
||||
Append(a,b) ::= "<a> + <b>"
|
||||
|
||||
AppendStr(a,b) ::= <%<Append(a,b)>%>
|
||||
|
||||
Concat(a,b) ::= "<a><b>"
|
||||
|
||||
DeclareLocal(s,v) ::= "var <s> = <v>;"
|
||||
|
@ -26,6 +28,12 @@ InitIntMember(n,v) ::= <%this.<n> = <v>;%>
|
|||
|
||||
InitBooleanMember(n,v) ::= <%this.<n> = <v>;%>
|
||||
|
||||
InitIntVar(n,v) ::= <%<InitIntMember(n,v)>%>
|
||||
|
||||
IntArg(n) ::= "<n>"
|
||||
|
||||
VarRef(n) ::= "<n>"
|
||||
|
||||
GetMember(n) ::= <%this.<n>%>
|
||||
|
||||
SetMember(n,v) ::= <%this.<n> = <v>;%>
|
||||
|
@ -92,6 +100,8 @@ this.Property = function() {
|
|||
}
|
||||
>>
|
||||
|
||||
PositionAdjustingLexerDef() ::= ""
|
||||
|
||||
PositionAdjustingLexer() ::= <<
|
||||
|
||||
PositionAdjustingLexer.prototype.resetAcceptPosition = function(index, line, column) {
|
||||
|
|
|
@ -9,6 +9,7 @@ Assert(s) ::= ""
|
|||
Cast(t,v) ::= "dynamic_cast\<<t> *>(<v>)" // Should actually use a more specific name. We may have to use other casts as well.
|
||||
Append(a,b) ::= "<a> + <b>->toString()"
|
||||
Concat(a,b) ::= "<a><b>"
|
||||
AppendStr(a,b) ::= "<a> + <b>"
|
||||
|
||||
DeclareLocal(s,v) ::= "<s> = <v>"
|
||||
|
||||
|
@ -17,6 +18,9 @@ AssignLocal(s,v) ::= "<s> = <v>;"
|
|||
|
||||
InitIntMember(n,v) ::= "int <n> = <v>;"
|
||||
InitBooleanMember(n,v) ::= "bool <n> = <v>;"
|
||||
InitIntVar(n,v) ::= <%<InitIntMember(n,v)>%>
|
||||
IntArg(n) ::= "int <n>"
|
||||
VarRef(n) ::= "<n>"
|
||||
|
||||
GetMember(n) ::= "<n>"
|
||||
SetMember(n,v) ::= "<n> = <v>;"
|
||||
|
@ -68,6 +72,8 @@ bool Property() {
|
|||
|
||||
ParserPropertyCall(p, call) ::= "<call>"
|
||||
|
||||
PositionAdjustingLexerDef() ::= ""
|
||||
|
||||
PositionAdjustingLexer() ::= <<
|
||||
protected:
|
||||
class PositionAdjustingLexerATNSimulator : public antlr4::atn::LexerATNSimulator {
|
||||
|
|
|
@ -14,6 +14,8 @@ Cast(t,v) ::= "<v>"
|
|||
|
||||
Append(a,b) ::= "<a> + <b>"
|
||||
|
||||
AppendStr(a,b) ::= <%<Append(a,b)>%>
|
||||
|
||||
Concat(a,b) ::= "<a><b>"
|
||||
|
||||
DeclareLocal(s,v) ::= "var <s> = <v>;"
|
||||
|
@ -26,6 +28,12 @@ InitIntMember(n,v) ::= <%this.<n> = <v>;%>
|
|||
|
||||
InitBooleanMember(n,v) ::= <%this.<n> = <v>;%>
|
||||
|
||||
InitIntVar(n,v) ::= <%<InitIntMember(n,v)>%>
|
||||
|
||||
IntArg(n) ::= "<n>"
|
||||
|
||||
VarRef(n) ::= "<n>"
|
||||
|
||||
GetMember(n) ::= <%this.<n>%>
|
||||
|
||||
SetMember(n,v) ::= <%this.<n> = <v>;%>
|
||||
|
@ -98,6 +106,8 @@ this.Property = function() {
|
|||
|
||||
ParserPropertyCall(p, call) ::= "<p>.<call>"
|
||||
|
||||
PositionAdjustingLexerDef() ::= ""
|
||||
|
||||
PositionAdjustingLexer() ::= <<
|
||||
|
||||
PositionAdjustingLexer.prototype.resetAcceptPosition = function(index, line, column) {
|
||||
|
|
|
@ -14,6 +14,8 @@ Cast(t,v) ::= "<v>"
|
|||
|
||||
Append(a,b) ::= "<a> + <b>"
|
||||
|
||||
AppendStr(a,b) ::= <%<Append(a,b)>%>
|
||||
|
||||
Concat(a,b) ::= "<a><b>"
|
||||
|
||||
DeclareLocal(s,v) ::= "var <s> = <v>;"
|
||||
|
@ -26,6 +28,12 @@ InitIntMember(n,v) ::= <%this.<n> = <v>;%>
|
|||
|
||||
InitBooleanMember(n,v) ::= <%this.<n> = <v>;%>
|
||||
|
||||
InitIntVar(n,v) ::= <%<InitIntMember(n,v)>%>
|
||||
|
||||
IntArg(n) ::= "<n>"
|
||||
|
||||
VarRef(n) ::= "<n>"
|
||||
|
||||
GetMember(n) ::= <%this.<n>%>
|
||||
|
||||
SetMember(n,v) ::= <%this.<n> = <v>;%>
|
||||
|
@ -100,6 +108,8 @@ this.Property = function() {
|
|||
|
||||
ParserPropertyCall(p, call) ::= "<p>.<call>"
|
||||
|
||||
PositionAdjustingLexerDef() ::= ""
|
||||
|
||||
PositionAdjustingLexer() ::= <<
|
||||
|
||||
PositionAdjustingLexer.prototype.resetAcceptPosition = function(index, line, column) {
|
||||
|
|
|
@ -14,6 +14,8 @@ Cast(t,v) ::= "(<v>)"
|
|||
|
||||
Append(a,b) ::= "<a> + fmt.Sprint(<b>)"
|
||||
|
||||
AppendStr(a,b) ::= "<a> + <b>"
|
||||
|
||||
Concat(a,b) ::= "<a><b>"
|
||||
|
||||
DeclareLocal(s, v) ::= "var <s> = <v>"
|
||||
|
@ -26,6 +28,12 @@ InitIntMember(n, v) ::= <%var <n> int = <v>; var _ int = <n>; %>
|
|||
|
||||
InitBooleanMember(n, v) ::= <%var <n> bool = <v>; var _ bool = <n>; %>
|
||||
|
||||
InitIntVar(n,v) ::= <%<InitIntMember(n,v)>%>
|
||||
|
||||
IntArg(n) ::= "int <n>"
|
||||
|
||||
VarRef(n) ::= "<n>"
|
||||
|
||||
GetMember(n) ::= <%<n>%>
|
||||
|
||||
SetMember(n, v) ::= <%<n> = <v>;%>
|
||||
|
@ -94,6 +102,8 @@ func (p *TParser) Property() bool {
|
|||
|
||||
ParserPropertyCall(p, call) ::= "<p>.<call>"
|
||||
|
||||
PositionAdjustingLexerDef() ::= ""
|
||||
|
||||
PositionAdjustingLexer() ::= <<
|
||||
func (p *PositionAdjustingLexer) NextToken() antlr.Token {
|
||||
if _, ok := p.Interpreter.(*PositionAdjustingLexerATNSimulator); !ok {
|
||||
|
|
|
@ -14,6 +14,8 @@ Cast(t,v) ::= "((<t>)<v>)"
|
|||
|
||||
Append(a,b) ::= "<a> + <b>"
|
||||
|
||||
AppendStr(a,b) ::= <%<Append(a,b)>%>
|
||||
|
||||
Concat(a,b) ::= "<a><b>"
|
||||
|
||||
DeclareLocal(s,v) ::= "Object <s> = <v>;"
|
||||
|
@ -26,6 +28,12 @@ InitIntMember(n,v) ::= <%int <n> = <v>;%>
|
|||
|
||||
InitBooleanMember(n,v) ::= <%boolean <n> = <v>;%>
|
||||
|
||||
InitIntVar(n,v) ::= <%<InitIntMember(n,v)>%>
|
||||
|
||||
IntArg(n) ::= "int <n>"
|
||||
|
||||
VarRef(n) ::= "<n>"
|
||||
|
||||
GetMember(n) ::= <%this.<n>%>
|
||||
|
||||
SetMember(n,v) ::= <%this.<n> = <v>;%>
|
||||
|
@ -94,6 +102,8 @@ boolean Property() {
|
|||
|
||||
ParserPropertyCall(p, call) ::= "<p>.<call>"
|
||||
|
||||
PositionAdjustingLexerDef() ::= ""
|
||||
|
||||
PositionAdjustingLexer() ::= <<
|
||||
|
||||
@Override
|
||||
|
|
|
@ -14,6 +14,8 @@ Cast(t,v) ::= "<v>"
|
|||
|
||||
Append(a,b) ::= "<a> + <b>"
|
||||
|
||||
AppendStr(a,b) ::= <%<Append(a,b)>%>
|
||||
|
||||
Concat(a,b) ::= "<a><b>"
|
||||
|
||||
DeclareLocal(s,v) ::= "var <s> = <v>;"
|
||||
|
@ -26,6 +28,12 @@ InitIntMember(n,v) ::= <%this.<n> = <v>;%>
|
|||
|
||||
InitBooleanMember(n,v) ::= <%this.<n> = <v>;%>
|
||||
|
||||
InitIntVar(n,v) ::= <%<InitIntMember(n,v)>%>
|
||||
|
||||
IntArg(n) ::= "<n>"
|
||||
|
||||
VarRef(n) ::= "<n>"
|
||||
|
||||
GetMember(n) ::= <%this.<n>%>
|
||||
|
||||
SetMember(n,v) ::= <%this.<n> = <v>;%>
|
||||
|
@ -98,6 +106,8 @@ this.Property = function() {
|
|||
|
||||
ParserPropertyCall(p, call) ::= "<p>.<call>"
|
||||
|
||||
PositionAdjustingLexerDef() ::= ""
|
||||
|
||||
PositionAdjustingLexer() ::= <<
|
||||
|
||||
PositionAdjustingLexer.prototype.resetAcceptPosition = function(index, line, column) {
|
||||
|
|
|
@ -0,0 +1,272 @@
|
|||
writeln(s) ::= <<echo <s> . \PHP_EOL;>>
|
||||
write(s) ::= <<echo <s>;>>
|
||||
writeList(s) ::= <<echo <s; separator=".">;>>
|
||||
|
||||
False() ::= "false"
|
||||
True() ::= "true"
|
||||
Not(v) ::= "!<v>"
|
||||
Assert(s) ::= <<assert(<s>);>>
|
||||
Cast(t,v) ::= "<v>"
|
||||
Append(a,b) ::= "<a> . <b>"
|
||||
AppendStr(a,b) ::= <%<Append(a,b)>%>
|
||||
Concat(a,b) ::= "<a><b>"
|
||||
|
||||
DeclareLocal(s,v) ::= "<s> = <v>;"
|
||||
|
||||
AssertIsList(v) ::= "assert(\is_array(<v>));" // just use static type system
|
||||
AssignLocal(s,v) ::= "<s> = <v>;"
|
||||
|
||||
InitIntMember(n,v) ::= <%public \$<n> = <v>;%>
|
||||
InitBooleanMember(n,v) ::= <%public \$<n> = <v>;%>
|
||||
InitIntVar(n,v) ::= <%\$<n> = <v>;%>
|
||||
IntArg(n) ::= "int <n>"
|
||||
VarRef(n) ::= "$<n>"
|
||||
|
||||
GetMember(n) ::= <%\$this-><n>%>
|
||||
SetMember(n,v) ::= <%\$this-><n> = <v>;%>
|
||||
AddMember(n,v) ::= <%\$this-><n> += <v>;%>
|
||||
PlusMember(v,n) ::= <%<v> + \$this-><n>%>
|
||||
MemberEquals(n,v) ::= <%\$this-><n> == <v>%>
|
||||
ModMemberEquals(n,m,v) ::= <%\$this-><n> % <m> == <v>%>
|
||||
ModMemberNotEquals(n,m,v) ::= <%\$this-><n> % <m> !== <v>%>
|
||||
|
||||
DumpDFA() ::= "\$this->dumpDFA();"
|
||||
Pass() ::= ""
|
||||
|
||||
StringList() ::= ""
|
||||
BuildParseTrees() ::= "\$this->setBuildParseTree(true);"
|
||||
BailErrorStrategy() ::= <%\$this->setErrorHandler(new Antlr\\Antlr4\\Runtime\\Error\\BailErrorStrategy());%>
|
||||
|
||||
ToStringTree(s) ::= <%<s>->toStringTree(\$this->getRuleNames())%>
|
||||
Column() ::= "\$this->getCharPositionInLine()"
|
||||
Text() ::= "\$this->getText()"
|
||||
ValEquals(a,b) ::= <%<a>===<b>%>
|
||||
TextEquals(a) ::= <%\$this->getText() === "<a>"%>
|
||||
PlusText(a) ::= <%"<a>" . \$this->getText()%>
|
||||
InputText() ::= "\$this->input->getText()"
|
||||
LTEquals(i, v) ::= <%\$this->input->LT(<i>)->getText() === <v>%>
|
||||
LANotEquals(i, v) ::= <%\$this->input->LA(<i>) !== <v>%>
|
||||
TokenStartColumnEquals(i) ::= <%\$this->tokenStartCharPositionInLine === <i>%>
|
||||
|
||||
ImportListener(X) ::= ""
|
||||
|
||||
GetExpectedTokenNames() ::= "\$this->getExpectedTokens()->toStringVocabulary(\$this->getVocabulary())"
|
||||
|
||||
RuleInvocationStack() ::= "'[' . \implode(', ', \$this->getRuleInvocationStack()) . ']'"
|
||||
|
||||
LL_EXACT_AMBIG_DETECTION() ::= <<\$this->interp->setPredictionMode(Antlr\\Antlr4\\Runtime\\Atn\\PredictionMode::LL_EXACT_AMBIG_DETECTION);>>
|
||||
|
||||
|
||||
ParserToken(parser, token) ::= <%<parser>::<token>%>
|
||||
|
||||
Production(p) ::= <%<p>%>
|
||||
|
||||
Result(r) ::= <%<r>%>
|
||||
|
||||
ParserPropertyMember() ::= <<
|
||||
@members {
|
||||
public function Property() : bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
ParserPropertyCall(p, call) ::= "<p>-><call>"
|
||||
|
||||
PositionAdjustingLexerDef() ::= <<
|
||||
class PositionAdjustingLexerATNSimulator extends LexerATNSimulator {
|
||||
public function resetAcceptPosition(CharStream \$input, int \$index, int \$line, int \$charPositionInLine) : void {
|
||||
\$input->seek(\$index);
|
||||
\$this->line = \$line;
|
||||
\$this->charPositionInLine = \$charPositionInLine;
|
||||
\$this->consume(\$input);
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
PositionAdjustingLexer() ::= <<
|
||||
public function nextToken() : Antlr\\Antlr4\\Runtime\\Token
|
||||
{
|
||||
if (!\$this->interp instanceof PositionAdjustingLexerATNSimulator) {
|
||||
\$this->interp = new PositionAdjustingLexerATNSimulator(\$this, self::\$atn, self::\$decisionToDFA, self::\$sharedContextCache);
|
||||
}
|
||||
|
||||
return parent::nextToken();
|
||||
}
|
||||
|
||||
public function emit() : Antlr\\Antlr4\\Runtime\\Token
|
||||
{
|
||||
switch (\$this->type) {
|
||||
case self::TOKENS:
|
||||
\$this->handleAcceptPositionForKeyword('tokens');
|
||||
break;
|
||||
|
||||
case self::LABEL:
|
||||
\$this->handleAcceptPositionForIdentifier();
|
||||
break;
|
||||
}
|
||||
|
||||
return parent::emit();
|
||||
}
|
||||
|
||||
private function handleAcceptPositionForIdentifier() : bool
|
||||
{
|
||||
\$tokenText = \$this->getText();
|
||||
\$identifierLength = 0;
|
||||
while (\$identifierLength \< \strlen(\$tokenText) && self::isIdentifierChar(\$tokenText[\$identifierLength])) {
|
||||
\$identifierLength++;
|
||||
}
|
||||
|
||||
if (\$this->getInputStream()->getIndex() > \$this->tokenStartCharIndex + \$identifierLength) {
|
||||
\$offset = \$identifierLength - 1;
|
||||
\$this->getInterpreter()->resetAcceptPosition(\$this->getInputStream(), \$this->tokenStartCharIndex + \$offset, \$this->tokenStartLine, \$this->tokenStartCharPositionInLine + \$offset);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function handleAcceptPositionForKeyword(string \$keyword) : bool
|
||||
{
|
||||
if (\$this->getInputStream()->getIndex() > \$this->tokenStartCharIndex + \strlen(\$keyword)) {
|
||||
\$offset = \strlen(\$keyword) - 1;
|
||||
\$this->getInterpreter()->resetAcceptPosition(\$this->getInputStream(), \$this->tokenStartCharIndex + \$offset, \$this->tokenStartLine, \$this->tokenStartCharPositionInLine + \$offset);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static function isIdentifierChar(string \$c) : bool
|
||||
{
|
||||
return \ctype_alnum(\$c) || \$c === '_';
|
||||
}
|
||||
>>
|
||||
|
||||
BasicListener(X) ::= <<
|
||||
@parser::definitions {
|
||||
class LeafListener extends TBaseListener
|
||||
{
|
||||
public function visitTerminal(Antlr\\Antlr4\\Runtime\\Tree\\TerminalNode \$node) : void
|
||||
{
|
||||
echo \$node->getSymbol()->getText() . \PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
WalkListener(s) ::= <<
|
||||
\$walker = new Antlr\\Antlr4\\Runtime\\Tree\\ParseTreeWalker();
|
||||
\$walker->walk(new LeafListener(), <s>);
|
||||
>>
|
||||
|
||||
TreeNodeWithAltNumField(X) ::= <<
|
||||
@parser::contexts {
|
||||
class MyRuleNode extends ParserRuleContext
|
||||
{
|
||||
public \$altNum;
|
||||
|
||||
public function getAltNumber() : int
|
||||
{
|
||||
return \$this->altNum;
|
||||
}
|
||||
|
||||
public function setAltNumber(int \$altNum) : void
|
||||
{
|
||||
\$this->altNum = \$altNum;
|
||||
}
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
TokenGetterListener(X) ::= <<
|
||||
@parser::definitions {
|
||||
class LeafListener extends TBaseListener {
|
||||
public function exitA(Context\\AContext \$ctx) : void {
|
||||
if (\$ctx->getChildCount() === 2) {
|
||||
echo \sprintf('%s %s [%s]',\$ctx->INT(0)->getSymbol()->getText(), \$ctx->INT(1)->getSymbol()->getText(), \implode(', ', \$ctx->INT())) . \PHP_EOL;
|
||||
} else {
|
||||
echo \$ctx->ID()->getSymbol() . \PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
RuleGetterListener(X) ::= <<
|
||||
@parser::definitions {
|
||||
class LeafListener extends TBaseListener {
|
||||
public function exitA(Context\\AContext \$ctx) : void
|
||||
{
|
||||
if (\$ctx->getChildCount() === 2) {
|
||||
echo \sprintf('%s %s %s', \$ctx->b(0)->start->getText(), \$ctx->b(1)->start->getText(),\$ctx->b()[0]->start->getText()) . \PHP_EOL;
|
||||
} else {
|
||||
echo \$ctx->b(0)->start->getText() . \PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
|
||||
LRListener(X) ::= <<
|
||||
@parser::definitions {
|
||||
class LeafListener extends TBaseListener {
|
||||
public function exitE(Context\\EContext \$ctx) : void
|
||||
{
|
||||
if (\$ctx->getChildCount() === 3) {
|
||||
echo \sprintf('%s %s %s', \$ctx->e(0)->start->getText(), \$ctx->e(1)->start->getText(), \$ctx->e()[0]->start->getText()) . \PHP_EOL;
|
||||
} else {
|
||||
echo \$ctx->INT()->getSymbol()->getText() . \PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
LRWithLabelsListener(X) ::= <<
|
||||
@parser::definitions {
|
||||
class LeafListener extends TBaseListener
|
||||
{
|
||||
public function exitCall(Context\\CallContext \$ctx) : void {
|
||||
echo \sprintf('%s %s',\$ctx->e()->start->getText(),\$ctx->eList()) . \PHP_EOL;
|
||||
}
|
||||
|
||||
public function exitInt(Context\\IntContext \$ctx) : void {
|
||||
echo \$ctx->INT()->getSymbol()->getText() . \PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
DeclareContextListGettersFunction() ::= <<
|
||||
public function foo() : void {
|
||||
\$s = null;
|
||||
\$a = \$s->a();
|
||||
\$b = \$s->b();
|
||||
}
|
||||
>>
|
||||
|
||||
Declare_foo() ::= <<
|
||||
public function foo() : void {
|
||||
echo 'foo' . \PHP_EOL;
|
||||
}
|
||||
>>
|
||||
|
||||
Invoke_foo() ::= "\$this->foo();"
|
||||
|
||||
Declare_pred() ::= <<public function pred(bool \$v) : bool {
|
||||
echo "eval=".(\$v ? 'true' : 'false') . \PHP_EOL;
|
||||
return \$v;
|
||||
}
|
||||
>>
|
||||
|
||||
Invoke_pred(v) ::= "\$this->pred(<v>)"
|
||||
|
||||
ParserTokenType(t) ::= "Parser::<t>"
|
||||
ContextRuleFunction(ctx, rule) ::= "<ctx>-><rule>"
|
||||
StringType() ::= ""
|
||||
ContextMember(ctx, subctx, member) ::= "<ctx>-><subctx>-><member>"
|
|
@ -14,6 +14,8 @@ Cast(t,v) ::= "<v>"
|
|||
|
||||
Append(a,b) ::= "<a> + str(<b>)"
|
||||
|
||||
AppendStr(a,b) ::= "<a> + <b>"
|
||||
|
||||
Concat(a,b) ::= "<a><b>"
|
||||
|
||||
DeclareLocal(s,v) ::= "<s> = <v>"
|
||||
|
@ -26,6 +28,12 @@ InitIntMember(n,v) ::= <%<n> = <v>%>
|
|||
|
||||
InitBooleanMember(n,v) ::= <%<n> = <v>%>
|
||||
|
||||
InitIntVar(n,v) ::= <%<InitIntMember(n,v)>%>
|
||||
|
||||
IntArg(n) ::= "<n>"
|
||||
|
||||
VarRef(n) ::= "<n>"
|
||||
|
||||
GetMember(n) ::= <%self.<n>%>
|
||||
|
||||
SetMember(n,v) ::= <%self.<n> = <v>%>
|
||||
|
@ -94,6 +102,8 @@ def Property(self):
|
|||
|
||||
ParserPropertyCall(p, call) ::= "<p>.<call>"
|
||||
|
||||
PositionAdjustingLexerDef() ::= ""
|
||||
|
||||
PositionAdjustingLexer() ::= <<
|
||||
|
||||
def resetAcceptPosition(self, index, line, column):
|
||||
|
|
|
@ -14,6 +14,8 @@ Cast(t,v) ::= "<v>"
|
|||
|
||||
Append(a,b) ::= "<a> + str(<b>)"
|
||||
|
||||
AppendStr(a,b) ::= "<a> + <b>"
|
||||
|
||||
Concat(a,b) ::= "<a><b>"
|
||||
|
||||
DeclareLocal(s,v) ::= "<s> = <v>"
|
||||
|
@ -26,6 +28,12 @@ InitIntMember(n,v) ::= <%<n> = <v>%>
|
|||
|
||||
InitBooleanMember(n,v) ::= <%<n> = <v>%>
|
||||
|
||||
InitIntVar(n,v) ::= <%<InitIntMember(n,v)>%>
|
||||
|
||||
IntArg(n) ::= "<n>"
|
||||
|
||||
VarRef(n) ::= "<n>"
|
||||
|
||||
GetMember(n) ::= <%self.<n>%>
|
||||
|
||||
SetMember(n,v) ::= <%self.<n> = <v>%>
|
||||
|
@ -99,6 +107,8 @@ def Property(self):
|
|||
|
||||
ParserPropertyCall(p, call) ::= "<p>.<call>"
|
||||
|
||||
PositionAdjustingLexerDef() ::= ""
|
||||
|
||||
PositionAdjustingLexer() ::= <<
|
||||
|
||||
def resetAcceptPosition(self, index, line, column):
|
||||
|
|
|
@ -14,6 +14,8 @@ Cast(t,v) ::= "<v>"
|
|||
|
||||
Append(a,b) ::= "<a> + <b>"
|
||||
|
||||
AppendStr(a,b) ::= <%<Append(a,b)>%>
|
||||
|
||||
Concat(a,b) ::= "<a><b>"
|
||||
|
||||
DeclareLocal(s,v) ::= "var <s> = <v>;"
|
||||
|
@ -26,6 +28,12 @@ InitIntMember(n,v) ::= <%this.<n> = <v>;%>
|
|||
|
||||
InitBooleanMember(n,v) ::= <%this.<n> = <v>;%>
|
||||
|
||||
InitIntVar(n,v) ::= <%<InitIntMember(n,v)>%>
|
||||
|
||||
IntArg(n) ::= "<n>"
|
||||
|
||||
VarRef(n) ::= "<n>"
|
||||
|
||||
GetMember(n) ::= <%this.<n>%>
|
||||
|
||||
SetMember(n,v) ::= <%this.<n> = <v>;%>
|
||||
|
@ -98,6 +106,8 @@ this.Property = function() {
|
|||
|
||||
ParserPropertyCall(p, call) ::= "<p>.<call>"
|
||||
|
||||
PositionAdjustingLexerDef() ::= ""
|
||||
|
||||
PositionAdjustingLexer() ::= <<
|
||||
|
||||
PositionAdjustingLexer.prototype.resetAcceptPosition = function(index, line, column) {
|
||||
|
|
|
@ -14,6 +14,8 @@ Cast(t,v) ::= "((<v> as! <t>))"
|
|||
|
||||
Append(a,b) ::= "<a> + <b>"
|
||||
|
||||
AppendStr(a,b) ::= <%<Append(a,b)>%>
|
||||
|
||||
Concat(a,b) ::= "<a><b>"
|
||||
|
||||
DeclareLocal(s,v) ::= "var <s> = <v>"
|
||||
|
@ -26,6 +28,12 @@ InitIntMember(n,v) ::= <%var <n> = <v>%>
|
|||
|
||||
InitBooleanMember(n,v) ::= <%var <n> = <v>%>
|
||||
|
||||
InitIntVar(n,v) ::= <%<InitIntMember(n,v)>%>
|
||||
|
||||
IntArg(n) ::= "int <n>"
|
||||
|
||||
VarRef(n) ::= "<n>"
|
||||
|
||||
GetMember(n) ::= <%self.<n>%>
|
||||
|
||||
SetMember(n,v) ::= <%self.<n> = <v>%>
|
||||
|
@ -96,6 +104,8 @@ ParserPropertyCall(parser, property) ::= <<
|
|||
<parser>.<property>
|
||||
>>
|
||||
|
||||
PositionAdjustingLexerDef() ::= ""
|
||||
|
||||
PositionAdjustingLexer() ::= <<
|
||||
|
||||
override
|
||||
|
|
|
@ -50,6 +50,7 @@ public abstract class BaseRuntimeTest {
|
|||
"Go",
|
||||
"CSharp",
|
||||
"Python2", "Python3",
|
||||
"PHP",
|
||||
"Node", "Safari", "Firefox", "Explorer", "Chrome"
|
||||
};
|
||||
public final static String[] JavaScriptTargets = {
|
||||
|
@ -116,6 +117,7 @@ public abstract class BaseRuntimeTest {
|
|||
System.out.printf("Ignore "+descriptor);
|
||||
return;
|
||||
}
|
||||
|
||||
if ( descriptor.getTestType().contains("Parser") ) {
|
||||
testParser(descriptor);
|
||||
}
|
||||
|
|
|
@ -418,7 +418,7 @@ public class CompositeParsersDescriptors {
|
|||
parser grammar S;
|
||||
type_ : 'int' ;
|
||||
decl : type_ ID ';'
|
||||
| type_ ID init_ ';' {<write("\"JavaDecl: \" + $text")>};
|
||||
| type_ ID init_ ';' {<AppendStr("\"JavaDecl: \"","$text"):writeln()>};
|
||||
init_ : '=' INT;
|
||||
*/
|
||||
@CommentHasStringValue
|
||||
|
@ -532,7 +532,7 @@ public class CompositeParsersDescriptors {
|
|||
|
||||
/**
|
||||
parser grammar S;
|
||||
a @after {<InitIntMember("x","0")>} : B;
|
||||
a @after {<InitIntVar("x","0")>} : B;
|
||||
*/
|
||||
@CommentHasStringValue
|
||||
public String slaveGrammarS;
|
||||
|
|
|
@ -372,7 +372,7 @@ public class FullContextParsingDescriptors {
|
|||
: expr_or_assign*;
|
||||
expr_or_assign
|
||||
: expr '++' {<writeln("\"fail.\"")>}
|
||||
| expr {<writeln("\"pass: \"+$expr.text")>}
|
||||
| expr {<AppendStr("\"pass: \"","$expr.text"):writeln()>}
|
||||
;
|
||||
expr: expr_primary ('\<-' ID)?;
|
||||
expr_primary
|
||||
|
|
|
@ -529,8 +529,8 @@ public class LeftRecursionDescriptors {
|
|||
| e '+' e {$v = <Cast("BinaryContext","$ctx"):ContextMember({<Production("e")>(0)}, {<Result("v")>})> + <Cast("BinaryContext","$ctx"):ContextMember({<Production("e")>(1)}, {<Result("v")>})>;} # binary
|
||||
| INT {$v = $INT.int;} # anInt
|
||||
| '(' e ')' {$v = $e.v;} # parens
|
||||
| left=e INC {<Cast("UnaryContext","$ctx"):Concat(".INC() != null"):Assert()>$v = $left.v + 1;} # unary
|
||||
| left=e DEC {<Cast("UnaryContext","$ctx"):Concat(".DEC() != null"):Assert()>$v = $left.v - 1;} # unary
|
||||
| left=e INC {<ContextRuleFunction(Cast("UnaryContext","$ctx"), "INC()"):Concat(" != null"):Assert()>$v = $left.v + 1;} # unary
|
||||
| left=e DEC {<ContextRuleFunction(Cast("UnaryContext","$ctx"), "DEC()"):Concat(" != null"):Assert()>$v = $left.v - 1;} # unary
|
||||
| ID {<AssignLocal("$v","3")>} # anID
|
||||
;
|
||||
ID : 'a'..'z'+ ;
|
||||
|
@ -636,9 +636,9 @@ public class LeftRecursionDescriptors {
|
|||
grammar T;
|
||||
s : e {<writeln("$e.result")>} ;
|
||||
e returns [<StringType()> result]
|
||||
: ID '=' e1=e {$result = "(" + $ID.text + "=" + $e1.result + ")";}
|
||||
: ID '=' e1=e {$result = <AppendStr("\"(\"", AppendStr("$ID.text", AppendStr("\"=\"", AppendStr("$e1.result", "\")\""))))>;}
|
||||
| ID {$result = $ID.text;}
|
||||
| e1=e '+' e2=e {$result = "(" + $e1.result + "+" + $e2.result + ")";}
|
||||
| e1=e '+' e2=e {$result = <AppendStr("\"(\"", AppendStr("$e1.result", AppendStr("\"+\"", AppendStr("$e2.result", "\")\""))))>;}
|
||||
;
|
||||
ID : 'a'..'z'+ ;
|
||||
INT : '0'..'9'+ ;
|
||||
|
|
|
@ -766,6 +766,10 @@ public class LexerExecDescriptors {
|
|||
/**
|
||||
lexer grammar PositionAdjustingLexer;
|
||||
|
||||
@definitions {
|
||||
<PositionAdjustingLexerDef()>
|
||||
}
|
||||
|
||||
@members {
|
||||
<PositionAdjustingLexer()>
|
||||
}
|
||||
|
|
|
@ -144,8 +144,8 @@ public class SemPredEvalParserDescriptors {
|
|||
/**
|
||||
grammar T;
|
||||
s : b[2] ';' | b[2] '.' ; // decision in s drills down to ctx-dependent pred in a;
|
||||
b[int i] : a[i] ;
|
||||
a[int i]
|
||||
b[<IntArg("i")>] : a[<VarRef("i")>] ;
|
||||
a[<IntArg("i")>]
|
||||
: {<ValEquals("$i","1")>}? ID {<writeln("\"alt 1\"")>}
|
||||
| {<ValEquals("$i","2")>}? ID {<writeln("\"alt 2\"")>}
|
||||
;
|
||||
|
@ -310,7 +310,7 @@ public class SemPredEvalParserDescriptors {
|
|||
grammar T;
|
||||
@parser::members {<InitBooleanMember("enumKeyword",True())>}
|
||||
primary
|
||||
: ID {<writeln("\"ID \"+$ID.text")>}
|
||||
: ID {<AppendStr("\"ID \"", "$ID.text"):writeln()>}
|
||||
| {<GetMember("enumKeyword"):Not()>}? 'enum' {<writeln("\"enum\"")>}
|
||||
;
|
||||
ID : [a-z]+ ;
|
||||
|
|
|
@ -0,0 +1,599 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package org.antlr.v4.test.runtime.php;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.antlr.v4.Tool;
|
||||
import org.antlr.v4.automata.LexerATNFactory;
|
||||
import org.antlr.v4.automata.ParserATNFactory;
|
||||
import org.antlr.v4.runtime.atn.ATN;
|
||||
import org.antlr.v4.runtime.atn.ATNDeserializer;
|
||||
import org.antlr.v4.runtime.atn.ATNSerializer;
|
||||
import org.antlr.v4.semantics.SemanticPipeline;
|
||||
import org.antlr.v4.test.runtime.ErrorQueue;
|
||||
import org.antlr.v4.test.runtime.RuntimeTestSupport;
|
||||
import org.antlr.v4.test.runtime.StreamVacuum;
|
||||
import org.antlr.v4.tool.Grammar;
|
||||
import org.antlr.v4.tool.LexerGrammar;
|
||||
import org.stringtemplate.v4.ST;
|
||||
|
||||
import static org.antlr.v4.test.runtime.BaseRuntimeTest.antlrOnString;
|
||||
import static org.antlr.v4.test.runtime.BaseRuntimeTest.writeFile;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class BasePHPTest implements RuntimeTestSupport {
|
||||
public static final String newline = System.getProperty("line.separator");
|
||||
|
||||
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.
|
||||
*/
|
||||
protected String stderrDuringParse;
|
||||
|
||||
/**
|
||||
* Errors found while running antlr
|
||||
*/
|
||||
protected StringBuilder antlrToolErrors;
|
||||
|
||||
private String getPropertyPrefix() {
|
||||
return "antlr-php";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testSetUp() throws Exception {
|
||||
// new output dir for each test
|
||||
String propName = getPropertyPrefix() + "-test-dir";
|
||||
String prop = System.getProperty(propName);
|
||||
|
||||
if (prop != null && prop.length() > 0) {
|
||||
tmpdir = prop;
|
||||
} else {
|
||||
String classSimpleName = getClass().getSimpleName();
|
||||
String threadName = Thread.currentThread().getName();
|
||||
String childPath = String.format("%s-%s-%s", classSimpleName, threadName, System.currentTimeMillis());
|
||||
tmpdir = new File(System.getProperty("java.io.tmpdir"), childPath).getAbsolutePath();
|
||||
}
|
||||
|
||||
antlrToolErrors = new StringBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testTearDown() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTmpDir() {
|
||||
return tmpdir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStdout() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParseErrors() {
|
||||
return stderrDuringParse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getANTLRToolErrors() {
|
||||
if (antlrToolErrors.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return antlrToolErrors.toString();
|
||||
}
|
||||
|
||||
protected ATN createATN(Grammar g, boolean useSerializer) {
|
||||
if (g.atn == null) {
|
||||
semanticProcess(g);
|
||||
|
||||
assertEquals(0, g.tool.getNumErrors());
|
||||
|
||||
ParserATNFactory f;
|
||||
|
||||
if (g.isLexer()) {
|
||||
f = new LexerATNFactory((LexerGrammar) g);
|
||||
} else {
|
||||
f = new ParserATNFactory(g);
|
||||
}
|
||||
|
||||
g.atn = f.createATN();
|
||||
assertEquals(0, g.tool.getNumErrors());
|
||||
}
|
||||
|
||||
ATN atn = g.atn;
|
||||
|
||||
if (useSerializer) {
|
||||
char[] serialized = ATNSerializer.getSerializedAsChars(atn);
|
||||
|
||||
return new ATNDeserializer().deserialize(serialized);
|
||||
}
|
||||
|
||||
return atn;
|
||||
}
|
||||
|
||||
protected void semanticProcess(Grammar g) {
|
||||
if (g.ast != null && !g.ast.hasErrors) {
|
||||
Tool antlr = new Tool();
|
||||
SemanticPipeline sem = new SemanticPipeline(g);
|
||||
sem.process();
|
||||
|
||||
if (g.getImportedGrammars() != null) {
|
||||
for (Grammar imp: g.getImportedGrammars()) {
|
||||
antlr.processNonCombinedGrammar(imp, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected String execLexer(
|
||||
String grammarFileName,
|
||||
String grammarStr,
|
||||
String lexerName,
|
||||
String input
|
||||
) {
|
||||
return execLexer(grammarFileName, grammarStr, lexerName, input, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String execLexer(
|
||||
String grammarFileName,
|
||||
String grammarStr,
|
||||
String lexerName,
|
||||
String input,
|
||||
boolean showDFA
|
||||
) {
|
||||
boolean success = rawGenerateAndBuildRecognizer(
|
||||
grammarFileName,
|
||||
grammarStr,
|
||||
null,
|
||||
lexerName,
|
||||
"-no-listener"
|
||||
);
|
||||
assertTrue(success);
|
||||
writeFile(tmpdir, "input", input);
|
||||
writeLexerTestFile(lexerName, showDFA);
|
||||
String output = execModule("Test.php");
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
public String execParser(
|
||||
String grammarFileName,
|
||||
String grammarStr,
|
||||
String parserName,
|
||||
String lexerName,
|
||||
String listenerName,
|
||||
String visitorName,
|
||||
String startRuleName,
|
||||
String input,
|
||||
boolean showDiagnosticErrors
|
||||
) {
|
||||
return execParser_(
|
||||
grammarFileName,
|
||||
grammarStr,
|
||||
parserName,
|
||||
lexerName,
|
||||
listenerName,
|
||||
visitorName,
|
||||
startRuleName,
|
||||
input,
|
||||
showDiagnosticErrors,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
public String execParser_(
|
||||
String grammarFileName,
|
||||
String grammarStr,
|
||||
String parserName,
|
||||
String lexerName,
|
||||
String listenerName,
|
||||
String visitorName,
|
||||
String startRuleName,
|
||||
String input,
|
||||
boolean debug,
|
||||
boolean trace
|
||||
) {
|
||||
boolean success = rawGenerateAndBuildRecognizer(
|
||||
grammarFileName,
|
||||
grammarStr,
|
||||
parserName,
|
||||
lexerName,
|
||||
"-visitor"
|
||||
);
|
||||
|
||||
assertTrue(success);
|
||||
|
||||
writeFile(tmpdir, "input", input);
|
||||
|
||||
rawBuildRecognizerTestFile(
|
||||
parserName,
|
||||
lexerName,
|
||||
listenerName,
|
||||
visitorName,
|
||||
startRuleName,
|
||||
debug,
|
||||
trace
|
||||
);
|
||||
|
||||
return execRecognizer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if all is well
|
||||
*/
|
||||
protected boolean rawGenerateAndBuildRecognizer(
|
||||
String grammarFileName,
|
||||
String grammarStr,
|
||||
String parserName,
|
||||
String lexerName,
|
||||
String... extraOptions
|
||||
) {
|
||||
return rawGenerateAndBuildRecognizer(
|
||||
grammarFileName,
|
||||
grammarStr,
|
||||
parserName,
|
||||
lexerName,
|
||||
false,
|
||||
extraOptions
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if all is well
|
||||
*/
|
||||
protected boolean rawGenerateAndBuildRecognizer(
|
||||
String grammarFileName,
|
||||
String grammarStr,
|
||||
String parserName,
|
||||
String lexerName,
|
||||
boolean defaultListener,
|
||||
String... extraOptions
|
||||
) {
|
||||
ErrorQueue equeue = antlrOnString(getTmpDir(), "PHP", grammarFileName, grammarStr, defaultListener, extraOptions);
|
||||
|
||||
if (!equeue.errors.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<String> files = new ArrayList<String>();
|
||||
|
||||
if (lexerName != null) {
|
||||
files.add(lexerName + ".php");
|
||||
}
|
||||
|
||||
if (parserName != null) {
|
||||
files.add(parserName + ".php");
|
||||
Set<String> optionsSet = new HashSet<String>(Arrays.asList(extraOptions));
|
||||
|
||||
if (!optionsSet.contains("-no-listener")) {
|
||||
files.add(grammarFileName.substring(0, grammarFileName.lastIndexOf('.')) + "Listener.php");
|
||||
}
|
||||
|
||||
if (optionsSet.contains("-visitor")) {
|
||||
files.add(grammarFileName.substring(0, grammarFileName.lastIndexOf('.')) + "Visitor.php");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void rawBuildRecognizerTestFile(
|
||||
String parserName,
|
||||
String lexerName,
|
||||
String listenerName,
|
||||
String visitorName,
|
||||
String parserStartRuleName,
|
||||
boolean debug,
|
||||
boolean trace
|
||||
) {
|
||||
this.stderrDuringParse = null;
|
||||
if (parserName == null) {
|
||||
writeLexerTestFile(lexerName, false);
|
||||
} else {
|
||||
writeParserTestFile(
|
||||
parserName,
|
||||
lexerName,
|
||||
listenerName,
|
||||
visitorName,
|
||||
parserStartRuleName,
|
||||
debug,
|
||||
trace
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public String execRecognizer() {
|
||||
return execModule("Test.php");
|
||||
}
|
||||
|
||||
public String execModule(String fileName) {
|
||||
String phpPath = locatePhp();
|
||||
String runtimePath = locateRuntime();
|
||||
|
||||
File tmpdirFile = new File(tmpdir);
|
||||
String modulePath = new File(tmpdirFile, fileName).getAbsolutePath();
|
||||
String inputPath = new File(tmpdirFile, "input").getAbsolutePath();
|
||||
Path outputPath = tmpdirFile.toPath().resolve("output").toAbsolutePath();
|
||||
|
||||
try {
|
||||
ProcessBuilder builder = new ProcessBuilder(phpPath, modulePath, inputPath, outputPath.toString());
|
||||
builder.environment().put("RUNTIME", runtimePath);
|
||||
builder.directory(tmpdirFile);
|
||||
Process process = builder.start();
|
||||
StreamVacuum stdoutVacuum = new StreamVacuum(process.getInputStream());
|
||||
StreamVacuum stderrVacuum = new StreamVacuum(process.getErrorStream());
|
||||
stdoutVacuum.start();
|
||||
stderrVacuum.start();
|
||||
process.waitFor();
|
||||
stdoutVacuum.join();
|
||||
stderrVacuum.join();
|
||||
String output = stdoutVacuum.toString();
|
||||
|
||||
if (output.length() == 0) {
|
||||
output = null;
|
||||
}
|
||||
|
||||
if (stderrVacuum.toString().length() > 0) {
|
||||
this.stderrDuringParse = stderrVacuum.toString();
|
||||
}
|
||||
|
||||
return output;
|
||||
} catch (Exception e) {
|
||||
System.err.println("can't exec recognizer");
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String locateTool(String tool) {
|
||||
final String phpPath = System.getProperty("PHP_PATH");
|
||||
|
||||
if (phpPath != null && new File(phpPath).exists()) {
|
||||
return phpPath;
|
||||
}
|
||||
|
||||
String[] roots = {"/usr/local/bin/", "/opt/local/bin", "/usr/bin/"};
|
||||
|
||||
for (String root: roots) {
|
||||
if (new File(root + tool).exists()) {
|
||||
return root + tool;
|
||||
}
|
||||
}
|
||||
|
||||
throw new RuntimeException("Could not locate " + tool);
|
||||
}
|
||||
|
||||
protected String locatePhp() {
|
||||
String propName = getPropertyPrefix() + "-php";
|
||||
String prop = System.getProperty(propName);
|
||||
|
||||
if (prop == null || prop.length() == 0) {
|
||||
prop = locateTool("php");
|
||||
}
|
||||
|
||||
File file = new File(prop);
|
||||
|
||||
if (!file.exists()) {
|
||||
throw new RuntimeException("Missing system property:" + propName);
|
||||
}
|
||||
|
||||
return file.getAbsolutePath();
|
||||
}
|
||||
|
||||
protected String locateRuntime() {
|
||||
String propName = "antlr-php-runtime";
|
||||
String prop = System.getProperty(propName);
|
||||
|
||||
if (prop == null || prop.length() == 0) {
|
||||
prop = "../runtime/PHP";
|
||||
}
|
||||
|
||||
File file = new File(prop);
|
||||
|
||||
if (!file.exists()) {
|
||||
throw new RuntimeException("Missing system property:" + propName);
|
||||
}
|
||||
|
||||
try {
|
||||
return file.getCanonicalPath();
|
||||
} catch (IOException e) {
|
||||
return file.getAbsolutePath();
|
||||
}
|
||||
}
|
||||
|
||||
protected void mkdir(String dir) {
|
||||
File f = new File(dir);
|
||||
f.mkdirs();
|
||||
}
|
||||
|
||||
protected void writeLexerTestFile(String lexerName, boolean showDFA) {
|
||||
ST outputFileST = new ST(
|
||||
"\\<?php\n"
|
||||
+ "\n"
|
||||
+ "declare(strict_types=1);\n"
|
||||
+ "\n"
|
||||
+ "use Antlr\\Antlr4\\Runtime\\CommonTokenStream;\n"
|
||||
+ "use Antlr\\Antlr4\\Runtime\\Error\\Listeners\\ConsoleErrorListener;\n"
|
||||
+ "use Antlr\\Antlr4\\Runtime\\InputStream;\n"
|
||||
+ "use Antlr\\Antlr4\\Runtime\\Lexer;\n"
|
||||
+ "\n"
|
||||
+ "$runtime = \\getenv('RUNTIME');\n"
|
||||
+ "\n"
|
||||
+ "\\spl_autoload_register(function (string $class) use ($runtime) : void {\n"
|
||||
+ " $file = \\str_replace('\\\\\\', \\DIRECTORY_SEPARATOR, \\str_replace('Antlr\\Antlr4\\Runtime\\\\\\', $runtime . '\\\\\\src\\\\\\', $class)) . '.php';\n"
|
||||
+ "\n"
|
||||
+ " if (\\file_exists($file)) {\n"
|
||||
+ " require_once $file; \n"
|
||||
+ " }\n"
|
||||
+ "});"
|
||||
+ "\n"
|
||||
+ "$input = InputStream::fromPath($argv[1]);\n"
|
||||
+ "$lexer = new <lexerName>($input);\n"
|
||||
+ "$lexer->addErrorListener(new ConsoleErrorListener());"
|
||||
+ "$tokens = new CommonTokenStream($lexer);\n"
|
||||
+ "$tokens->fill();\n"
|
||||
+ "\n"
|
||||
+ "foreach ($tokens->getAllTokens() as $token) {\n"
|
||||
+ " echo $token . \\PHP_EOL;\n"
|
||||
+ "}"
|
||||
+ (showDFA
|
||||
? "echo $lexer->getInterpreter()->getDFA(Lexer::DEFAULT_MODE)->toLexerString();\n"
|
||||
: "")
|
||||
);
|
||||
|
||||
outputFileST.add("lexerName", lexerName);
|
||||
|
||||
writeFile(tmpdir, "Test.php", outputFileST.render());
|
||||
}
|
||||
|
||||
protected void writeParserTestFile(
|
||||
String parserName, String lexerName,
|
||||
String listenerName, String visitorName,
|
||||
String parserStartRuleName, boolean debug, boolean trace
|
||||
) {
|
||||
if (!parserStartRuleName.endsWith(")")) {
|
||||
parserStartRuleName += "()";
|
||||
}
|
||||
ST outputFileST = new ST(
|
||||
"\\<?php\n"
|
||||
+ "\n"
|
||||
+ "declare(strict_types=1);\n"
|
||||
+ "\n"
|
||||
+ "use Antlr\\Antlr4\\Runtime\\CommonTokenStream;\n"
|
||||
+ "use Antlr\\Antlr4\\Runtime\\Error\\Listeners\\DiagnosticErrorListener;\n"
|
||||
+ "use Antlr\\Antlr4\\Runtime\\Error\\Listeners\\ConsoleErrorListener;\n"
|
||||
+ "use Antlr\\Antlr4\\Runtime\\InputStream;\n"
|
||||
+ "use Antlr\\Antlr4\\Runtime\\ParserRuleContext;\n"
|
||||
+ "use Antlr\\Antlr4\\Runtime\\Tree\\ErrorNode;\n"
|
||||
+ "use Antlr\\Antlr4\\Runtime\\Tree\\ParseTreeListener;\n"
|
||||
+ "use Antlr\\Antlr4\\Runtime\\Tree\\ParseTreeWalker;\n"
|
||||
+ "use Antlr\\Antlr4\\Runtime\\Tree\\RuleNode;\n"
|
||||
+ "use Antlr\\Antlr4\\Runtime\\Tree\\TerminalNode;\n"
|
||||
+ "\n"
|
||||
+ "$runtime = \\getenv('RUNTIME');\n"
|
||||
+ "\n"
|
||||
+ "\\spl_autoload_register(function (string $class) use ($runtime) : void {\n"
|
||||
+ " $file = \\str_replace('\\\\\\', \\DIRECTORY_SEPARATOR, \\str_replace('Antlr\\Antlr4\\Runtime\\\\\\', $runtime . '\\\\\\src\\\\\\', $class)) . '.php';\n"
|
||||
+ "\n"
|
||||
+ " if (\\file_exists($file)) {\n"
|
||||
+ " require_once $file; \n"
|
||||
+ " }\n"
|
||||
+ "});\n"
|
||||
+ "\n"
|
||||
+ "final class TreeShapeListener implements ParseTreeListener {\n"
|
||||
+ " public function visitTerminal(TerminalNode $node) : void {}\n"
|
||||
+ " public function visitErrorNode(ErrorNode $node) : void {}\n"
|
||||
+ " public function exitEveryRule(ParserRuleContext $ctx) : void {}\n"
|
||||
+ "\n"
|
||||
+ " public function enterEveryRule(ParserRuleContext $ctx) : void {\n"
|
||||
+ " for ($i = 0, $count = $ctx->getChildCount(); $i \\< $count; $i++) {\n"
|
||||
+ " $parent = $ctx->getChild($i)->getParent();\n"
|
||||
+ "\n"
|
||||
+ " if (!($parent instanceof RuleNode) || $parent->getRuleContext() !== $ctx) {\n"
|
||||
+ " throw new RuntimeException('Invalid parse tree shape detected.');\n"
|
||||
+ " }\n"
|
||||
+ " }\n"
|
||||
+ " }\n"
|
||||
+ "}"
|
||||
+ "\n"
|
||||
+ "$input = InputStream::fromPath($argv[1]);\n"
|
||||
+ "$lexer = new <lexerName>($input);\n"
|
||||
+ "$lexer->addErrorListener(new ConsoleErrorListener());"
|
||||
+ "$tokens = new CommonTokenStream($lexer);\n"
|
||||
+ "<createParser>"
|
||||
+ "$parser->addErrorListener(new ConsoleErrorListener());"
|
||||
+ "$parser->setBuildParseTree(true);\n"
|
||||
+ "$tree = $parser-><parserStartRuleName>;\n\n"
|
||||
+ "ParseTreeWalker::default()->walk(new TreeShapeListener(), $tree);\n"
|
||||
);
|
||||
|
||||
String stSource = "$parser = new <parserName>($tokens);\n";
|
||||
|
||||
if (debug) {
|
||||
stSource += "$parser->addErrorListener(new DiagnosticErrorListener());\n";
|
||||
}
|
||||
|
||||
if (trace) {
|
||||
stSource += "$parser->setTrace(true);\n";
|
||||
}
|
||||
|
||||
ST createParserST = new ST(stSource);
|
||||
outputFileST.add("createParser", createParserST);
|
||||
outputFileST.add("parserName", parserName);
|
||||
outputFileST.add("lexerName", lexerName);
|
||||
outputFileST.add("listenerName", listenerName);
|
||||
outputFileST.add("visitorName", visitorName);
|
||||
outputFileST.add("parserStartRuleName", parserStartRuleName);
|
||||
|
||||
writeFile(tmpdir, "Test.php", outputFileST.render());
|
||||
}
|
||||
|
||||
protected void eraseFiles(File dir) {
|
||||
String[] files = dir.list();
|
||||
for (int i = 0; files != null && i < files.length; i++) {
|
||||
new File(dir, files[i]).delete();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eraseTempDir() {
|
||||
boolean doErase = true;
|
||||
String propName = getPropertyPrefix() + "-erase-test-dir";
|
||||
String prop = System.getProperty(propName);
|
||||
if (prop != null && prop.length() > 0) {
|
||||
doErase = Boolean.getBoolean(prop);
|
||||
}
|
||||
if (doErase) {
|
||||
File tmpdirF = new File(tmpdir);
|
||||
if (tmpdirF.exists()) {
|
||||
eraseFiles(tmpdirF);
|
||||
tmpdirF.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort a list
|
||||
*/
|
||||
public <T extends Comparable<? super T>> List<T> sort(List<T> data) {
|
||||
List<T> dup = new ArrayList<T>();
|
||||
dup.addAll(data);
|
||||
Collections.sort(dup);
|
||||
return dup;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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>();
|
||||
keys.addAll(data.keySet());
|
||||
Collections.sort(keys);
|
||||
for (K k: keys) {
|
||||
dup.put(k, data.get(k));
|
||||
}
|
||||
return dup;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package org.antlr.v4.test.runtime.php;
|
||||
|
||||
import org.antlr.v4.test.runtime.BaseRuntimeTest;
|
||||
import org.antlr.v4.test.runtime.RuntimeTestDescriptor;
|
||||
import org.antlr.v4.test.runtime.descriptors.CompositeLexersDescriptors;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class TestCompositeLexers extends BaseRuntimeTest {
|
||||
public TestCompositeLexers(RuntimeTestDescriptor descriptor) {
|
||||
super(descriptor,new BasePHPTest());
|
||||
}
|
||||
|
||||
@Parameterized.Parameters(name="{0}")
|
||||
public static RuntimeTestDescriptor[] getAllTestDescriptors() {
|
||||
return BaseRuntimeTest.getRuntimeTestDescriptors(CompositeLexersDescriptors.class, "PHP");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package org.antlr.v4.test.runtime.php;
|
||||
|
||||
import org.antlr.v4.test.runtime.BaseRuntimeTest;
|
||||
import org.antlr.v4.test.runtime.RuntimeTestDescriptor;
|
||||
import org.antlr.v4.test.runtime.descriptors.CompositeParsersDescriptors;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class TestCompositeParsers extends BaseRuntimeTest {
|
||||
public TestCompositeParsers(RuntimeTestDescriptor descriptor) {
|
||||
super(descriptor,new BasePHPTest());
|
||||
}
|
||||
|
||||
@Parameterized.Parameters(name="{0}")
|
||||
public static RuntimeTestDescriptor[] getAllTestDescriptors() {
|
||||
return BaseRuntimeTest.getRuntimeTestDescriptors(CompositeParsersDescriptors.class, "PHP");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package org.antlr.v4.test.runtime.php;
|
||||
|
||||
import org.antlr.v4.test.runtime.BaseRuntimeTest;
|
||||
import org.antlr.v4.test.runtime.RuntimeTestDescriptor;
|
||||
import org.antlr.v4.test.runtime.descriptors.FullContextParsingDescriptors;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class TestFullContextParsing extends BaseRuntimeTest {
|
||||
public TestFullContextParsing(RuntimeTestDescriptor descriptor) {
|
||||
super(descriptor,new BasePHPTest());
|
||||
}
|
||||
|
||||
@Parameterized.Parameters(name="{0}")
|
||||
public static RuntimeTestDescriptor[] getAllTestDescriptors() {
|
||||
return BaseRuntimeTest.getRuntimeTestDescriptors(FullContextParsingDescriptors.class, "PHP");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package org.antlr.v4.test.runtime.php;
|
||||
|
||||
import org.antlr.v4.test.runtime.BaseRuntimeTest;
|
||||
import org.antlr.v4.test.runtime.RuntimeTestDescriptor;
|
||||
import org.antlr.v4.test.runtime.descriptors.LeftRecursionDescriptors;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class TestLeftRecursion extends BaseRuntimeTest {
|
||||
public TestLeftRecursion(RuntimeTestDescriptor descriptor) {
|
||||
super(descriptor,new BasePHPTest());
|
||||
}
|
||||
|
||||
@Parameterized.Parameters(name="{0}")
|
||||
public static RuntimeTestDescriptor[] getAllTestDescriptors() {
|
||||
return BaseRuntimeTest.getRuntimeTestDescriptors(LeftRecursionDescriptors.class, "PHP");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package org.antlr.v4.test.runtime.php;
|
||||
|
||||
import org.antlr.v4.test.runtime.BaseRuntimeTest;
|
||||
import org.antlr.v4.test.runtime.RuntimeTestDescriptor;
|
||||
import org.antlr.v4.test.runtime.descriptors.LexerErrorsDescriptors;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class TestLexerErrors extends BaseRuntimeTest {
|
||||
public TestLexerErrors(RuntimeTestDescriptor descriptor) {
|
||||
super(descriptor,new BasePHPTest());
|
||||
}
|
||||
|
||||
@Parameterized.Parameters(name="{0}")
|
||||
public static RuntimeTestDescriptor[] getAllTestDescriptors() {
|
||||
return BaseRuntimeTest.getRuntimeTestDescriptors(LexerErrorsDescriptors.class, "PHP");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package org.antlr.v4.test.runtime.php;
|
||||
|
||||
import org.antlr.v4.test.runtime.BaseRuntimeTest;
|
||||
import org.antlr.v4.test.runtime.RuntimeTestDescriptor;
|
||||
import org.antlr.v4.test.runtime.descriptors.LexerExecDescriptors;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class TestLexerExec extends BaseRuntimeTest {
|
||||
public TestLexerExec(RuntimeTestDescriptor descriptor) {
|
||||
super(descriptor,new BasePHPTest());
|
||||
}
|
||||
|
||||
@Parameterized.Parameters(name="{0}")
|
||||
public static RuntimeTestDescriptor[] getAllTestDescriptors() {
|
||||
return BaseRuntimeTest.getRuntimeTestDescriptors(LexerExecDescriptors.class, "PHP");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package org.antlr.v4.test.runtime.php;
|
||||
|
||||
import org.antlr.v4.test.runtime.BaseRuntimeTest;
|
||||
import org.antlr.v4.test.runtime.RuntimeTestDescriptor;
|
||||
import org.antlr.v4.test.runtime.descriptors.ListenersDescriptors;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class TestListeners extends BaseRuntimeTest {
|
||||
public TestListeners(RuntimeTestDescriptor descriptor) {
|
||||
super(descriptor,new BasePHPTest());
|
||||
}
|
||||
|
||||
@Parameterized.Parameters(name="{0}")
|
||||
public static RuntimeTestDescriptor[] getAllTestDescriptors() {
|
||||
return BaseRuntimeTest.getRuntimeTestDescriptors(ListenersDescriptors.class, "PHP");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package org.antlr.v4.test.runtime.php;
|
||||
|
||||
import org.antlr.v4.test.runtime.BaseRuntimeTest;
|
||||
import org.antlr.v4.test.runtime.RuntimeTestDescriptor;
|
||||
import org.antlr.v4.test.runtime.descriptors.ParseTreesDescriptors;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class TestParseTrees extends BaseRuntimeTest {
|
||||
public TestParseTrees(RuntimeTestDescriptor descriptor) {
|
||||
super(descriptor,new BasePHPTest());
|
||||
}
|
||||
|
||||
@Parameterized.Parameters(name="{0}")
|
||||
public static RuntimeTestDescriptor[] getAllTestDescriptors() {
|
||||
return BaseRuntimeTest.getRuntimeTestDescriptors(ParseTreesDescriptors.class, "PHP");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package org.antlr.v4.test.runtime.php;
|
||||
|
||||
import org.antlr.v4.test.runtime.BaseRuntimeTest;
|
||||
import org.antlr.v4.test.runtime.RuntimeTestDescriptor;
|
||||
import org.antlr.v4.test.runtime.descriptors.ParserErrorsDescriptors;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class TestParserErrors extends BaseRuntimeTest {
|
||||
public TestParserErrors(RuntimeTestDescriptor descriptor) {
|
||||
super(descriptor,new BasePHPTest());
|
||||
}
|
||||
|
||||
@Parameterized.Parameters(name="{0}")
|
||||
public static RuntimeTestDescriptor[] getAllTestDescriptors() {
|
||||
return BaseRuntimeTest.getRuntimeTestDescriptors(ParserErrorsDescriptors.class, "PHP");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package org.antlr.v4.test.runtime.php;
|
||||
|
||||
import org.antlr.v4.test.runtime.BaseRuntimeTest;
|
||||
import org.antlr.v4.test.runtime.RuntimeTestDescriptor;
|
||||
import org.antlr.v4.test.runtime.descriptors.ParserExecDescriptors;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class TestParserExec extends BaseRuntimeTest {
|
||||
public TestParserExec(RuntimeTestDescriptor descriptor) {
|
||||
super(descriptor,new BasePHPTest());
|
||||
}
|
||||
|
||||
@Parameterized.Parameters(name="{0}")
|
||||
public static RuntimeTestDescriptor[] getAllTestDescriptors() {
|
||||
return BaseRuntimeTest.getRuntimeTestDescriptors(ParserExecDescriptors.class, "PHP");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package org.antlr.v4.test.runtime.php;
|
||||
|
||||
import org.antlr.v4.test.runtime.BaseRuntimeTest;
|
||||
import org.antlr.v4.test.runtime.RuntimeTestDescriptor;
|
||||
import org.antlr.v4.test.runtime.descriptors.PerformanceDescriptors;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class TestPerformance extends BaseRuntimeTest {
|
||||
public TestPerformance(RuntimeTestDescriptor descriptor) {
|
||||
super(descriptor,new BasePHPTest());
|
||||
}
|
||||
|
||||
@Parameterized.Parameters(name="{0}")
|
||||
public static RuntimeTestDescriptor[] getAllTestDescriptors() {
|
||||
return BaseRuntimeTest.getRuntimeTestDescriptors(PerformanceDescriptors.class, "PHP");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package org.antlr.v4.test.runtime.php;
|
||||
|
||||
import org.antlr.v4.test.runtime.BaseRuntimeTest;
|
||||
import org.antlr.v4.test.runtime.RuntimeTestDescriptor;
|
||||
import org.antlr.v4.test.runtime.descriptors.SemPredEvalLexerDescriptors;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class TestSemPredEvalLexer extends BaseRuntimeTest {
|
||||
public TestSemPredEvalLexer(RuntimeTestDescriptor descriptor) {
|
||||
super(descriptor,new BasePHPTest());
|
||||
}
|
||||
|
||||
@Parameterized.Parameters(name="{0}")
|
||||
public static RuntimeTestDescriptor[] getAllTestDescriptors() {
|
||||
return BaseRuntimeTest.getRuntimeTestDescriptors(SemPredEvalLexerDescriptors.class, "PHP");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package org.antlr.v4.test.runtime.php;
|
||||
|
||||
import org.antlr.v4.test.runtime.BaseRuntimeTest;
|
||||
import org.antlr.v4.test.runtime.RuntimeTestDescriptor;
|
||||
import org.antlr.v4.test.runtime.descriptors.SemPredEvalParserDescriptors;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class TestSemPredEvalParser extends BaseRuntimeTest {
|
||||
public TestSemPredEvalParser(RuntimeTestDescriptor descriptor) {
|
||||
super(descriptor,new BasePHPTest());
|
||||
}
|
||||
|
||||
@Parameterized.Parameters(name="{0}")
|
||||
public static RuntimeTestDescriptor[] getAllTestDescriptors() {
|
||||
return BaseRuntimeTest.getRuntimeTestDescriptors(SemPredEvalParserDescriptors.class, "PHP");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package org.antlr.v4.test.runtime.php;
|
||||
|
||||
import org.antlr.v4.test.runtime.BaseRuntimeTest;
|
||||
import org.antlr.v4.test.runtime.RuntimeTestDescriptor;
|
||||
import org.antlr.v4.test.runtime.descriptors.SetsDescriptors;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class TestSets extends BaseRuntimeTest {
|
||||
public TestSets(RuntimeTestDescriptor descriptor) {
|
||||
super(descriptor,new BasePHPTest());
|
||||
}
|
||||
|
||||
@Parameterized.Parameters(name="{0}")
|
||||
public static RuntimeTestDescriptor[] getAllTestDescriptors() {
|
||||
return BaseRuntimeTest.getRuntimeTestDescriptors(SetsDescriptors.class, "PHP");
|
||||
}
|
||||
}
|
|
@ -31,6 +31,8 @@ namespace Antlr4.Runtime
|
|||
private readonly string _grammarFileName;
|
||||
|
||||
private readonly ATN _atn;
|
||||
|
||||
private readonly Dfa.DFA[] _decisionToDFA;
|
||||
|
||||
protected internal readonly BitSet pushRecursionContextStates;
|
||||
|
||||
|
@ -61,8 +63,17 @@ namespace Antlr4.Runtime
|
|||
this.pushRecursionContextStates.Set(state.stateNumber);
|
||||
}
|
||||
}
|
||||
// get atn simulator that knows how to do predictions
|
||||
Interpreter = new ParserATNSimulator(this, atn, null, null);
|
||||
|
||||
//init decision DFA
|
||||
int numberofDecisions = atn.NumberOfDecisions;
|
||||
this._decisionToDFA = new Dfa.DFA[numberofDecisions];
|
||||
for (int i = 0; i < numberofDecisions; i++)
|
||||
{
|
||||
DecisionState decisionState = atn.GetDecisionState(i);
|
||||
_decisionToDFA[i] = new Dfa.DFA(decisionState, i);
|
||||
}
|
||||
// get atn simulator that knows how to do predictions
|
||||
Interpreter = new ParserATNSimulator(this, atn, _decisionToDFA, null);
|
||||
}
|
||||
|
||||
public override ATN Atn
|
||||
|
|
|
@ -612,7 +612,6 @@ namespace Antlr4.Runtime
|
|||
}
|
||||
// throw exception unless disjoint or identical
|
||||
bool disjoint = prevRop.lastIndex < rop.index || prevRop.index > rop.lastIndex;
|
||||
bool same = prevRop.index == rop.index && prevRop.lastIndex == rop.lastIndex;
|
||||
// Delete special case of replace (text==null):
|
||||
// D.i-j.u D.x-y.v | boundaries overlap combine to max(min)..max(right)
|
||||
if (prevRop.text == null && rop.text == null && !disjoint)
|
||||
|
@ -628,7 +627,7 @@ namespace Antlr4.Runtime
|
|||
}
|
||||
else
|
||||
{
|
||||
if (!disjoint && !same)
|
||||
if (!disjoint)
|
||||
{
|
||||
throw new ArgumentException("replace op boundaries of " + rop + " overlap with previous " + prevRop);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ given input file during build.
|
|||
The following table lists the parameters that can be used with the function:
|
||||
|
||||
Argument# | Required | Default | Use
|
||||
----------|-----------|---------|--
|
||||
----------|-----------|---------|---
|
||||
0 | Yes | n/a | Unique target name. It is used to generate CMake Variables to reference the various outputs of the generation
|
||||
1 | Yes | n/a | Input file containing the lexer/parser definition
|
||||
2 | Yes | n/a | Type of Rules contained in the input: LEXER, PARSER or BOTH
|
||||
|
@ -24,10 +24,10 @@ Argument# | Required | Default | Use
|
|||
7 | No | none | Additional files on which the input depends
|
||||
8 | No | none | Library path to use during generation
|
||||
|
||||
The `ANTLR4_JAR_LOCATION` CMake variable must be set to the location where the `antlr-4*-complete.jar` generator is located.
|
||||
You can download the file from [here](http://www.antlr.org/download.html).
|
||||
The `ANTLR4_JAR_LOCATION` CMake variable must be set to the location where the `antlr-4*-complete.jar` generator is located. You can download the file from [here](http://www.antlr.org/download.html).
|
||||
|
||||
Additional option to the ANTLR4 generator can be passed in the `ANTLR4_GENERATED_OPTIONS` variable
|
||||
Additional options to the ANTLR4 generator can be passed in the `ANTLR4_GENERATED_OPTIONS` variable. Add the installation prefix of `antlr4-runtime` to `CMAKE_PREFIX_PATH` or set
|
||||
`antlr4-runtime_DIR` to a directory containing the files.
|
||||
|
||||
The following CMake variables are available following a call to `antlr4_generate`
|
||||
|
||||
|
|
|
@ -332,7 +332,7 @@
|
|||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "pushd ..\nif [ TParser.g4 -nt generated/TParser.cpp -o TLexer.g4 -nt generated/TLexer.cpp ]; then\n./generate.sh;\nfi\npopd";
|
||||
shellScript = "pushd ..\nif [ TParser.g4 -nt generated/TParser.cpp -o TLexer.g4 -nt generated/TLexer.cpp ]; then\n./generate.sh;\nfi\npopd\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
|
|
@ -0,0 +1,651 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug Static|Win32">
|
||||
<Configuration>Debug Static</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug Static|x64">
|
||||
<Configuration>Debug Static</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug DLL|Win32">
|
||||
<Configuration>Debug DLL</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug DLL|x64">
|
||||
<Configuration>Debug DLL</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release Static|Win32">
|
||||
<Configuration>Release Static</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release Static|x64">
|
||||
<Configuration>Release Static</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release DLL|Win32">
|
||||
<Configuration>Release DLL</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release DLL|x64">
|
||||
<Configuration>Release DLL</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{83BE66CD-9C4F-4F84-B72A-DD1855C8FC8A}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>antlr4cpp</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug DLL|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Static|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug DLL|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Static|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release DLL|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Static|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release DLL|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Static|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug DLL|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Static|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug DLL|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Static|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release DLL|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Static|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release DLL|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Static|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug DLL|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)bin\vs-2019\$(PlatformTarget)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
<TargetName>antlr4-runtime</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Static|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)bin\vs-2019\$(PlatformTarget)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
<TargetName>antlr4-runtime</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug DLL|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)bin\vs-2019\$(PlatformTarget)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
<TargetName>antlr4-runtime</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Static|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)bin\vs-2019\$(PlatformTarget)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
<TargetName>antlr4-runtime</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release DLL|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)bin\vs-2019\$(PlatformTarget)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
<TargetName>antlr4-runtime</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Static|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)bin\vs-2019\$(PlatformTarget)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
<TargetName>antlr4-runtime</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release DLL|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)bin\vs-2019\$(PlatformTarget)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
<TargetName>antlr4-runtime</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Static|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)bin\vs-2019\$(PlatformTarget)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
<TargetName>antlr4-runtime</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug DLL|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>ANTLR4CPP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeaderFile>
|
||||
</PrecompiledHeaderFile>
|
||||
<ForcedIncludeFiles>
|
||||
</ForcedIncludeFiles>
|
||||
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Static|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>ANTLR4CPP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeaderFile>
|
||||
</PrecompiledHeaderFile>
|
||||
<ForcedIncludeFiles>
|
||||
</ForcedIncludeFiles>
|
||||
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug DLL|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>ANTLR4CPP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeaderFile>
|
||||
</PrecompiledHeaderFile>
|
||||
<ForcedIncludeFiles>
|
||||
</ForcedIncludeFiles>
|
||||
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Static|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>ANTLR4CPP_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeaderFile>
|
||||
</PrecompiledHeaderFile>
|
||||
<ForcedIncludeFiles>
|
||||
</ForcedIncludeFiles>
|
||||
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release DLL|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>ANTLR4CPP_DLL;ANTLR4CPP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeaderFile>
|
||||
</PrecompiledHeaderFile>
|
||||
<ForcedIncludeFiles>
|
||||
</ForcedIncludeFiles>
|
||||
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Static|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>ANTLR4CPP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeaderFile>
|
||||
</PrecompiledHeaderFile>
|
||||
<ForcedIncludeFiles>
|
||||
</ForcedIncludeFiles>
|
||||
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release DLL|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>ANTLR4CPP_DLL;ANTLR4CPP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeaderFile>
|
||||
</PrecompiledHeaderFile>
|
||||
<ForcedIncludeFiles>
|
||||
</ForcedIncludeFiles>
|
||||
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Static|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>ANTLR4CPP_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeaderFile>
|
||||
</PrecompiledHeaderFile>
|
||||
<ForcedIncludeFiles>
|
||||
</ForcedIncludeFiles>
|
||||
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\ANTLRErrorListener.cpp" />
|
||||
<ClCompile Include="src\ANTLRErrorStrategy.cpp" />
|
||||
<ClCompile Include="src\ANTLRFileStream.cpp" />
|
||||
<ClCompile Include="src\ANTLRInputStream.cpp" />
|
||||
<ClCompile Include="src\atn\AbstractPredicateTransition.cpp" />
|
||||
<ClCompile Include="src\atn\ActionTransition.cpp" />
|
||||
<ClCompile Include="src\atn\AmbiguityInfo.cpp" />
|
||||
<ClCompile Include="src\atn\ArrayPredictionContext.cpp" />
|
||||
<ClCompile Include="src\atn\ATN.cpp" />
|
||||
<ClCompile Include="src\atn\ATNConfig.cpp" />
|
||||
<ClCompile Include="src\atn\ATNConfigSet.cpp" />
|
||||
<ClCompile Include="src\atn\ATNDeserializationOptions.cpp" />
|
||||
<ClCompile Include="src\atn\ATNDeserializer.cpp" />
|
||||
<ClCompile Include="src\atn\ATNSerializer.cpp" />
|
||||
<ClCompile Include="src\atn\ATNSimulator.cpp" />
|
||||
<ClCompile Include="src\atn\ATNState.cpp" />
|
||||
<ClCompile Include="src\atn\AtomTransition.cpp" />
|
||||
<ClCompile Include="src\atn\BasicBlockStartState.cpp" />
|
||||
<ClCompile Include="src\atn\BasicState.cpp" />
|
||||
<ClCompile Include="src\atn\BlockEndState.cpp" />
|
||||
<ClCompile Include="src\atn\BlockStartState.cpp" />
|
||||
<ClCompile Include="src\atn\ContextSensitivityInfo.cpp" />
|
||||
<ClCompile Include="src\atn\DecisionEventInfo.cpp" />
|
||||
<ClCompile Include="src\atn\DecisionInfo.cpp" />
|
||||
<ClCompile Include="src\atn\DecisionState.cpp" />
|
||||
<ClCompile Include="src\atn\EmptyPredictionContext.cpp" />
|
||||
<ClCompile Include="src\atn\EpsilonTransition.cpp" />
|
||||
<ClCompile Include="src\atn\ErrorInfo.cpp" />
|
||||
<ClCompile Include="src\atn\LexerAction.cpp" />
|
||||
<ClCompile Include="src\atn\LexerActionExecutor.cpp" />
|
||||
<ClCompile Include="src\atn\LexerATNConfig.cpp" />
|
||||
<ClCompile Include="src\atn\LexerATNSimulator.cpp" />
|
||||
<ClCompile Include="src\atn\LexerChannelAction.cpp" />
|
||||
<ClCompile Include="src\atn\LexerCustomAction.cpp" />
|
||||
<ClCompile Include="src\atn\LexerIndexedCustomAction.cpp" />
|
||||
<ClCompile Include="src\atn\LexerModeAction.cpp" />
|
||||
<ClCompile Include="src\atn\LexerMoreAction.cpp" />
|
||||
<ClCompile Include="src\atn\LexerPopModeAction.cpp" />
|
||||
<ClCompile Include="src\atn\LexerPushModeAction.cpp" />
|
||||
<ClCompile Include="src\atn\LexerSkipAction.cpp" />
|
||||
<ClCompile Include="src\atn\LexerTypeAction.cpp" />
|
||||
<ClCompile Include="src\atn\LL1Analyzer.cpp" />
|
||||
<ClCompile Include="src\atn\LookaheadEventInfo.cpp" />
|
||||
<ClCompile Include="src\atn\LoopEndState.cpp" />
|
||||
<ClCompile Include="src\atn\NotSetTransition.cpp" />
|
||||
<ClCompile Include="src\atn\OrderedATNConfigSet.cpp" />
|
||||
<ClCompile Include="src\atn\ParseInfo.cpp" />
|
||||
<ClCompile Include="src\atn\ParserATNSimulator.cpp" />
|
||||
<ClCompile Include="src\atn\PlusBlockStartState.cpp" />
|
||||
<ClCompile Include="src\atn\PlusLoopbackState.cpp" />
|
||||
<ClCompile Include="src\atn\PrecedencePredicateTransition.cpp" />
|
||||
<ClCompile Include="src\atn\PredicateEvalInfo.cpp" />
|
||||
<ClCompile Include="src\atn\PredicateTransition.cpp" />
|
||||
<ClCompile Include="src\atn\PredictionContext.cpp" />
|
||||
<ClCompile Include="src\atn\PredictionMode.cpp" />
|
||||
<ClCompile Include="src\atn\ProfilingATNSimulator.cpp" />
|
||||
<ClCompile Include="src\atn\RangeTransition.cpp" />
|
||||
<ClCompile Include="src\atn\RuleStartState.cpp" />
|
||||
<ClCompile Include="src\atn\RuleStopState.cpp" />
|
||||
<ClCompile Include="src\atn\RuleTransition.cpp" />
|
||||
<ClCompile Include="src\atn\SemanticContext.cpp" />
|
||||
<ClCompile Include="src\atn\SetTransition.cpp" />
|
||||
<ClCompile Include="src\atn\SingletonPredictionContext.cpp" />
|
||||
<ClCompile Include="src\atn\StarBlockStartState.cpp" />
|
||||
<ClCompile Include="src\atn\StarLoopbackState.cpp" />
|
||||
<ClCompile Include="src\atn\StarLoopEntryState.cpp" />
|
||||
<ClCompile Include="src\atn\TokensStartState.cpp" />
|
||||
<ClCompile Include="src\atn\Transition.cpp" />
|
||||
<ClCompile Include="src\atn\WildcardTransition.cpp" />
|
||||
<ClCompile Include="src\BailErrorStrategy.cpp" />
|
||||
<ClCompile Include="src\BaseErrorListener.cpp" />
|
||||
<ClCompile Include="src\BufferedTokenStream.cpp" />
|
||||
<ClCompile Include="src\CharStream.cpp" />
|
||||
<ClCompile Include="src\CommonToken.cpp" />
|
||||
<ClCompile Include="src\CommonTokenFactory.cpp" />
|
||||
<ClCompile Include="src\CommonTokenStream.cpp" />
|
||||
<ClCompile Include="src\ConsoleErrorListener.cpp" />
|
||||
<ClCompile Include="src\DefaultErrorStrategy.cpp" />
|
||||
<ClCompile Include="src\dfa\DFA.cpp" />
|
||||
<ClCompile Include="src\dfa\DFASerializer.cpp" />
|
||||
<ClCompile Include="src\dfa\DFAState.cpp" />
|
||||
<ClCompile Include="src\dfa\LexerDFASerializer.cpp" />
|
||||
<ClCompile Include="src\DiagnosticErrorListener.cpp" />
|
||||
<ClCompile Include="src\Exceptions.cpp" />
|
||||
<ClCompile Include="src\FailedPredicateException.cpp" />
|
||||
<ClCompile Include="src\InputMismatchException.cpp" />
|
||||
<ClCompile Include="src\InterpreterRuleContext.cpp" />
|
||||
<ClCompile Include="src\IntStream.cpp" />
|
||||
<ClCompile Include="src\Lexer.cpp" />
|
||||
<ClCompile Include="src\LexerInterpreter.cpp" />
|
||||
<ClCompile Include="src\LexerNoViableAltException.cpp" />
|
||||
<ClCompile Include="src\ListTokenSource.cpp" />
|
||||
<ClCompile Include="src\misc\InterpreterDataReader.cpp" />
|
||||
<ClCompile Include="src\misc\Interval.cpp" />
|
||||
<ClCompile Include="src\misc\IntervalSet.cpp" />
|
||||
<ClCompile Include="src\misc\MurmurHash.cpp" />
|
||||
<ClCompile Include="src\misc\Predicate.cpp" />
|
||||
<ClCompile Include="src\NoViableAltException.cpp" />
|
||||
<ClCompile Include="src\Parser.cpp" />
|
||||
<ClCompile Include="src\ParserInterpreter.cpp" />
|
||||
<ClCompile Include="src\ParserRuleContext.cpp" />
|
||||
<ClCompile Include="src\ProxyErrorListener.cpp" />
|
||||
<ClCompile Include="src\RecognitionException.cpp" />
|
||||
<ClCompile Include="src\Recognizer.cpp" />
|
||||
<ClCompile Include="src\RuleContext.cpp" />
|
||||
<ClCompile Include="src\RuleContextWithAltNum.cpp" />
|
||||
<ClCompile Include="src\RuntimeMetaData.cpp" />
|
||||
<ClCompile Include="src\support\Any.cpp" />
|
||||
<ClCompile Include="src\support\Arrays.cpp" />
|
||||
<ClCompile Include="src\support\CPPUtils.cpp" />
|
||||
<ClCompile Include="src\support\guid.cpp" />
|
||||
<ClCompile Include="src\support\StringUtils.cpp" />
|
||||
<ClCompile Include="src\Token.cpp" />
|
||||
<ClCompile Include="src\TokenSource.cpp" />
|
||||
<ClCompile Include="src\TokenStream.cpp" />
|
||||
<ClCompile Include="src\TokenStreamRewriter.cpp" />
|
||||
<ClCompile Include="src\tree\ErrorNode.cpp" />
|
||||
<ClCompile Include="src\tree\ErrorNodeImpl.cpp" />
|
||||
<ClCompile Include="src\tree\IterativeParseTreeWalker.cpp" />
|
||||
<ClCompile Include="src\tree\ParseTree.cpp" />
|
||||
<ClCompile Include="src\tree\ParseTreeListener.cpp" />
|
||||
<ClCompile Include="src\tree\ParseTreeVisitor.cpp" />
|
||||
<ClCompile Include="src\tree\ParseTreeWalker.cpp" />
|
||||
<ClCompile Include="src\tree\pattern\Chunk.cpp" />
|
||||
<ClCompile Include="src\tree\pattern\ParseTreeMatch.cpp" />
|
||||
<ClCompile Include="src\tree\pattern\ParseTreePattern.cpp" />
|
||||
<ClCompile Include="src\tree\pattern\ParseTreePatternMatcher.cpp" />
|
||||
<ClCompile Include="src\tree\pattern\RuleTagToken.cpp" />
|
||||
<ClCompile Include="src\tree\pattern\TagChunk.cpp" />
|
||||
<ClCompile Include="src\tree\pattern\TextChunk.cpp" />
|
||||
<ClCompile Include="src\tree\pattern\TokenTagToken.cpp" />
|
||||
<ClCompile Include="src\tree\TerminalNode.cpp" />
|
||||
<ClCompile Include="src\tree\TerminalNodeImpl.cpp" />
|
||||
<ClCompile Include="src\tree\Trees.cpp" />
|
||||
<ClCompile Include="src\tree\xpath\XPath.cpp" />
|
||||
<ClCompile Include="src\tree\xpath\XPathElement.cpp" />
|
||||
<ClCompile Include="src\tree\xpath\XPathLexer.cpp" />
|
||||
<ClCompile Include="src\tree\xpath\XPathLexerErrorListener.cpp" />
|
||||
<ClCompile Include="src\tree\xpath\XPathRuleAnywhereElement.cpp" />
|
||||
<ClCompile Include="src\tree\xpath\XPathRuleElement.cpp" />
|
||||
<ClCompile Include="src\tree\xpath\XPathTokenAnywhereElement.cpp" />
|
||||
<ClCompile Include="src\tree\xpath\XPathTokenElement.cpp" />
|
||||
<ClCompile Include="src\tree\xpath\XPathWildcardAnywhereElement.cpp" />
|
||||
<ClCompile Include="src\tree\xpath\XPathWildcardElement.cpp" />
|
||||
<ClCompile Include="src\UnbufferedCharStream.cpp" />
|
||||
<ClCompile Include="src\UnbufferedTokenStream.cpp" />
|
||||
<ClCompile Include="src\Vocabulary.cpp" />
|
||||
<ClCompile Include="src\WritableToken.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\antlr4-common.h" />
|
||||
<ClInclude Include="src\antlr4-runtime.h" />
|
||||
<ClInclude Include="src\ANTLRErrorListener.h" />
|
||||
<ClInclude Include="src\ANTLRErrorStrategy.h" />
|
||||
<ClInclude Include="src\ANTLRFileStream.h" />
|
||||
<ClInclude Include="src\ANTLRInputStream.h" />
|
||||
<ClInclude Include="src\atn\AbstractPredicateTransition.h" />
|
||||
<ClInclude Include="src\atn\ActionTransition.h" />
|
||||
<ClInclude Include="src\atn\AmbiguityInfo.h" />
|
||||
<ClInclude Include="src\atn\ArrayPredictionContext.h" />
|
||||
<ClInclude Include="src\atn\ATN.h" />
|
||||
<ClInclude Include="src\atn\ATNConfig.h" />
|
||||
<ClInclude Include="src\atn\ATNConfigSet.h" />
|
||||
<ClInclude Include="src\atn\ATNDeserializationOptions.h" />
|
||||
<ClInclude Include="src\atn\ATNDeserializer.h" />
|
||||
<ClInclude Include="src\atn\ATNSerializer.h" />
|
||||
<ClInclude Include="src\atn\ATNSimulator.h" />
|
||||
<ClInclude Include="src\atn\ATNState.h" />
|
||||
<ClInclude Include="src\atn\ATNType.h" />
|
||||
<ClInclude Include="src\atn\AtomTransition.h" />
|
||||
<ClInclude Include="src\atn\BasicBlockStartState.h" />
|
||||
<ClInclude Include="src\atn\BasicState.h" />
|
||||
<ClInclude Include="src\atn\BlockEndState.h" />
|
||||
<ClInclude Include="src\atn\BlockStartState.h" />
|
||||
<ClInclude Include="src\atn\ConfigLookup.h" />
|
||||
<ClInclude Include="src\atn\ContextSensitivityInfo.h" />
|
||||
<ClInclude Include="src\atn\DecisionEventInfo.h" />
|
||||
<ClInclude Include="src\atn\DecisionInfo.h" />
|
||||
<ClInclude Include="src\atn\DecisionState.h" />
|
||||
<ClInclude Include="src\atn\EmptyPredictionContext.h" />
|
||||
<ClInclude Include="src\atn\EpsilonTransition.h" />
|
||||
<ClInclude Include="src\atn\ErrorInfo.h" />
|
||||
<ClInclude Include="src\atn\LexerAction.h" />
|
||||
<ClInclude Include="src\atn\LexerActionExecutor.h" />
|
||||
<ClInclude Include="src\atn\LexerActionType.h" />
|
||||
<ClInclude Include="src\atn\LexerATNConfig.h" />
|
||||
<ClInclude Include="src\atn\LexerATNSimulator.h" />
|
||||
<ClInclude Include="src\atn\LexerChannelAction.h" />
|
||||
<ClInclude Include="src\atn\LexerCustomAction.h" />
|
||||
<ClInclude Include="src\atn\LexerIndexedCustomAction.h" />
|
||||
<ClInclude Include="src\atn\LexerModeAction.h" />
|
||||
<ClInclude Include="src\atn\LexerMoreAction.h" />
|
||||
<ClInclude Include="src\atn\LexerPopModeAction.h" />
|
||||
<ClInclude Include="src\atn\LexerPushModeAction.h" />
|
||||
<ClInclude Include="src\atn\LexerSkipAction.h" />
|
||||
<ClInclude Include="src\atn\LexerTypeAction.h" />
|
||||
<ClInclude Include="src\atn\LL1Analyzer.h" />
|
||||
<ClInclude Include="src\atn\LookaheadEventInfo.h" />
|
||||
<ClInclude Include="src\atn\LoopEndState.h" />
|
||||
<ClInclude Include="src\atn\NotSetTransition.h" />
|
||||
<ClInclude Include="src\atn\OrderedATNConfigSet.h" />
|
||||
<ClInclude Include="src\atn\ParseInfo.h" />
|
||||
<ClInclude Include="src\atn\ParserATNSimulator.h" />
|
||||
<ClInclude Include="src\atn\PlusBlockStartState.h" />
|
||||
<ClInclude Include="src\atn\PlusLoopbackState.h" />
|
||||
<ClInclude Include="src\atn\PrecedencePredicateTransition.h" />
|
||||
<ClInclude Include="src\atn\PredicateEvalInfo.h" />
|
||||
<ClInclude Include="src\atn\PredicateTransition.h" />
|
||||
<ClInclude Include="src\atn\PredictionContext.h" />
|
||||
<ClInclude Include="src\atn\PredictionMode.h" />
|
||||
<ClInclude Include="src\atn\ProfilingATNSimulator.h" />
|
||||
<ClInclude Include="src\atn\RangeTransition.h" />
|
||||
<ClInclude Include="src\atn\RuleStartState.h" />
|
||||
<ClInclude Include="src\atn\RuleStopState.h" />
|
||||
<ClInclude Include="src\atn\RuleTransition.h" />
|
||||
<ClInclude Include="src\atn\SemanticContext.h" />
|
||||
<ClInclude Include="src\atn\SetTransition.h" />
|
||||
<ClInclude Include="src\atn\SingletonPredictionContext.h" />
|
||||
<ClInclude Include="src\atn\StarBlockStartState.h" />
|
||||
<ClInclude Include="src\atn\StarLoopbackState.h" />
|
||||
<ClInclude Include="src\atn\StarLoopEntryState.h" />
|
||||
<ClInclude Include="src\atn\TokensStartState.h" />
|
||||
<ClInclude Include="src\atn\Transition.h" />
|
||||
<ClInclude Include="src\atn\WildcardTransition.h" />
|
||||
<ClInclude Include="src\BailErrorStrategy.h" />
|
||||
<ClInclude Include="src\BaseErrorListener.h" />
|
||||
<ClInclude Include="src\BufferedTokenStream.h" />
|
||||
<ClInclude Include="src\CharStream.h" />
|
||||
<ClInclude Include="src\CommonToken.h" />
|
||||
<ClInclude Include="src\CommonTokenFactory.h" />
|
||||
<ClInclude Include="src\CommonTokenStream.h" />
|
||||
<ClInclude Include="src\ConsoleErrorListener.h" />
|
||||
<ClInclude Include="src\DefaultErrorStrategy.h" />
|
||||
<ClInclude Include="src\dfa\DFA.h" />
|
||||
<ClInclude Include="src\dfa\DFASerializer.h" />
|
||||
<ClInclude Include="src\dfa\DFAState.h" />
|
||||
<ClInclude Include="src\dfa\LexerDFASerializer.h" />
|
||||
<ClInclude Include="src\DiagnosticErrorListener.h" />
|
||||
<ClInclude Include="src\Exceptions.h" />
|
||||
<ClInclude Include="src\FailedPredicateException.h" />
|
||||
<ClInclude Include="src\InputMismatchException.h" />
|
||||
<ClInclude Include="src\InterpreterRuleContext.h" />
|
||||
<ClInclude Include="src\IntStream.h" />
|
||||
<ClInclude Include="src\Lexer.h" />
|
||||
<ClInclude Include="src\LexerInterpreter.h" />
|
||||
<ClInclude Include="src\LexerNoViableAltException.h" />
|
||||
<ClInclude Include="src\ListTokenSource.h" />
|
||||
<ClInclude Include="src\misc\InterpreterDataReader.h" />
|
||||
<ClInclude Include="src\misc\Interval.h" />
|
||||
<ClInclude Include="src\misc\IntervalSet.h" />
|
||||
<ClInclude Include="src\misc\MurmurHash.h" />
|
||||
<ClInclude Include="src\misc\Predicate.h" />
|
||||
<ClInclude Include="src\NoViableAltException.h" />
|
||||
<ClInclude Include="src\Parser.h" />
|
||||
<ClInclude Include="src\ParserInterpreter.h" />
|
||||
<ClInclude Include="src\ParserRuleContext.h" />
|
||||
<ClInclude Include="src\ProxyErrorListener.h" />
|
||||
<ClInclude Include="src\RecognitionException.h" />
|
||||
<ClInclude Include="src\Recognizer.h" />
|
||||
<ClInclude Include="src\RuleContext.h" />
|
||||
<ClInclude Include="src\RuleContextWithAltNum.h" />
|
||||
<ClInclude Include="src\RuntimeMetaData.h" />
|
||||
<ClInclude Include="src\support\Any.h" />
|
||||
<ClInclude Include="src\support\Arrays.h" />
|
||||
<ClInclude Include="src\support\BitSet.h" />
|
||||
<ClInclude Include="src\support\CPPUtils.h" />
|
||||
<ClInclude Include="src\support\Declarations.h" />
|
||||
<ClInclude Include="src\support\guid.h" />
|
||||
<ClInclude Include="src\support\StringUtils.h" />
|
||||
<ClInclude Include="src\Token.h" />
|
||||
<ClInclude Include="src\TokenFactory.h" />
|
||||
<ClInclude Include="src\TokenSource.h" />
|
||||
<ClInclude Include="src\TokenStream.h" />
|
||||
<ClInclude Include="src\TokenStreamRewriter.h" />
|
||||
<ClInclude Include="src\tree\AbstractParseTreeVisitor.h" />
|
||||
<ClInclude Include="src\tree\ErrorNode.h" />
|
||||
<ClInclude Include="src\tree\ErrorNodeImpl.h" />
|
||||
<ClInclude Include="src\tree\IterativeParseTreeWalker.h" />
|
||||
<ClInclude Include="src\tree\ParseTree.h" />
|
||||
<ClInclude Include="src\tree\ParseTreeListener.h" />
|
||||
<ClInclude Include="src\tree\ParseTreeProperty.h" />
|
||||
<ClInclude Include="src\tree\ParseTreeVisitor.h" />
|
||||
<ClInclude Include="src\tree\ParseTreeWalker.h" />
|
||||
<ClInclude Include="src\tree\pattern\Chunk.h" />
|
||||
<ClInclude Include="src\tree\pattern\ParseTreeMatch.h" />
|
||||
<ClInclude Include="src\tree\pattern\ParseTreePattern.h" />
|
||||
<ClInclude Include="src\tree\pattern\ParseTreePatternMatcher.h" />
|
||||
<ClInclude Include="src\tree\pattern\RuleTagToken.h" />
|
||||
<ClInclude Include="src\tree\pattern\TagChunk.h" />
|
||||
<ClInclude Include="src\tree\pattern\TextChunk.h" />
|
||||
<ClInclude Include="src\tree\pattern\TokenTagToken.h" />
|
||||
<ClInclude Include="src\tree\RuleNode.h" />
|
||||
<ClInclude Include="src\tree\SyntaxTree.h" />
|
||||
<ClInclude Include="src\tree\TerminalNode.h" />
|
||||
<ClInclude Include="src\tree\TerminalNodeImpl.h" />
|
||||
<ClInclude Include="src\tree\Trees.h" />
|
||||
<ClInclude Include="src\tree\xpath\XPath.h" />
|
||||
<ClInclude Include="src\tree\xpath\XPathElement.h" />
|
||||
<ClInclude Include="src\tree\xpath\XPathLexer.h" />
|
||||
<ClInclude Include="src\tree\xpath\XPathLexerErrorListener.h" />
|
||||
<ClInclude Include="src\tree\xpath\XPathRuleAnywhereElement.h" />
|
||||
<ClInclude Include="src\tree\xpath\XPathRuleElement.h" />
|
||||
<ClInclude Include="src\tree\xpath\XPathTokenAnywhereElement.h" />
|
||||
<ClInclude Include="src\tree\xpath\XPathTokenElement.h" />
|
||||
<ClInclude Include="src\tree\xpath\XPathWildcardAnywhereElement.h" />
|
||||
<ClInclude Include="src\tree\xpath\XPathWildcardElement.h" />
|
||||
<ClInclude Include="src\UnbufferedCharStream.h" />
|
||||
<ClInclude Include="src\UnbufferedTokenStream.h" />
|
||||
<ClInclude Include="src\Vocabulary.h" />
|
||||
<ClInclude Include="src\WritableToken.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
|
@ -0,0 +1,987 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\atn">
|
||||
<UniqueIdentifier>{587a2726-4856-4d21-937a-fbaebaa90232}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\atn">
|
||||
<UniqueIdentifier>{2662156f-1508-4dad-b991-a8298a6db9bf}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\dfa">
|
||||
<UniqueIdentifier>{5b1e59b1-7fa5-46a5-8d92-965bd709cca0}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\dfa">
|
||||
<UniqueIdentifier>{9de9fe74-5d67-441d-a972-3cebe6dfbfcc}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\misc">
|
||||
<UniqueIdentifier>{89fd3896-0ab1-476d-8d64-a57f10a5e73b}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\misc">
|
||||
<UniqueIdentifier>{23939d7b-8e11-421e-80eb-b2cfdfdd64e9}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\support">
|
||||
<UniqueIdentifier>{05f2bacb-b5b2-4ca3-abe1-ca9a7239ecaa}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\support">
|
||||
<UniqueIdentifier>{d3b2ae2d-836b-4c73-8180-aca4ebb7d658}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\tree">
|
||||
<UniqueIdentifier>{6674a0f0-c65d-4a00-a9e5-1f243b89d0a2}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\tree">
|
||||
<UniqueIdentifier>{1893fffe-7a2b-4708-8ce5-003aa9b749f7}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\tree\pattern">
|
||||
<UniqueIdentifier>{053a0632-27bc-4043-b5e8-760951b3b5b9}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\tree\pattern">
|
||||
<UniqueIdentifier>{048c180d-44cf-49ca-a7aa-d0053fea07f5}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\tree\xpath">
|
||||
<UniqueIdentifier>{3181cae5-cc15-4050-8c45-22af44a823de}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\tree\xpath">
|
||||
<UniqueIdentifier>{290632d2-c56e-4005-a417-eb83b9531e1a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\ANTLRErrorListener.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\ANTLRErrorStrategy.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\ANTLRFileStream.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\ANTLRInputStream.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\BailErrorStrategy.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\BaseErrorListener.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\BufferedTokenStream.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\CharStream.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\CommonToken.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\CommonTokenFactory.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\CommonTokenStream.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\ConsoleErrorListener.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\DefaultErrorStrategy.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\DiagnosticErrorListener.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Exceptions.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\FailedPredicateException.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\InputMismatchException.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\InterpreterRuleContext.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\IntStream.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Lexer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\LexerInterpreter.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\LexerNoViableAltException.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\ListTokenSource.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\NoViableAltException.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Parser.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\ParserInterpreter.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\ParserRuleContext.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\ProxyErrorListener.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\RecognitionException.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Recognizer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\RuleContext.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Token.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\TokenFactory.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\TokenSource.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\TokenStream.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\TokenStreamRewriter.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\UnbufferedCharStream.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\UnbufferedTokenStream.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\WritableToken.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\DecisionState.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\EmptyPredictionContext.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\EpsilonTransition.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\LexerATNConfig.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\LexerATNSimulator.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\LL1Analyzer.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\LoopEndState.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\NotSetTransition.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\OrderedATNConfigSet.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\ParserATNSimulator.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\PlusBlockStartState.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\PlusLoopbackState.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\PrecedencePredicateTransition.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\PredicateTransition.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\PredictionContext.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\PredictionMode.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\RangeTransition.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\RuleStartState.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\RuleStopState.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\RuleTransition.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\SemanticContext.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\SetTransition.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\SingletonPredictionContext.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\StarBlockStartState.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\StarLoopbackState.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\StarLoopEntryState.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\TokensStartState.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\Transition.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\WildcardTransition.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\AbstractPredicateTransition.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\ActionTransition.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\ArrayPredictionContext.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\ATN.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\ATNConfig.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\ATNConfigSet.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\ATNDeserializationOptions.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\ATNDeserializer.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\ATNSerializer.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\ATNSimulator.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\ATNState.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\ATNType.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\AtomTransition.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\BasicBlockStartState.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\BasicState.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\BlockEndState.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\BlockStartState.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\ConfigLookup.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\dfa\LexerDFASerializer.h">
|
||||
<Filter>Header Files\dfa</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\dfa\DFA.h">
|
||||
<Filter>Header Files\dfa</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\dfa\DFASerializer.h">
|
||||
<Filter>Header Files\dfa</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\dfa\DFAState.h">
|
||||
<Filter>Header Files\dfa</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\misc\Interval.h">
|
||||
<Filter>Header Files\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\misc\IntervalSet.h">
|
||||
<Filter>Header Files\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\misc\MurmurHash.h">
|
||||
<Filter>Header Files\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\support\Arrays.h">
|
||||
<Filter>Header Files\support</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\support\BitSet.h">
|
||||
<Filter>Header Files\support</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\support\CPPUtils.h">
|
||||
<Filter>Header Files\support</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\support\Declarations.h">
|
||||
<Filter>Header Files\support</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\support\guid.h">
|
||||
<Filter>Header Files\support</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\AbstractParseTreeVisitor.h">
|
||||
<Filter>Header Files\tree</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\ErrorNode.h">
|
||||
<Filter>Header Files\tree</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\ErrorNodeImpl.h">
|
||||
<Filter>Header Files\tree</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\ParseTree.h">
|
||||
<Filter>Header Files\tree</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\ParseTreeListener.h">
|
||||
<Filter>Header Files\tree</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\ParseTreeProperty.h">
|
||||
<Filter>Header Files\tree</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\ParseTreeVisitor.h">
|
||||
<Filter>Header Files\tree</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\ParseTreeWalker.h">
|
||||
<Filter>Header Files\tree</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\RuleNode.h">
|
||||
<Filter>Header Files\tree</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\SyntaxTree.h">
|
||||
<Filter>Header Files\tree</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\TerminalNode.h">
|
||||
<Filter>Header Files\tree</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\TerminalNodeImpl.h">
|
||||
<Filter>Header Files\tree</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\Trees.h">
|
||||
<Filter>Header Files\tree</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\pattern\Chunk.h">
|
||||
<Filter>Header Files\tree\pattern</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\pattern\ParseTreeMatch.h">
|
||||
<Filter>Header Files\tree\pattern</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\pattern\ParseTreePattern.h">
|
||||
<Filter>Header Files\tree\pattern</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\pattern\ParseTreePatternMatcher.h">
|
||||
<Filter>Header Files\tree\pattern</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\pattern\RuleTagToken.h">
|
||||
<Filter>Header Files\tree\pattern</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\pattern\TagChunk.h">
|
||||
<Filter>Header Files\tree\pattern</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\pattern\TextChunk.h">
|
||||
<Filter>Header Files\tree\pattern</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\pattern\TokenTagToken.h">
|
||||
<Filter>Header Files\tree\pattern</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\xpath\XPathLexer.h">
|
||||
<Filter>Header Files\tree\xpath</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Vocabulary.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\AmbiguityInfo.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\ContextSensitivityInfo.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\DecisionEventInfo.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\DecisionInfo.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\ErrorInfo.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\LexerAction.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\LexerActionExecutor.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\LexerActionType.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\LexerChannelAction.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\LexerCustomAction.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\LexerIndexedCustomAction.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\LexerModeAction.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\LexerMoreAction.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\LexerPopModeAction.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\LexerPushModeAction.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\LexerSkipAction.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\LexerTypeAction.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\LookaheadEventInfo.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\ParseInfo.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\PredicateEvalInfo.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\atn\ProfilingATNSimulator.h">
|
||||
<Filter>Header Files\atn</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\misc\Predicate.h">
|
||||
<Filter>Header Files\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\RuleContextWithAltNum.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\RuntimeMetaData.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\support\StringUtils.h">
|
||||
<Filter>Header Files\support</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\xpath\XPath.h">
|
||||
<Filter>Header Files\tree\xpath</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\xpath\XPathElement.h">
|
||||
<Filter>Header Files\tree\xpath</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\xpath\XPathLexerErrorListener.h">
|
||||
<Filter>Header Files\tree\xpath</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\xpath\XPathRuleAnywhereElement.h">
|
||||
<Filter>Header Files\tree\xpath</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\xpath\XPathRuleElement.h">
|
||||
<Filter>Header Files\tree\xpath</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\xpath\XPathTokenAnywhereElement.h">
|
||||
<Filter>Header Files\tree\xpath</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\xpath\XPathTokenElement.h">
|
||||
<Filter>Header Files\tree\xpath</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\xpath\XPathWildcardAnywhereElement.h">
|
||||
<Filter>Header Files\tree\xpath</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\xpath\XPathWildcardElement.h">
|
||||
<Filter>Header Files\tree\xpath</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\antlr4-common.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\antlr4-runtime.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tree\IterativeParseTreeWalker.h">
|
||||
<Filter>Header Files\tree</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\misc\InterpreterDataReader.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\support\Any.h">
|
||||
<Filter>Header Files\support</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\ANTLRFileStream.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\ANTLRInputStream.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\BailErrorStrategy.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\BaseErrorListener.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\BufferedTokenStream.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\CharStream.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\CommonToken.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\CommonTokenFactory.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\CommonTokenStream.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\ConsoleErrorListener.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\DefaultErrorStrategy.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\DiagnosticErrorListener.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Exceptions.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\FailedPredicateException.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\InputMismatchException.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\InterpreterRuleContext.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\IntStream.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Lexer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\LexerInterpreter.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\LexerNoViableAltException.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\ListTokenSource.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\NoViableAltException.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Parser.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\ParserInterpreter.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\ParserRuleContext.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\ProxyErrorListener.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\RecognitionException.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Recognizer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\RuleContext.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\TokenStream.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\TokenStreamRewriter.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\UnbufferedCharStream.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\UnbufferedTokenStream.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\AbstractPredicateTransition.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\ActionTransition.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\ArrayPredictionContext.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\ATN.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\ATNConfig.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\ATNConfigSet.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\ATNDeserializationOptions.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\ATNDeserializer.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\ATNSerializer.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\ATNSimulator.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\ATNState.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\AtomTransition.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\BasicBlockStartState.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\BasicState.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\BlockEndState.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\DecisionState.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\EmptyPredictionContext.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\EpsilonTransition.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\LexerATNConfig.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\LexerATNSimulator.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\LL1Analyzer.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\LoopEndState.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\NotSetTransition.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\OrderedATNConfigSet.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\ParserATNSimulator.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\PlusBlockStartState.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\PlusLoopbackState.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\PrecedencePredicateTransition.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\PredicateTransition.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\PredictionContext.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\PredictionMode.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\RangeTransition.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\RuleStartState.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\RuleStopState.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\RuleTransition.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\SemanticContext.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\SetTransition.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\SingletonPredictionContext.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\StarBlockStartState.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\StarLoopbackState.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\StarLoopEntryState.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\TokensStartState.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\Transition.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\WildcardTransition.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\dfa\DFA.cpp">
|
||||
<Filter>Source Files\dfa</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\dfa\DFASerializer.cpp">
|
||||
<Filter>Source Files\dfa</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\dfa\DFAState.cpp">
|
||||
<Filter>Source Files\dfa</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\dfa\LexerDFASerializer.cpp">
|
||||
<Filter>Source Files\dfa</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\misc\Interval.cpp">
|
||||
<Filter>Source Files\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\misc\IntervalSet.cpp">
|
||||
<Filter>Source Files\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\misc\MurmurHash.cpp">
|
||||
<Filter>Source Files\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\support\Arrays.cpp">
|
||||
<Filter>Source Files\support</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\support\CPPUtils.cpp">
|
||||
<Filter>Source Files\support</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\support\guid.cpp">
|
||||
<Filter>Source Files\support</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tree\ErrorNodeImpl.cpp">
|
||||
<Filter>Source Files\tree</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tree\ParseTreeWalker.cpp">
|
||||
<Filter>Source Files\tree</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tree\TerminalNodeImpl.cpp">
|
||||
<Filter>Source Files\tree</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tree\Trees.cpp">
|
||||
<Filter>Source Files\tree</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tree\pattern\ParseTreeMatch.cpp">
|
||||
<Filter>Source Files\tree\pattern</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tree\pattern\ParseTreePattern.cpp">
|
||||
<Filter>Source Files\tree\pattern</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tree\pattern\ParseTreePatternMatcher.cpp">
|
||||
<Filter>Source Files\tree\pattern</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tree\pattern\RuleTagToken.cpp">
|
||||
<Filter>Source Files\tree\pattern</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tree\pattern\TagChunk.cpp">
|
||||
<Filter>Source Files\tree\pattern</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tree\pattern\TextChunk.cpp">
|
||||
<Filter>Source Files\tree\pattern</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tree\pattern\TokenTagToken.cpp">
|
||||
<Filter>Source Files\tree\pattern</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\AmbiguityInfo.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\ContextSensitivityInfo.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\DecisionEventInfo.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\DecisionInfo.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\ErrorInfo.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\LexerActionExecutor.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\LexerChannelAction.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\LexerCustomAction.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\LexerIndexedCustomAction.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\LexerModeAction.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\LexerMoreAction.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\LexerPopModeAction.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\LexerPushModeAction.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\LexerSkipAction.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\LexerTypeAction.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\LookaheadEventInfo.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\ParseInfo.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\PredicateEvalInfo.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\ProfilingATNSimulator.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\RuleContextWithAltNum.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\RuntimeMetaData.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\support\StringUtils.cpp">
|
||||
<Filter>Source Files\support</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tree\xpath\XPath.cpp">
|
||||
<Filter>Source Files\tree\xpath</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tree\xpath\XPathElement.cpp">
|
||||
<Filter>Source Files\tree\xpath</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tree\xpath\XPathLexer.cpp">
|
||||
<Filter>Source Files\tree\xpath</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tree\xpath\XPathLexerErrorListener.cpp">
|
||||
<Filter>Source Files\tree\xpath</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tree\xpath\XPathRuleAnywhereElement.cpp">
|
||||
<Filter>Source Files\tree\xpath</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tree\xpath\XPathRuleElement.cpp">
|
||||
<Filter>Source Files\tree\xpath</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tree\xpath\XPathTokenAnywhereElement.cpp">
|
||||
<Filter>Source Files\tree\xpath</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tree\xpath\XPathTokenElement.cpp">
|
||||
<Filter>Source Files\tree\xpath</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tree\xpath\XPathWildcardAnywhereElement.cpp">
|
||||
<Filter>Source Files\tree\xpath</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tree\xpath\XPathWildcardElement.cpp">
|
||||
<Filter>Source Files\tree\xpath</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Vocabulary.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tree\ParseTree.cpp">
|
||||
<Filter>Source Files\tree</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tree\IterativeParseTreeWalker.cpp">
|
||||
<Filter>Source Files\tree</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\misc\InterpreterDataReader.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\ANTLRErrorListener.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\ANTLRErrorStrategy.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\BlockStartState.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\atn\LexerAction.cpp">
|
||||
<Filter>Source Files\atn</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\misc\Predicate.cpp">
|
||||
<Filter>Source Files\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Token.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\TokenSource.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\WritableToken.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\support\Any.cpp">
|
||||
<Filter>Source Files\support</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tree\ErrorNode.cpp">
|
||||
<Filter>Source Files\tree</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tree\ParseTreeListener.cpp">
|
||||
<Filter>Source Files\tree</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tree\ParseTreeVisitor.cpp">
|
||||
<Filter>Source Files\tree</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tree\TerminalNode.cpp">
|
||||
<Filter>Source Files\tree</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tree\pattern\Chunk.cpp">
|
||||
<Filter>Source Files\tree\pattern</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -2226,7 +2226,7 @@
|
|||
37D727A21867AF1E007B6D10 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 1010;
|
||||
LastUpgradeCheck = 1030;
|
||||
ORGANIZATIONNAME = ANTLR;
|
||||
TargetAttributes = {
|
||||
270C67EF1CDB4F1E00116E17 = {
|
||||
|
@ -2239,10 +2239,11 @@
|
|||
};
|
||||
buildConfigurationList = 37D727A51867AF1E007B6D10 /* Build configuration list for PBXProject "antlrcpp" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = 37D727A11867AF1E007B6D10;
|
||||
productRefGroup = 37D727AB1867AF1E007B6D10 /* Products */;
|
||||
|
@ -2839,6 +2840,7 @@
|
|||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
|
@ -2898,6 +2900,7 @@
|
|||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1010"
|
||||
LastUpgradeVersion = "1030"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
@ -29,8 +29,6 @@
|
|||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
|
@ -51,8 +49,6 @@
|
|||
ReferencedContainer = "container:antlrcpp.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1010"
|
||||
LastUpgradeVersion = "1030"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1010"
|
||||
LastUpgradeVersion = "1030"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
@ -24,7 +24,7 @@ namespace antlr4 {
|
|||
/// Implementations of this interface report syntax errors by calling
|
||||
/// <seealso cref="Parser#notifyErrorListeners"/>.
|
||||
/// <p/>
|
||||
/// TO_DO: what to do about lexers
|
||||
/// TODO: what to do about lexers
|
||||
/// </summary>
|
||||
class ANTLR4CPP_PUBLIC ANTLRErrorStrategy {
|
||||
public:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
@ -273,7 +273,7 @@ std::string Lexer::getErrorDisplay(const std::string &s) {
|
|||
}
|
||||
|
||||
void Lexer::recover(RecognitionException * /*re*/) {
|
||||
// TO_DO: Do we lose character or line position information?
|
||||
// TODO: Do we lose character or line position information?
|
||||
_input->consume();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
@ -464,7 +464,7 @@ bool Parser::precpred(RuleContext * /*localctx*/, int precedence) {
|
|||
}
|
||||
|
||||
bool Parser::inContext(const std::string &/*context*/) {
|
||||
// TO_DO: useful in parser?
|
||||
// TODO: useful in parser?
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -348,7 +348,6 @@ std::unordered_map<size_t, TokenStreamRewriter::RewriteOperation*> TokenStreamRe
|
|||
}
|
||||
// throw exception unless disjoint or identical
|
||||
bool disjoint = prevRop->lastIndex < rop->index || prevRop->index > rop->lastIndex;
|
||||
bool same = prevRop->index == rop->index && prevRop->lastIndex == rop->lastIndex;
|
||||
// Delete special case of replace (text==null):
|
||||
// D.i-j.u D.x-y.v | boundaries overlap combine to max(min)..max(right)
|
||||
if (prevRop->text.empty() && rop->text.empty() && !disjoint) {
|
||||
|
@ -358,7 +357,7 @@ std::unordered_map<size_t, TokenStreamRewriter::RewriteOperation*> TokenStreamRe
|
|||
rop->lastIndex = std::max(prevRop->lastIndex, rop->lastIndex);
|
||||
std::cout << "new rop " << rop << std::endl;
|
||||
}
|
||||
else if (!disjoint && !same) {
|
||||
else if (!disjoint) {
|
||||
throw IllegalArgumentException("replace op boundaries of " + rop->toString() +
|
||||
" overlap with previous " + prevRop->toString());
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ namespace dfa {
|
|||
public:
|
||||
Vocabulary(Vocabulary const&) = default;
|
||||
virtual ~Vocabulary();
|
||||
Vocabulary& operator=(Vocabulary const&) = default;
|
||||
|
||||
/// Gets an empty <seealso cref="Vocabulary"/> instance.
|
||||
///
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
@ -57,7 +57,7 @@ namespace atn {
|
|||
* <p>
|
||||
* closure() tracks the depth of how far we dip into the outer context:
|
||||
* depth > 0. Note that it may not be totally accurate depth since I
|
||||
* don't ever decrement. TO_DO: make it a boolean then</p>
|
||||
* don't ever decrement. TODO: make it a boolean then</p>
|
||||
*
|
||||
* <p>
|
||||
* For memory efficiency, the {@link #isPrecedenceFilterSuppressed} method
|
||||
|
@ -87,7 +87,6 @@ namespace atn {
|
|||
|
||||
ATNConfig(ATNConfig const&) = default;
|
||||
virtual ~ATNConfig();
|
||||
ATNConfig& operator=(ATNConfig const&) = default;
|
||||
|
||||
virtual size_t hashCode() const;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
@ -18,8 +18,8 @@ namespace atn {
|
|||
/// Track the elements as they are added to the set; supports get(i)
|
||||
std::vector<Ref<ATNConfig>> configs;
|
||||
|
||||
// TO_DO: these fields make me pretty uncomfortable but nice to pack up info together, saves recomputation
|
||||
// TO_DO: can we track conflicts as they are added to save scanning configs later?
|
||||
// TODO: these fields make me pretty uncomfortable but nice to pack up info together, saves recomputation
|
||||
// TODO: can we track conflicts as they are added to save scanning configs later?
|
||||
size_t uniqueAlt;
|
||||
|
||||
/** Currently this is only used when we detect SLL conflict; this does
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
@ -10,7 +10,7 @@
|
|||
namespace antlr4 {
|
||||
namespace atn {
|
||||
|
||||
/// TO_DO: make all transitions sets? no, should remove set edges.
|
||||
/// TODO: make all transitions sets? no, should remove set edges.
|
||||
class ANTLR4CPP_PUBLIC AtomTransition final : public Transition {
|
||||
public:
|
||||
/// The token type or character value; or, signifies special label.
|
||||
|
|
|
@ -422,7 +422,7 @@ Ref<LexerATNConfig> LexerATNSimulator::getEpsilonTarget(CharStream *input, const
|
|||
if (config->context == nullptr|| config->context->hasEmptyPath()) {
|
||||
// execute actions anywhere in the start rule for a token.
|
||||
//
|
||||
// TO_DO: if the entry rule is invoked recursively, some
|
||||
// TODO: if the entry rule is invoked recursively, some
|
||||
// actions may be executed during the recursive call. The
|
||||
// problem can appear when hasEmptyPath() is true but
|
||||
// isEmpty() is false. In this case, the config needs to be
|
||||
|
|
|
@ -922,7 +922,7 @@ void ParserATNSimulator::closure_(Ref<ATNConfig> const& config, ATNConfigSet *co
|
|||
}
|
||||
}
|
||||
|
||||
configs->dipsIntoOuterContext = true; // TO_DO: can remove? only care when we add to set per middle of this method
|
||||
configs->dipsIntoOuterContext = true; // TODO: can remove? only care when we add to set per middle of this method
|
||||
assert(newDepth > INT_MIN);
|
||||
|
||||
newDepth--;
|
||||
|
|
|
@ -760,7 +760,7 @@ namespace atn {
|
|||
virtual bool evalSemanticContext(Ref<SemanticContext> const& pred, ParserRuleContext *parserCallStack,
|
||||
size_t alt, bool fullCtx);
|
||||
|
||||
/* TO_DO: If we are doing predicates, there is no point in pursuing
|
||||
/* TODO: If we are doing predicates, there is no point in pursuing
|
||||
closure operations if we reach a DFA state that uniquely predicts
|
||||
alternative. We will not be caching that DFA state and it is a
|
||||
waste to pursue the closure. Might have to advance when we do
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
@ -11,7 +11,7 @@
|
|||
namespace antlr4 {
|
||||
namespace atn {
|
||||
|
||||
/// TO_DO: this is old comment:
|
||||
/// TODO: this is old comment:
|
||||
/// A tree of semantic predicates from the grammar AST if label==SEMPRED.
|
||||
/// In the ATN, labels will always be exactly one predicate, but the DFA
|
||||
/// may have to combine a bunch of them as it collects predicates from
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
@ -335,7 +335,7 @@ Ref<PredictionContext> PredictionContext::mergeArrays(const Ref<ArrayPredictionC
|
|||
Ref<ArrayPredictionContext> M = std::make_shared<ArrayPredictionContext>(mergedParents, mergedReturnStates);
|
||||
|
||||
// if we created same array as a or b, return that instead
|
||||
// TO_DO: track whether this is possible above during merge sort for speed
|
||||
// TODO: track whether this is possible above during merge sort for speed
|
||||
if (*M == *a) {
|
||||
if (mergeCache != nullptr) {
|
||||
mergeCache->put(a, b, a);
|
||||
|
|
|
@ -99,7 +99,7 @@ std::unique_ptr<ATNConfigSet> ProfilingATNSimulator::computeReachSet(ATNConfigSe
|
|||
_decisions[_currentDecision].LL_ATNTransitions++; // count computation even if error
|
||||
if (reachConfigs != nullptr) {
|
||||
} else { // no reach on current lookahead symbol. ERROR.
|
||||
// TO_DO: does not handle delayed errors per getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule()
|
||||
// TODO: does not handle delayed errors per getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule()
|
||||
_decisions[_currentDecision].errors.push_back(ErrorInfo(_currentDecision, closure, _input, _startIndex, _llStopIndex, true));
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace antlrcpp {
|
|||
inline std::string utf32_to_utf8(T const& data)
|
||||
{
|
||||
// Don't make the converter static or we have to serialize access to it.
|
||||
UTF32Converter converter;
|
||||
thread_local UTF32Converter converter;
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000
|
||||
auto p = reinterpret_cast<const int32_t *>(data.data());
|
||||
|
@ -34,7 +34,7 @@ namespace antlrcpp {
|
|||
|
||||
inline UTF32String utf8_to_utf32(const char* first, const char* last)
|
||||
{
|
||||
UTF32Converter converter;
|
||||
thread_local UTF32Converter converter;
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000
|
||||
auto r = converter.from_bytes(first, last);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
@ -45,7 +45,6 @@ namespace pattern {
|
|||
const std::map<std::string, std::vector<ParseTree *>> &labels, ParseTree *mismatchedNode);
|
||||
ParseTreeMatch(ParseTreeMatch const&) = default;
|
||||
virtual ~ParseTreeMatch();
|
||||
ParseTreeMatch& operator=(ParseTreeMatch const&) = default;
|
||||
|
||||
/// <summary>
|
||||
/// Get the last node associated with a specific {@code label}.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
||||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
@ -30,7 +30,6 @@ namespace pattern {
|
|||
ParseTree *patternTree);
|
||||
ParseTreePattern(ParseTreePattern const&) = default;
|
||||
virtual ~ParseTreePattern();
|
||||
ParseTreePattern& operator=(ParseTreePattern const&) = default;
|
||||
|
||||
/// <summary>
|
||||
/// Match a specific parse tree against this tree pattern.
|
||||
|
|
|
@ -25,11 +25,10 @@ const std::string XPath::NOT = "!";
|
|||
XPath::XPath(Parser *parser, const std::string &path) {
|
||||
_parser = parser;
|
||||
_path = path;
|
||||
_elements = split(path);
|
||||
}
|
||||
|
||||
std::vector<XPathElement> XPath::split(const std::string &path) {
|
||||
ANTLRFileStream in(path);
|
||||
std::vector<std::unique_ptr<XPathElement>> XPath::split(const std::string &path) {
|
||||
ANTLRInputStream in(path);
|
||||
XPathLexer lexer(&in);
|
||||
lexer.removeErrorListeners();
|
||||
XPathLexerErrorListener listener;
|
||||
|
@ -44,7 +43,7 @@ std::vector<XPathElement> XPath::split(const std::string &path) {
|
|||
}
|
||||
|
||||
std::vector<Token *> tokens = tokenStream.getTokens();
|
||||
std::vector<XPathElement> elements;
|
||||
std::vector<std::unique_ptr<XPathElement>> elements;
|
||||
size_t n = tokens.size();
|
||||
size_t i = 0;
|
||||
bool done = false;
|
||||
|
@ -62,9 +61,9 @@ std::vector<XPathElement> XPath::split(const std::string &path) {
|
|||
i++;
|
||||
next = tokens[i];
|
||||
}
|
||||
XPathElement pathElement = getXPathElement(next, anywhere);
|
||||
pathElement.setInvert(invert);
|
||||
elements.push_back(pathElement);
|
||||
std::unique_ptr<XPathElement> pathElement = getXPathElement(next, anywhere);
|
||||
pathElement->setInvert(invert);
|
||||
elements.push_back(std::move(pathElement));
|
||||
i++;
|
||||
break;
|
||||
|
||||
|
@ -81,25 +80,26 @@ std::vector<XPathElement> XPath::split(const std::string &path) {
|
|||
break;
|
||||
|
||||
default :
|
||||
throw IllegalArgumentException("Unknow path element " + el->toString());
|
||||
throw IllegalArgumentException("Unknown path element " + el->toString());
|
||||
}
|
||||
}
|
||||
|
||||
return elements;
|
||||
}
|
||||
|
||||
XPathElement XPath::getXPathElement(Token *wordToken, bool anywhere) {
|
||||
std::unique_ptr<XPathElement> XPath::getXPathElement(Token *wordToken, bool anywhere) {
|
||||
if (wordToken->getType() == Token::EOF) {
|
||||
throw IllegalArgumentException("Missing path element at end of path");
|
||||
}
|
||||
|
||||
std::string word = wordToken->getText();
|
||||
size_t ttype = _parser->getTokenType(word);
|
||||
ssize_t ruleIndex = _parser->getRuleIndex(word);
|
||||
switch (wordToken->getType()) {
|
||||
case XPathLexer::WILDCARD :
|
||||
if (anywhere)
|
||||
return XPathWildcardAnywhereElement();
|
||||
return XPathWildcardElement();
|
||||
return std::unique_ptr<XPathWildcardAnywhereElement>(new XPathWildcardAnywhereElement());
|
||||
return std::unique_ptr<XPathWildcardElement>(new XPathWildcardElement());
|
||||
|
||||
case XPathLexer::TOKEN_REF:
|
||||
case XPathLexer::STRING :
|
||||
|
@ -107,35 +107,42 @@ XPathElement XPath::getXPathElement(Token *wordToken, bool anywhere) {
|
|||
throw IllegalArgumentException(word + " at index " + std::to_string(wordToken->getStartIndex()) + " isn't a valid token name");
|
||||
}
|
||||
if (anywhere)
|
||||
return XPathTokenAnywhereElement(word, (int)ttype);
|
||||
return XPathTokenElement(word, (int)ttype);
|
||||
return std::unique_ptr<XPathTokenAnywhereElement>(new XPathTokenAnywhereElement(word, (int)ttype));
|
||||
return std::unique_ptr<XPathTokenElement>(new XPathTokenElement(word, (int)ttype));
|
||||
|
||||
default :
|
||||
if (ruleIndex == -1) {
|
||||
throw IllegalArgumentException(word + " at index " + std::to_string(wordToken->getStartIndex()) + " isn't a valid rule name");
|
||||
}
|
||||
if (anywhere)
|
||||
return XPathRuleAnywhereElement(word, (int)ruleIndex);
|
||||
return XPathRuleElement(word, (int)ruleIndex);
|
||||
return std::unique_ptr<XPathRuleAnywhereElement>(new XPathRuleAnywhereElement(word, (int)ruleIndex));
|
||||
return std::unique_ptr<XPathRuleElement>(new XPathRuleElement(word, (int)ruleIndex));
|
||||
}
|
||||
}
|
||||
|
||||
static ParserRuleContext dummyRoot;
|
||||
|
||||
std::vector<ParseTree *> XPath::findAll(ParseTree *tree, std::string const& xpath, Parser *parser) {
|
||||
XPath p(parser, xpath);
|
||||
return p.evaluate(tree);
|
||||
}
|
||||
|
||||
std::vector<ParseTree *> XPath::evaluate(ParseTree *t) {
|
||||
dummyRoot.children = { t }; // don't set t's parent.
|
||||
|
||||
std::vector<ParseTree *> work = { &dummyRoot };
|
||||
|
||||
size_t i = 0;
|
||||
while (i < _elements.size()) {
|
||||
std::vector<std::unique_ptr<XPathElement>> elements = split(_path);
|
||||
|
||||
while (i < elements.size()) {
|
||||
std::vector<ParseTree *> next;
|
||||
for (auto node : work) {
|
||||
if (!node->children.empty()) {
|
||||
// only try to match next element if it has children
|
||||
// e.g., //func/*/stat might have a token node for which
|
||||
// we can't go looking for stat nodes.
|
||||
auto matching = _elements[i].evaluate(node);
|
||||
auto matching = elements[i]->evaluate(node);
|
||||
next.insert(next.end(), matching.begin(), matching.end());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,8 +61,10 @@ namespace xpath {
|
|||
XPath(Parser *parser, const std::string &path);
|
||||
virtual ~XPath() {}
|
||||
|
||||
// TO_DO: check for invalid token/rule names, bad syntax
|
||||
virtual std::vector<XPathElement> split(const std::string &path);
|
||||
// TODO: check for invalid token/rule names, bad syntax
|
||||
virtual std::vector<std::unique_ptr<XPathElement>> split(const std::string &path);
|
||||
|
||||
static std::vector<ParseTree *> findAll(ParseTree *tree, std::string const& xpath, Parser *parser);
|
||||
|
||||
/// Return a list of all nodes starting at {@code t} as root that satisfy the
|
||||
/// path. The root {@code /} is relative to the node passed to
|
||||
|
@ -71,13 +73,12 @@ namespace xpath {
|
|||
|
||||
protected:
|
||||
std::string _path;
|
||||
std::vector<XPathElement> _elements;
|
||||
Parser *_parser;
|
||||
|
||||
/// Convert word like {@code *} or {@code ID} or {@code expr} to a path
|
||||
/// element. {@code anywhere} is {@code true} if {@code //} precedes the
|
||||
/// word.
|
||||
virtual XPathElement getXPathElement(Token *wordToken, bool anywhere);
|
||||
virtual std::unique_ptr<XPathElement> getXPathElement(Token *wordToken, bool anywhere);
|
||||
};
|
||||
|
||||
} // namespace xpath
|
||||
|
|
|
@ -78,8 +78,6 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
|
||||
protected final SimState prevAccept = new SimState();
|
||||
|
||||
public static int match_calls = 0;
|
||||
|
||||
public LexerATNSimulator(ATN atn, DFA[] decisionToDFA,
|
||||
PredictionContextCache sharedContextCache)
|
||||
{
|
||||
|
@ -103,7 +101,6 @@ public class LexerATNSimulator extends ATNSimulator {
|
|||
}
|
||||
|
||||
public int match(CharStream input, int mode) {
|
||||
match_calls++;
|
||||
this.mode = mode;
|
||||
int mark = input.mark();
|
||||
try {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
var RuleContext = require('./RuleContext').RuleContext;
|
||||
var Hash = require('./Utils').Hash;
|
||||
var Map = require('./Utils').Map;
|
||||
|
||||
function PredictionContext(cachedHashCode) {
|
||||
this.cachedHashCode = cachedHashCode;
|
||||
|
@ -79,7 +80,7 @@ function calculateHashString(parent, returnState) {
|
|||
// can be used for both lexers and parsers.
|
||||
|
||||
function PredictionContextCache() {
|
||||
this.cache = {};
|
||||
this.cache = new Map();
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -91,16 +92,16 @@ PredictionContextCache.prototype.add = function(ctx) {
|
|||
if (ctx === PredictionContext.EMPTY) {
|
||||
return PredictionContext.EMPTY;
|
||||
}
|
||||
var existing = this.cache[ctx] || null;
|
||||
var existing = this.cache.get(ctx) || null;
|
||||
if (existing !== null) {
|
||||
return existing;
|
||||
}
|
||||
this.cache[ctx] = ctx;
|
||||
this.cache.put(ctx, ctx);
|
||||
return ctx;
|
||||
};
|
||||
|
||||
PredictionContextCache.prototype.get = function(ctx) {
|
||||
return this.cache[ctx] || null;
|
||||
return this.cache.get(ctx) || null;
|
||||
};
|
||||
|
||||
Object.defineProperty(PredictionContextCache.prototype, "length", {
|
||||
|
@ -111,11 +112,13 @@ Object.defineProperty(PredictionContextCache.prototype, "length", {
|
|||
|
||||
function SingletonPredictionContext(parent, returnState) {
|
||||
var hashCode = 0;
|
||||
var hash = new Hash();
|
||||
if(parent !== null) {
|
||||
var hash = new Hash();
|
||||
hash.update(parent, returnState);
|
||||
hashCode = hash.finish();
|
||||
} else {
|
||||
hash.update(1);
|
||||
}
|
||||
hashCode = hash.finish();
|
||||
PredictionContext.call(this, hashCode);
|
||||
this.parentCtx = parent;
|
||||
this.returnState = returnState;
|
||||
|
@ -640,16 +643,16 @@ function mergeArrays(a, b, rootIsWildcard, mergeCache) {
|
|||
// ones.
|
||||
// /
|
||||
function combineCommonParents(parents) {
|
||||
var uniqueParents = {};
|
||||
var uniqueParents = new Map();
|
||||
|
||||
for (var p = 0; p < parents.length; p++) {
|
||||
var parent = parents[p];
|
||||
if (!(parent in uniqueParents)) {
|
||||
uniqueParents[parent] = parent;
|
||||
if (!(uniqueParents.containsKey(parent))) {
|
||||
uniqueParents.put(parent, parent);
|
||||
}
|
||||
}
|
||||
for (var q = 0; q < parents.length; q++) {
|
||||
parents[q] = uniqueParents[parents[q]];
|
||||
parents[q] = uniqueParents.get(parents[q]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -657,13 +660,13 @@ function getCachedPredictionContext(context, contextCache, visited) {
|
|||
if (context.isEmpty()) {
|
||||
return context;
|
||||
}
|
||||
var existing = visited[context] || null;
|
||||
var existing = visited.get(context) || null;
|
||||
if (existing !== null) {
|
||||
return existing;
|
||||
}
|
||||
existing = contextCache.get(context);
|
||||
if (existing !== null) {
|
||||
visited[context] = existing;
|
||||
visited.put(context, existing);
|
||||
return existing;
|
||||
}
|
||||
var changed = false;
|
||||
|
@ -683,7 +686,7 @@ function getCachedPredictionContext(context, contextCache, visited) {
|
|||
}
|
||||
if (!changed) {
|
||||
contextCache.add(context);
|
||||
visited[context] = context;
|
||||
visited.put(context, context);
|
||||
return context;
|
||||
}
|
||||
var updated = null;
|
||||
|
@ -696,8 +699,8 @@ function getCachedPredictionContext(context, contextCache, visited) {
|
|||
updated = new ArrayPredictionContext(parents, context.returnStates);
|
||||
}
|
||||
contextCache.add(updated);
|
||||
visited[updated] = updated;
|
||||
visited[context] = updated;
|
||||
visited.put(updated, updated);
|
||||
visited.put(context, updated);
|
||||
|
||||
return updated;
|
||||
}
|
||||
|
@ -708,13 +711,13 @@ function getAllContextNodes(context, nodes, visited) {
|
|||
nodes = [];
|
||||
return getAllContextNodes(context, nodes, visited);
|
||||
} else if (visited === null) {
|
||||
visited = {};
|
||||
visited = new Map();
|
||||
return getAllContextNodes(context, nodes, visited);
|
||||
} else {
|
||||
if (context === null || visited[context] !== null) {
|
||||
if (context === null || visited.containsKey(context)) {
|
||||
return nodes;
|
||||
}
|
||||
visited[context] = context;
|
||||
visited.put(context, context);
|
||||
nodes.push(context);
|
||||
for (var i = 0; i < context.length; i++) {
|
||||
getAllContextNodes(context.getParent(i), nodes, visited);
|
||||
|
|
|
@ -323,7 +323,9 @@ AltDict.prototype.values = function () {
|
|||
});
|
||||
};
|
||||
|
||||
function DoubleDict() {
|
||||
function DoubleDict(defaultMapCtor) {
|
||||
this.defaultMapCtor = defaultMapCtor || Map;
|
||||
this.cacheMap = new this.defaultMapCtor();
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -339,7 +341,7 @@ Hash.prototype.update = function () {
|
|||
if (value == null)
|
||||
continue;
|
||||
if(Array.isArray(value))
|
||||
this.update.apply(value);
|
||||
this.update.apply(this, value);
|
||||
else {
|
||||
var k = 0;
|
||||
switch (typeof(value)) {
|
||||
|
@ -354,7 +356,10 @@ Hash.prototype.update = function () {
|
|||
k = value.hashCode();
|
||||
break;
|
||||
default:
|
||||
value.updateHashCode(this);
|
||||
if(value.updateHashCode)
|
||||
value.updateHashCode(this);
|
||||
else
|
||||
console.log("No updateHashCode for " + value.toString())
|
||||
continue;
|
||||
}
|
||||
k = k * 0xCC9E2D51;
|
||||
|
@ -367,7 +372,7 @@ Hash.prototype.update = function () {
|
|||
this.hash = hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Hash.prototype.finish = function () {
|
||||
var hash = this.hash ^ (this.count * 4);
|
||||
|
@ -377,26 +382,26 @@ Hash.prototype.finish = function () {
|
|||
hash = hash * 0xC2B2AE35;
|
||||
hash = hash ^ (hash >>> 16);
|
||||
return hash;
|
||||
}
|
||||
};
|
||||
|
||||
function hashStuff() {
|
||||
var hash = new Hash();
|
||||
hash.update.apply(arguments);
|
||||
hash.update.apply(hash, arguments);
|
||||
return hash.finish();
|
||||
}
|
||||
|
||||
DoubleDict.prototype.get = function (a, b) {
|
||||
var d = this[a] || null;
|
||||
return d === null ? null : (d[b] || null);
|
||||
var d = this.cacheMap.get(a) || null;
|
||||
return d === null ? null : (d.get(b) || null);
|
||||
};
|
||||
|
||||
DoubleDict.prototype.set = function (a, b, o) {
|
||||
var d = this[a] || null;
|
||||
var d = this.cacheMap.get(a) || null;
|
||||
if (d === null) {
|
||||
d = {};
|
||||
this[a] = d;
|
||||
d = new this.defaultMapCtor();
|
||||
this.cacheMap.put(a, d);
|
||||
}
|
||||
d[b] = o;
|
||||
d.put(b, o);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ ATNConfigSet.prototype.equals = function(other) {
|
|||
|
||||
ATNConfigSet.prototype.hashCode = function() {
|
||||
var hash = new Hash();
|
||||
this.updateHashCode(hash);
|
||||
hash.update(this.configs);
|
||||
return hash.finish();
|
||||
};
|
||||
|
||||
|
@ -183,13 +183,11 @@ ATNConfigSet.prototype.hashCode = function() {
|
|||
ATNConfigSet.prototype.updateHashCode = function(hash) {
|
||||
if (this.readOnly) {
|
||||
if (this.cachedHashCode === -1) {
|
||||
var hash = new Hash();
|
||||
hash.update(this.configs);
|
||||
this.cachedHashCode = hash.finish();
|
||||
this.cachedHashCode = this.hashCode();
|
||||
}
|
||||
hash.update(this.cachedHashCode);
|
||||
} else {
|
||||
hash.update(this.configs);
|
||||
hash.update(this.hashCode());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ ATNDeserializer.prototype.deserialize = function(data) {
|
|||
ATNDeserializer.prototype.reset = function(data) {
|
||||
var adjust = function(c) {
|
||||
var v = c.charCodeAt(0);
|
||||
return v>1 ? v-2 : v + 65533;
|
||||
return v>1 ? v-2 : v + 65534;
|
||||
};
|
||||
var temp = data.split("").map(adjust);
|
||||
// don't adjust the first value since that's the version number
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
var DFAState = require('./../dfa/DFAState').DFAState;
|
||||
var ATNConfigSet = require('./ATNConfigSet').ATNConfigSet;
|
||||
var getCachedPredictionContext = require('./../PredictionContext').getCachedPredictionContext;
|
||||
var Map = require('./../Utils').Map;
|
||||
|
||||
function ATNSimulator(atn, sharedContextCache) {
|
||||
|
||||
|
@ -44,7 +45,7 @@ ATNSimulator.prototype.getCachedContext = function(context) {
|
|||
if (this.sharedContextCache ===null) {
|
||||
return context;
|
||||
}
|
||||
var visited = {};
|
||||
var visited = new Map();
|
||||
return getCachedPredictionContext(context, this.sharedContextCache, visited);
|
||||
};
|
||||
|
||||
|
|
|
@ -139,12 +139,6 @@ DFAState.prototype.toString = function() {
|
|||
DFAState.prototype.hashCode = function() {
|
||||
var hash = new Hash();
|
||||
hash.update(this.configs);
|
||||
if(this.isAcceptState) {
|
||||
if (this.predicates !== null)
|
||||
hash.update(this.predicates);
|
||||
else
|
||||
hash.update(this.prediction);
|
||||
}
|
||||
return hash.finish();
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 9e1b759d02220eedf477771169bdfb6a186a2984
|
|
@ -157,13 +157,12 @@ class TokenStreamRewriter(object):
|
|||
rewrites[prevRop.instructionIndex] = None
|
||||
continue
|
||||
isDisjoint = any((prevRop.last_index < rop.index, prevRop.index > rop.last_index))
|
||||
isSame = all((prevRop.index == rop.index, prevRop.last_index == rop.last_index))
|
||||
if all((prevRop.text is None, rop.text is None, not isDisjoint)):
|
||||
rewrites[prevRop.instructionIndex] = None
|
||||
rop.index = min(prevRop.index, rop.index)
|
||||
rop.last_index = min(prevRop.last_index, rop.last_index)
|
||||
print('New rop {}'.format(rop))
|
||||
elif not all((isDisjoint, isSame)):
|
||||
elif (not(isDisjoint)):
|
||||
raise ValueError("replace op boundaries of {} overlap with previous {}".format(rop, prevRop))
|
||||
|
||||
# Walk inserts before
|
||||
|
|
|
@ -156,13 +156,12 @@ class TokenStreamRewriter(object):
|
|||
rewrites[prevRop.instructionIndex] = None
|
||||
continue
|
||||
isDisjoint = any((prevRop.last_index<rop.index, prevRop.index>rop.last_index))
|
||||
isSame = all((prevRop.index == rop.index, prevRop.last_index == rop.last_index))
|
||||
if all((prevRop.text is None, rop.text is None, not isDisjoint)):
|
||||
rewrites[prevRop.instructionIndex] = None
|
||||
rop.index = min(prevRop.index, rop.index)
|
||||
rop.last_index = min(prevRop.last_index, rop.last_index)
|
||||
print('New rop {}'.format(rop))
|
||||
elif not all((isDisjoint, isSame)):
|
||||
elif (not(isDisjoint)):
|
||||
raise ValueError("replace op boundaries of {} overlap with previous {}".format(rop, prevRop))
|
||||
|
||||
# Walk inserts
|
||||
|
@ -249,4 +248,4 @@ class TokenStreamRewriter(object):
|
|||
def __str__(self):
|
||||
if self.text:
|
||||
return '<ReplaceOp@{}..{}:"{}">'.format(self.tokens.get(self.index), self.tokens.get(self.last_index),
|
||||
self.text)
|
||||
self.text)
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
# <p>
|
||||
# Whitespace is not allowed.</p>
|
||||
#
|
||||
from antlr4 import CommonTokenStream, DFA, PredictionContextCache, Lexer, LexerATNSimulator
|
||||
from antlr4 import CommonTokenStream, DFA, PredictionContextCache, Lexer, LexerATNSimulator, ParserRuleContext, TerminalNode
|
||||
from antlr4.InputStream import InputStream
|
||||
from antlr4.Parser import Parser
|
||||
from antlr4.RuleContext import RuleContext
|
||||
|
@ -134,7 +134,7 @@ class XPathLexer(Lexer):
|
|||
if _action is not None:
|
||||
_action(localctx, actionIndex)
|
||||
else:
|
||||
raise Exception("No registered action for:" + str(ruleIndex))
|
||||
raise Exception("No registered action for: %d" % ruleIndex)
|
||||
|
||||
def ID_action(self, localctx:RuleContext , actionIndex:int):
|
||||
if actionIndex == 0:
|
||||
|
@ -166,40 +166,40 @@ class XPath(object):
|
|||
try:
|
||||
tokenStream.fill()
|
||||
except LexerNoViableAltException as e:
|
||||
pos = lexer.getColumn()
|
||||
msg = "Invalid tokens or characters at index " + str(pos) + " in path '" + path + "'"
|
||||
pos = lexer.column
|
||||
msg = "Invalid tokens or characters at index %d in path '%s'" % (pos, path)
|
||||
raise Exception(msg, e)
|
||||
|
||||
tokens = tokenStream.getTokens()
|
||||
tokens = iter(tokenStream.tokens)
|
||||
elements = list()
|
||||
n = len(tokens)
|
||||
i=0
|
||||
while i < n :
|
||||
el = tokens[i]
|
||||
next = None
|
||||
for el in tokens:
|
||||
invert = False
|
||||
anywhere = False
|
||||
# Check for path separators, if none assume root
|
||||
if el.type in [XPathLexer.ROOT, XPathLexer.ANYWHERE]:
|
||||
anywhere = el.type == XPathLexer.ANYWHERE
|
||||
i += 1
|
||||
next = tokens[i]
|
||||
invert = next.type==XPathLexer.BANG
|
||||
if invert:
|
||||
i += 1
|
||||
next = tokens[i]
|
||||
pathElement = self.getXPathElement(next, anywhere)
|
||||
pathElement.invert = invert
|
||||
elements.append(pathElement)
|
||||
i += 1
|
||||
|
||||
elif el.type in [XPathLexer.TOKEN_REF, XPathLexer.RULE_REF, XPathLexer.WILDCARD] :
|
||||
elements.append( self.getXPathElement(el, False) )
|
||||
i += 1
|
||||
|
||||
elif el.type==Token.EOF :
|
||||
break
|
||||
|
||||
anywhere = el.type == XPathLexer.ANYWHERE
|
||||
next_el = next(tokens, None)
|
||||
if not next_el:
|
||||
raise Exception('Missing element after %s' % el.getText())
|
||||
else:
|
||||
el = next_el
|
||||
# Check for bangs
|
||||
if el.type == XPathLexer.BANG:
|
||||
invert = True
|
||||
next_el = next(tokens, None)
|
||||
if not next_el:
|
||||
raise Exception('Missing element after %s' % el.getText())
|
||||
else:
|
||||
el = next_el
|
||||
# Add searched element
|
||||
if el.type in [XPathLexer.TOKEN_REF, XPathLexer.RULE_REF, XPathLexer.WILDCARD, XPathLexer.STRING]:
|
||||
element = self.getXPathElement(el, anywhere)
|
||||
element.invert = invert
|
||||
elements.append(element)
|
||||
elif el.type==Token.EOF:
|
||||
break
|
||||
else:
|
||||
raise Exception("Unknown path element " + str(el))
|
||||
|
||||
raise Exception("Unknown path element %s" % lexer.symbolicNames[el.type])
|
||||
return elements
|
||||
|
||||
#
|
||||
|
@ -210,24 +210,31 @@ class XPath(object):
|
|||
def getXPathElement(self, wordToken:Token, anywhere:bool):
|
||||
if wordToken.type==Token.EOF:
|
||||
raise Exception("Missing path element at end of path")
|
||||
|
||||
word = wordToken.text
|
||||
ttype = self.parser.getTokenType(word)
|
||||
ruleIndex = self.parser.getRuleIndex(word)
|
||||
|
||||
if wordToken.type==XPathLexer.WILDCARD :
|
||||
|
||||
return XPathWildcardAnywhereElement() if anywhere else XPathWildcardElement()
|
||||
|
||||
elif wordToken.type in [XPathLexer.TOKEN_REF, XPathLexer.STRING]:
|
||||
tsource = self.parser.getTokenStream().tokenSource
|
||||
|
||||
if ttype==Token.INVALID_TYPE:
|
||||
raise Exception( word + " at index " + str(wordToken.startIndex) + " isn't a valid token name")
|
||||
ttype = Token.INVALID_TYPE
|
||||
if wordToken.type == XPathLexer.TOKEN_REF:
|
||||
if word in tsource.ruleNames:
|
||||
ttype = tsource.ruleNames.index(word) + 1
|
||||
else:
|
||||
if word in tsource.literalNames:
|
||||
ttype = tsource.literalNames.index(word)
|
||||
|
||||
if ttype == Token.INVALID_TYPE:
|
||||
raise Exception("%s at index %d isn't a valid token name" % (word, wordToken.tokenIndex))
|
||||
return XPathTokenAnywhereElement(word, ttype) if anywhere else XPathTokenElement(word, ttype)
|
||||
|
||||
else:
|
||||
ruleIndex = self.parser.ruleNames.index(word) if word in self.parser.ruleNames else -1
|
||||
|
||||
if ruleIndex==-1:
|
||||
raise Exception( word + " at index " + str(wordToken.getStartIndex()) + " isn't a valid rule name")
|
||||
if ruleIndex == -1:
|
||||
raise Exception("%s at index %d isn't a valid rule name" % (word, wordToken.tokenIndex))
|
||||
return XPathRuleAnywhereElement(word, ruleIndex) if anywhere else XPathRuleElement(word, ruleIndex)
|
||||
|
||||
|
||||
|
@ -246,18 +253,21 @@ class XPath(object):
|
|||
dummyRoot.children = [t] # don't set t's parent.
|
||||
|
||||
work = [dummyRoot]
|
||||
|
||||
for i in range(0, len(self.elements)):
|
||||
next = set()
|
||||
for element in self.elements:
|
||||
work_next = list()
|
||||
for node in work:
|
||||
if len( node.children) > 0 :
|
||||
if not isinstance(node, TerminalNode) and node.children:
|
||||
# only try to match next element if it has children
|
||||
# e.g., //func/*/stat might have a token node for which
|
||||
# we can't go looking for stat nodes.
|
||||
matching = self.elements[i].evaluate(node)
|
||||
next |= matching
|
||||
i += 1
|
||||
work = next
|
||||
matching = element.evaluate(node)
|
||||
|
||||
# See issue antlr#370 - Prevents XPath from returning the
|
||||
# same node multiple times
|
||||
matching = filter(lambda m: m not in work_next, matching)
|
||||
|
||||
work_next.extend(matching)
|
||||
work = work_next
|
||||
|
||||
return work
|
||||
|
||||
|
@ -283,8 +293,8 @@ class XPathRuleAnywhereElement(XPathElement):
|
|||
self.ruleIndex = ruleIndex
|
||||
|
||||
def evaluate(self, t:ParseTree):
|
||||
return Trees.findAllRuleNodes(t, self.ruleIndex)
|
||||
|
||||
# return all ParserRuleContext descendants of t that match ruleIndex (or do not match if inverted)
|
||||
return filter(lambda c: isinstance(c, ParserRuleContext) and (self.invert ^ (c.getRuleIndex() == self.ruleIndex)), Trees.descendants(t))
|
||||
|
||||
class XPathRuleElement(XPathElement):
|
||||
|
||||
|
@ -293,9 +303,8 @@ class XPathRuleElement(XPathElement):
|
|||
self.ruleIndex = ruleIndex
|
||||
|
||||
def evaluate(self, t:ParseTree):
|
||||
# return all children of t that match nodeName
|
||||
return [c for c in Trees.getChildren(t) if isinstance(c, ParserRuleContext) and (c.ruleIndex == self.ruleIndex) == (not self.invert)]
|
||||
|
||||
# return all ParserRuleContext children of t that match ruleIndex (or do not match if inverted)
|
||||
return filter(lambda c: isinstance(c, ParserRuleContext) and (self.invert ^ (c.getRuleIndex() == self.ruleIndex)), Trees.getChildren(t))
|
||||
|
||||
class XPathTokenAnywhereElement(XPathElement):
|
||||
|
||||
|
@ -304,8 +313,8 @@ class XPathTokenAnywhereElement(XPathElement):
|
|||
self.tokenType = tokenType
|
||||
|
||||
def evaluate(self, t:ParseTree):
|
||||
return Trees.findAllTokenNodes(t, self.tokenType)
|
||||
|
||||
# return all TerminalNode descendants of t that match tokenType (or do not match if inverted)
|
||||
return filter(lambda c: isinstance(c, TerminalNode) and (self.invert ^ (c.symbol.type == self.tokenType)), Trees.descendants(t))
|
||||
|
||||
class XPathTokenElement(XPathElement):
|
||||
|
||||
|
@ -314,8 +323,8 @@ class XPathTokenElement(XPathElement):
|
|||
self.tokenType = tokenType
|
||||
|
||||
def evaluate(self, t:ParseTree):
|
||||
# return all children of t that match nodeName
|
||||
return [c for c in Trees.getChildren(t) if isinstance(c, TerminalNode) and (c.symbol.type == self.tokenType) == (not self.invert)]
|
||||
# return all TerminalNode children of t that match tokenType (or do not match if inverted)
|
||||
return filter(lambda c: isinstance(c, TerminalNode) and (self.invert ^ (c.symbol.type == self.tokenType)), Trees.getChildren(t))
|
||||
|
||||
|
||||
class XPathWildcardAnywhereElement(XPathElement):
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
// Taken from "tool-testsuite/test/org/antlr/v4/test/tool/TestXPath.java"
|
||||
// Builds ExprLexer.py and ExprParser.py
|
||||
|
||||
grammar Expr;
|
||||
prog: func+ ;
|
||||
func: 'def' ID '(' arg (',' arg)* ')' body ;
|
||||
body: '{' stat+ '}' ;
|
||||
arg : ID ;
|
||||
stat: expr ';' # printExpr
|
||||
| ID '=' expr ';' # assign
|
||||
| 'return' expr ';' # ret
|
||||
| ';' # blank
|
||||
;
|
||||
expr: expr ('*'|'/') expr # MulDiv
|
||||
| expr ('+'|'-') expr # AddSub
|
||||
| primary # prim
|
||||
;
|
||||
primary
|
||||
: INT # int
|
||||
| ID # id
|
||||
| '(' expr ')' # parens
|
||||
;
|
||||
MUL : '*' ; // assigns token name to '*' used above in grammar
|
||||
DIV : '/' ;
|
||||
ADD : '+' ;
|
||||
SUB : '-' ;
|
||||
RETURN : 'return' ;
|
||||
ID : [a-zA-Z]+ ; // match identifiers
|
||||
INT : [0-9]+ ; // match integers
|
||||
NEWLINE:'\r'? '\n' -> skip; // return newlines to parser (is end-statement signal)
|
||||
WS : [ \t]+ -> skip ; // toss out whitespace
|
|
@ -0,0 +1,94 @@
|
|||
# Generated from expr/Expr.g4 by ANTLR 4.7.2
|
||||
from antlr4 import *
|
||||
from io import StringIO
|
||||
from typing.io import TextIO
|
||||
import sys
|
||||
|
||||
|
||||
def serializedATN():
|
||||
with StringIO() as buf:
|
||||
buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\23")
|
||||
buf.write("^\b\1\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7")
|
||||
buf.write("\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r\4\16")
|
||||
buf.write("\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22\3\2\3\2")
|
||||
buf.write("\3\2\3\2\3\3\3\3\3\4\3\4\3\5\3\5\3\6\3\6\3\7\3\7\3\b\3")
|
||||
buf.write("\b\3\t\3\t\3\n\3\n\3\13\3\13\3\f\3\f\3\r\3\r\3\16\3\16")
|
||||
buf.write("\3\16\3\16\3\16\3\16\3\16\3\17\6\17H\n\17\r\17\16\17I")
|
||||
buf.write("\3\20\6\20M\n\20\r\20\16\20N\3\21\5\21R\n\21\3\21\3\21")
|
||||
buf.write("\3\21\3\21\3\22\6\22Y\n\22\r\22\16\22Z\3\22\3\22\2\2\23")
|
||||
buf.write("\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31")
|
||||
buf.write("\16\33\17\35\20\37\21!\22#\23\3\2\5\4\2C\\c|\3\2\62;\4")
|
||||
buf.write("\2\13\13\"\"\2a\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2")
|
||||
buf.write("\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21")
|
||||
buf.write("\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3")
|
||||
buf.write("\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2")
|
||||
buf.write("\2\2#\3\2\2\2\3%\3\2\2\2\5)\3\2\2\2\7+\3\2\2\2\t-\3\2")
|
||||
buf.write("\2\2\13/\3\2\2\2\r\61\3\2\2\2\17\63\3\2\2\2\21\65\3\2")
|
||||
buf.write("\2\2\23\67\3\2\2\2\259\3\2\2\2\27;\3\2\2\2\31=\3\2\2\2")
|
||||
buf.write("\33?\3\2\2\2\35G\3\2\2\2\37L\3\2\2\2!Q\3\2\2\2#X\3\2\2")
|
||||
buf.write("\2%&\7f\2\2&\'\7g\2\2\'(\7h\2\2(\4\3\2\2\2)*\7*\2\2*\6")
|
||||
buf.write("\3\2\2\2+,\7.\2\2,\b\3\2\2\2-.\7+\2\2.\n\3\2\2\2/\60\7")
|
||||
buf.write("}\2\2\60\f\3\2\2\2\61\62\7\177\2\2\62\16\3\2\2\2\63\64")
|
||||
buf.write("\7=\2\2\64\20\3\2\2\2\65\66\7?\2\2\66\22\3\2\2\2\678\7")
|
||||
buf.write(",\2\28\24\3\2\2\29:\7\61\2\2:\26\3\2\2\2;<\7-\2\2<\30")
|
||||
buf.write("\3\2\2\2=>\7/\2\2>\32\3\2\2\2?@\7t\2\2@A\7g\2\2AB\7v\2")
|
||||
buf.write("\2BC\7w\2\2CD\7t\2\2DE\7p\2\2E\34\3\2\2\2FH\t\2\2\2GF")
|
||||
buf.write("\3\2\2\2HI\3\2\2\2IG\3\2\2\2IJ\3\2\2\2J\36\3\2\2\2KM\t")
|
||||
buf.write("\3\2\2LK\3\2\2\2MN\3\2\2\2NL\3\2\2\2NO\3\2\2\2O \3\2\2")
|
||||
buf.write("\2PR\7\17\2\2QP\3\2\2\2QR\3\2\2\2RS\3\2\2\2ST\7\f\2\2")
|
||||
buf.write("TU\3\2\2\2UV\b\21\2\2V\"\3\2\2\2WY\t\4\2\2XW\3\2\2\2Y")
|
||||
buf.write("Z\3\2\2\2ZX\3\2\2\2Z[\3\2\2\2[\\\3\2\2\2\\]\b\22\2\2]")
|
||||
buf.write("$\3\2\2\2\7\2INQZ\3\b\2\2")
|
||||
return buf.getvalue()
|
||||
|
||||
|
||||
class ExprLexer(Lexer):
|
||||
|
||||
atn = ATNDeserializer().deserialize(serializedATN())
|
||||
|
||||
decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ]
|
||||
|
||||
T__0 = 1
|
||||
T__1 = 2
|
||||
T__2 = 3
|
||||
T__3 = 4
|
||||
T__4 = 5
|
||||
T__5 = 6
|
||||
T__6 = 7
|
||||
T__7 = 8
|
||||
MUL = 9
|
||||
DIV = 10
|
||||
ADD = 11
|
||||
SUB = 12
|
||||
RETURN = 13
|
||||
ID = 14
|
||||
INT = 15
|
||||
NEWLINE = 16
|
||||
WS = 17
|
||||
|
||||
channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ]
|
||||
|
||||
modeNames = [ "DEFAULT_MODE" ]
|
||||
|
||||
literalNames = [ "<INVALID>",
|
||||
"'def'", "'('", "','", "')'", "'{'", "'}'", "';'", "'='", "'*'",
|
||||
"'/'", "'+'", "'-'", "'return'" ]
|
||||
|
||||
symbolicNames = [ "<INVALID>",
|
||||
"MUL", "DIV", "ADD", "SUB", "RETURN", "ID", "INT", "NEWLINE",
|
||||
"WS" ]
|
||||
|
||||
ruleNames = [ "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6",
|
||||
"T__7", "MUL", "DIV", "ADD", "SUB", "RETURN", "ID", "INT",
|
||||
"NEWLINE", "WS" ]
|
||||
|
||||
grammarFileName = "Expr.g4"
|
||||
|
||||
def __init__(self, input=None, output:TextIO = sys.stdout):
|
||||
super().__init__(input, output)
|
||||
self.checkVersion("4.7.2")
|
||||
self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache())
|
||||
self._actions = None
|
||||
self._predicates = None
|
||||
|
||||
|
|
@ -0,0 +1,658 @@
|
|||
# Generated from expr/Expr.g4 by ANTLR 4.7.2
|
||||
# encoding: utf-8
|
||||
from antlr4 import *
|
||||
from io import StringIO
|
||||
from typing.io import TextIO
|
||||
import sys
|
||||
|
||||
def serializedATN():
|
||||
with StringIO() as buf:
|
||||
buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\23")
|
||||
buf.write("S\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b")
|
||||
buf.write("\t\b\3\2\6\2\22\n\2\r\2\16\2\23\3\3\3\3\3\3\3\3\3\3\3")
|
||||
buf.write("\3\7\3\34\n\3\f\3\16\3\37\13\3\3\3\3\3\3\3\3\4\3\4\6\4")
|
||||
buf.write("&\n\4\r\4\16\4\'\3\4\3\4\3\5\3\5\3\6\3\6\3\6\3\6\3\6\3")
|
||||
buf.write("\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\5\6;\n\6\3\7\3\7\3\7\3")
|
||||
buf.write("\7\3\7\3\7\3\7\3\7\3\7\7\7F\n\7\f\7\16\7I\13\7\3\b\3\b")
|
||||
buf.write("\3\b\3\b\3\b\3\b\5\bQ\n\b\3\b\2\3\f\t\2\4\6\b\n\f\16\2")
|
||||
buf.write("\4\3\2\13\f\3\2\r\16\2U\2\21\3\2\2\2\4\25\3\2\2\2\6#\3")
|
||||
buf.write("\2\2\2\b+\3\2\2\2\n:\3\2\2\2\f<\3\2\2\2\16P\3\2\2\2\20")
|
||||
buf.write("\22\5\4\3\2\21\20\3\2\2\2\22\23\3\2\2\2\23\21\3\2\2\2")
|
||||
buf.write("\23\24\3\2\2\2\24\3\3\2\2\2\25\26\7\3\2\2\26\27\7\20\2")
|
||||
buf.write("\2\27\30\7\4\2\2\30\35\5\b\5\2\31\32\7\5\2\2\32\34\5\b")
|
||||
buf.write("\5\2\33\31\3\2\2\2\34\37\3\2\2\2\35\33\3\2\2\2\35\36\3")
|
||||
buf.write("\2\2\2\36 \3\2\2\2\37\35\3\2\2\2 !\7\6\2\2!\"\5\6\4\2")
|
||||
buf.write("\"\5\3\2\2\2#%\7\7\2\2$&\5\n\6\2%$\3\2\2\2&\'\3\2\2\2")
|
||||
buf.write("\'%\3\2\2\2\'(\3\2\2\2()\3\2\2\2)*\7\b\2\2*\7\3\2\2\2")
|
||||
buf.write("+,\7\20\2\2,\t\3\2\2\2-.\5\f\7\2./\7\t\2\2/;\3\2\2\2\60")
|
||||
buf.write("\61\7\20\2\2\61\62\7\n\2\2\62\63\5\f\7\2\63\64\7\t\2\2")
|
||||
buf.write("\64;\3\2\2\2\65\66\7\17\2\2\66\67\5\f\7\2\678\7\t\2\2")
|
||||
buf.write("8;\3\2\2\29;\7\t\2\2:-\3\2\2\2:\60\3\2\2\2:\65\3\2\2\2")
|
||||
buf.write(":9\3\2\2\2;\13\3\2\2\2<=\b\7\1\2=>\5\16\b\2>G\3\2\2\2")
|
||||
buf.write("?@\f\5\2\2@A\t\2\2\2AF\5\f\7\6BC\f\4\2\2CD\t\3\2\2DF\5")
|
||||
buf.write("\f\7\5E?\3\2\2\2EB\3\2\2\2FI\3\2\2\2GE\3\2\2\2GH\3\2\2")
|
||||
buf.write("\2H\r\3\2\2\2IG\3\2\2\2JQ\7\21\2\2KQ\7\20\2\2LM\7\4\2")
|
||||
buf.write("\2MN\5\f\7\2NO\7\6\2\2OQ\3\2\2\2PJ\3\2\2\2PK\3\2\2\2P")
|
||||
buf.write("L\3\2\2\2Q\17\3\2\2\2\t\23\35\':EGP")
|
||||
return buf.getvalue()
|
||||
|
||||
|
||||
class ExprParser ( Parser ):
|
||||
|
||||
grammarFileName = "Expr.g4"
|
||||
|
||||
atn = ATNDeserializer().deserialize(serializedATN())
|
||||
|
||||
decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ]
|
||||
|
||||
sharedContextCache = PredictionContextCache()
|
||||
|
||||
literalNames = [ "<INVALID>", "'def'", "'('", "','", "')'", "'{'", "'}'",
|
||||
"';'", "'='", "'*'", "'/'", "'+'", "'-'", "'return'" ]
|
||||
|
||||
symbolicNames = [ "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
|
||||
"<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
|
||||
"<INVALID>", "MUL", "DIV", "ADD", "SUB", "RETURN",
|
||||
"ID", "INT", "NEWLINE", "WS" ]
|
||||
|
||||
RULE_prog = 0
|
||||
RULE_func = 1
|
||||
RULE_body = 2
|
||||
RULE_arg = 3
|
||||
RULE_stat = 4
|
||||
RULE_expr = 5
|
||||
RULE_primary = 6
|
||||
|
||||
ruleNames = [ "prog", "func", "body", "arg", "stat", "expr", "primary" ]
|
||||
|
||||
EOF = Token.EOF
|
||||
T__0=1
|
||||
T__1=2
|
||||
T__2=3
|
||||
T__3=4
|
||||
T__4=5
|
||||
T__5=6
|
||||
T__6=7
|
||||
T__7=8
|
||||
MUL=9
|
||||
DIV=10
|
||||
ADD=11
|
||||
SUB=12
|
||||
RETURN=13
|
||||
ID=14
|
||||
INT=15
|
||||
NEWLINE=16
|
||||
WS=17
|
||||
|
||||
def __init__(self, input:TokenStream, output:TextIO = sys.stdout):
|
||||
super().__init__(input, output)
|
||||
self.checkVersion("4.7.2")
|
||||
self._interp = ParserATNSimulator(self, self.atn, self.decisionsToDFA, self.sharedContextCache)
|
||||
self._predicates = None
|
||||
|
||||
|
||||
|
||||
class ProgContext(ParserRuleContext):
|
||||
|
||||
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
||||
super().__init__(parent, invokingState)
|
||||
self.parser = parser
|
||||
|
||||
def func(self, i:int=None):
|
||||
if i is None:
|
||||
return self.getTypedRuleContexts(ExprParser.FuncContext)
|
||||
else:
|
||||
return self.getTypedRuleContext(ExprParser.FuncContext,i)
|
||||
|
||||
|
||||
def getRuleIndex(self):
|
||||
return ExprParser.RULE_prog
|
||||
|
||||
|
||||
|
||||
|
||||
def prog(self):
|
||||
|
||||
localctx = ExprParser.ProgContext(self, self._ctx, self.state)
|
||||
self.enterRule(localctx, 0, self.RULE_prog)
|
||||
self._la = 0 # Token type
|
||||
try:
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 15
|
||||
self._errHandler.sync(self)
|
||||
_la = self._input.LA(1)
|
||||
while True:
|
||||
self.state = 14
|
||||
self.func()
|
||||
self.state = 17
|
||||
self._errHandler.sync(self)
|
||||
_la = self._input.LA(1)
|
||||
if not (_la==ExprParser.T__0):
|
||||
break
|
||||
|
||||
except RecognitionException as re:
|
||||
localctx.exception = re
|
||||
self._errHandler.reportError(self, re)
|
||||
self._errHandler.recover(self, re)
|
||||
finally:
|
||||
self.exitRule()
|
||||
return localctx
|
||||
|
||||
class FuncContext(ParserRuleContext):
|
||||
|
||||
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
||||
super().__init__(parent, invokingState)
|
||||
self.parser = parser
|
||||
|
||||
def ID(self):
|
||||
return self.getToken(ExprParser.ID, 0)
|
||||
|
||||
def arg(self, i:int=None):
|
||||
if i is None:
|
||||
return self.getTypedRuleContexts(ExprParser.ArgContext)
|
||||
else:
|
||||
return self.getTypedRuleContext(ExprParser.ArgContext,i)
|
||||
|
||||
|
||||
def body(self):
|
||||
return self.getTypedRuleContext(ExprParser.BodyContext,0)
|
||||
|
||||
|
||||
def getRuleIndex(self):
|
||||
return ExprParser.RULE_func
|
||||
|
||||
|
||||
|
||||
|
||||
def func(self):
|
||||
|
||||
localctx = ExprParser.FuncContext(self, self._ctx, self.state)
|
||||
self.enterRule(localctx, 2, self.RULE_func)
|
||||
self._la = 0 # Token type
|
||||
try:
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 19
|
||||
self.match(ExprParser.T__0)
|
||||
self.state = 20
|
||||
self.match(ExprParser.ID)
|
||||
self.state = 21
|
||||
self.match(ExprParser.T__1)
|
||||
self.state = 22
|
||||
self.arg()
|
||||
self.state = 27
|
||||
self._errHandler.sync(self)
|
||||
_la = self._input.LA(1)
|
||||
while _la==ExprParser.T__2:
|
||||
self.state = 23
|
||||
self.match(ExprParser.T__2)
|
||||
self.state = 24
|
||||
self.arg()
|
||||
self.state = 29
|
||||
self._errHandler.sync(self)
|
||||
_la = self._input.LA(1)
|
||||
|
||||
self.state = 30
|
||||
self.match(ExprParser.T__3)
|
||||
self.state = 31
|
||||
self.body()
|
||||
except RecognitionException as re:
|
||||
localctx.exception = re
|
||||
self._errHandler.reportError(self, re)
|
||||
self._errHandler.recover(self, re)
|
||||
finally:
|
||||
self.exitRule()
|
||||
return localctx
|
||||
|
||||
class BodyContext(ParserRuleContext):
|
||||
|
||||
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
||||
super().__init__(parent, invokingState)
|
||||
self.parser = parser
|
||||
|
||||
def stat(self, i:int=None):
|
||||
if i is None:
|
||||
return self.getTypedRuleContexts(ExprParser.StatContext)
|
||||
else:
|
||||
return self.getTypedRuleContext(ExprParser.StatContext,i)
|
||||
|
||||
|
||||
def getRuleIndex(self):
|
||||
return ExprParser.RULE_body
|
||||
|
||||
|
||||
|
||||
|
||||
def body(self):
|
||||
|
||||
localctx = ExprParser.BodyContext(self, self._ctx, self.state)
|
||||
self.enterRule(localctx, 4, self.RULE_body)
|
||||
self._la = 0 # Token type
|
||||
try:
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 33
|
||||
self.match(ExprParser.T__4)
|
||||
self.state = 35
|
||||
self._errHandler.sync(self)
|
||||
_la = self._input.LA(1)
|
||||
while True:
|
||||
self.state = 34
|
||||
self.stat()
|
||||
self.state = 37
|
||||
self._errHandler.sync(self)
|
||||
_la = self._input.LA(1)
|
||||
if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << ExprParser.T__1) | (1 << ExprParser.T__6) | (1 << ExprParser.RETURN) | (1 << ExprParser.ID) | (1 << ExprParser.INT))) != 0)):
|
||||
break
|
||||
|
||||
self.state = 39
|
||||
self.match(ExprParser.T__5)
|
||||
except RecognitionException as re:
|
||||
localctx.exception = re
|
||||
self._errHandler.reportError(self, re)
|
||||
self._errHandler.recover(self, re)
|
||||
finally:
|
||||
self.exitRule()
|
||||
return localctx
|
||||
|
||||
class ArgContext(ParserRuleContext):
|
||||
|
||||
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
||||
super().__init__(parent, invokingState)
|
||||
self.parser = parser
|
||||
|
||||
def ID(self):
|
||||
return self.getToken(ExprParser.ID, 0)
|
||||
|
||||
def getRuleIndex(self):
|
||||
return ExprParser.RULE_arg
|
||||
|
||||
|
||||
|
||||
|
||||
def arg(self):
|
||||
|
||||
localctx = ExprParser.ArgContext(self, self._ctx, self.state)
|
||||
self.enterRule(localctx, 6, self.RULE_arg)
|
||||
try:
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 41
|
||||
self.match(ExprParser.ID)
|
||||
except RecognitionException as re:
|
||||
localctx.exception = re
|
||||
self._errHandler.reportError(self, re)
|
||||
self._errHandler.recover(self, re)
|
||||
finally:
|
||||
self.exitRule()
|
||||
return localctx
|
||||
|
||||
class StatContext(ParserRuleContext):
|
||||
|
||||
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
||||
super().__init__(parent, invokingState)
|
||||
self.parser = parser
|
||||
|
||||
|
||||
def getRuleIndex(self):
|
||||
return ExprParser.RULE_stat
|
||||
|
||||
|
||||
def copyFrom(self, ctx:ParserRuleContext):
|
||||
super().copyFrom(ctx)
|
||||
|
||||
|
||||
|
||||
class RetContext(StatContext):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a ExprParser.StatContext
|
||||
super().__init__(parser)
|
||||
self.copyFrom(ctx)
|
||||
|
||||
def RETURN(self):
|
||||
return self.getToken(ExprParser.RETURN, 0)
|
||||
def expr(self):
|
||||
return self.getTypedRuleContext(ExprParser.ExprContext,0)
|
||||
|
||||
|
||||
|
||||
class BlankContext(StatContext):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a ExprParser.StatContext
|
||||
super().__init__(parser)
|
||||
self.copyFrom(ctx)
|
||||
|
||||
|
||||
|
||||
class PrintExprContext(StatContext):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a ExprParser.StatContext
|
||||
super().__init__(parser)
|
||||
self.copyFrom(ctx)
|
||||
|
||||
def expr(self):
|
||||
return self.getTypedRuleContext(ExprParser.ExprContext,0)
|
||||
|
||||
|
||||
|
||||
class AssignContext(StatContext):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a ExprParser.StatContext
|
||||
super().__init__(parser)
|
||||
self.copyFrom(ctx)
|
||||
|
||||
def ID(self):
|
||||
return self.getToken(ExprParser.ID, 0)
|
||||
def expr(self):
|
||||
return self.getTypedRuleContext(ExprParser.ExprContext,0)
|
||||
|
||||
|
||||
|
||||
|
||||
def stat(self):
|
||||
|
||||
localctx = ExprParser.StatContext(self, self._ctx, self.state)
|
||||
self.enterRule(localctx, 8, self.RULE_stat)
|
||||
try:
|
||||
self.state = 56
|
||||
self._errHandler.sync(self)
|
||||
la_ = self._interp.adaptivePredict(self._input,3,self._ctx)
|
||||
if la_ == 1:
|
||||
localctx = ExprParser.PrintExprContext(self, localctx)
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 43
|
||||
self.expr(0)
|
||||
self.state = 44
|
||||
self.match(ExprParser.T__6)
|
||||
pass
|
||||
|
||||
elif la_ == 2:
|
||||
localctx = ExprParser.AssignContext(self, localctx)
|
||||
self.enterOuterAlt(localctx, 2)
|
||||
self.state = 46
|
||||
self.match(ExprParser.ID)
|
||||
self.state = 47
|
||||
self.match(ExprParser.T__7)
|
||||
self.state = 48
|
||||
self.expr(0)
|
||||
self.state = 49
|
||||
self.match(ExprParser.T__6)
|
||||
pass
|
||||
|
||||
elif la_ == 3:
|
||||
localctx = ExprParser.RetContext(self, localctx)
|
||||
self.enterOuterAlt(localctx, 3)
|
||||
self.state = 51
|
||||
self.match(ExprParser.RETURN)
|
||||
self.state = 52
|
||||
self.expr(0)
|
||||
self.state = 53
|
||||
self.match(ExprParser.T__6)
|
||||
pass
|
||||
|
||||
elif la_ == 4:
|
||||
localctx = ExprParser.BlankContext(self, localctx)
|
||||
self.enterOuterAlt(localctx, 4)
|
||||
self.state = 55
|
||||
self.match(ExprParser.T__6)
|
||||
pass
|
||||
|
||||
|
||||
except RecognitionException as re:
|
||||
localctx.exception = re
|
||||
self._errHandler.reportError(self, re)
|
||||
self._errHandler.recover(self, re)
|
||||
finally:
|
||||
self.exitRule()
|
||||
return localctx
|
||||
|
||||
class ExprContext(ParserRuleContext):
|
||||
|
||||
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
||||
super().__init__(parent, invokingState)
|
||||
self.parser = parser
|
||||
|
||||
|
||||
def getRuleIndex(self):
|
||||
return ExprParser.RULE_expr
|
||||
|
||||
|
||||
def copyFrom(self, ctx:ParserRuleContext):
|
||||
super().copyFrom(ctx)
|
||||
|
||||
|
||||
class PrimContext(ExprContext):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a ExprParser.ExprContext
|
||||
super().__init__(parser)
|
||||
self.copyFrom(ctx)
|
||||
|
||||
def primary(self):
|
||||
return self.getTypedRuleContext(ExprParser.PrimaryContext,0)
|
||||
|
||||
|
||||
|
||||
class MulDivContext(ExprContext):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a ExprParser.ExprContext
|
||||
super().__init__(parser)
|
||||
self.copyFrom(ctx)
|
||||
|
||||
def expr(self, i:int=None):
|
||||
if i is None:
|
||||
return self.getTypedRuleContexts(ExprParser.ExprContext)
|
||||
else:
|
||||
return self.getTypedRuleContext(ExprParser.ExprContext,i)
|
||||
|
||||
def MUL(self):
|
||||
return self.getToken(ExprParser.MUL, 0)
|
||||
def DIV(self):
|
||||
return self.getToken(ExprParser.DIV, 0)
|
||||
|
||||
|
||||
class AddSubContext(ExprContext):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a ExprParser.ExprContext
|
||||
super().__init__(parser)
|
||||
self.copyFrom(ctx)
|
||||
|
||||
def expr(self, i:int=None):
|
||||
if i is None:
|
||||
return self.getTypedRuleContexts(ExprParser.ExprContext)
|
||||
else:
|
||||
return self.getTypedRuleContext(ExprParser.ExprContext,i)
|
||||
|
||||
def ADD(self):
|
||||
return self.getToken(ExprParser.ADD, 0)
|
||||
def SUB(self):
|
||||
return self.getToken(ExprParser.SUB, 0)
|
||||
|
||||
|
||||
|
||||
def expr(self, _p:int=0):
|
||||
_parentctx = self._ctx
|
||||
_parentState = self.state
|
||||
localctx = ExprParser.ExprContext(self, self._ctx, _parentState)
|
||||
_prevctx = localctx
|
||||
_startState = 10
|
||||
self.enterRecursionRule(localctx, 10, self.RULE_expr, _p)
|
||||
self._la = 0 # Token type
|
||||
try:
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
localctx = ExprParser.PrimContext(self, localctx)
|
||||
self._ctx = localctx
|
||||
_prevctx = localctx
|
||||
|
||||
self.state = 59
|
||||
self.primary()
|
||||
self._ctx.stop = self._input.LT(-1)
|
||||
self.state = 69
|
||||
self._errHandler.sync(self)
|
||||
_alt = self._interp.adaptivePredict(self._input,5,self._ctx)
|
||||
while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
|
||||
if _alt==1:
|
||||
if self._parseListeners is not None:
|
||||
self.triggerExitRuleEvent()
|
||||
_prevctx = localctx
|
||||
self.state = 67
|
||||
self._errHandler.sync(self)
|
||||
la_ = self._interp.adaptivePredict(self._input,4,self._ctx)
|
||||
if la_ == 1:
|
||||
localctx = ExprParser.MulDivContext(self, ExprParser.ExprContext(self, _parentctx, _parentState))
|
||||
self.pushNewRecursionContext(localctx, _startState, self.RULE_expr)
|
||||
self.state = 61
|
||||
if not self.precpred(self._ctx, 3):
|
||||
from antlr4.error.Errors import FailedPredicateException
|
||||
raise FailedPredicateException(self, "self.precpred(self._ctx, 3)")
|
||||
self.state = 62
|
||||
_la = self._input.LA(1)
|
||||
if not(_la==ExprParser.MUL or _la==ExprParser.DIV):
|
||||
self._errHandler.recoverInline(self)
|
||||
else:
|
||||
self._errHandler.reportMatch(self)
|
||||
self.consume()
|
||||
self.state = 63
|
||||
self.expr(4)
|
||||
pass
|
||||
|
||||
elif la_ == 2:
|
||||
localctx = ExprParser.AddSubContext(self, ExprParser.ExprContext(self, _parentctx, _parentState))
|
||||
self.pushNewRecursionContext(localctx, _startState, self.RULE_expr)
|
||||
self.state = 64
|
||||
if not self.precpred(self._ctx, 2):
|
||||
from antlr4.error.Errors import FailedPredicateException
|
||||
raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
|
||||
self.state = 65
|
||||
_la = self._input.LA(1)
|
||||
if not(_la==ExprParser.ADD or _la==ExprParser.SUB):
|
||||
self._errHandler.recoverInline(self)
|
||||
else:
|
||||
self._errHandler.reportMatch(self)
|
||||
self.consume()
|
||||
self.state = 66
|
||||
self.expr(3)
|
||||
pass
|
||||
|
||||
|
||||
self.state = 71
|
||||
self._errHandler.sync(self)
|
||||
_alt = self._interp.adaptivePredict(self._input,5,self._ctx)
|
||||
|
||||
except RecognitionException as re:
|
||||
localctx.exception = re
|
||||
self._errHandler.reportError(self, re)
|
||||
self._errHandler.recover(self, re)
|
||||
finally:
|
||||
self.unrollRecursionContexts(_parentctx)
|
||||
return localctx
|
||||
|
||||
class PrimaryContext(ParserRuleContext):
|
||||
|
||||
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
||||
super().__init__(parent, invokingState)
|
||||
self.parser = parser
|
||||
|
||||
|
||||
def getRuleIndex(self):
|
||||
return ExprParser.RULE_primary
|
||||
|
||||
|
||||
def copyFrom(self, ctx:ParserRuleContext):
|
||||
super().copyFrom(ctx)
|
||||
|
||||
|
||||
|
||||
class ParensContext(PrimaryContext):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a ExprParser.PrimaryContext
|
||||
super().__init__(parser)
|
||||
self.copyFrom(ctx)
|
||||
|
||||
def expr(self):
|
||||
return self.getTypedRuleContext(ExprParser.ExprContext,0)
|
||||
|
||||
|
||||
|
||||
class IdContext(PrimaryContext):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a ExprParser.PrimaryContext
|
||||
super().__init__(parser)
|
||||
self.copyFrom(ctx)
|
||||
|
||||
def ID(self):
|
||||
return self.getToken(ExprParser.ID, 0)
|
||||
|
||||
|
||||
class IntContext(PrimaryContext):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a ExprParser.PrimaryContext
|
||||
super().__init__(parser)
|
||||
self.copyFrom(ctx)
|
||||
|
||||
def INT(self):
|
||||
return self.getToken(ExprParser.INT, 0)
|
||||
|
||||
|
||||
|
||||
def primary(self):
|
||||
|
||||
localctx = ExprParser.PrimaryContext(self, self._ctx, self.state)
|
||||
self.enterRule(localctx, 12, self.RULE_primary)
|
||||
try:
|
||||
self.state = 78
|
||||
self._errHandler.sync(self)
|
||||
token = self._input.LA(1)
|
||||
if token in [ExprParser.INT]:
|
||||
localctx = ExprParser.IntContext(self, localctx)
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 72
|
||||
self.match(ExprParser.INT)
|
||||
pass
|
||||
elif token in [ExprParser.ID]:
|
||||
localctx = ExprParser.IdContext(self, localctx)
|
||||
self.enterOuterAlt(localctx, 2)
|
||||
self.state = 73
|
||||
self.match(ExprParser.ID)
|
||||
pass
|
||||
elif token in [ExprParser.T__1]:
|
||||
localctx = ExprParser.ParensContext(self, localctx)
|
||||
self.enterOuterAlt(localctx, 3)
|
||||
self.state = 74
|
||||
self.match(ExprParser.T__1)
|
||||
self.state = 75
|
||||
self.expr(0)
|
||||
self.state = 76
|
||||
self.match(ExprParser.T__3)
|
||||
pass
|
||||
else:
|
||||
raise NoViableAltException(self)
|
||||
|
||||
except RecognitionException as re:
|
||||
localctx.exception = re
|
||||
self._errHandler.reportError(self, re)
|
||||
self._errHandler.recover(self, re)
|
||||
finally:
|
||||
self.exitRule()
|
||||
return localctx
|
||||
|
||||
|
||||
|
||||
def sempred(self, localctx:RuleContext, ruleIndex:int, predIndex:int):
|
||||
if self._predicates == None:
|
||||
self._predicates = dict()
|
||||
self._predicates[5] = self.expr_sempred
|
||||
pred = self._predicates.get(ruleIndex, None)
|
||||
if pred is None:
|
||||
raise Exception("No predicate with index:" + str(ruleIndex))
|
||||
else:
|
||||
return pred(localctx, predIndex)
|
||||
|
||||
def expr_sempred(self, localctx:ExprContext, predIndex:int):
|
||||
if predIndex == 0:
|
||||
return self.precpred(self._ctx, 3)
|
||||
|
||||
|
||||
if predIndex == 1:
|
||||
return self.precpred(self._ctx, 2)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -3,5 +3,6 @@ import os
|
|||
src_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'src')
|
||||
sys.path.insert(0,src_path)
|
||||
from TestTokenStreamRewriter import TestTokenStreamRewriter
|
||||
from xpathtest import XPathTest
|
||||
import unittest
|
||||
unittest.main()
|
|
@ -0,0 +1,89 @@
|
|||
import antlr4
|
||||
from antlr4 import InputStream, CommonTokenStream, TerminalNode
|
||||
from antlr4.xpath.XPath import XPath
|
||||
import unittest
|
||||
from expr.ExprParser import ExprParser
|
||||
from expr.ExprLexer import ExprLexer
|
||||
|
||||
def tokenToString(token, ruleNames):
|
||||
if isinstance(token, TerminalNode):
|
||||
return str(token)
|
||||
else:
|
||||
return ruleNames[token.getRuleIndex()]
|
||||
|
||||
class XPathTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.input_stream = InputStream(
|
||||
"def f(x,y) { x = 3+4; y; ; }\n"
|
||||
"def g(x) { return 1+2*x; }\n"
|
||||
)
|
||||
|
||||
# Create the Token Stream
|
||||
self.lexer = ExprLexer(self.input_stream)
|
||||
self.stream = CommonTokenStream(self.lexer)
|
||||
self.stream.fill()
|
||||
|
||||
# Create the parser and expression parse tree
|
||||
self.parser = ExprParser(self.stream)
|
||||
self.tree = self.parser.prog()
|
||||
|
||||
def testValidPaths(self):
|
||||
valid_paths = [
|
||||
"/prog/func", # all funcs under prog at root
|
||||
"/prog/*", # all children of prog at root
|
||||
"/*/func", # all func kids of any root node
|
||||
"prog", # prog must be root node
|
||||
"/prog", # prog must be root node
|
||||
"/*", # any root
|
||||
"*", # any root
|
||||
"//ID", # any ID in tree
|
||||
"//expr/primary/ID", # any ID child of a primary under any expr
|
||||
"//body//ID", # any ID under a body
|
||||
"//'return'", # any 'return' literal in tree, matched by literal name
|
||||
"//RETURN", # any 'return' literal in tree, matched by symbolic name
|
||||
"//primary/*", # all kids of any primary
|
||||
"//func/*/stat", # all stat nodes grandkids of any func node
|
||||
"/prog/func/'def'", # all def literal kids of func kid of prog
|
||||
"//stat/';'", # all ';' under any stat node
|
||||
"//expr/primary/!ID",# anything but ID under primary under any expr node
|
||||
"//expr/!primary", # anything but primary under any expr node
|
||||
"//!*", # nothing anywhere
|
||||
"/!*", # nothing at root
|
||||
"//expr//ID" # any ID under any expression (tests antlr/antlr4#370)
|
||||
]
|
||||
|
||||
expected_results = [
|
||||
"[func, func]",
|
||||
"[func, func]",
|
||||
"[func, func]",
|
||||
"[prog]",
|
||||
"[prog]",
|
||||
"[prog]",
|
||||
"[prog]",
|
||||
"[f, x, y, x, y, g, x, x]",
|
||||
"[y, x]",
|
||||
"[x, y, x]",
|
||||
"[return]",
|
||||
"[return]",
|
||||
"[3, 4, y, 1, 2, x]",
|
||||
"[stat, stat, stat, stat]",
|
||||
"[def, def]",
|
||||
"[;, ;, ;, ;]",
|
||||
"[3, 4, 1, 2]",
|
||||
"[expr, expr, expr, expr, expr, expr]",
|
||||
"[]",
|
||||
"[]",
|
||||
"[y, x]",
|
||||
]
|
||||
|
||||
for path, expected in zip(valid_paths, expected_results):
|
||||
# Build test string
|
||||
res = XPath.findAll(self.tree, path, self.parser)
|
||||
res_str = ", ".join([tokenToString(token, self.parser.ruleNames) for token in res])
|
||||
res_str = "[%s]" % res_str
|
||||
|
||||
# Test against expected output
|
||||
self.assertEqual(res_str, expected, "Failed test %s" % path)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue