forked from jasder/antlr
Merge branch 'feature/addtests'
This commit is contained in:
commit
d18109eccf
|
@ -0,0 +1,138 @@
|
|||
# C++
|
||||
|
||||
The C++ target supports all platforms that can either run MS Visual Studio 2013 (or newer), XCode 7 (or newer) or CMake (C++11 required). All build tools can either create static or dynamic libraries, both as 64bit or 32bit arch. Additionally, XCode can create an iOS library.
|
||||
|
||||
## How to create a C++ lexer or parser?
|
||||
This is pretty much the same as creating a Java lexer or parser, except you need to specify the language target, for example:
|
||||
|
||||
```
|
||||
$ antlr4 -Dlanguage=Cpp MyGrammar.g4
|
||||
```
|
||||
|
||||
You will see that there are a whole bunch of files generated by this call. If visitor or listener are not suppressed (which is the default) you'll get:
|
||||
|
||||
* MyGrammarLexer.h + MyGrammarLexer.cpp
|
||||
* MyGrammarParser.h + MyGrammarParser.cpp
|
||||
* MyGrammarVisitor.h + MyGrammarVisitor.cpp
|
||||
* MyGrammarBaseVisitor.h + MyGrammarBaseVisitor.cpp
|
||||
* MyGrammarListener.h + MyGrammarListener.cpp
|
||||
* MyGrammarBaseListener.h + MyGrammarBaseListener.cpp
|
||||
|
||||
## Where can I get the runtime?
|
||||
|
||||
Once you've generated the lexer and/or parser code, you need to download or build the runtime. Prebuilt C++ runtime binaries for Windows (VS 2013 runtime), OSX and iOS are available on the ANTLR web site:
|
||||
|
||||
* http://www.antlr.org
|
||||
|
||||
Use CMake to build a Linux library (works also on OSX, however not for the iOS library). Building your own library on OSX or Windows is trivial, however. Just open the VS or XCode project, select target + arch and build it. Should work out of the box without any additional dependency.
|
||||
|
||||
|
||||
## How do I run the generated lexer and/or parser?
|
||||
|
||||
Putting it all together to get a working parser is really easy. Look in the [runtime/Cpp/demo](../runtime/Cpp/demo) folder for a simple example. The [README](../runtime/Cpp/demo/README.md) there describes shortly how to build and run the demo on OSX, Windows or Linux.
|
||||
|
||||
## How do I create and run a custom listener?
|
||||
|
||||
The generation step above created a listener and base listener class for you. The listener class is an abstract interface, which declares enter and exit methods for each of your parser rules. The base listener implements all those abstract methods with an empty body, so you don't have to do it yourself if you just want to implement a single function. Hence use this base listener as the base class for your custom listener:
|
||||
|
||||
```c++
|
||||
#include <iostream>
|
||||
|
||||
#include "antlr4-runtime.h"
|
||||
#include "MyGrammarLexer.h"
|
||||
#include "MyGrammarParser.h"
|
||||
#include "MyGrammarBaseListener.h"
|
||||
|
||||
using namespace org::antlr::v4::runtime;
|
||||
|
||||
class TreeShapeListener : public MyGrammarBaseListener {
|
||||
public:
|
||||
void enterKey(Ref<ParserRuleContext> ctx) {
|
||||
// Do something when entering the key rule.
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, const char* argv[]) {
|
||||
std::wifstream stream;
|
||||
stream.open(argv[1]);
|
||||
ANTLRInputStream input("ae");
|
||||
MyGrammarLexer lexer(&input);
|
||||
CommonTokenStream tokens(&lexer);
|
||||
MyGrammarParser parser(&tokens);
|
||||
|
||||
Ref<tree::ParseTree> tree = parser.key();
|
||||
Ref<TreeShapeListener> listener(new TreeShapeListener());
|
||||
tree::ParseTreeWalker::DEFAULT->walk(listener, tree);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
This example assumes your grammar contains a parser rule named `key` for which the enterKey function was generated. The `Ref<>` template is an alias for `std::shared_ptr<>` to simplify the runtime source code which often makes use of smart pointers.
|
||||
|
||||
### Specialities of this ANTLR target
|
||||
|
||||
There are a couple of things that only the C++ ANTLR target has to deal with. They are described here.
|
||||
|
||||
### Memory Management
|
||||
Since C++ has no built-in memory management we need to take extra care for that. For that we rely mostly on smart pointers, which however might cause time penalties or memory side effects (like cyclic references) if not used with care. Currently however the memory household looks very stable.
|
||||
|
||||
### Unicode Support
|
||||
Encoding is mostly an input issue, i.e. when the lexer converts text input into lexer tokens. The parser is completely encoding unaware. However, lexer input in in the grammar is defined by character ranges with either a single member (e.g. 'a' or [a]), an explicit range (e.g. 'a'..'z' or [a-z]), the full Unicode range (for a wildcard) and the full Unicode range minus a sub range (for negated ranges, e.g. ~[a]). The explicit ranges are encoded in the serialized ATN by 16bit numbers, hence cannot reach beyond 0xFFFF (the Unicode BMP), while the implicit ranges can include any value (and hence support the full Unicode set, up to 0x10FFFF).
|
||||
|
||||
> An interesting side note here is that the Java target fully supports Unicode as well, despite the inherent limitations from the serialized ATN. That's possible because the Java String class represents characters beyond the BMP as surrogate pairs (two 16bit values) and even reads them as 2 characters. To make this work a character range for an identifier in a grammar must include the surrogate pairs area (for a Java parser).
|
||||
|
||||
The C++ target however always expects UTF-8 input (either in a string or via a wide stream) which is then converted to UTF-32 (a char32_t array) and fed to the lexer. ANTLR, when parsing your grammar, limits character ranges explicitly to the BMP currently. So, in order to allow specifying the full Unicode set the C++ target uses a little trick: whenever an explicit character range includes the (unused) codepoint 0xFFFF in a grammar it is silently extended to the full Unicode range. It's clear that this is an all-or-nothing solution. You cannot define a subset of Unicode codepoints > 0xFFFF that way. This can only be solved if ANTLR supports larger character intervals.
|
||||
|
||||
The differences in handling characters beyond the BMP leads to a difference between Java and C++ parsers: the character offsets may not concur. This is because Java reads two 16bit values per Unicode char (if that falls into the surrogate area) while a C++ parser only reads one 32bit value. That usually doesn't have practical consequences, but might confuse people when comparing token positions.
|
||||
|
||||
### Named Actions
|
||||
In order to help customizing the generated files there are a number of additional socalled **named actions**. These actions are tight to specific areas in the generated code and allow to add custom (target specific) code. All targets support these actions
|
||||
|
||||
* @parser::header
|
||||
* @parser::members
|
||||
* @lexer::header
|
||||
* @lexer::members
|
||||
|
||||
|
||||
(and their scopeless alternatives `@header` and `@members`) where header doesn't mean a C/C++ header file, but the top of a code file. The content of the header action appears in all generated files at the first line. So it's good for things like license/copyright information.
|
||||
|
||||
The content of a *members* action is placed in the public section of lexer or parser class declarations. Hence it can be used for public variables or predicate functions used in a grammar predicate. Since all targets support *header* + *members* they are the best place for stuff that should be available also in generated files for other languages.
|
||||
|
||||
In addition to that the C++ target supports many more such named actions. Unfortunately, it's not possible to define new scopes (e.g. *listener* in addition to *parser*) so they had to be defined as part of the existing scopes (*lexer* or *parser*). The grammar in the demo application contains all of the named actions as well for reference. Here's the list:
|
||||
|
||||
* **@lexer::preinclude** - Placed right before the first #include (e.g. good for headers that must appear first, for system headers etc.). Appears in both lexer h and cpp file.
|
||||
* **@lexer::postinclude** - Placed right after the last #include, but before any class code (e.g. for additional namespaces). Appears in both lexer h and cpp file.
|
||||
* **@lexer::context** - Placed right before the lexer class declaration. Use for e.g. additional types, aliases, forward declarations and the like. Appears in the lexer h file.
|
||||
* **@lexer::declarations** - Placed in the private section of the lexer declaration (generated sections in all classes strictly follow the pattern: public, protected, privat, from top to bottom). Use this for private vars etc.
|
||||
* **@lexer::definitions** - Placed before other implementations in the cpp file (but after *@postinclude*). Use this to implement e.g. private types.
|
||||
|
||||
For the parser there are the same for actions as shown above for the lexer. In addition to that there are even more actions for visitor and listener classes, which are:
|
||||
|
||||
* **@parser::listenerpreinclude**
|
||||
* **@parser::listenerpostinclude**
|
||||
* **@parser::listenerdeclarations**
|
||||
* **@parser::listenermembers**
|
||||
* **@parser::listenerdefinitions**
|
||||
*
|
||||
* **@parser::baselistenerpreinclude**
|
||||
* **@parser::baselistenerpostinclude**
|
||||
* **@parser::baselistenerdeclarations**
|
||||
* **@parser::baselistenermembers**
|
||||
* **@parser::baselistenerdefinitions**
|
||||
*
|
||||
* **@parser::visitorpreinclude**
|
||||
* **@parser::visitorpostinclude**
|
||||
* **@parser::visitordeclarations**
|
||||
* **@parser::visitormembers**
|
||||
* **@parser::visitordefinitions**
|
||||
*
|
||||
* **@parser::basevisitorpreinclude**
|
||||
* **@parser::basevisitorpostinclude**
|
||||
* **@parser::basevisitordeclarations**
|
||||
* **@parser::basevisitormembers**
|
||||
* **@parser::basevisitordefinitions**
|
||||
|
||||
and should be self explanatory now. Note: there is no *context* action for listeners or visitors, simply because they would be even less used than the other actions and there are so many already.
|
|
@ -19,4 +19,4 @@ Creating a new target involves the following key elements:
|
|||
```bash
|
||||
$ mvn compile
|
||||
```
|
||||
That should proceed with success. See [Building ANTLR](building-antlr.md) for more details. (That link does not currently work as I have that documentation in a branch. see https://github.com/parrt/antlr4/blob/move-doc-to-repo/doc/building-antlr.md for now.)
|
||||
That should proceed with success. See [Building ANTLR](building-antlr.md) for more details.
|
||||
|
|
|
@ -16,6 +16,9 @@ $ git push upstream :refs/tags/4.5.2
|
|||
|
||||
Edit the repository looking for 4.5 or whatever and update it. Bump version in the following files:
|
||||
|
||||
* runtime/Cpp/VERSION
|
||||
* runtime/Cpp/runtime/antlr4cpp.vcxproj
|
||||
* runtime/Cpp/runtime/antlrcpp.xcodeproj
|
||||
* runtime/Java/src/org/antlr/v4/runtime/RuntimeMetaData.java
|
||||
* runtime/Python2/setup.py
|
||||
* runtime/Python2/src/antlr4/Recognizer.py
|
||||
|
@ -24,6 +27,7 @@ Edit the repository looking for 4.5 or whatever and update it. Bump version in t
|
|||
* runtime/CSharp/runtime/CSharp/Antlr4.Runtime/Properties/AssemblyInfo.cs
|
||||
* runtime/JavaScript/src/antlr4/package.json
|
||||
* runtime/JavaScript/src/antlr4/Recognizer.js
|
||||
* tool/src/org/antlr/v4/codegen/target/CppTarget.java
|
||||
* tool/src/org/antlr/v4/codegen/target/CSharpTarget.java
|
||||
* tool/src/org/antlr/v4/codegen/target/JavaScriptTarget.java
|
||||
* tool/src/org/antlr/v4/codegen/target/Python2Target.java
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
# Overview of the ANTLR Runtime Test Suite
|
||||
|
||||
An important part of ANTLR4 is its runtime test suite, which consist of 2 subparts:
|
||||
|
||||
* Tests for the tool itself
|
||||
* Tests for the ANTLR runtime
|
||||
|
||||
Usually the tests are executed while compiling and installing an ANTLR4 jar from source code. The command for that is simply:
|
||||
|
||||
```bash
|
||||
$ mvn install
|
||||
```
|
||||
|
||||
to be executed in the root of the ANTLR4 repository. More details about this can be found in [Building ANTLR](building-antlr.md).
|
||||
|
||||
However, you don't need to run the installation again and again just to run the tests. Instead use
|
||||
|
||||
```bash
|
||||
$ mvn test
|
||||
```
|
||||
|
||||
to only trigger testing. You can find all runtime tests in the [runtime-testsuite/resources/org/antlr/v4/test/runtime](../runtime-testsuite/resources/org/antlr/v4/test/runtime) subfolder (tool tests under [tool-testsuite/test/org/antlr/v4/test/tool](../tool-testsuite/test/org/antlr/v4/test/tool)). The tool tests are just a bunch of Java test cases that test the tool's internal behavior (e.g. for code generation). We focus on the runtime tests here.
|
||||
|
||||
The underlying process of running the tests is quite a complicated setup to cater especially for a flexible test specification that can run with different target runtimes. Everything runs in Java, except for the actual target runtime tests. Runtime tests run first, followed by the tool tests. If there was a test failure in the first step, the tool tests are not executed, however. These are the steps involved when running the runtime tests:
|
||||
|
||||
* Generate Java JUnit test cases from the test templates, once for each target (C++, C#, Python, Java, Javascript atm.).
|
||||
* These test cases generate grammar files when executed and run the target specific parser generation step, including compiling a binary, if necessary (e.g. for C++ and C#).
|
||||
* Finally run the compiled test module using the input specified in the test template. The output (usually a token or parse tree dump) is then compared against the expected output, specified in the test template as well. This also includes any error messages written to the console.
|
||||
|
||||
## Generating JUnit Tests
|
||||
|
||||
The test specification part makes heavy use of the StringTemplate engine to allow defining target language agnostic tests. For that all tests are described in template (`stg`) files. You can find them in the [templates](../runtime-testsuite/resources/org/antlr/v4/test/runtime/templates) subfolder of the runtime tests folder. Read more about the folder structure in the [adding-tests.md](adding-tests.md) file. As lined out there you have to run
|
||||
|
||||
```bash
|
||||
$ mvn -Pgen generate-test-sources
|
||||
```
|
||||
everytime you change any of the test templates or your target language specific template (which is used to translate certain text to your specific language). And a small hint: this command can be executed from the ANTLR source root as well. No need to dig into a subfolder.
|
||||
|
||||
## Running the Generated Tests
|
||||
|
||||
After generation you can run the tests as written above (`mvn install` or `mvn test`, both recompile ANTLR if necessary), which takes about 40 minutes for the full set (of which 30 mins are alone consumed by the C++ target tests). Which tests actually run is controlled by the [runtime tests pom.xml file](../runtime-testsuite/pom.xml). Look for the `maven-surefire-plugin` plugin entry and especially its includes. If you ever want to run tests only for a specific target, comment out all other `<include>` elements. For a specific test change the wildcard to that specific test name. This is especially helpful when debugging a test (e.g. when it fails) or when creating/changing tests. Additionally, some targets require to install additional dependencies you may not want to add to your box (e.g. mono, python 3.5) just to run e.g. the Java or C++ tests.
|
|
@ -71,6 +71,7 @@
|
|||
<configuration>
|
||||
<includes>
|
||||
<include>**/csharp/Test*.java</include>
|
||||
<include>**/cpp/Test*.java</include>
|
||||
<include>**/java/Test*.java</include>
|
||||
<include>**/javascript/node/Test*.java</include>
|
||||
<include>**/python2/Test*.java</include>
|
||||
|
|
|
@ -0,0 +1,425 @@
|
|||
IgnoredTests ::= [
|
||||
default: false
|
||||
]
|
||||
|
||||
TestFile(file) ::= <<
|
||||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.cpp;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
<if(file.Options.("ImportErrorQueue"))>
|
||||
import org.antlr.v4.test.runtime.java.ErrorQueue;
|
||||
<endif>
|
||||
<if(file.Options.("ImportGrammar"))>
|
||||
import org.antlr.v4.tool.Grammar;
|
||||
<endif>
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class Test<file.name> extends BaseCppTest {
|
||||
|
||||
<file.tests:{test | <test>}; separator="\n", wrap, anchor>
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
LexerTestMethod(test) ::= <<
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
<testAnnotations(test)>
|
||||
public void test<test.name>() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
<test.SlaveGrammars:{grammar |
|
||||
String slave_<grammar> = <writeStringLiteral(test.SlaveGrammars.(grammar))>;
|
||||
writeFile(tmpdir, "<grammar>.g4", slave_<grammar>);
|
||||
}; separator="\n">
|
||||
<test.Grammar:{grammar |
|
||||
<buildStringLiteral(test.Grammar.(grammar), "grammar")>
|
||||
|
||||
<if(test.AfterGrammar)>
|
||||
<test.AfterGrammar>
|
||||
<endif>
|
||||
String input =<writeStringLiteral(test.Input)>;
|
||||
String found = execLexer("<grammar>.g4", grammar, "<grammar><if(test.Options.("CombinedGrammar"))>Lexer<endif>", input, <writeBoolean(test.Options.("ShowDFA"))>);
|
||||
assertEquals(<writeStringLiteral(test.Output)>, found);
|
||||
<if(!isEmpty.(test.Errors))>
|
||||
assertEquals(<writeStringLiteral(test.Errors)>, this.stderrDuringParse);
|
||||
<else>
|
||||
assertNull(this.stderrDuringParse);
|
||||
<endif>
|
||||
}>
|
||||
}
|
||||
|
||||
>>
|
||||
|
||||
CompositeLexerTestMethod(test) ::= <<
|
||||
<LexerTestMethod(test)>
|
||||
>>
|
||||
|
||||
ParserTestMethod(test) ::= <<
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
<testAnnotations(test)>
|
||||
public void test<test.name>() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
<test.SlaveGrammars:{grammar |
|
||||
String slave_<grammar> =<writeStringLiteral(test.SlaveGrammars.(grammar))>;
|
||||
<if(test.Options.("SlaveIsLexer"))>
|
||||
rawGenerateAndBuildRecognizer("<grammar>.g4", slave_<grammar>, null, "<grammar>");
|
||||
<else>
|
||||
writeFile(tmpdir, "<grammar>.g4", slave_<grammar>);
|
||||
<endif>
|
||||
}; separator="\n">
|
||||
<test.Grammar:{grammar |
|
||||
<buildStringLiteral(test.Grammar.(grammar), "grammar")>
|
||||
|
||||
<test.AfterGrammar>
|
||||
|
||||
String input =<writeStringLiteral(test.Input)>;
|
||||
String found = execParser("<grammar>.g4", grammar, "<grammar><if(!test.slaveIsLexer)>Parser<endif>", "<if(test.slaveIsLexer)><first(test.slaveGrammars).grammarName><else><grammar>Lexer<endif>", "<grammar>Listener", "<grammar>Visitor", "<test.Rule>", input, <writeBoolean(test.Options.("Debug"))>);
|
||||
|
||||
assertEquals(<writeStringLiteral(test.Output)>, found);
|
||||
<if(!isEmpty.(test.Errors))>
|
||||
assertEquals(<writeStringLiteral(test.Errors)>, this.stderrDuringParse);
|
||||
<else>
|
||||
assertNull(this.stderrDuringParse);
|
||||
<endif>
|
||||
}>
|
||||
}
|
||||
|
||||
>>
|
||||
|
||||
CompositeParserTestMethod(test) ::= <<
|
||||
<ParserTestMethod(test)>
|
||||
>>
|
||||
|
||||
AbstractParserTestMethod(test) ::= <<
|
||||
/* this file and method are generated, any edit will be overwritten by the next generation */
|
||||
String test<test.name>(String input) throws Exception {
|
||||
String grammar = <test.grammar.lines:{ line | "<line>};separator="\\n\" +\n", wrap, anchor>";
|
||||
return execParser("<test.grammar.grammarName>.g4", grammar, "<test.grammar.grammarName>Parser", "<test.grammar.grammarName>Lexer", "<test.startRule>", input, <test.debug>);
|
||||
}
|
||||
|
||||
>>
|
||||
|
||||
ConcreteParserTestMethod(test) ::= <<
|
||||
/* this file and method are generated, any edit will be overwritten by the next generation */
|
||||
@Test
|
||||
public void test<test.name>() throws Exception {
|
||||
String found = test<test.baseName>("<test.input>");
|
||||
assertEquals("<test.expectedOutput>", found);
|
||||
<if(test.expectedErrors)>
|
||||
assertEquals("<test.expectedErrors>", this.stderrDuringParse);
|
||||
<else>
|
||||
assertNull(this.stderrDuringParse);
|
||||
<endif>
|
||||
}
|
||||
|
||||
>>
|
||||
|
||||
testAnnotations(test) ::= <%
|
||||
@Test
|
||||
<if(test.Options.("Ignore"))>
|
||||
<\n>@Ignore(<writeStringLiteral(test.Options.("Ignore"))>)
|
||||
<elseif(IgnoredTests.(({<file.name>.<test.name>})))>
|
||||
<\n>@Ignore(<writeStringLiteral(IgnoredTests.(({<file.name>.<test.name>})))>)
|
||||
<endif>
|
||||
%>
|
||||
|
||||
buildStringLiteral(text, variable) ::= <<
|
||||
StringBuilder <variable>Builder = new StringBuilder(<strlen.(text)>);
|
||||
<lines.(text):{line|<variable>Builder.append("<escape.(line)>");}; separator="\n">
|
||||
String <variable> = <variable>Builder.toString();
|
||||
>>
|
||||
|
||||
writeStringLiteral(text) ::= <%
|
||||
<if(isEmpty.(text))>
|
||||
""
|
||||
<else>
|
||||
<writeLines(lines.(text))>
|
||||
<endif>
|
||||
%>
|
||||
|
||||
writeLines(textLines) ::= <%
|
||||
<if(rest(textLines))>
|
||||
<textLines:{line|
|
||||
<\n> "<escape.(line)>}; separator="\" +">"
|
||||
<else>
|
||||
"<escape.(first(textLines))>"
|
||||
<endif>
|
||||
%>
|
||||
|
||||
string(text) ::= <<
|
||||
"<escape.(text)>"
|
||||
>>
|
||||
|
||||
writeBoolean(o) ::= "<if(o && !isEmpty.(o))>true<else>false<endif>"
|
||||
|
||||
writeln(s) ::= "std::cout \<\< <s> \<\< std::endl;"
|
||||
write(s) ::= "std::cout \<\< <s>;"
|
||||
writeList(s) ::= << std::cout \<\< <s; separator=" \<\< "> \<\< std::endl;>>
|
||||
|
||||
False() ::= "false"
|
||||
True() ::= "true"
|
||||
Not(v) ::= "!<v>"
|
||||
Assert(s) ::= ""
|
||||
Cast(t,v) ::= "std::dynamic_pointer_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>"
|
||||
|
||||
DeclareLocal(s,v) ::= "<s> = <v>"
|
||||
|
||||
AssertIsList(v) ::= "assert(<v>.size() >= 0);" // Use a method that exists only on a list (vector actually).
|
||||
AssignLocal(s,v) ::= "<s> = <v>;"
|
||||
|
||||
InitIntMember(n,v) ::= "int <n> = <v>;"
|
||||
InitBooleanMember(n,v) ::= "bool <n> = <v>;"
|
||||
|
||||
GetMember(n) ::= "<n>"
|
||||
SetMember(n,v) ::= "<n> = <v>;"
|
||||
AddMember(n,v) ::= "<n> += <v>;"
|
||||
PlusMember(v,n) ::= "<v> + <n>"
|
||||
MemberEquals(n,v) ::= "<n> == <v>"
|
||||
ModMemberEquals(n,m,v) ::= "<n> % <m> == <v>"
|
||||
ModMemberNotEquals(n,m,v) ::= "<n> % <m> != <v>"
|
||||
|
||||
DumpDFA() ::= "dumpDFA();"
|
||||
Pass() ::= "/* do nothing */"
|
||||
|
||||
StringList() ::= "std::vector\<std::string>"
|
||||
BuildParseTrees() ::= "setBuildParseTree(true);"
|
||||
BailErrorStrategy() ::= "_errHandler = std::make_shared\<BailErrorStrategy>();"
|
||||
|
||||
ToStringTree(s) ::= "<s>->toStringTree(this)"
|
||||
Column() ::= "getCharPositionInLine()"
|
||||
Text() ::= "getText()"
|
||||
ValEquals(a,b) ::= "<a> == <b>"
|
||||
TextEquals(a) ::= "getText() == \"<a>\""
|
||||
PlusText(a) ::="\"<a>\" + getText()"
|
||||
InputText() ::= "_input->getText()"
|
||||
LTEquals(i, v) ::= "_input->LT(<i>)->getText() == <v>"
|
||||
LANotEquals(i, v) ::= "_input->LA(<i>) != <v>"
|
||||
TokenStartColumnEquals(i) ::= "tokenStartCharPositionInLine == <i>"
|
||||
|
||||
ImportListener(X) ::= ""
|
||||
|
||||
GetExpectedTokenNames() ::= "getExpectedTokens().toString(_tokenNames)"
|
||||
|
||||
RuleInvocationStack() ::= "Arrays::listToString(getRuleInvocationStack(), \", \")"
|
||||
|
||||
LL_EXACT_AMBIG_DETECTION() ::= <<getInterpreter\<atn::ParserATNSimulator>()->setPredictionMode(atn::PredictionMode::LL_EXACT_AMBIG_DETECTION);>>
|
||||
|
||||
ParserPropertyMember() ::= <<
|
||||
@members {
|
||||
bool Property() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
ParserPropertyCall(p, call) ::= "<call>"
|
||||
|
||||
PositionAdjustingLexer() ::= <<
|
||||
protected:
|
||||
class PositionAdjustingLexerATNSimulator : public atn::LexerATNSimulator {
|
||||
public:
|
||||
PositionAdjustingLexerATNSimulator(Lexer *recog, const atn::ATN &atn, std::vector\<dfa::DFA> &decisionToDFA,
|
||||
Ref\<atn::PredictionContextCache> sharedContextCache)
|
||||
: atn::LexerATNSimulator(recog, atn, decisionToDFA, sharedContextCache) {
|
||||
}
|
||||
|
||||
void resetAcceptPosition(CharStream *input, int index, int line, int charPositionInLine) {
|
||||
input->seek(index);
|
||||
_line = line;
|
||||
_charPositionInLine = charPositionInLine;
|
||||
consume(input);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public:
|
||||
virtual Ref\<Token> nextToken() override {
|
||||
if (dynamic_cast\<PositionAdjustingLexerATNSimulator *>(_interpreter) == nullptr) {
|
||||
delete _interpreter;
|
||||
_interpreter = new PositionAdjustingLexerATNSimulator(this, _atn, _decisionToDFA, _sharedContextCache);
|
||||
}
|
||||
|
||||
return Lexer::nextToken();
|
||||
}
|
||||
|
||||
virtual Ref\<Token> emit() override {
|
||||
switch (type) {
|
||||
case TOKENS:
|
||||
handleAcceptPositionForKeyword("tokens");
|
||||
break;
|
||||
|
||||
case LABEL:
|
||||
handleAcceptPositionForIdentifier();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return Lexer::emit();
|
||||
}
|
||||
|
||||
private:
|
||||
bool handleAcceptPositionForIdentifier() {
|
||||
std::string tokenText = getText();
|
||||
int identifierLength = 0;
|
||||
while (identifierLength \< tokenText.length() && isIdentifierChar(tokenText[identifierLength])) {
|
||||
identifierLength++;
|
||||
}
|
||||
|
||||
if (getInputStream()->index() > tokenStartCharIndex + identifierLength) {
|
||||
int offset = identifierLength - 1;
|
||||
getInterpreter\<PositionAdjustingLexerATNSimulator>()->resetAcceptPosition(getInputStream(),
|
||||
tokenStartCharIndex + offset, tokenStartLine, tokenStartCharPositionInLine + offset);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool handleAcceptPositionForKeyword(const std::string &keyword) {
|
||||
if (getInputStream()->index() > tokenStartCharIndex + keyword.length()) {
|
||||
long offset = keyword.size() - 1;
|
||||
getInterpreter\<PositionAdjustingLexerATNSimulator>()->resetAcceptPosition(getInputStream(),
|
||||
tokenStartCharIndex + offset, tokenStartLine, tokenStartCharPositionInLine + offset);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool isIdentifierChar(char c) {
|
||||
return std::isalnum(c) || c == '_';
|
||||
}
|
||||
|
||||
public:
|
||||
>>
|
||||
|
||||
BasicListener(X) ::= <<
|
||||
@parser::definitions {
|
||||
class LeafListener : public TBaseListener {
|
||||
public:
|
||||
virtual void visitTerminal(Ref\<tree::TerminalNode> node) override {
|
||||
std::cout \<\< node->getSymbol()->getText() \<\< std::endl;
|
||||
}
|
||||
};
|
||||
}
|
||||
>>
|
||||
|
||||
WalkListener(s) ::= <<
|
||||
tree::ParseTreeWalker::DEFAULT->walk(std::make_shared\<LeafListener>(), <s>);
|
||||
>>
|
||||
|
||||
TreeNodeWithAltNumField(X) ::= <<
|
||||
@parser::members {
|
||||
class MyRuleNode : public ParserRuleContext {
|
||||
public:
|
||||
int altNum;
|
||||
MyRuleNode(std::weak_ptr\<ParserRuleContext> parent, int invokingStateNumber)
|
||||
: ParserRuleContext(parent, invokingStateNumber) {
|
||||
}
|
||||
virtual int getAltNumber() const override { return altNum; }
|
||||
virtual void setAltNumber(int altNum) override { this->altNum = altNum; }
|
||||
};
|
||||
}
|
||||
>>
|
||||
|
||||
TokenGetterListener(X) ::= <<
|
||||
@parser::definitions {
|
||||
class LeafListener : public TBaseListener {
|
||||
public:
|
||||
virtual void exitA(TParser::AContext *ctx) override {
|
||||
if (ctx->getChildCount() == 2)
|
||||
std::cout \<\< ctx->INT(0)->getSymbol()->getText() \<\< " " \<\< ctx->INT(1)->getSymbol()->getText()
|
||||
\<\< " " \<\< Arrays::toString(ctx->INT()) \<\< std::endl;
|
||||
else
|
||||
std::cout \<\< ctx->ID()->getSymbol()->toString() \<\< std::endl;
|
||||
}
|
||||
};
|
||||
}
|
||||
>>
|
||||
|
||||
RuleGetterListener(X) ::= <<
|
||||
@parser::definitions {
|
||||
class LeafListener : public TBaseListener {
|
||||
public:
|
||||
virtual void exitA(TParser::AContext *ctx) override {
|
||||
if (ctx->getChildCount() == 2) {
|
||||
std::cout \<\< ctx->b(0)->start->getText() \<\< " " \<\< ctx->b(1)->start->getText() \<\< " " \<\< ctx->b()[0]->start->getText() \<\< std::endl;
|
||||
} else {
|
||||
std::cout \<\< ctx->b(0)->start->getText() \<\< std::endl;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
>>
|
||||
|
||||
|
||||
LRListener(X) ::= <<
|
||||
@parser::definitions {
|
||||
class LeafListener : public TBaseListener {
|
||||
public:
|
||||
virtual void exitE(TParser::EContext *ctx) override {
|
||||
if (ctx->getChildCount() == 3) {
|
||||
std::cout \<\< ctx->e(0)->start->getText() \<\< " " \<\< ctx->e(1)->start->getText() \<\< " " \<\< ctx->e()[0]->start->getText() \<\< std::endl;
|
||||
} else {
|
||||
std::cout \<\< ctx->INT()->getSymbol()->getText() \<\< std::endl;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
>>
|
||||
|
||||
LRWithLabelsListener(X) ::= <<
|
||||
@parser::definitions {
|
||||
class LeafListener : public TBaseListener {
|
||||
public:
|
||||
virtual void exitCall(TParser::CallContext *ctx) override {
|
||||
std::cout \<\< ctx->e()->start->getText() \<\< " " \<\< ctx->eList()->toString() \<\< std::endl;
|
||||
}
|
||||
virtual void exitInt(TParser::IntContext *ctx) override {
|
||||
std::cout \<\< ctx->INT()->getSymbol()->getText() \<\< std::endl;
|
||||
}
|
||||
};
|
||||
}
|
||||
>>
|
||||
|
||||
DeclareContextListGettersFunction() ::= <<
|
||||
void foo() {
|
||||
Ref\<SContext> s;
|
||||
std::vector\<Ref\<AContext\>> a = s->a();
|
||||
std::vector\<Ref\<BContext\>> b = s->b();
|
||||
}
|
||||
>>
|
||||
|
||||
Declare_foo() ::= <<void foo() {
|
||||
std::cout \<\< "foo";
|
||||
}
|
||||
>>
|
||||
|
||||
Invoke_foo() ::= "foo();"
|
||||
|
||||
Declare_pred() ::= <<
|
||||
bool pred(bool v) {
|
||||
std::cout \<\< "eval=" \<\< std::boolalpha \<\< v \<\< std::endl;
|
||||
return v;
|
||||
}
|
||||
>>
|
||||
|
||||
Invoke_pred(v) ::= <<pred(<v>)>>
|
||||
|
||||
ParserTokenType(t) ::= "Parser::<t>"
|
||||
ContextRuleFunction(ctx, rule) ::= "<ctx>-><rule>"
|
||||
StringType() ::= "std::string"
|
||||
ContextMember(ctx, subctx, member) ::= "<ctx>-><subctx>-><member>"
|
||||
|
||||
isEmpty ::= [
|
||||
"": true,
|
||||
default: false
|
||||
]
|
|
@ -148,8 +148,8 @@ string(text) ::= <<
|
|||
writeBoolean(o) ::= "<if(o && !isEmpty.(o))>true<else>false<endif>"
|
||||
|
||||
writeln(s) ::= <<Console.WriteLine(<s>);>>
|
||||
|
||||
write(s) ::= <<Console.Write(<s>);>>
|
||||
writeList(s) ::= <<Console.WriteLine(<s; separator="+">);>>
|
||||
|
||||
False() ::= "false"
|
||||
|
||||
|
@ -235,6 +235,8 @@ bool Property() {
|
|||
}
|
||||
>>
|
||||
|
||||
ParserPropertyCall(p, call) ::= "<p>.<call>"
|
||||
|
||||
PositionAdjustingLexer() ::= <<
|
||||
|
||||
public override IToken NextToken() {
|
||||
|
@ -315,11 +317,13 @@ public class PositionAdjustingLexerATNSimulator : LexerATNSimulator {
|
|||
>>
|
||||
|
||||
BasicListener(X) ::= <<
|
||||
@parser::members {
|
||||
public class LeafListener : TBaseListener {
|
||||
public override void VisitTerminal(ITerminalNode node) {
|
||||
Console.WriteLine(node.Symbol.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
WalkListener(s) ::= <<
|
||||
|
@ -341,6 +345,7 @@ public class MyRuleNode : ParserRuleContext {
|
|||
>>
|
||||
|
||||
TokenGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
public class LeafListener : TBaseListener {
|
||||
public override void ExitA(TParser.AContext ctx) {
|
||||
if (ctx.ChildCount==2)
|
||||
|
@ -359,9 +364,11 @@ public class LeafListener : TBaseListener {
|
|||
Console.WriteLine(ctx.ID().Symbol);
|
||||
}
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
RuleGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
public class LeafListener : TBaseListener {
|
||||
public override void ExitA(TParser.AContext ctx) {
|
||||
if (ctx.ChildCount==2) {
|
||||
|
@ -371,10 +378,12 @@ public class LeafListener : TBaseListener {
|
|||
Console.WriteLine(ctx.b(0).Start.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
|
||||
LRListener(X) ::= <<
|
||||
@parser::members {
|
||||
public class LeafListener : TBaseListener {
|
||||
public override void ExitE(TParser.EContext ctx) {
|
||||
if (ctx.ChildCount==3) {
|
||||
|
@ -384,9 +393,11 @@ public class LeafListener : TBaseListener {
|
|||
Console.WriteLine(ctx.INT().Symbol.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
LRWithLabelsListener(X) ::= <<
|
||||
@parser::members {
|
||||
public class LeafListener : TBaseListener {
|
||||
public override void ExitCall(TParser.CallContext ctx) {
|
||||
Console.Write("{0} {1}",ctx.e().Start.Text,ctx.eList());
|
||||
|
@ -395,6 +406,7 @@ public class LeafListener : TBaseListener {
|
|||
Console.WriteLine(ctx.INT().Symbol.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
DeclareContextListGettersFunction() ::= <<
|
||||
|
@ -416,6 +428,10 @@ Declare_pred() ::= <<bool pred(bool v) {
|
|||
>>
|
||||
|
||||
Invoke_pred(v) ::= <<this.pred(<v>)>>
|
||||
ParserTokenType(t) ::= "Parser.<t>"
|
||||
ContextRuleFunction(ctx, rule) ::= "<ctx>.<rule>"
|
||||
StringType() ::= "String"
|
||||
ContextMember(ctx, subctx, member) ::= "<ctx>.<subctx>.<member>"
|
||||
|
||||
isEmpty ::= [
|
||||
"": true,
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
IgnoredTests ::= [
|
||||
default: false
|
||||
]
|
||||
|
||||
TestFile(file) ::= <<
|
||||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.java;
|
||||
|
@ -151,8 +155,8 @@ string(text) ::= <<
|
|||
writeBoolean(o) ::= "<if(o && !isEmpty.(o))>true<else>false<endif>"
|
||||
|
||||
writeln(s) ::= <<System.out.println(<s>);>>
|
||||
|
||||
write(s) ::= <<System.out.print(<s>);>>
|
||||
writeList(s) ::= <<System.out.println(<s; separator="+">);>>
|
||||
|
||||
False() ::= "false"
|
||||
|
||||
|
@ -238,6 +242,8 @@ boolean Property() {
|
|||
}
|
||||
>>
|
||||
|
||||
ParserPropertyCall(p, call) ::= "<p>.<call>"
|
||||
|
||||
PositionAdjustingLexer() ::= <<
|
||||
|
||||
@Override
|
||||
|
@ -323,11 +329,13 @@ protected static class PositionAdjustingLexerATNSimulator extends LexerATNSimula
|
|||
>>
|
||||
|
||||
BasicListener(X) ::= <<
|
||||
@parser::members {
|
||||
public static class LeafListener extends TBaseListener {
|
||||
public void visitTerminal(TerminalNode node) {
|
||||
System.out.println(node.getSymbol().getText());
|
||||
}
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
WalkListener(s) ::= <<
|
||||
|
@ -349,6 +357,7 @@ public static class MyRuleNode extends ParserRuleContext {
|
|||
>>
|
||||
|
||||
TokenGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
public static class LeafListener extends TBaseListener {
|
||||
public void exitA(TParser.AContext ctx) {
|
||||
if (ctx.getChildCount()==2)
|
||||
|
@ -358,9 +367,11 @@ public static class LeafListener extends TBaseListener {
|
|||
System.out.println(ctx.ID().getSymbol());
|
||||
}
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
RuleGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
public static class LeafListener extends TBaseListener {
|
||||
public void exitA(TParser.AContext ctx) {
|
||||
if (ctx.getChildCount()==2) {
|
||||
|
@ -370,10 +381,12 @@ public static class LeafListener extends TBaseListener {
|
|||
System.out.println(ctx.b(0).start.getText());
|
||||
}
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
|
||||
LRListener(X) ::= <<
|
||||
@parser::members {
|
||||
public static class LeafListener extends TBaseListener {
|
||||
public void exitE(TParser.EContext ctx) {
|
||||
if (ctx.getChildCount()==3) {
|
||||
|
@ -383,9 +396,11 @@ public static class LeafListener extends TBaseListener {
|
|||
System.out.println(ctx.INT().getSymbol().getText());
|
||||
}
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
LRWithLabelsListener(X) ::= <<
|
||||
@parser::members {
|
||||
public static class LeafListener extends TBaseListener {
|
||||
public void exitCall(TParser.CallContext ctx) {
|
||||
System.out.printf("%s %s",ctx.e().start.getText(),ctx.eList());
|
||||
|
@ -394,6 +409,7 @@ public static class LeafListener extends TBaseListener {
|
|||
System.out.println(ctx.INT().getSymbol().getText());
|
||||
}
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
DeclareContextListGettersFunction() ::= <<
|
||||
|
@ -418,9 +434,10 @@ Declare_pred() ::= <<boolean pred(boolean v) {
|
|||
|
||||
Invoke_pred(v) ::= <<this.pred(<v>)>>
|
||||
|
||||
IgnoredTests ::= [
|
||||
default: false
|
||||
]
|
||||
ParserTokenType(t) ::= "Parser.<t>"
|
||||
ContextRuleFunction(ctx, rule) ::= "<ctx>.<rule>"
|
||||
StringType() ::= "String"
|
||||
ContextMember(ctx, subctx, member) ::= "<ctx>.<subctx>.<member>"
|
||||
|
||||
isEmpty ::= [
|
||||
"": true,
|
||||
|
|
|
@ -428,6 +428,8 @@ Declare_pred() ::= <<this.pred = function(v) {
|
|||
|
||||
Invoke_pred(v) ::= <<this.pred(<v>)>>
|
||||
|
||||
ParserToken(t) ::= "Parser.<t>"
|
||||
|
||||
isEmpty ::= [
|
||||
"": true,
|
||||
default: false
|
||||
|
|
|
@ -154,8 +154,8 @@ string(text) ::= <<
|
|||
writeBoolean(o) ::= "<if(o && !isEmpty.(o))>true<else>false<endif>"
|
||||
|
||||
writeln(s) ::= <<document.getElementById('output').value += <s> + '\\n';>>
|
||||
|
||||
write(s) ::= <<document.getElementById('output').value += <s>;>>
|
||||
writeList(s) ::= <<document.getElementById('output').value += <s; separator="+">;>>
|
||||
|
||||
False() ::= "false"
|
||||
|
||||
|
@ -225,7 +225,11 @@ LANotEquals(i, v) ::= <%this._input.LA(<i>)!=<v>%>
|
|||
|
||||
TokenStartColumnEquals(i) ::= <%this._tokenStartColumn===<i>%>
|
||||
|
||||
ImportListener(X) ::= <<var <X>Listener = require('./<X>Listener').<X>Listener;>>
|
||||
ImportListener(X) ::= <<
|
||||
@parser::header {
|
||||
var <X>Listener = require('./<X>Listener').<X>Listener;
|
||||
}
|
||||
>>
|
||||
|
||||
GetExpectedTokenNames() ::= "this.getExpectedTokens().toString(this.literalNames)"
|
||||
|
||||
|
@ -241,6 +245,8 @@ this.Property = function() {
|
|||
}
|
||||
>>
|
||||
|
||||
ParserPropertyCall(p, call) ::= "<p>.<call>"
|
||||
|
||||
PositionAdjustingLexer() ::= <<
|
||||
|
||||
PositionAdjustingLexer.prototype.resetAcceptPosition = function(index, line, column) {
|
||||
|
@ -306,6 +312,7 @@ PositionAdjustingLexer.isIdentifierChar = function(c) {
|
|||
>>
|
||||
|
||||
BasicListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.visitTerminal = function(node) {
|
||||
document.getElementById('output').value += node.symbol.text + '\\n';
|
||||
|
@ -314,7 +321,7 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
WalkListener(s) ::= <<
|
||||
|
@ -323,7 +330,6 @@ walker.walk(new this.LeafListener(), <s>);
|
|||
>>
|
||||
|
||||
TreeNodeWithAltNumField(X) ::= <<
|
||||
|
||||
@parser::header {
|
||||
MyRuleNode = function(parent, invokingState) {
|
||||
antlr4.ParserRuleContext.call(this, parent, invokingState);
|
||||
|
@ -337,6 +343,7 @@ MyRuleNode.prototype.constructor = MyRuleNode;
|
|||
>>
|
||||
|
||||
TokenGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitA = function(ctx) {
|
||||
var str;
|
||||
|
@ -351,10 +358,11 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
RuleGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitA = function(ctx) {
|
||||
var str;
|
||||
|
@ -369,11 +377,12 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
|
||||
LRListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitE = function(ctx) {
|
||||
var str;
|
||||
|
@ -388,10 +397,11 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
LRWithLabelsListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitCall = function(ctx) {
|
||||
var str = ctx.e().start.text + ' ' + ctx.eList();
|
||||
|
@ -405,7 +415,7 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
DeclareContextListGettersFunction() ::= <<
|
||||
|
@ -427,6 +437,10 @@ Declare_pred() ::= <<this.pred = function(v) {
|
|||
>>
|
||||
|
||||
Invoke_pred(v) ::= <<this.pred(<v>)>>
|
||||
ParserTokenType(t) ::= "Parser.<t>"
|
||||
ContextRuleFunction(ctx, rule) ::= "<ctx>.<rule>"
|
||||
StringType() ::= "String"
|
||||
ContextMember(ctx, subctx, member) ::= "<ctx>.<subctx>.<member>"
|
||||
|
||||
isEmpty ::= [
|
||||
"": true,
|
||||
|
|
|
@ -154,8 +154,8 @@ string(text) ::= <<
|
|||
writeBoolean(o) ::= "<if(o && !isEmpty.(o))>true<else>false<endif>"
|
||||
|
||||
writeln(s) ::= <<document.getElementById('output').value += <s> + '\\n';>>
|
||||
|
||||
write(s) ::= <<document.getElementById('output').value += <s>;>>
|
||||
writeList(s) ::= <<document.getElementById('output').value += <s; separator="+">;>>
|
||||
|
||||
False() ::= "false"
|
||||
|
||||
|
@ -227,7 +227,11 @@ LANotEquals(i, v) ::= <%this._input.LA(<i>)!=<v>%>
|
|||
|
||||
TokenStartColumnEquals(i) ::= <%this._tokenStartColumn===<i>%>
|
||||
|
||||
ImportListener(X) ::= <<var <X>Listener = require('./<X>Listener').<X>Listener;>>
|
||||
ImportListener(X) ::= <<
|
||||
@parser::header {
|
||||
var <X>Listener = require('./<X>Listener').<X>Listener;
|
||||
}
|
||||
>>
|
||||
|
||||
GetExpectedTokenNames() ::= "this.getExpectedTokens().toString(this.literalNames)"
|
||||
|
||||
|
@ -243,6 +247,8 @@ this.Property = function() {
|
|||
}
|
||||
>>
|
||||
|
||||
ParserPropertyCall(p, call) ::= "<p>.<call>"
|
||||
|
||||
PositionAdjustingLexer() ::= <<
|
||||
|
||||
PositionAdjustingLexer.prototype.resetAcceptPosition = function(index, line, column) {
|
||||
|
@ -308,6 +314,7 @@ PositionAdjustingLexer.isIdentifierChar = function(c) {
|
|||
>>
|
||||
|
||||
BasicListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.visitTerminal = function(node) {
|
||||
document.getElementById('output').value += node.symbol.text + '\\n';
|
||||
|
@ -316,7 +323,7 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
WalkListener(s) ::= <<
|
||||
|
@ -325,7 +332,6 @@ walker.walk(new this.LeafListener(), <s>);
|
|||
>>
|
||||
|
||||
TreeNodeWithAltNumField(X) ::= <<
|
||||
|
||||
@parser::header {
|
||||
MyRuleNode = function(parent, invokingState) {
|
||||
antlr4.ParserRuleContext.call(this, parent, invokingState);
|
||||
|
@ -339,6 +345,7 @@ MyRuleNode.prototype.constructor = MyRuleNode;
|
|||
>>
|
||||
|
||||
TokenGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitA = function(ctx) {
|
||||
var str;
|
||||
|
@ -353,10 +360,11 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
RuleGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitA = function(ctx) {
|
||||
var str;
|
||||
|
@ -371,11 +379,12 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
|
||||
LRListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitE = function(ctx) {
|
||||
var str;
|
||||
|
@ -390,10 +399,11 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
LRWithLabelsListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitCall = function(ctx) {
|
||||
var str = ctx.e().start.text + ' ' + ctx.eList();
|
||||
|
@ -407,7 +417,7 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
DeclareContextListGettersFunction() ::= <<
|
||||
|
@ -429,6 +439,10 @@ Declare_pred() ::= <<this.pred = function(v) {
|
|||
>>
|
||||
|
||||
Invoke_pred(v) ::= <<this.pred(<v>)>>
|
||||
ParserTokenType(t) ::= "Parser.<t>"
|
||||
ContextRuleFunction(ctx, rule) ::= "<ctx>.<rule>"
|
||||
StringType() ::= "String"
|
||||
ContextMember(ctx, subctx, member) ::= "<ctx>.<subctx>.<member>"
|
||||
|
||||
isEmpty ::= [
|
||||
"": true,
|
||||
|
|
|
@ -154,8 +154,8 @@ string(text) ::= <<
|
|||
writeBoolean(o) ::= "<if(o && !isEmpty.(o))>true<else>false<endif>"
|
||||
|
||||
writeln(s) ::= <<console.log(<s>);>>
|
||||
|
||||
write(s) ::= <<process.stdout.write(<s>);>>
|
||||
writeList(s) ::= <<console.log(<s; separator="+">);>>
|
||||
|
||||
False() ::= "false"
|
||||
|
||||
|
@ -225,7 +225,11 @@ LANotEquals(i, v) ::= <%this._input.LA(<i>)!=<v>%>
|
|||
|
||||
TokenStartColumnEquals(i) ::= <%this._tokenStartColumn===<i>%>
|
||||
|
||||
ImportListener(X) ::= <<var <X>Listener = require('./<X>Listener').<X>Listener;>>
|
||||
ImportListener(X) ::= <<
|
||||
@parser::header {
|
||||
var <X>Listener = require('./<X>Listener').<X>Listener;
|
||||
}
|
||||
>>
|
||||
|
||||
GetExpectedTokenNames() ::= "this.getExpectedTokens().toString(this.literalNames)"
|
||||
|
||||
|
@ -241,6 +245,8 @@ this.Property = function() {
|
|||
}
|
||||
>>
|
||||
|
||||
ParserPropertyCall(p, call) ::= "<p>.<call>"
|
||||
|
||||
PositionAdjustingLexer() ::= <<
|
||||
|
||||
PositionAdjustingLexer.prototype.resetAcceptPosition = function(index, line, column) {
|
||||
|
@ -306,6 +312,7 @@ PositionAdjustingLexer.isIdentifierChar = function(c) {
|
|||
>>
|
||||
|
||||
BasicListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.visitTerminal = function(node) {
|
||||
console.log(node.symbol.text);
|
||||
|
@ -314,7 +321,7 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
WalkListener(s) ::= <<
|
||||
|
@ -323,7 +330,6 @@ walker.walk(new this.LeafListener(), <s>);
|
|||
>>
|
||||
|
||||
TreeNodeWithAltNumField(X) ::= <<
|
||||
|
||||
@parser::header {
|
||||
MyRuleNode = function(parent, invokingState) {
|
||||
antlr4.ParserRuleContext.call(this, parent, invokingState);
|
||||
|
@ -341,6 +347,7 @@ MyRuleNode.prototype.setAltNumber = function(altNumber) { this.altNum = altNumbe
|
|||
>>
|
||||
|
||||
TokenGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitA = function(ctx) {
|
||||
var str;
|
||||
|
@ -355,10 +362,11 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
RuleGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitA = function(ctx) {
|
||||
var str;
|
||||
|
@ -373,11 +381,12 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
|
||||
LRListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitE = function(ctx) {
|
||||
var str;
|
||||
|
@ -392,10 +401,11 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
LRWithLabelsListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitCall = function(ctx) {
|
||||
var str = ctx.e().start.text + ' ' + ctx.eList();
|
||||
|
@ -409,7 +419,7 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
DeclareContextListGettersFunction() ::= <<
|
||||
|
@ -431,6 +441,10 @@ Declare_pred() ::= <<this.pred = function(v) {
|
|||
>>
|
||||
|
||||
Invoke_pred(v) ::= <<this.pred(<v>)>>
|
||||
ParserTokenType(t) ::= "Parser.<t>"
|
||||
ContextRuleFunction(ctx, rule) ::= "<ctx>.<rule>"
|
||||
StringType() ::= "String"
|
||||
ContextMember(ctx, subctx, member) ::= "<ctx>.<subctx>.<member>"
|
||||
|
||||
isEmpty ::= [
|
||||
"": true,
|
||||
|
|
|
@ -154,8 +154,8 @@ string(text) ::= <<
|
|||
writeBoolean(o) ::= "<if(o && !isEmpty.(o))>true<else>false<endif>"
|
||||
|
||||
writeln(s) ::= <<document.getElementById('output').value += <s> + '\\n';>>
|
||||
|
||||
write(s) ::= <<document.getElementById('output').value += <s>;>>
|
||||
writeList(s) ::= <<document.getElementById('output').value += <s; separator="+">;>>
|
||||
|
||||
False() ::= "false"
|
||||
|
||||
|
@ -225,7 +225,11 @@ LANotEquals(i, v) ::= <%this._input.LA(<i>)!=<v>%>
|
|||
|
||||
TokenStartColumnEquals(i) ::= <%this._tokenStartColumn===<i>%>
|
||||
|
||||
ImportListener(X) ::= <<var <X>Listener = require('./<X>Listener').<X>Listener;>>
|
||||
ImportListener(X) ::= <<
|
||||
@parser::header {
|
||||
var <X>Listener = require('./<X>Listener').<X>Listener;
|
||||
}
|
||||
>>
|
||||
|
||||
GetExpectedTokenNames() ::= "this.getExpectedTokens().toString(this.literalNames)"
|
||||
|
||||
|
@ -241,6 +245,8 @@ this.Property = function() {
|
|||
}
|
||||
>>
|
||||
|
||||
ParserPropertyCall(p, call) ::= "<p>.<call>"
|
||||
|
||||
PositionAdjustingLexer() ::= <<
|
||||
|
||||
PositionAdjustingLexer.prototype.resetAcceptPosition = function(index, line, column) {
|
||||
|
@ -306,6 +312,7 @@ PositionAdjustingLexer.isIdentifierChar = function(c) {
|
|||
>>
|
||||
|
||||
BasicListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.visitTerminal = function(node) {
|
||||
document.getElementById('output').value += node.symbol.text + '\\n';
|
||||
|
@ -314,7 +321,7 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
WalkListener(s) ::= <<
|
||||
|
@ -323,7 +330,6 @@ walker.walk(new this.LeafListener(), <s>);
|
|||
>>
|
||||
|
||||
TreeNodeWithAltNumField(X) ::= <<
|
||||
|
||||
@parser::header {
|
||||
MyRuleNode = function(parent, invokingState) {
|
||||
antlr4.ParserRuleContext.call(this, parent, invokingState);
|
||||
|
@ -338,6 +344,7 @@ MyRuleNode.prototype.constructor = MyRuleNode;
|
|||
|
||||
|
||||
TokenGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitA = function(ctx) {
|
||||
var str;
|
||||
|
@ -352,10 +359,11 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
RuleGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitA = function(ctx) {
|
||||
var str;
|
||||
|
@ -370,11 +378,12 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
|
||||
LRListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitE = function(ctx) {
|
||||
var str;
|
||||
|
@ -389,10 +398,11 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
LRWithLabelsListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitCall = function(ctx) {
|
||||
var str = ctx.e().start.text + ' ' + ctx.eList();
|
||||
|
@ -406,7 +416,7 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
DeclareContextListGettersFunction() ::= <<
|
||||
|
@ -428,6 +438,10 @@ Declare_pred() ::= <<this.pred = function(v) {
|
|||
>>
|
||||
|
||||
Invoke_pred(v) ::= <<this.pred(<v>)>>
|
||||
ParserTokenType(t) ::= "Parser.<t>"
|
||||
ContextRuleFunction(ctx, rule) ::= "<ctx>.<rule>"
|
||||
StringType() ::= "String"
|
||||
ContextMember(ctx, subctx, member) ::= "<ctx>.<subctx>.<member>"
|
||||
|
||||
isEmpty ::= [
|
||||
"": true,
|
||||
|
|
|
@ -158,8 +158,8 @@ string(text) ::= <<
|
|||
writeBoolean(o) ::= "<if(o && !isEmpty.(o))>true<else>false<endif>"
|
||||
|
||||
writeln(s) ::= <<print(<s>)>>
|
||||
|
||||
write(s) ::= <<print(<s>,end='')>>
|
||||
writeList(s) ::= <<print(<s: {v | str(<v>)}; separator="+">)>>
|
||||
|
||||
False() ::= "False"
|
||||
|
||||
|
@ -245,6 +245,8 @@ def Property(self):
|
|||
}
|
||||
>>
|
||||
|
||||
ParserPropertyCall(p, call) ::= "<p>.<call>"
|
||||
|
||||
PositionAdjustingLexer() ::= <<
|
||||
|
||||
def resetAcceptPosition(self, index, line, column):
|
||||
|
@ -296,6 +298,7 @@ def isIdentifierChar(c):
|
|||
>>
|
||||
|
||||
BasicListener(X) ::= <<
|
||||
@parser::members {
|
||||
if __name__ is not None and "." in __name__:
|
||||
from .<X>Listener import <X>Listener
|
||||
else:
|
||||
|
@ -304,7 +307,7 @@ else:
|
|||
class LeafListener(TListener):
|
||||
def visitTerminal(self, node):
|
||||
print(node.symbol.text)
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
WalkListener(s) ::= <<
|
||||
|
@ -326,6 +329,7 @@ class MyRuleNode(ParserRuleContext):
|
|||
>>
|
||||
|
||||
TokenGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
if __name__ is not None and "." in __name__:
|
||||
from .<X>Listener import <X>Listener
|
||||
else:
|
||||
|
@ -337,10 +341,11 @@ class LeafListener(TListener):
|
|||
print(ctx.INT(0).symbol.text + ' ' + ctx.INT(1).symbol.text + ' ' + str_list(ctx.INT()))
|
||||
else:
|
||||
print(str(ctx.ID().symbol))
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
RuleGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
if __name__ is not None and "." in __name__:
|
||||
from .<X>Listener import <X>Listener
|
||||
else:
|
||||
|
@ -352,11 +357,12 @@ class LeafListener(TListener):
|
|||
print(ctx.b(0).start.text + ' ' + ctx.b(1).start.text + ' ' + ctx.b()[0].start.text)
|
||||
else:
|
||||
print(ctx.b(0).start.text)
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
|
||||
LRListener(X) ::= <<
|
||||
@parser::members {
|
||||
if __name__ is not None and "." in __name__:
|
||||
from .<X>Listener import <X>Listener
|
||||
else:
|
||||
|
@ -368,10 +374,11 @@ class LeafListener(TListener):
|
|||
print(ctx.e(0).start.text + ' ' + ctx.e(1).start.text + ' ' + ctx.e()[0].start.text)
|
||||
else:
|
||||
print(ctx.INT().symbol.text)
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
LRWithLabelsListener(X) ::= <<
|
||||
@parser::members {
|
||||
if __name__ is not None and "." in __name__:
|
||||
from .<X>Listener import <X>Listener
|
||||
else:
|
||||
|
@ -382,7 +389,7 @@ class LeafListener(TListener):
|
|||
print(ctx.e().start.text + ' ' + str(ctx.eList()))
|
||||
def exitInt(self, ctx):
|
||||
print(ctx.INT().symbol.text)
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
DeclareContextListGettersFunction() ::= <<
|
||||
|
@ -405,6 +412,10 @@ Declare_pred() ::= <<def pred(self, v):
|
|||
>>
|
||||
|
||||
Invoke_pred(v) ::= <<self.pred(<v>)>>
|
||||
ParserTokenType(t) ::= "Parser.<t>"
|
||||
ContextRuleFunction(ctx, rule) ::= "<ctx>.<rule>"
|
||||
StringType() ::= "String"
|
||||
ContextMember(ctx, subctx, member) ::= "<ctx>.<subctx>.<member>"
|
||||
|
||||
isEmpty ::= [
|
||||
"": true,
|
||||
|
|
|
@ -158,8 +158,8 @@ string(text) ::= <<
|
|||
writeBoolean(o) ::= "<if(o && !isEmpty.(o))>true<else>false<endif>"
|
||||
|
||||
writeln(s) ::= <<print(<s>)>>
|
||||
|
||||
write(s) ::= <<print(<s>,end='')>>
|
||||
writeList(s) ::= <<print(<s: {v | str(<v>)}; separator="+">)>>
|
||||
|
||||
False() ::= "False"
|
||||
|
||||
|
@ -229,8 +229,11 @@ LANotEquals(i, v) ::= <%self._input.LA(<i>)!=<v>%>
|
|||
|
||||
TokenStartColumnEquals(i) ::= <%self._tokenStartColumn==<i>%>
|
||||
|
||||
ImportListener(X) ::= <<class MockListener:
|
||||
ImportListener(X) ::= <<
|
||||
@parser::header {
|
||||
class MockListener:
|
||||
pass
|
||||
}
|
||||
>>
|
||||
|
||||
GetExpectedTokenNames() ::= "self.getExpectedTokens().toString(self.literalNames, self.symbolicNames)"
|
||||
|
@ -247,6 +250,8 @@ def Property(self):
|
|||
}
|
||||
>>
|
||||
|
||||
ParserPropertyCall(p, call) ::= "<p>.<call>"
|
||||
|
||||
PositionAdjustingLexer() ::= <<
|
||||
|
||||
def resetAcceptPosition(self, index, line, column):
|
||||
|
@ -298,10 +303,11 @@ def isIdentifierChar(c):
|
|||
>>
|
||||
|
||||
BasicListener(X) ::= <<
|
||||
@parser::members {
|
||||
class LeafListener(MockListener):
|
||||
def visitTerminal(self, node):
|
||||
print(node.symbol.text)
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
WalkListener(s) ::= <<
|
||||
|
@ -328,43 +334,47 @@ class MyRuleNode(ParserRuleContext):
|
|||
>>
|
||||
|
||||
TokenGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
class LeafListener(MockListener):
|
||||
def exitA(self, ctx):
|
||||
if ctx.getChildCount()==2:
|
||||
print(ctx.INT(0).symbol.text + ' ' + ctx.INT(1).symbol.text + ' ' + str_list(ctx.INT()))
|
||||
else:
|
||||
print(str(ctx.ID().symbol))
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
RuleGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
class LeafListener(MockListener):
|
||||
def exitA(self, ctx):
|
||||
if ctx.getChildCount()==2:
|
||||
print(ctx.b(0).start.text + ' ' + ctx.b(1).start.text + ' ' + ctx.b()[0].start.text)
|
||||
else:
|
||||
print(ctx.b(0).start.text)
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
|
||||
LRListener(X) ::= <<
|
||||
@parser::members {
|
||||
class LeafListener(MockListener):
|
||||
def exitE(self, ctx):
|
||||
if ctx.getChildCount()==3:
|
||||
print(ctx.e(0).start.text + ' ' + ctx.e(1).start.text + ' ' + ctx.e()[0].start.text)
|
||||
else:
|
||||
print(ctx.INT().symbol.text)
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
LRWithLabelsListener(X) ::= <<
|
||||
@parser::members {
|
||||
class LeafListener(MockListener):
|
||||
def exitCall(self, ctx):
|
||||
print(ctx.e().start.text + ' ' + str(ctx.eList()))
|
||||
def exitInt(self, ctx):
|
||||
print(ctx.INT().symbol.text)
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
DeclareContextListGettersFunction() ::= <<
|
||||
|
@ -387,6 +397,10 @@ Declare_pred() ::= <<def pred(self, v):
|
|||
>>
|
||||
|
||||
Invoke_pred(v) ::= <<self.pred(<v>)>>
|
||||
ParserTokenType(t) ::= "Parser.<t>"
|
||||
ContextRuleFunction(ctx, rule) ::= "<ctx>.<rule>"
|
||||
StringType() ::= "String"
|
||||
ContextMember(ctx, subctx, member) ::= "<ctx>.<subctx>.<member>"
|
||||
|
||||
isEmpty ::= [
|
||||
"": true,
|
||||
|
|
|
@ -25,5 +25,5 @@ e : a=e op=('*'|'/') b=e {}{<True()>}?
|
|||
| '(' x=e ')' {}{}
|
||||
;
|
||||
INT : '0'..'9'+ ;
|
||||
WS : (' '|'\n') -> skip ;
|
||||
WS : (' '|'\n') -> skip;
|
||||
>>
|
||||
|
|
|
@ -21,8 +21,8 @@ grammar(grammarName) ::= <<
|
|||
grammar <grammarName>;
|
||||
s : e {<writeln("$e.v")>};
|
||||
e returns [int v]
|
||||
: e '*' e {$v = <Cast("BinaryContext","$ctx")>.e(0).v * <Cast("BinaryContext","$ctx")>.e(1).v;} # binary
|
||||
| e '+' e {$v = <Cast("BinaryContext","$ctx")>.e(0).v + <Cast("BinaryContext","$ctx")>.e(1).v;} # binary
|
||||
: e '*' e {$v = <Cast("BinaryContext","$ctx"):ContextMember("e(0)", "v")> * <Cast("BinaryContext","$ctx"):ContextMember("e(1)", "v")>;} # binary
|
||||
| e '+' e {$v = <Cast("BinaryContext","$ctx"):ContextMember("e(0)", "v")> + <Cast("BinaryContext","$ctx"):ContextMember("e(1)", "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
|
||||
|
@ -33,5 +33,5 @@ ID : 'a'..'z'+ ;
|
|||
INT : '0'..'9'+ ;
|
||||
INC : '++' ;
|
||||
DEC : '--' ;
|
||||
WS : (' '|'\n') -> skip ;
|
||||
WS : (' '|'\n') -> skip;
|
||||
>>
|
||||
|
|
|
@ -13,7 +13,7 @@ Rule() ::= "s"
|
|||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
s : e {<writeln("$e.result")>} ;
|
||||
e returns [String result]
|
||||
e returns [<StringType()> result]
|
||||
: ID '=' e1=e {$result = "(" + $ID.text + "=" + $e1.result + ")";}
|
||||
| ID {$result = $ID.text;}
|
||||
| e1=e '+' e2=e {$result = "(" + $e1.result + "+" + $e2.result + ")";}
|
||||
|
|
|
@ -22,18 +22,14 @@ Errors() ::= ""
|
|||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
@parser::header {
|
||||
<ImportListener(grammarName)>
|
||||
}
|
||||
|
||||
@parser::members {
|
||||
<ImportListener(grammarName)>
|
||||
<BasicListener(grammarName)>
|
||||
}
|
||||
|
||||
s
|
||||
@after {
|
||||
<ToStringTree("$ctx.r"):writeln()>
|
||||
<WalkListener("$ctx.r")>
|
||||
<ContextRuleFunction("$ctx", "r"):ToStringTree():writeln()>
|
||||
<ContextRuleFunction("$ctx", "r"):WalkListener()>
|
||||
}
|
||||
: r=a ;
|
||||
a : INT INT
|
||||
|
|
|
@ -25,18 +25,14 @@ Errors() ::= ""
|
|||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
@parser::header {
|
||||
<ImportListener(grammarName)>
|
||||
}
|
||||
|
||||
@parser::members {
|
||||
<ImportListener(grammarName)>
|
||||
<LRListener(grammarName)>
|
||||
}
|
||||
|
||||
s
|
||||
@after {
|
||||
<ToStringTree("$ctx.r"):writeln()>
|
||||
<WalkListener("$ctx.r")>
|
||||
<ContextRuleFunction("$ctx", "r"):ToStringTree():writeln()>
|
||||
<ContextRuleFunction("$ctx", "r"):WalkListener()>
|
||||
}
|
||||
: r=e ;
|
||||
e : e op='*' e
|
||||
|
|
|
@ -24,18 +24,14 @@ Errors() ::= ""
|
|||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
@parser::header {
|
||||
<ImportListener(grammarName)>
|
||||
}
|
||||
|
||||
@parser::members {
|
||||
<ImportListener(grammarName)>
|
||||
<LRWithLabelsListener(grammarName)>
|
||||
}
|
||||
|
||||
s
|
||||
@after {
|
||||
<ToStringTree("$ctx.r"):writeln()>
|
||||
<WalkListener("$ctx.r")>
|
||||
<ContextRuleFunction("$ctx", "r"):ToStringTree():writeln()>
|
||||
<ContextRuleFunction("$ctx", "r"):WalkListener()>
|
||||
}
|
||||
: r=e ;
|
||||
e : e '(' eList ')' # Call
|
||||
|
|
|
@ -12,18 +12,14 @@ Rule() ::= "s"
|
|||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
@parser::header {
|
||||
<ImportListener(grammarName)>
|
||||
}
|
||||
|
||||
@parser::members {
|
||||
<ImportListener(grammarName)>
|
||||
<RuleGetterListener(grammarName)>
|
||||
}
|
||||
|
||||
s
|
||||
@after {
|
||||
<ToStringTree("$ctx.r"):writeln()>
|
||||
<WalkListener("$ctx.r")>
|
||||
<ContextRuleFunction("$ctx", "r"):ToStringTree():writeln()>
|
||||
<ContextRuleFunction("$ctx", "r"):WalkListener()>
|
||||
}
|
||||
: r=a ;
|
||||
a : b b // forces list
|
||||
|
|
|
@ -12,18 +12,14 @@ Rule() ::= "s"
|
|||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
@parser::header {
|
||||
<ImportListener(grammarName)>
|
||||
}
|
||||
|
||||
@parser::members {
|
||||
<ImportListener(grammarName)>
|
||||
<TokenGetterListener(grammarName)>
|
||||
}
|
||||
|
||||
s
|
||||
@after {
|
||||
<ToStringTree("$ctx.r"):writeln()>
|
||||
<WalkListener("$ctx.r")>
|
||||
<ContextRuleFunction("$ctx", "r"):ToStringTree():writeln()>
|
||||
<ContextRuleFunction("$ctx", "r"):WalkListener()>
|
||||
}
|
||||
: r=a ;
|
||||
a : INT INT
|
||||
|
|
|
@ -26,7 +26,7 @@ grammar(grammarName) ::= <<
|
|||
grammar <grammarName>;
|
||||
ifStatement
|
||||
@after {
|
||||
<AssertIsList("$ctx.elseIfStatement()")>
|
||||
<AssertIsList({<ContextRuleFunction("$ctx", "elseIfStatement()")>})>
|
||||
}
|
||||
: 'if' expression
|
||||
( ( 'then'
|
||||
|
|
|
@ -27,7 +27,7 @@ Errors() ::= ""
|
|||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
<ParserPropertyMember()>
|
||||
a : {$parser.Property()}? ID {<writeln("\"valid\"")>}
|
||||
a : {<ParserPropertyCall({$parser}, "Property()")>}? ID {<writeln("\"valid\"")>}
|
||||
;
|
||||
ID : 'a'..'z'+ ;
|
||||
WS : (' '|'\n') -> skip ;
|
||||
|
|
|
@ -25,7 +25,7 @@ grammar(grammarName) ::= <<
|
|||
grammar <grammarName>;
|
||||
s : stmt EOF ;
|
||||
stmt : ifStmt | ID;
|
||||
ifStmt : 'if' ID stmt ('else' stmt | { <LANotEquals("1", {<grammarName>Parser.ELSE})> }?);
|
||||
ifStmt : 'if' ID stmt ('else' stmt | { <LANotEquals("1", {<grammarName><ParserTokenType("ELSE")>})> }?);
|
||||
ELSE : 'else';
|
||||
ID : [a-zA-Z]+;
|
||||
WS : [ \\n\\t]+ -> skip;
|
||||
|
|
|
@ -18,7 +18,7 @@ file_
|
|||
@after {<ToStringTree("$ctx"):writeln()>}
|
||||
: para para EOF ;
|
||||
para: paraContent NL NL ;
|
||||
paraContent : ('s'|'x'|{<LANotEquals("2",{<grammarName>Parser.NL})>}? NL)+ ;
|
||||
paraContent : ('s'|'x'|{<LANotEquals("2", {<grammarName><ParserTokenType("NL")>})>}? NL)+ ;
|
||||
NL : '\n' ;
|
||||
s : 's' ;
|
||||
X : 'x' ;
|
||||
|
|
|
@ -33,7 +33,7 @@ grammar(grammarName) ::= <<
|
|||
grammar <grammarName>;
|
||||
@members {<InitIntMember("i","0")>}
|
||||
s : ({<AddMember("i","1")>
|
||||
<PlusMember("\"i=\"","i"):writeln()>} a)+ ;
|
||||
<writeList(["\"i=\"", "i"])>} a)+ ;
|
||||
a : {<ModMemberEquals("i","2","0")>}? ID {<writeln("\"alt 1\"")>}
|
||||
| {<ModMemberNotEquals("i","2","0")>}? ID {<writeln("\"alt 2\"")>}
|
||||
;
|
||||
|
|
|
@ -46,7 +46,7 @@ import org.stringtemplate.v4.gui.STViz;
|
|||
|
||||
public class TestGenerator {
|
||||
|
||||
public final static String[] targets = {"CSharp", "Java", "Python2", "Python3", "JavaScript/Node", "JavaScript/Safari", "JavaScript/Firefox", "JavaScript/Explorer", "JavaScript/Chrome"};
|
||||
public final static String[] targets = {"Cpp", "CSharp", "Java", "Python2", "Python3", "JavaScript/Node", "JavaScript/Safari", "JavaScript/Firefox", "JavaScript/Explorer", "JavaScript/Chrome"};
|
||||
|
||||
/** Execute from antlr4 root dir:
|
||||
* *
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,70 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.cpp;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestCompositeLexers extends BaseCppTest {
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testLexerDelegatorInvokesDelegateRule() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_S =
|
||||
"lexer grammar S;\n" +
|
||||
"A : 'a' {std::cout << \"S.A\" << std::endl;};\n" +
|
||||
"C : 'c' ;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(61);
|
||||
grammarBuilder.append("lexer grammar M;\n");
|
||||
grammarBuilder.append("import S;\n");
|
||||
grammarBuilder.append("B : 'b';\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
String input ="abc";
|
||||
String found = execLexer("M.g4", grammar, "M", input, false);
|
||||
assertEquals(
|
||||
"S.A\n" +
|
||||
"[@0,0:0='a',<3>,1:0]\n" +
|
||||
"[@1,1:1='b',<1>,1:1]\n" +
|
||||
"[@2,2:2='c',<4>,1:2]\n" +
|
||||
"[@3,3:2='<EOF>',<-1>,1:3]\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testLexerDelegatorRuleOverridesDelegate() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_S =
|
||||
"lexer grammar S;\n" +
|
||||
"A : 'a' {std::cout << \"S.A\" << std::endl;} ;\n" +
|
||||
"B : 'b' {std::cout << \"S.B\" << std::endl;} ;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(99);
|
||||
grammarBuilder.append("lexer grammar M;\n");
|
||||
grammarBuilder.append("import S;\n");
|
||||
grammarBuilder.append("A : 'a' B {std::cout << \"M.A\" << std::endl;} ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
String input ="ab";
|
||||
String found = execLexer("M.g4", grammar, "M", input, false);
|
||||
assertEquals(
|
||||
"M.A\n" +
|
||||
"[@0,0:1='ab',<1>,1:0]\n" +
|
||||
"[@1,2:1='<EOF>',<-1>,1:2]\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,489 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.cpp;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.antlr.v4.test.runtime.java.ErrorQueue;
|
||||
import org.antlr.v4.tool.Grammar;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestCompositeParsers extends BaseCppTest {
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testBringInLiteralsFromDelegate() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : '=' 'a' {std::cout << \"S.a\";};";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(54);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S;\n");
|
||||
grammarBuilder.append("s : a ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="=a";
|
||||
String found = execParser("M.g4", grammar, "MParser", "MLexer", "MListener", "MVisitor", "s", input, false);
|
||||
|
||||
assertEquals("S.a\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testCombinedImportsCombined() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"tokens { A, B, C }\n" +
|
||||
"x : 'x' INT {std::cout << \"S.x\" << std::endl;};\n" +
|
||||
"INT : '0'..'9'+ ;\n" +
|
||||
"WS : (' '|'\\n') -> skip ;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(31);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S;\n");
|
||||
grammarBuilder.append("s : x INT;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
writeFile(tmpdir, "M.g4", grammar);
|
||||
ErrorQueue equeue = new ErrorQueue();
|
||||
new Grammar(tmpdir+"/M.g4", grammar, equeue);
|
||||
assertEquals("unexpected errors: " + equeue, 0, equeue.errors.size());
|
||||
|
||||
|
||||
String input ="x 34 9";
|
||||
String found = execParser("M.g4", grammar, "MParser", "MLexer", "MListener", "MVisitor", "s", input, false);
|
||||
|
||||
assertEquals("S.x\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testDelegatesSeeSameTokenType() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { C, B, A } // reverse order\n" +
|
||||
"y : A {std::cout << \"T.y\" << std::endl;};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"tokens { A, B, C }\n" +
|
||||
"x : A {std::cout << \"S.x\" << std::endl;};";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(598);
|
||||
grammarBuilder.append("// The lexer will create rules to match letters a, b, c.\n");
|
||||
grammarBuilder.append("// The associated token types A, B, C must have the same value\n");
|
||||
grammarBuilder.append("// and all import'd parsers. Since ANTLR regenerates all imports\n");
|
||||
grammarBuilder.append("// for use with the delegator M, it can generate the same token type\n");
|
||||
grammarBuilder.append("// mapping in each parser:\n");
|
||||
grammarBuilder.append("// public static final int C=6;\n");
|
||||
grammarBuilder.append("// public static final int EOF=-1;\n");
|
||||
grammarBuilder.append("// public static final int B=5;\n");
|
||||
grammarBuilder.append("// public static final int WS=7;\n");
|
||||
grammarBuilder.append("// public static final int A=4;\n");
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S,T;\n");
|
||||
grammarBuilder.append("s : x y ; // matches AA, which should be 'aa'\n");
|
||||
grammarBuilder.append("B : 'b' ; // another order: B, A, C\n");
|
||||
grammarBuilder.append("A : 'a' ; \n");
|
||||
grammarBuilder.append("C : 'c' ; \n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
writeFile(tmpdir, "M.g4", grammar);
|
||||
ErrorQueue equeue = new ErrorQueue();
|
||||
Grammar g = new Grammar(tmpdir+"/M.g4", grammar, equeue);
|
||||
String expectedTokenIDToTypeMap = "{EOF=-1, B=1, A=2, C=3, WS=4}";
|
||||
String expectedStringLiteralToTypeMap = "{'a'=2, 'b'=1, 'c'=3}";
|
||||
String expectedTypeToTokenList = "[B, A, C, WS]";
|
||||
assertEquals(expectedTokenIDToTypeMap, g.tokenNameToTypeMap.toString());
|
||||
assertEquals(expectedStringLiteralToTypeMap, sort(g.stringLiteralToTypeMap).toString());
|
||||
assertEquals(expectedTypeToTokenList, realElements(g.typeToTokenList).toString());
|
||||
assertEquals("unexpected errors: "+equeue, 0, equeue.errors.size());
|
||||
|
||||
|
||||
String input ="aa";
|
||||
String found = execParser("M.g4", grammar, "MParser", "MLexer", "MListener", "MVisitor", "s", input, false);
|
||||
|
||||
assertEquals(
|
||||
"S.x\n" +
|
||||
"T.y\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testDelegatorAccessesDelegateMembers() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"@parser::members {\n" +
|
||||
"void foo() {\n" +
|
||||
" std::cout << \"foo\";\n" +
|
||||
"}\n" +
|
||||
"}\n" +
|
||||
"a : B;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(122);
|
||||
grammarBuilder.append("grammar M; // uses no rules from the import\n");
|
||||
grammarBuilder.append("import S;\n");
|
||||
grammarBuilder.append("s : 'b' {foo();} ; // gS is import pointer\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="b";
|
||||
String found = execParser("M.g4", grammar, "MParser", "MLexer", "MListener", "MVisitor", "s", input, false);
|
||||
|
||||
assertEquals("foo\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testDelegatorInvokesDelegateRule() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : B {std::cout << \"S.a\" << std::endl;};";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(104);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S;\n");
|
||||
grammarBuilder.append("s : a ;\n");
|
||||
grammarBuilder.append("B : 'b' ; // defines B from inherited token space\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="b";
|
||||
String found = execParser("M.g4", grammar, "MParser", "MLexer", "MListener", "MVisitor", "s", input, false);
|
||||
|
||||
assertEquals("S.a\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testDelegatorInvokesDelegateRuleWithArgs() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a[int x] returns [int y] : B {std::cout << \"S.a\";} {$y=1000;} ;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(151);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S;\n");
|
||||
grammarBuilder.append("s : label=a[3] {std::cout << $label.y << std::endl;} ;\n");
|
||||
grammarBuilder.append("B : 'b' ; // defines B from inherited token space\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="b";
|
||||
String found = execParser("M.g4", grammar, "MParser", "MLexer", "MListener", "MVisitor", "s", input, false);
|
||||
|
||||
assertEquals("S.a1000\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testDelegatorInvokesDelegateRuleWithReturnStruct() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : B {std::cout << \"S.a\";} ;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(128);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S;\n");
|
||||
grammarBuilder.append("s : a {std::cout << $a.text;} ;\n");
|
||||
grammarBuilder.append("B : 'b' ; // defines B from inherited token space\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="b";
|
||||
String found = execParser("M.g4", grammar, "MParser", "MLexer", "MListener", "MVisitor", "s", input, false);
|
||||
|
||||
assertEquals("S.ab\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testDelegatorInvokesFirstVersionOfDelegateRule() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"a : B {std::cout << \"T.a\" << std::endl;};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : b {std::cout << \"S.a\" << std::endl;};\n" +
|
||||
"b : B;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(106);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S,T;\n");
|
||||
grammarBuilder.append("s : a ;\n");
|
||||
grammarBuilder.append("B : 'b' ; // defines B from inherited token space\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="b";
|
||||
String found = execParser("M.g4", grammar, "MParser", "MLexer", "MListener", "MVisitor", "s", input, false);
|
||||
|
||||
assertEquals("S.a\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testDelegatorRuleOverridesDelegate() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : b {std::cout << \"S.a\";};\n" +
|
||||
"b : B ;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(59);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S;\n");
|
||||
grammarBuilder.append("b : 'b'|'c';\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="c";
|
||||
String found = execParser("M.g4", grammar, "MParser", "MLexer", "MListener", "MVisitor", "a", input, false);
|
||||
|
||||
assertEquals("S.a\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testDelegatorRuleOverridesDelegates() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { A }\n" +
|
||||
"b : 'b' {std::cout << \"T.b\" << std::endl;};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : b {std::cout << \"S.a\" << std::endl;};\n" +
|
||||
"b : 'b' ;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(101);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S, T;\n");
|
||||
grammarBuilder.append("b : 'b'|'c' {std::cout << \"M.b\" << std::endl;}|B|A;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="c";
|
||||
String found = execParser("M.g4", grammar, "MParser", "MLexer", "MListener", "MVisitor", "a", input, false);
|
||||
|
||||
assertEquals(
|
||||
"M.b\n" +
|
||||
"S.a\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testDelegatorRuleOverridesLookaheadInDelegate() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"type_ : 'int' ;\n" +
|
||||
"decl : type_ ID ';'\n" +
|
||||
" | type_ ID init ';' {std::cout << \"JavaDecl: \" + $text;};\n" +
|
||||
"init : '=' INT;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(121);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S;\n");
|
||||
grammarBuilder.append("prog : decl ;\n");
|
||||
grammarBuilder.append("type_ : 'int' | 'float' ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="float x = 3;";
|
||||
String found = execParser("M.g4", grammar, "MParser", "MLexer", "MListener", "MVisitor", "prog", input, false);
|
||||
|
||||
assertEquals("JavaDecl: floatx=3;\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testImportLexerWithOnlyFragmentRules() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_Unicode =
|
||||
"lexer grammar Unicode;\n" +
|
||||
"\n" +
|
||||
"fragment\n" +
|
||||
"UNICODE_CLASS_Zs : '\\u0020' | '\\u00A0' | '\\u1680' | '\\u180E'\n" +
|
||||
" | '\\u2000'..'\\u200A'\n" +
|
||||
" | '\\u202F' | '\\u205F' | '\\u3000'\n" +
|
||||
" ;\n";
|
||||
writeFile(tmpdir, "Unicode.g4", slave_Unicode);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(91);
|
||||
grammarBuilder.append("grammar Test;\n");
|
||||
grammarBuilder.append("import Unicode;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("program : 'test' 'test';\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("WS : (UNICODE_CLASS_Zs)+ -> skip;\n");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="test test";
|
||||
String found = execParser("Test.g4", grammar, "TestParser", "TestLexer", "TestListener", "TestVisitor", "program", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testImportedGrammarWithEmptyOptions() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"options {}\n" +
|
||||
"a : B ;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(64);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S;\n");
|
||||
grammarBuilder.append("s : a ;\n");
|
||||
grammarBuilder.append("B : 'b' ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="b";
|
||||
String found = execParser("M.g4", grammar, "MParser", "MLexer", "MListener", "MVisitor", "s", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testImportedRuleWithAction() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a @after {int x = 0;} : B;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(62);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S;\n");
|
||||
grammarBuilder.append("s : a;\n");
|
||||
grammarBuilder.append("B : 'b';\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="b";
|
||||
String found = execParser("M.g4", grammar, "MParser", "MLexer", "MListener", "MVisitor", "s", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testKeywordVSIDOrder() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_S =
|
||||
"lexer grammar S;\n" +
|
||||
"ID : 'a'..'z'+;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(153);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S;\n");
|
||||
grammarBuilder.append("a : A {std::cout << \"M.a: \" + $A->toString() << std::endl;};\n");
|
||||
grammarBuilder.append("A : 'abc' {std::cout << \"M.A\" << std::endl;};\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="abc";
|
||||
String found = execParser("M.g4", grammar, "MParser", "MLexer", "MListener", "MVisitor", "a", input, false);
|
||||
|
||||
assertEquals(
|
||||
"M.A\n" +
|
||||
"M.a: [@0,0:2='abc',<1>,1:0]\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,506 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.cpp;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestFullContextParsing extends BaseCppTest {
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testAmbigYieldsCtxSensitiveDFA() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(96);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s @after {dumpDFA();}\n");
|
||||
grammarBuilder.append(" : ID | ID {} ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\t'|'\\n')+ -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="abc";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, true);
|
||||
|
||||
assertEquals(
|
||||
"Decision 0:\n" +
|
||||
"s0-ID->:s1^=>1\n", found);
|
||||
|
||||
assertEquals("line 1:0 reportAttemptingFullContext d=0 (s), input='abc'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testAmbiguityNoLoop() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(264);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("prog\n");
|
||||
grammarBuilder.append("@init {getInterpreter<atn::ParserATNSimulator>()->setPredictionMode(atn::PredictionMode::LL_EXACT_AMBIG_DETECTION);}\n");
|
||||
grammarBuilder.append(" : expr expr {std::cout << \"alt 1\" << std::endl;}\n");
|
||||
grammarBuilder.append(" | expr\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("expr: '@'\n");
|
||||
grammarBuilder.append(" | ID '@'\n");
|
||||
grammarBuilder.append(" | ID\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : [a-z]+ ;\n");
|
||||
grammarBuilder.append("WS : [ \\r\\n\\t]+ -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="a@";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "prog", input, true);
|
||||
|
||||
assertEquals("alt 1\n", found);
|
||||
|
||||
assertEquals(
|
||||
"line 1:2 reportAttemptingFullContext d=0 (prog), input='a@'\n" +
|
||||
"line 1:2 reportAmbiguity d=0 (prog): ambigAlts={1, 2}, input='a@'\n" +
|
||||
"line 1:2 reportAttemptingFullContext d=1 (expr), input='a@'\n" +
|
||||
"line 1:2 reportContextSensitivity d=1 (expr), input='a@'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testCtxSensitiveDFATwoDiffInput() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(160);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s @after {dumpDFA();}\n");
|
||||
grammarBuilder.append(" : ('$' a | '@' b)+ ;\n");
|
||||
grammarBuilder.append("a : e ID ;\n");
|
||||
grammarBuilder.append("b : e INT ID ;\n");
|
||||
grammarBuilder.append("e : INT | ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\t'|'\\n')+ -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="$ 34 abc @ 34 abc";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, true);
|
||||
|
||||
assertEquals(
|
||||
"Decision 2:\n" +
|
||||
"s0-INT->s1\n" +
|
||||
"s1-ID->:s2^=>1\n", found);
|
||||
|
||||
assertEquals(
|
||||
"line 1:5 reportAttemptingFullContext d=2 (e), input='34abc'\n" +
|
||||
"line 1:2 reportContextSensitivity d=2 (e), input='34'\n" +
|
||||
"line 1:14 reportAttemptingFullContext d=2 (e), input='34abc'\n" +
|
||||
"line 1:14 reportContextSensitivity d=2 (e), input='34abc'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testCtxSensitiveDFA_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(157);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s @after {dumpDFA();}\n");
|
||||
grammarBuilder.append(" : '$' a | '@' b ;\n");
|
||||
grammarBuilder.append("a : e ID ;\n");
|
||||
grammarBuilder.append("b : e INT ID ;\n");
|
||||
grammarBuilder.append("e : INT | ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\t'|'\\n')+ -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="$ 34 abc";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, true);
|
||||
|
||||
assertEquals(
|
||||
"Decision 1:\n" +
|
||||
"s0-INT->s1\n" +
|
||||
"s1-ID->:s2^=>1\n", found);
|
||||
|
||||
assertEquals(
|
||||
"line 1:5 reportAttemptingFullContext d=1 (e), input='34abc'\n" +
|
||||
"line 1:2 reportContextSensitivity d=1 (e), input='34'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testCtxSensitiveDFA_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(157);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s @after {dumpDFA();}\n");
|
||||
grammarBuilder.append(" : '$' a | '@' b ;\n");
|
||||
grammarBuilder.append("a : e ID ;\n");
|
||||
grammarBuilder.append("b : e INT ID ;\n");
|
||||
grammarBuilder.append("e : INT | ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\t'|'\\n')+ -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="@ 34 abc";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, true);
|
||||
|
||||
assertEquals(
|
||||
"Decision 1:\n" +
|
||||
"s0-INT->s1\n" +
|
||||
"s1-ID->:s2^=>1\n", found);
|
||||
|
||||
assertEquals(
|
||||
"line 1:5 reportAttemptingFullContext d=1 (e), input='34abc'\n" +
|
||||
"line 1:5 reportContextSensitivity d=1 (e), input='34abc'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testExprAmbiguity_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(339);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@init {getInterpreter<atn::ParserATNSimulator>()->setPredictionMode(atn::PredictionMode::LL_EXACT_AMBIG_DETECTION);}\n");
|
||||
grammarBuilder.append(": expr[0] {std::cout << $expr.ctx->toStringTree(this) << std::endl;};\n");
|
||||
grammarBuilder.append(" expr[int _p]\n");
|
||||
grammarBuilder.append(" : ID \n");
|
||||
grammarBuilder.append(" ( \n");
|
||||
grammarBuilder.append(" {5 >= $_p}? '*' expr[6]\n");
|
||||
grammarBuilder.append(" | {4 >= $_p}? '+' expr[5]\n");
|
||||
grammarBuilder.append(" )*\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : [a-zA-Z]+ ;\n");
|
||||
grammarBuilder.append("WS : [ \\r\\n\\t]+ -> skip ;\n");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="a+b";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, true);
|
||||
|
||||
assertEquals("(expr a + (expr b))\n", found);
|
||||
|
||||
assertEquals(
|
||||
"line 1:1 reportAttemptingFullContext d=1 (expr), input='+'\n" +
|
||||
"line 1:2 reportContextSensitivity d=1 (expr), input='+b'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testExprAmbiguity_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(339);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@init {getInterpreter<atn::ParserATNSimulator>()->setPredictionMode(atn::PredictionMode::LL_EXACT_AMBIG_DETECTION);}\n");
|
||||
grammarBuilder.append(": expr[0] {std::cout << $expr.ctx->toStringTree(this) << std::endl;};\n");
|
||||
grammarBuilder.append(" expr[int _p]\n");
|
||||
grammarBuilder.append(" : ID \n");
|
||||
grammarBuilder.append(" ( \n");
|
||||
grammarBuilder.append(" {5 >= $_p}? '*' expr[6]\n");
|
||||
grammarBuilder.append(" | {4 >= $_p}? '+' expr[5]\n");
|
||||
grammarBuilder.append(" )*\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : [a-zA-Z]+ ;\n");
|
||||
grammarBuilder.append("WS : [ \\r\\n\\t]+ -> skip ;\n");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="a+b*c";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, true);
|
||||
|
||||
assertEquals("(expr a + (expr b * (expr c)))\n", found);
|
||||
|
||||
assertEquals(
|
||||
"line 1:1 reportAttemptingFullContext d=1 (expr), input='+'\n" +
|
||||
"line 1:2 reportContextSensitivity d=1 (expr), input='+b'\n" +
|
||||
"line 1:3 reportAttemptingFullContext d=1 (expr), input='*'\n" +
|
||||
"line 1:5 reportAmbiguity d=1 (expr): ambigAlts={1, 2}, input='*c'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testFullContextIF_THEN_ELSEParse_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(274);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s \n");
|
||||
grammarBuilder.append("@init {getInterpreter<atn::ParserATNSimulator>()->setPredictionMode(atn::PredictionMode::LL_EXACT_AMBIG_DETECTION);}\n");
|
||||
grammarBuilder.append("@after {dumpDFA();}\n");
|
||||
grammarBuilder.append(" : '{' stat* '}' ;\n");
|
||||
grammarBuilder.append("stat: 'if' ID 'then' stat ('else' ID)?\n");
|
||||
grammarBuilder.append(" | 'return'\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\t'|'\\n')+ -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="{ if x then return }";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, true);
|
||||
|
||||
assertEquals(
|
||||
"Decision 1:\n" +
|
||||
"s0-'}'->:s1=>2\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testFullContextIF_THEN_ELSEParse_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(274);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s \n");
|
||||
grammarBuilder.append("@init {getInterpreter<atn::ParserATNSimulator>()->setPredictionMode(atn::PredictionMode::LL_EXACT_AMBIG_DETECTION);}\n");
|
||||
grammarBuilder.append("@after {dumpDFA();}\n");
|
||||
grammarBuilder.append(" : '{' stat* '}' ;\n");
|
||||
grammarBuilder.append("stat: 'if' ID 'then' stat ('else' ID)?\n");
|
||||
grammarBuilder.append(" | 'return'\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\t'|'\\n')+ -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="{ if x then return else foo }";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, true);
|
||||
|
||||
assertEquals(
|
||||
"Decision 1:\n" +
|
||||
"s0-'else'->:s1^=>1\n", found);
|
||||
|
||||
assertEquals(
|
||||
"line 1:19 reportAttemptingFullContext d=1 (stat), input='else'\n" +
|
||||
"line 1:19 reportContextSensitivity d=1 (stat), input='else'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testFullContextIF_THEN_ELSEParse_3() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(274);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s \n");
|
||||
grammarBuilder.append("@init {getInterpreter<atn::ParserATNSimulator>()->setPredictionMode(atn::PredictionMode::LL_EXACT_AMBIG_DETECTION);}\n");
|
||||
grammarBuilder.append("@after {dumpDFA();}\n");
|
||||
grammarBuilder.append(" : '{' stat* '}' ;\n");
|
||||
grammarBuilder.append("stat: 'if' ID 'then' stat ('else' ID)?\n");
|
||||
grammarBuilder.append(" | 'return'\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\t'|'\\n')+ -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="{ if x then if y then return else foo }";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, true);
|
||||
|
||||
assertEquals(
|
||||
"Decision 1:\n" +
|
||||
"s0-'}'->:s2=>2\n" +
|
||||
"s0-'else'->:s1^=>1\n", found);
|
||||
|
||||
assertEquals(
|
||||
"line 1:29 reportAttemptingFullContext d=1 (stat), input='else'\n" +
|
||||
"line 1:38 reportAmbiguity d=1 (stat): ambigAlts={1, 2}, input='elsefoo}'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testFullContextIF_THEN_ELSEParse_4() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(274);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s \n");
|
||||
grammarBuilder.append("@init {getInterpreter<atn::ParserATNSimulator>()->setPredictionMode(atn::PredictionMode::LL_EXACT_AMBIG_DETECTION);}\n");
|
||||
grammarBuilder.append("@after {dumpDFA();}\n");
|
||||
grammarBuilder.append(" : '{' stat* '}' ;\n");
|
||||
grammarBuilder.append("stat: 'if' ID 'then' stat ('else' ID)?\n");
|
||||
grammarBuilder.append(" | 'return'\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\t'|'\\n')+ -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="{ if x then if y then return else foo else bar }";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, true);
|
||||
|
||||
assertEquals(
|
||||
"Decision 1:\n" +
|
||||
"s0-'else'->:s1^=>1\n", found);
|
||||
|
||||
assertEquals(
|
||||
"line 1:29 reportAttemptingFullContext d=1 (stat), input='else'\n" +
|
||||
"line 1:38 reportContextSensitivity d=1 (stat), input='elsefooelse'\n" +
|
||||
"line 1:38 reportAttemptingFullContext d=1 (stat), input='else'\n" +
|
||||
"line 1:38 reportContextSensitivity d=1 (stat), input='else'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testFullContextIF_THEN_ELSEParse_5() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(274);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s \n");
|
||||
grammarBuilder.append("@init {getInterpreter<atn::ParserATNSimulator>()->setPredictionMode(atn::PredictionMode::LL_EXACT_AMBIG_DETECTION);}\n");
|
||||
grammarBuilder.append("@after {dumpDFA();}\n");
|
||||
grammarBuilder.append(" : '{' stat* '}' ;\n");
|
||||
grammarBuilder.append("stat: 'if' ID 'then' stat ('else' ID)?\n");
|
||||
grammarBuilder.append(" | 'return'\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\t'|'\\n')+ -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input =
|
||||
"{ if x then return else foo\n" +
|
||||
"if x then if y then return else foo }";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, true);
|
||||
|
||||
assertEquals(
|
||||
"Decision 1:\n" +
|
||||
"s0-'}'->:s2=>2\n" +
|
||||
"s0-'else'->:s1^=>1\n", found);
|
||||
|
||||
assertEquals(
|
||||
"line 1:19 reportAttemptingFullContext d=1 (stat), input='else'\n" +
|
||||
"line 1:19 reportContextSensitivity d=1 (stat), input='else'\n" +
|
||||
"line 2:27 reportAttemptingFullContext d=1 (stat), input='else'\n" +
|
||||
"line 2:36 reportAmbiguity d=1 (stat): ambigAlts={1, 2}, input='elsefoo}'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testFullContextIF_THEN_ELSEParse_6() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(274);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s \n");
|
||||
grammarBuilder.append("@init {getInterpreter<atn::ParserATNSimulator>()->setPredictionMode(atn::PredictionMode::LL_EXACT_AMBIG_DETECTION);}\n");
|
||||
grammarBuilder.append("@after {dumpDFA();}\n");
|
||||
grammarBuilder.append(" : '{' stat* '}' ;\n");
|
||||
grammarBuilder.append("stat: 'if' ID 'then' stat ('else' ID)?\n");
|
||||
grammarBuilder.append(" | 'return'\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\t'|'\\n')+ -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input =
|
||||
"{ if x then return else foo\n" +
|
||||
"if x then if y then return else foo }";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, true);
|
||||
|
||||
assertEquals(
|
||||
"Decision 1:\n" +
|
||||
"s0-'}'->:s2=>2\n" +
|
||||
"s0-'else'->:s1^=>1\n", found);
|
||||
|
||||
assertEquals(
|
||||
"line 1:19 reportAttemptingFullContext d=1 (stat), input='else'\n" +
|
||||
"line 1:19 reportContextSensitivity d=1 (stat), input='else'\n" +
|
||||
"line 2:27 reportAttemptingFullContext d=1 (stat), input='else'\n" +
|
||||
"line 2:36 reportAmbiguity d=1 (stat): ambigAlts={1, 2}, input='elsefoo}'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testLoopsSimulateTailRecursion() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(377);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("prog\n");
|
||||
grammarBuilder.append("@init {getInterpreter<atn::ParserATNSimulator>()->setPredictionMode(atn::PredictionMode::LL_EXACT_AMBIG_DETECTION);}\n");
|
||||
grammarBuilder.append(" : expr_or_assign*;\n");
|
||||
grammarBuilder.append("expr_or_assign\n");
|
||||
grammarBuilder.append(" : expr '++' {std::cout << \"fail.\" << std::endl;}\n");
|
||||
grammarBuilder.append(" | expr {std::cout << \"pass: \"+$expr.text << std::endl;}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("expr: expr_primary ('<-' ID)?;\n");
|
||||
grammarBuilder.append("expr_primary\n");
|
||||
grammarBuilder.append(" : '(' ID ')'\n");
|
||||
grammarBuilder.append(" | ID '(' ID ')'\n");
|
||||
grammarBuilder.append(" | ID\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : [a-z]+ ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="a(i)<-x";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "prog", input, true);
|
||||
|
||||
assertEquals("pass: a(i)<-x\n", found);
|
||||
|
||||
assertEquals(
|
||||
"line 1:3 reportAttemptingFullContext d=3 (expr_primary), input='a(i)'\n" +
|
||||
"line 1:7 reportAmbiguity d=3 (expr_primary): ambigAlts={2, 3}, input='a(i)<-x'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testSLLSeesEOFInLLGrammar() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(144);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s @after {dumpDFA();}\n");
|
||||
grammarBuilder.append(" : a;\n");
|
||||
grammarBuilder.append("a : e ID ;\n");
|
||||
grammarBuilder.append("b : e INT ID ;\n");
|
||||
grammarBuilder.append("e : INT | ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\t'|'\\n')+ -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="34 abc";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, true);
|
||||
|
||||
assertEquals(
|
||||
"Decision 0:\n" +
|
||||
"s0-INT->s1\n" +
|
||||
"s1-ID->:s2^=>1\n", found);
|
||||
|
||||
assertEquals(
|
||||
"line 1:3 reportAttemptingFullContext d=0 (e), input='34abc'\n" +
|
||||
"line 1:0 reportContextSensitivity d=0 (e), input='34'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,258 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.cpp;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestLexerErrors extends BaseCppTest {
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testDFAToATNThatFailsBackToDFA() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(39);
|
||||
grammarBuilder.append("lexer grammar L;\n");
|
||||
grammarBuilder.append("A : 'ab' ;\n");
|
||||
grammarBuilder.append("B : 'abc' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
String input ="ababx";
|
||||
String found = execLexer("L.g4", grammar, "L", input, false);
|
||||
assertEquals(
|
||||
"[@0,0:1='ab',<1>,1:0]\n" +
|
||||
"[@1,2:3='ab',<1>,1:2]\n" +
|
||||
"[@2,5:4='<EOF>',<-1>,1:5]\n", found);
|
||||
|
||||
assertEquals("line 1:4 token recognition error at: 'x'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testDFAToATNThatMatchesThenFailsInATN() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(52);
|
||||
grammarBuilder.append("lexer grammar L;\n");
|
||||
grammarBuilder.append("A : 'ab' ;\n");
|
||||
grammarBuilder.append("B : 'abc' ;\n");
|
||||
grammarBuilder.append("C : 'abcd' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
String input ="ababcx";
|
||||
String found = execLexer("L.g4", grammar, "L", input, false);
|
||||
assertEquals(
|
||||
"[@0,0:1='ab',<1>,1:0]\n" +
|
||||
"[@1,2:4='abc',<2>,1:2]\n" +
|
||||
"[@2,6:5='<EOF>',<-1>,1:6]\n", found);
|
||||
|
||||
assertEquals("line 1:5 token recognition error at: 'x'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testEnforcedGreedyNestedBrances_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(77);
|
||||
grammarBuilder.append("lexer grammar L;\n");
|
||||
grammarBuilder.append("ACTION : '{' (ACTION | ~[{}])* '}';\n");
|
||||
grammarBuilder.append("WS : [ \\r\\n\\t]+ -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
String input ="{ { } }";
|
||||
String found = execLexer("L.g4", grammar, "L", input, false);
|
||||
assertEquals(
|
||||
"[@0,0:6='{ { } }',<1>,1:0]\n" +
|
||||
"[@1,7:6='<EOF>',<-1>,1:7]\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testEnforcedGreedyNestedBrances_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(77);
|
||||
grammarBuilder.append("lexer grammar L;\n");
|
||||
grammarBuilder.append("ACTION : '{' (ACTION | ~[{}])* '}';\n");
|
||||
grammarBuilder.append("WS : [ \\r\\n\\t]+ -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
String input ="{ { }";
|
||||
String found = execLexer("L.g4", grammar, "L", input, false);
|
||||
assertEquals("[@0,5:4='<EOF>',<-1>,1:5]\n", found);
|
||||
|
||||
assertEquals("line 1:0 token recognition error at: '{ { }'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testErrorInMiddle() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(28);
|
||||
grammarBuilder.append("lexer grammar L;\n");
|
||||
grammarBuilder.append("A : 'abc' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
String input ="abx";
|
||||
String found = execLexer("L.g4", grammar, "L", input, false);
|
||||
assertEquals("[@0,3:2='<EOF>',<-1>,1:3]\n", found);
|
||||
|
||||
assertEquals("line 1:0 token recognition error at: 'abx'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testInvalidCharAtStart() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(30);
|
||||
grammarBuilder.append("lexer grammar L;\n");
|
||||
grammarBuilder.append("A : 'a' 'b' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
String input ="x";
|
||||
String found = execLexer("L.g4", grammar, "L", input, false);
|
||||
assertEquals("[@0,1:0='<EOF>',<-1>,1:1]\n", found);
|
||||
|
||||
assertEquals("line 1:0 token recognition error at: 'x'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testInvalidCharAtStartAfterDFACache() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(30);
|
||||
grammarBuilder.append("lexer grammar L;\n");
|
||||
grammarBuilder.append("A : 'a' 'b' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
String input ="abx";
|
||||
String found = execLexer("L.g4", grammar, "L", input, false);
|
||||
assertEquals(
|
||||
"[@0,0:1='ab',<1>,1:0]\n" +
|
||||
"[@1,3:2='<EOF>',<-1>,1:3]\n", found);
|
||||
|
||||
assertEquals("line 1:2 token recognition error at: 'x'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testInvalidCharInToken() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(30);
|
||||
grammarBuilder.append("lexer grammar L;\n");
|
||||
grammarBuilder.append("A : 'a' 'b' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
String input ="ax";
|
||||
String found = execLexer("L.g4", grammar, "L", input, false);
|
||||
assertEquals("[@0,2:1='<EOF>',<-1>,1:2]\n", found);
|
||||
|
||||
assertEquals("line 1:0 token recognition error at: 'ax'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testInvalidCharInTokenAfterDFACache() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(30);
|
||||
grammarBuilder.append("lexer grammar L;\n");
|
||||
grammarBuilder.append("A : 'a' 'b' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
String input ="abax";
|
||||
String found = execLexer("L.g4", grammar, "L", input, false);
|
||||
assertEquals(
|
||||
"[@0,0:1='ab',<1>,1:0]\n" +
|
||||
"[@1,4:3='<EOF>',<-1>,1:4]\n", found);
|
||||
|
||||
assertEquals("line 1:2 token recognition error at: 'ax'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testLexerExecDFA() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(98);
|
||||
grammarBuilder.append("grammar L;\n");
|
||||
grammarBuilder.append("start : ID ':' expr;\n");
|
||||
grammarBuilder.append("expr : primary expr? {} | expr '->' ID;\n");
|
||||
grammarBuilder.append("primary : ID;\n");
|
||||
grammarBuilder.append("ID : [a-z]+;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
String input ="x : x";
|
||||
String found = execLexer("L.g4", grammar, "LLexer", input, false);
|
||||
assertEquals(
|
||||
"[@0,0:0='x',<3>,1:0]\n" +
|
||||
"[@1,2:2=':',<1>,1:2]\n" +
|
||||
"[@2,4:4='x',<3>,1:4]\n" +
|
||||
"[@3,5:4='<EOF>',<-1>,1:5]\n", found);
|
||||
|
||||
assertEquals(
|
||||
"line 1:1 token recognition error at: ' '\n" +
|
||||
"line 1:3 token recognition error at: ' '\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testStringsEmbeddedInActions_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(109);
|
||||
grammarBuilder.append("lexer grammar L;\n");
|
||||
grammarBuilder.append("ACTION2 : '[' (STRING | ~'\"')*? ']';\n");
|
||||
grammarBuilder.append("STRING : '\"' ('\\\"' | .)*? '\"';\n");
|
||||
grammarBuilder.append("WS : [ \\t\\r\\n]+ -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
String input ="[\"foo\"]";
|
||||
String found = execLexer("L.g4", grammar, "L", input, false);
|
||||
assertEquals(
|
||||
"[@0,0:6='[\"foo\"]',<1>,1:0]\n" +
|
||||
"[@1,7:6='<EOF>',<-1>,1:7]\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testStringsEmbeddedInActions_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(109);
|
||||
grammarBuilder.append("lexer grammar L;\n");
|
||||
grammarBuilder.append("ACTION2 : '[' (STRING | ~'\"')*? ']';\n");
|
||||
grammarBuilder.append("STRING : '\"' ('\\\"' | .)*? '\"';\n");
|
||||
grammarBuilder.append("WS : [ \\t\\r\\n]+ -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
String input ="[\"foo]";
|
||||
String found = execLexer("L.g4", grammar, "L", input, false);
|
||||
assertEquals("[@0,6:5='<EOF>',<-1>,1:6]\n", found);
|
||||
|
||||
assertEquals("line 1:0 token recognition error at: '[\"foo]'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,355 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.cpp;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestListeners extends BaseCppTest {
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testBasic() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(484);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::definitions {\n");
|
||||
grammarBuilder.append("class LeafListener : public TBaseListener {\n");
|
||||
grammarBuilder.append("public:\n");
|
||||
grammarBuilder.append(" virtual void visitTerminal(Ref<tree::TerminalNode> node) override {\n");
|
||||
grammarBuilder.append(" std::cout << node->getSymbol()->getText() << std::endl;\n");
|
||||
grammarBuilder.append(" }\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
grammarBuilder.append("std::cout << $ctx->r->toStringTree(this) << std::endl;\n");
|
||||
grammarBuilder.append("tree::ParseTreeWalker::DEFAULT->walk(std::make_shared<LeafListener>(), $ctx->r);\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append(" : r=a ;\n");
|
||||
grammarBuilder.append("a : INT INT\n");
|
||||
grammarBuilder.append(" | ID\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("MULT: '*' ;\n");
|
||||
grammarBuilder.append("ADD : '+' ;\n");
|
||||
grammarBuilder.append("INT : [0-9]+ ;\n");
|
||||
grammarBuilder.append("ID : [a-z]+ ;\n");
|
||||
grammarBuilder.append("WS : [ \\t\\n]+ -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="1 2";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals(
|
||||
"(a 1 2)\n" +
|
||||
"1\n" +
|
||||
"2\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testLR() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(690);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::definitions {\n");
|
||||
grammarBuilder.append("class LeafListener : public TBaseListener {\n");
|
||||
grammarBuilder.append("public:\n");
|
||||
grammarBuilder.append(" virtual void exitE(TParser::EContext *ctx) override {\n");
|
||||
grammarBuilder.append(" if (ctx->getChildCount() == 3) {\n");
|
||||
grammarBuilder.append(" std::cout << ctx->e(0)->start->getText() << \" \" << ctx->e(1)->start->getText() << \" \" << ctx->e()[0]->start->getText() << std::endl;\n");
|
||||
grammarBuilder.append(" } else {\n");
|
||||
grammarBuilder.append(" std::cout << ctx->INT()->getSymbol()->getText() << std::endl;\n");
|
||||
grammarBuilder.append(" }\n");
|
||||
grammarBuilder.append(" }\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
grammarBuilder.append("std::cout << $ctx->r->toStringTree(this) << std::endl;\n");
|
||||
grammarBuilder.append("tree::ParseTreeWalker::DEFAULT->walk(std::make_shared<LeafListener>(), $ctx->r);\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append(" : r=e ;\n");
|
||||
grammarBuilder.append("e : e op='*' e\n");
|
||||
grammarBuilder.append(" | e op='+' e\n");
|
||||
grammarBuilder.append(" | INT\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("MULT: '*' ;\n");
|
||||
grammarBuilder.append("ADD : '+' ;\n");
|
||||
grammarBuilder.append("INT : [0-9]+ ;\n");
|
||||
grammarBuilder.append("ID : [a-z]+ ;\n");
|
||||
grammarBuilder.append("WS : [ \\t\\n]+ -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="1+2*3";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals(
|
||||
"(e (e 1) + (e (e 2) * (e 3)))\n" +
|
||||
"1\n" +
|
||||
"2\n" +
|
||||
"3\n" +
|
||||
"2 3 2\n" +
|
||||
"1 2 1\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testLRWithLabels() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(692);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::definitions {\n");
|
||||
grammarBuilder.append("class LeafListener : public TBaseListener {\n");
|
||||
grammarBuilder.append("public:\n");
|
||||
grammarBuilder.append(" virtual void exitCall(TParser::CallContext *ctx) override {\n");
|
||||
grammarBuilder.append(" std::cout << ctx->e()->start->getText() << \" \" << ctx->eList()->toString() << std::endl;\n");
|
||||
grammarBuilder.append(" }\n");
|
||||
grammarBuilder.append(" virtual void exitInt(TParser::IntContext *ctx) override {\n");
|
||||
grammarBuilder.append(" std::cout << ctx->INT()->getSymbol()->getText() << std::endl;\n");
|
||||
grammarBuilder.append(" }\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
grammarBuilder.append("std::cout << $ctx->r->toStringTree(this) << std::endl;\n");
|
||||
grammarBuilder.append("tree::ParseTreeWalker::DEFAULT->walk(std::make_shared<LeafListener>(), $ctx->r);\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append(" : r=e ;\n");
|
||||
grammarBuilder.append("e : e '(' eList ')' # Call\n");
|
||||
grammarBuilder.append(" | INT # Int\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("eList : e (',' e)* ;\n");
|
||||
grammarBuilder.append("MULT: '*' ;\n");
|
||||
grammarBuilder.append("ADD : '+' ;\n");
|
||||
grammarBuilder.append("INT : [0-9]+ ;\n");
|
||||
grammarBuilder.append("ID : [a-z]+ ;\n");
|
||||
grammarBuilder.append("WS : [ \\t\\n]+ -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="1(2,3)";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals(
|
||||
"(e (e 1) ( (eList (e 2) , (e 3)) ))\n" +
|
||||
"1\n" +
|
||||
"2\n" +
|
||||
"3\n" +
|
||||
"1 [13 6]\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testRuleGetters_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(710);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::definitions {\n");
|
||||
grammarBuilder.append("class LeafListener : public TBaseListener {\n");
|
||||
grammarBuilder.append("public:\n");
|
||||
grammarBuilder.append(" virtual void exitA(TParser::AContext *ctx) override {\n");
|
||||
grammarBuilder.append(" if (ctx->getChildCount() == 2) {\n");
|
||||
grammarBuilder.append(" std::cout << ctx->b(0)->start->getText() << \" \" << ctx->b(1)->start->getText() << \" \" << ctx->b()[0]->start->getText() << std::endl;\n");
|
||||
grammarBuilder.append(" } else {\n");
|
||||
grammarBuilder.append(" std::cout << ctx->b(0)->start->getText() << std::endl;\n");
|
||||
grammarBuilder.append(" }\n");
|
||||
grammarBuilder.append(" }\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
grammarBuilder.append("std::cout << $ctx->r->toStringTree(this) << std::endl;\n");
|
||||
grammarBuilder.append("tree::ParseTreeWalker::DEFAULT->walk(std::make_shared<LeafListener>(), $ctx->r);\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append(" : r=a ;\n");
|
||||
grammarBuilder.append("a : b b // forces list\n");
|
||||
grammarBuilder.append(" | b // a list still\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("b : ID | INT;\n");
|
||||
grammarBuilder.append("MULT: '*' ;\n");
|
||||
grammarBuilder.append("ADD : '+' ;\n");
|
||||
grammarBuilder.append("INT : [0-9]+ ;\n");
|
||||
grammarBuilder.append("ID : [a-z]+ ;\n");
|
||||
grammarBuilder.append("WS : [ \\t\\n]+ -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="1 2";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals(
|
||||
"(a (b 1) (b 2))\n" +
|
||||
"1 2 1\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testRuleGetters_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(710);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::definitions {\n");
|
||||
grammarBuilder.append("class LeafListener : public TBaseListener {\n");
|
||||
grammarBuilder.append("public:\n");
|
||||
grammarBuilder.append(" virtual void exitA(TParser::AContext *ctx) override {\n");
|
||||
grammarBuilder.append(" if (ctx->getChildCount() == 2) {\n");
|
||||
grammarBuilder.append(" std::cout << ctx->b(0)->start->getText() << \" \" << ctx->b(1)->start->getText() << \" \" << ctx->b()[0]->start->getText() << std::endl;\n");
|
||||
grammarBuilder.append(" } else {\n");
|
||||
grammarBuilder.append(" std::cout << ctx->b(0)->start->getText() << std::endl;\n");
|
||||
grammarBuilder.append(" }\n");
|
||||
grammarBuilder.append(" }\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
grammarBuilder.append("std::cout << $ctx->r->toStringTree(this) << std::endl;\n");
|
||||
grammarBuilder.append("tree::ParseTreeWalker::DEFAULT->walk(std::make_shared<LeafListener>(), $ctx->r);\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append(" : r=a ;\n");
|
||||
grammarBuilder.append("a : b b // forces list\n");
|
||||
grammarBuilder.append(" | b // a list still\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("b : ID | INT;\n");
|
||||
grammarBuilder.append("MULT: '*' ;\n");
|
||||
grammarBuilder.append("ADD : '+' ;\n");
|
||||
grammarBuilder.append("INT : [0-9]+ ;\n");
|
||||
grammarBuilder.append("ID : [a-z]+ ;\n");
|
||||
grammarBuilder.append("WS : [ \\t\\n]+ -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="abc";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals(
|
||||
"(a (b abc))\n" +
|
||||
"abc\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testTokenGetters_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(675);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::definitions {\n");
|
||||
grammarBuilder.append("class LeafListener : public TBaseListener {\n");
|
||||
grammarBuilder.append("public:\n");
|
||||
grammarBuilder.append(" virtual void exitA(TParser::AContext *ctx) override {\n");
|
||||
grammarBuilder.append(" if (ctx->getChildCount() == 2)\n");
|
||||
grammarBuilder.append(" std::cout << ctx->INT(0)->getSymbol()->getText() << \" \" << ctx->INT(1)->getSymbol()->getText()\n");
|
||||
grammarBuilder.append(" << \" \" << Arrays::toString(ctx->INT()) << std::endl;\n");
|
||||
grammarBuilder.append(" else\n");
|
||||
grammarBuilder.append(" std::cout << ctx->ID()->getSymbol()->toString() << std::endl;\n");
|
||||
grammarBuilder.append(" }\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
grammarBuilder.append("std::cout << $ctx->r->toStringTree(this) << std::endl;\n");
|
||||
grammarBuilder.append("tree::ParseTreeWalker::DEFAULT->walk(std::make_shared<LeafListener>(), $ctx->r);\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append(" : r=a ;\n");
|
||||
grammarBuilder.append("a : INT INT\n");
|
||||
grammarBuilder.append(" | ID\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("MULT: '*' ;\n");
|
||||
grammarBuilder.append("ADD : '+' ;\n");
|
||||
grammarBuilder.append("INT : [0-9]+ ;\n");
|
||||
grammarBuilder.append("ID : [a-z]+ ;\n");
|
||||
grammarBuilder.append("WS : [ \\t\\n]+ -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="1 2";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals(
|
||||
"(a 1 2)\n" +
|
||||
"1 2 [1, 2]\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testTokenGetters_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(675);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::definitions {\n");
|
||||
grammarBuilder.append("class LeafListener : public TBaseListener {\n");
|
||||
grammarBuilder.append("public:\n");
|
||||
grammarBuilder.append(" virtual void exitA(TParser::AContext *ctx) override {\n");
|
||||
grammarBuilder.append(" if (ctx->getChildCount() == 2)\n");
|
||||
grammarBuilder.append(" std::cout << ctx->INT(0)->getSymbol()->getText() << \" \" << ctx->INT(1)->getSymbol()->getText()\n");
|
||||
grammarBuilder.append(" << \" \" << Arrays::toString(ctx->INT()) << std::endl;\n");
|
||||
grammarBuilder.append(" else\n");
|
||||
grammarBuilder.append(" std::cout << ctx->ID()->getSymbol()->toString() << std::endl;\n");
|
||||
grammarBuilder.append(" }\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
grammarBuilder.append("std::cout << $ctx->r->toStringTree(this) << std::endl;\n");
|
||||
grammarBuilder.append("tree::ParseTreeWalker::DEFAULT->walk(std::make_shared<LeafListener>(), $ctx->r);\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append(" : r=a ;\n");
|
||||
grammarBuilder.append("a : INT INT\n");
|
||||
grammarBuilder.append(" | ID\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("MULT: '*' ;\n");
|
||||
grammarBuilder.append("ADD : '+' ;\n");
|
||||
grammarBuilder.append("INT : [0-9]+ ;\n");
|
||||
grammarBuilder.append("ID : [a-z]+ ;\n");
|
||||
grammarBuilder.append("WS : [ \\t\\n]+ -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="abc";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals(
|
||||
"(a abc)\n" +
|
||||
"[@0,0:2='abc',<4>,1:0]\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,301 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.cpp;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestParseTrees extends BaseCppTest {
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void test2AltLoop() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(147);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@init {\n");
|
||||
grammarBuilder.append("setBuildParseTree(true);\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
grammarBuilder.append("std::cout << $r.ctx->toStringTree(this) << std::endl;\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append(" : r=a ;\n");
|
||||
grammarBuilder.append("a : ('x' | 'y')* 'z'\n");
|
||||
grammarBuilder.append(" ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="xyyxyxz";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals("(a x y y x y x z)\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void test2Alts() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(140);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@init {\n");
|
||||
grammarBuilder.append("setBuildParseTree(true);\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
grammarBuilder.append("std::cout << $r.ctx->toStringTree(this) << std::endl;\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append(" : r=a ;\n");
|
||||
grammarBuilder.append("a : 'x' | 'y'\n");
|
||||
grammarBuilder.append(" ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="y";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals("(a y)\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testAltNum() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(587);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("options { contextSuperClass=MyRuleNode; }\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("class MyRuleNode : public ParserRuleContext {\n");
|
||||
grammarBuilder.append("public:\n");
|
||||
grammarBuilder.append(" int altNum;\n");
|
||||
grammarBuilder.append(" MyRuleNode(std::weak_ptr<ParserRuleContext> parent, int invokingStateNumber)\n");
|
||||
grammarBuilder.append(" : ParserRuleContext(parent, invokingStateNumber) {\n");
|
||||
grammarBuilder.append(" }\n");
|
||||
grammarBuilder.append(" virtual int getAltNumber() const override { return altNum; }\n");
|
||||
grammarBuilder.append(" virtual void setAltNumber(int altNum) override { this->altNum = altNum; }\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@init {\n");
|
||||
grammarBuilder.append("setBuildParseTree(true);\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
grammarBuilder.append("std::cout << $r.ctx->toStringTree(this) << std::endl;\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append(" : r=a ;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("a : 'f'\n");
|
||||
grammarBuilder.append(" | 'g'\n");
|
||||
grammarBuilder.append(" | 'x' b 'z'\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("b : 'e' {} | 'y'\n");
|
||||
grammarBuilder.append(" ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="xyz";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals("(a:3 x (b:2 y) z)\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testExtraToken() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(153);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@init {\n");
|
||||
grammarBuilder.append("setBuildParseTree(true);\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
grammarBuilder.append("std::cout << $r.ctx->toStringTree(this) << std::endl;\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append(" : r=a ;\n");
|
||||
grammarBuilder.append("a : 'x' 'y'\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("Z : 'z' \n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append(" ");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="xzy";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals("(a x z y)\n", found);
|
||||
|
||||
assertEquals("line 1:1 extraneous input 'z' expecting 'y'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testNoViableAlt() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(155);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@init {\n");
|
||||
grammarBuilder.append("setBuildParseTree(true);\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
grammarBuilder.append("std::cout << $r.ctx->toStringTree(this) << std::endl;\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append(" : r=a ;\n");
|
||||
grammarBuilder.append("a : 'x' | 'y'\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("Z : 'z' \n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append(" ");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="z";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals("(a z)\n", found);
|
||||
|
||||
assertEquals("line 1:0 mismatched input 'z' expecting {'x', 'y'}\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testRuleRef() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(149);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@init {\n");
|
||||
grammarBuilder.append("setBuildParseTree(true);\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
grammarBuilder.append("std::cout << $r.ctx->toStringTree(this) << std::endl;\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append(" : r=a ;\n");
|
||||
grammarBuilder.append("a : b 'x'\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("b : 'y' \n");
|
||||
grammarBuilder.append(" ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="yx";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals("(a (b y) x)\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testSync() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(156);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@init {\n");
|
||||
grammarBuilder.append("setBuildParseTree(true);\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
grammarBuilder.append("std::cout << $r.ctx->toStringTree(this) << std::endl;\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append(" : r=a ;\n");
|
||||
grammarBuilder.append("a : 'x' 'y'* '!'\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("Z : 'z' \n");
|
||||
grammarBuilder.append(" ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="xzyy!";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals("(a x z y y !)\n", found);
|
||||
|
||||
assertEquals("line 1:1 extraneous input 'z' expecting {'y', '!'}\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testToken2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(138);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@init {\n");
|
||||
grammarBuilder.append("setBuildParseTree(true);\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
grammarBuilder.append("std::cout << $r.ctx->toStringTree(this) << std::endl;\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append(" : r=a ;\n");
|
||||
grammarBuilder.append("a : 'x' 'y'\n");
|
||||
grammarBuilder.append(" ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="xy";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals("(a x y)\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testTokenAndRuleContextString() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(217);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@init {\n");
|
||||
grammarBuilder.append("setBuildParseTree(true);\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
grammarBuilder.append("std::cout << $r.ctx->toStringTree(this) << std::endl;\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append(" : r=a ;\n");
|
||||
grammarBuilder.append("a : 'x' { \n");
|
||||
grammarBuilder.append("std::cout << Arrays::listToString(getRuleInvocationStack(), \", \") << std::endl;\n");
|
||||
grammarBuilder.append("} ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="x";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals(
|
||||
"[a, s]\n" +
|
||||
"(a x)\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,719 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.cpp;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestParserErrors extends BaseCppTest {
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testConjuringUpToken() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(88);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : 'a' x='b' {std::cout << \"conjured=\" + $x->toString() << std::endl;} 'c' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="ac";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("conjured=[@-1,-1:-1='<missing 'b'>',<2>,1:1]\n", found);
|
||||
|
||||
assertEquals("line 1:1 missing 'b' at 'c'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testConjuringUpTokenFromSet() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(94);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : 'a' x=('b'|'c') {std::cout << \"conjured=\" + $x->toString() << std::endl;} 'd' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="ad";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("conjured=[@-1,-1:-1='<missing 'b'>',<2>,1:1]\n", found);
|
||||
|
||||
assertEquals("line 1:1 missing {'b', 'c'} at 'd'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testContextListGetters() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(218);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::members{\n");
|
||||
grammarBuilder.append("void foo() {\n");
|
||||
grammarBuilder.append(" Ref<SContext> s;\n");
|
||||
grammarBuilder.append(" std::vector<Ref<AContext>> a = s->a();\n");
|
||||
grammarBuilder.append(" std::vector<Ref<BContext>> b = s->b();\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("s : (a | b)+;\n");
|
||||
grammarBuilder.append("a : 'a' {std::cout << 'a';};\n");
|
||||
grammarBuilder.append("b : 'b' {std::cout << 'b';};");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="abab";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, true);
|
||||
|
||||
assertEquals("abab\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testDuplicatedLeftRecursiveCall_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(63);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("start : expr EOF;\n");
|
||||
grammarBuilder.append("expr : 'x'\n");
|
||||
grammarBuilder.append(" | expr expr\n");
|
||||
grammarBuilder.append(" ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="x";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "start", input, true);
|
||||
|
||||
assertEquals("", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testDuplicatedLeftRecursiveCall_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(63);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("start : expr EOF;\n");
|
||||
grammarBuilder.append("expr : 'x'\n");
|
||||
grammarBuilder.append(" | expr expr\n");
|
||||
grammarBuilder.append(" ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="xx";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "start", input, true);
|
||||
|
||||
assertEquals("", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testDuplicatedLeftRecursiveCall_3() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(63);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("start : expr EOF;\n");
|
||||
grammarBuilder.append("expr : 'x'\n");
|
||||
grammarBuilder.append(" | expr expr\n");
|
||||
grammarBuilder.append(" ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="xxx";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "start", input, true);
|
||||
|
||||
assertEquals("", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testDuplicatedLeftRecursiveCall_4() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(63);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("start : expr EOF;\n");
|
||||
grammarBuilder.append("expr : 'x'\n");
|
||||
grammarBuilder.append(" | expr expr\n");
|
||||
grammarBuilder.append(" ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="xxxx";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "start", input, true);
|
||||
|
||||
assertEquals("", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testInvalidATNStateRemoval() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(114);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("start : ID ':' expr;\n");
|
||||
grammarBuilder.append("expr : primary expr? {/* do nothing */} | expr '->' ID;\n");
|
||||
grammarBuilder.append("primary : ID;\n");
|
||||
grammarBuilder.append("ID : [a-z]+;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="x:x";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "start", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testInvalidEmptyInput() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(36);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("start : ID+;\n");
|
||||
grammarBuilder.append("ID : [a-z]+;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "start", input, true);
|
||||
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals("line 1:0 missing ID at '<EOF>'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testLL1ErrorInfo() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(303);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("start : animal (AND acClass)? service EOF;\n");
|
||||
grammarBuilder.append("animal : (DOG | CAT );\n");
|
||||
grammarBuilder.append("service : (HARDWARE | SOFTWARE) ;\n");
|
||||
grammarBuilder.append("AND : 'and';\n");
|
||||
grammarBuilder.append("DOG : 'dog';\n");
|
||||
grammarBuilder.append("CAT : 'cat';\n");
|
||||
grammarBuilder.append("HARDWARE: 'hardware';\n");
|
||||
grammarBuilder.append("SOFTWARE: 'software';\n");
|
||||
grammarBuilder.append("WS : ' ' -> skip ;\n");
|
||||
grammarBuilder.append("acClass\n");
|
||||
grammarBuilder.append("@init\n");
|
||||
grammarBuilder.append("{std::cout << getExpectedTokens().toString(_tokenNames) << std::endl;}\n");
|
||||
grammarBuilder.append(" : ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="dog and software";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "start", input, false);
|
||||
|
||||
assertEquals("{'hardware', 'software'}\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testLL2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(46);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : 'a' 'b'\n");
|
||||
grammarBuilder.append(" | 'a' 'c'\n");
|
||||
grammarBuilder.append(";\n");
|
||||
grammarBuilder.append("q : 'e' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="ae";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals("line 1:1 no viable alternative at input 'ae'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testLL3() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(55);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : 'a' 'b'* 'c'\n");
|
||||
grammarBuilder.append(" | 'a' 'b' 'd'\n");
|
||||
grammarBuilder.append(";\n");
|
||||
grammarBuilder.append("q : 'e' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="abe";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals("line 1:2 no viable alternative at input 'abe'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testLLStar() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(48);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : 'a'+ 'b'\n");
|
||||
grammarBuilder.append(" | 'a'+ 'c'\n");
|
||||
grammarBuilder.append(";\n");
|
||||
grammarBuilder.append("q : 'e' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="aaae";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals("line 1:3 no viable alternative at input 'aaae'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testMultiTokenDeletionBeforeLoop() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(28);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : 'a' 'b'* 'c';");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="aacabc";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals("line 1:1 extraneous input 'a' expecting {'b', 'c'}\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testMultiTokenDeletionBeforeLoop2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(52);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : 'a' ('b'|'z'{/* do nothing */})* 'c';");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="aacabc";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals("line 1:1 extraneous input 'a' expecting {'b', 'z', 'c'}\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testMultiTokenDeletionDuringLoop() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(29);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : 'a' 'b'* 'c' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="abaaababc";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals(
|
||||
"line 1:2 extraneous input 'a' expecting {'b', 'c'}\n" +
|
||||
"line 1:6 extraneous input 'a' expecting {'b', 'c'}\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testMultiTokenDeletionDuringLoop2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(53);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : 'a' ('b'|'z'{/* do nothing */})* 'c' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="abaaababc";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals(
|
||||
"line 1:2 extraneous input 'a' expecting {'b', 'z', 'c'}\n" +
|
||||
"line 1:6 extraneous input 'a' expecting {'b', 'z', 'c'}\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testNoViableAltAvoidance() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(83);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e '!' ;\n");
|
||||
grammarBuilder.append("e : 'a' 'b'\n");
|
||||
grammarBuilder.append(" | 'a'\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("DOT : '.' ;\n");
|
||||
grammarBuilder.append("WS : [ \\t\\r\\n]+ -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="a.";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals("line 1:1 mismatched input '.' expecting '!'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testSingleSetInsertion() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(34);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : 'a' ('b'|'c') 'd' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="ad";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals("line 1:1 missing {'b', 'c'} at 'd'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testSingleSetInsertionConsumption() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(107);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("myset: ('b'|'c') ;\n");
|
||||
grammarBuilder.append("a: 'a' myset 'd' {std::cout << \"\" + $myset.stop->toString() << std::endl;} ; ");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="ad";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("[@0,0:0='a',<3>,1:0]\n", found);
|
||||
|
||||
assertEquals("line 1:1 missing {'b', 'c'} at 'd'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testSingleTokenDeletion() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(24);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : 'a' 'b' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="aab";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals("line 1:1 extraneous input 'a' expecting 'b'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testSingleTokenDeletionBeforeAlt() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(38);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : ('b' | 'c')\n");
|
||||
grammarBuilder.append(";\n");
|
||||
grammarBuilder.append("q : 'a'\n");
|
||||
grammarBuilder.append(";");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="ac";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals("line 1:0 extraneous input 'a' expecting {'b', 'c'}\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testSingleTokenDeletionBeforeLoop() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(25);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : 'a' 'b'* ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="aabc";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals(
|
||||
"line 1:1 extraneous input 'a' expecting {<EOF>, 'b'}\n" +
|
||||
"line 1:3 token recognition error at: 'c'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testSingleTokenDeletionBeforeLoop2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(48);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : 'a' ('b'|'z'{/* do nothing */})*;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="aabc";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals(
|
||||
"line 1:1 extraneous input 'a' expecting {<EOF>, 'b', 'z'}\n" +
|
||||
"line 1:3 token recognition error at: 'c'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testSingleTokenDeletionBeforePredict() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(48);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : 'a'+ 'b'\n");
|
||||
grammarBuilder.append(" | 'a'+ 'c'\n");
|
||||
grammarBuilder.append(";\n");
|
||||
grammarBuilder.append("q : 'e' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="caaab";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals("line 1:0 extraneous input 'c' expecting 'a'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testSingleTokenDeletionConsumption() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(107);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("myset: ('b'|'c') ;\n");
|
||||
grammarBuilder.append("a: 'a' myset 'd' {std::cout << \"\" + $myset.stop->toString() << std::endl;} ; ");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="aabd";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("[@2,2:2='b',<1>,1:2]\n", found);
|
||||
|
||||
assertEquals("line 1:1 extraneous input 'a' expecting {'b', 'c'}\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testSingleTokenDeletionDuringLoop() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(29);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : 'a' 'b'* 'c' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="ababbc";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals("line 1:2 extraneous input 'a' expecting {'b', 'c'}\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testSingleTokenDeletionDuringLoop2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(53);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : 'a' ('b'|'z'{/* do nothing */})* 'c' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="ababbc";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals("line 1:2 extraneous input 'a' expecting {'b', 'z', 'c'}\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testSingleTokenDeletionExpectingSet() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(30);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : 'a' ('b'|'c') ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="aab";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals("line 1:1 extraneous input 'a' expecting {'b', 'c'}\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testSingleTokenInsertion() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(28);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : 'a' 'b' 'c' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="ac";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals("line 1:1 missing 'b' at 'c'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testTokenMismatch() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(24);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : 'a' 'b' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="aa";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals("line 1:1 mismatched input 'a' expecting 'b'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testTokenMismatch2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(165);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("stat: ( '(' expr? ')' )? EOF ;\n");
|
||||
grammarBuilder.append("expr: ID '=' STR ;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("ERR : '~FORCE_ERROR~' ;\n");
|
||||
grammarBuilder.append("ID : [a-zA-Z]+ ;\n");
|
||||
grammarBuilder.append("STR : '\"' ~[\"]* '\"' ;\n");
|
||||
grammarBuilder.append("WS : [ \\t\\r\\n]+ -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="( ~FORCE_ERROR~ ";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "stat", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals("line 1:2 mismatched input '~FORCE_ERROR~' expecting ')'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,790 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.cpp;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestParserExec extends BaseCppTest {
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testAPlus() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(97);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : ID+ {\n");
|
||||
grammarBuilder.append("std::cout << $text << std::endl;\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="a b c";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("abc\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testAStar_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(97);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : ID* {\n");
|
||||
grammarBuilder.append("std::cout << $text << std::endl;\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testAStar_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(97);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : ID* {\n");
|
||||
grammarBuilder.append("std::cout << $text << std::endl;\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="a b c";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("abc\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testAorAPlus() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(102);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : (ID|ID)+ {\n");
|
||||
grammarBuilder.append("std::cout << $text << std::endl;\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="a b c";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("abc\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testAorAStar_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(102);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : (ID|ID)* {\n");
|
||||
grammarBuilder.append("std::cout << $text << std::endl;\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testAorAStar_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(102);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : (ID|ID)* {\n");
|
||||
grammarBuilder.append("std::cout << $text << std::endl;\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="a b c";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("abc\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testAorB() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(162);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : ID {\n");
|
||||
grammarBuilder.append("std::cout << \"alt 1\" << std::endl;\n");
|
||||
grammarBuilder.append("} | INT {\n");
|
||||
grammarBuilder.append("std::cout << \"alt 2\" << std::endl;\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="34";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("alt 2\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testAorBPlus() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(125);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : (ID|INT{\n");
|
||||
grammarBuilder.append("})+ {\n");
|
||||
grammarBuilder.append("std::cout << $text << std::endl;\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="a 34 c";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("a34c\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testAorBStar_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(125);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : (ID|INT{\n");
|
||||
grammarBuilder.append("})* {\n");
|
||||
grammarBuilder.append("std::cout << $text << std::endl;\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testAorBStar_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(125);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : (ID|INT{\n");
|
||||
grammarBuilder.append("})* {\n");
|
||||
grammarBuilder.append("std::cout << $text << std::endl;\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="a 34 c";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("a34c\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testBasic() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(118);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : ID INT {\n");
|
||||
grammarBuilder.append("std::cout << $text << std::endl;\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="abc 34";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("abc34\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testEOFInClosure() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(53);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("prog : stat EOF;\n");
|
||||
grammarBuilder.append("stat : 'x' ('y' | EOF)*?;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="x";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "prog", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testIfIfElseGreedyBinding1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(206);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("start : statement+ ;\n");
|
||||
grammarBuilder.append("statement : 'x' | ifStatement;\n");
|
||||
grammarBuilder.append("ifStatement : 'if' 'y' statement ('else' statement)? {\n");
|
||||
grammarBuilder.append("std::cout << $text << std::endl;\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> channel(HIDDEN);");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="if y if y x else x";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "start", input, false);
|
||||
|
||||
assertEquals(
|
||||
"if y x else x\n" +
|
||||
"if y if y x else x\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testIfIfElseGreedyBinding2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(206);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("start : statement+ ;\n");
|
||||
grammarBuilder.append("statement : 'x' | ifStatement;\n");
|
||||
grammarBuilder.append("ifStatement : 'if' 'y' statement ('else' statement|) {\n");
|
||||
grammarBuilder.append("std::cout << $text << std::endl;\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> channel(HIDDEN);");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="if y if y x else x";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "start", input, false);
|
||||
|
||||
assertEquals(
|
||||
"if y x else x\n" +
|
||||
"if y if y x else x\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testIfIfElseNonGreedyBinding1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(207);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("start : statement+ ;\n");
|
||||
grammarBuilder.append("statement : 'x' | ifStatement;\n");
|
||||
grammarBuilder.append("ifStatement : 'if' 'y' statement ('else' statement)?? {\n");
|
||||
grammarBuilder.append("std::cout << $text << std::endl;\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> channel(HIDDEN);");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="if y if y x else x";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "start", input, false);
|
||||
|
||||
assertEquals(
|
||||
"if y x\n" +
|
||||
"if y if y x else x\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testIfIfElseNonGreedyBinding2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(206);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("start : statement+ ;\n");
|
||||
grammarBuilder.append("statement : 'x' | ifStatement;\n");
|
||||
grammarBuilder.append("ifStatement : 'if' 'y' statement (|'else' statement) {\n");
|
||||
grammarBuilder.append("std::cout << $text << std::endl;\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> channel(HIDDEN);");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="if y if y x else x";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "start", input, false);
|
||||
|
||||
assertEquals(
|
||||
"if y x\n" +
|
||||
"if y if y x else x\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testLL1OptionalBlock_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(123);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : (ID|{}INT)? {\n");
|
||||
grammarBuilder.append("std::cout << $text << std::endl;\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testLL1OptionalBlock_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(123);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : (ID|{}INT)? {\n");
|
||||
grammarBuilder.append("std::cout << $text << std::endl;\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="a";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("a\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testLabelAliasingAcrossLabeledAlternatives() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(197);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("start : a* EOF;\n");
|
||||
grammarBuilder.append("a\n");
|
||||
grammarBuilder.append(" : label=subrule {std::cout << $label.text << std::endl;} #One\n");
|
||||
grammarBuilder.append(" | label='y' {std::cout << $label.text << std::endl;} #Two\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("subrule : 'x';\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="xy";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "start", input, false);
|
||||
|
||||
assertEquals(
|
||||
"x\n" +
|
||||
"y\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testLabels() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(118);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : b1=b b2+=b* b3+=';' ;\n");
|
||||
grammarBuilder.append("b : id_=ID val+=INT*;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="abc 34;";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testListLabelForClosureContext() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(465);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("ifStatement\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
grammarBuilder.append("assert($ctx->elseIfStatement().size() >= 0);\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append(" : 'if' expression\n");
|
||||
grammarBuilder.append(" ( ( 'then'\n");
|
||||
grammarBuilder.append(" executableStatement*\n");
|
||||
grammarBuilder.append(" elseIfStatement* // <--- problem is here; should yield a list not node\n");
|
||||
grammarBuilder.append(" elseStatement?\n");
|
||||
grammarBuilder.append(" 'end' 'if'\n");
|
||||
grammarBuilder.append(" ) | executableStatement )\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("elseIfStatement\n");
|
||||
grammarBuilder.append(" : 'else' 'if' expression 'then' executableStatement*\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("expression : 'a' ;\n");
|
||||
grammarBuilder.append("executableStatement : 'a' ;\n");
|
||||
grammarBuilder.append("elseStatement : 'a' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="a";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "expression", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testListLabelsOnSet() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(140);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : b b* ';' ;\n");
|
||||
grammarBuilder.append("b : ID val+=(INT | FLOAT)*;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||
grammarBuilder.append("FLOAT : [0-9]+ '.' [0-9]+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="abc 34;";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testMultipleEOFHandling() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(42);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("prog : ('x' | 'x' 'y') EOF EOF;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="x";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "prog", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testOptional_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(90);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("stat : ifstat | 'x';\n");
|
||||
grammarBuilder.append("ifstat : 'if' stat ('else' stat)?;\n");
|
||||
grammarBuilder.append("WS : [ \\n\\t]+ -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="x";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "stat", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testOptional_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(90);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("stat : ifstat | 'x';\n");
|
||||
grammarBuilder.append("ifstat : 'if' stat ('else' stat)?;\n");
|
||||
grammarBuilder.append("WS : [ \\n\\t]+ -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="if x";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "stat", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testOptional_3() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(90);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("stat : ifstat | 'x';\n");
|
||||
grammarBuilder.append("ifstat : 'if' stat ('else' stat)?;\n");
|
||||
grammarBuilder.append("WS : [ \\n\\t]+ -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="if x else x";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "stat", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testOptional_4() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(90);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("stat : ifstat | 'x';\n");
|
||||
grammarBuilder.append("ifstat : 'if' stat ('else' stat)?;\n");
|
||||
grammarBuilder.append("WS : [ \\n\\t]+ -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="if if x else x";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "stat", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testParserProperty() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(162);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@members {\n");
|
||||
grammarBuilder.append("bool Property() {\n");
|
||||
grammarBuilder.append(" return true;\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("a : {Property()}? ID {std::cout << \"valid\" << std::endl;}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="abc";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("valid\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testPredicatedIfIfElse() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(174);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : stmt EOF ;\n");
|
||||
grammarBuilder.append("stmt : ifStmt | ID;\n");
|
||||
grammarBuilder.append("ifStmt : 'if' ID stmt ('else' stmt | { _input->LA(1) != TParser::ELSE }?);\n");
|
||||
grammarBuilder.append("ELSE : 'else';\n");
|
||||
grammarBuilder.append("ID : [a-zA-Z]+;\n");
|
||||
grammarBuilder.append("WS : [ \\n\\t]+ -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="if x if x a else b";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, true);
|
||||
|
||||
assertEquals("", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testPredictionIssue334() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(273);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("file_ @init{\n");
|
||||
grammarBuilder.append("_errHandler = std::make_shared<BailErrorStrategy>();\n");
|
||||
grammarBuilder.append("} \n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
grammarBuilder.append("std::cout << $ctx->toStringTree(this) << std::endl;\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append(" : item (SEMICOLON item)* SEMICOLON? EOF ;\n");
|
||||
grammarBuilder.append("item : A B?;\n");
|
||||
grammarBuilder.append("SEMICOLON: ';';\n");
|
||||
grammarBuilder.append("A : 'a'|'A';\n");
|
||||
grammarBuilder.append("B : 'b'|'B';\n");
|
||||
grammarBuilder.append("WS : [ \\r\\t\\n]+ -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="a";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "file_", input, false);
|
||||
|
||||
assertEquals("(file_ (item a) <EOF>)\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testReferenceToATN_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(126);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : (ID|ATN)* ATN? {std::cout << $text << std::endl;} ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("ATN : '0'..'9'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testReferenceToATN_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(126);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : (ID|ATN)* ATN? {std::cout << $text << std::endl;} ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("ATN : '0'..'9'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="a 34 c";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("a34c\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,217 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.cpp;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestPerformance extends BaseCppTest {
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testExpressionGrammar_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(164);
|
||||
grammarBuilder.append("grammar Expr;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("program: expr EOF;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("expr\n");
|
||||
grammarBuilder.append(" : ID\n");
|
||||
grammarBuilder.append(" | 'not' expr\n");
|
||||
grammarBuilder.append(" | expr 'and' expr\n");
|
||||
grammarBuilder.append(" | expr 'or' expr\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("ID: [a-zA-Z_][a-zA-Z_0-9]*;\n");
|
||||
grammarBuilder.append("WS: [ \\t\\n\\r\\f]+ -> skip;\n");
|
||||
grammarBuilder.append("ERROR: .;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input =
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
" X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and X12";
|
||||
String found = execParser("Expr.g4", grammar, "ExprParser", "ExprLexer", "ExprListener", "ExprVisitor", "program", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testExpressionGrammar_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(164);
|
||||
grammarBuilder.append("grammar Expr;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("program: expr EOF;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("expr\n");
|
||||
grammarBuilder.append(" : ID\n");
|
||||
grammarBuilder.append(" | 'not' expr\n");
|
||||
grammarBuilder.append(" | expr 'and' expr\n");
|
||||
grammarBuilder.append(" | expr 'or' expr\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("ID: [a-zA-Z_][a-zA-Z_0-9]*;\n");
|
||||
grammarBuilder.append("WS: [ \\t\\n\\r\\f]+ -> skip;\n");
|
||||
grammarBuilder.append("ERROR: .;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input =
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
" X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
" X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
" X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
" X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
" X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
" X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
" X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
" X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
" X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
" X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and X7 and not X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and X8 and not X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and X9 and not X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and X10 and not X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and X11 and not X12 or\n" +
|
||||
"not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and X12";
|
||||
String found = execParser("Expr.g4", grammar, "ExprParser", "ExprLexer", "ExprListener", "ExprVisitor", "program", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,217 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.cpp;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestSemPredEvalLexer extends BaseCppTest {
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testDisableRule() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(131);
|
||||
grammarBuilder.append("lexer grammar L;\n");
|
||||
grammarBuilder.append("E1 : 'enum' { false }? ;\n");
|
||||
grammarBuilder.append("E2 : 'enum' { true }? ; // winner not E1 or ID\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
String input ="enum abc";
|
||||
String found = execLexer("L.g4", grammar, "L", input, true);
|
||||
assertEquals(
|
||||
"[@0,0:3='enum',<2>,1:0]\n" +
|
||||
"[@1,5:7='abc',<3>,1:5]\n" +
|
||||
"[@2,8:7='<EOF>',<-1>,1:8]\n" +
|
||||
"s0-' '->:s5=>4\n" +
|
||||
"s0-'a'->:s6=>3\n" +
|
||||
"s0-'e'->:s1=>3\n" +
|
||||
":s1=>3-'n'->:s2=>3\n" +
|
||||
":s2=>3-'u'->:s3=>3\n" +
|
||||
":s6=>3-'b'->:s6=>3\n" +
|
||||
":s6=>3-'c'->:s6=>3\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testEnumNotID() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(98);
|
||||
grammarBuilder.append("lexer grammar L;\n");
|
||||
grammarBuilder.append("ENUM : [a-z]+ { getText() == \"enum\" }? ;\n");
|
||||
grammarBuilder.append("ID : [a-z]+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
String input ="enum abc enum";
|
||||
String found = execLexer("L.g4", grammar, "L", input, true);
|
||||
assertEquals(
|
||||
"[@0,0:3='enum',<1>,1:0]\n" +
|
||||
"[@1,5:7='abc',<2>,1:5]\n" +
|
||||
"[@2,9:12='enum',<1>,1:9]\n" +
|
||||
"[@3,13:12='<EOF>',<-1>,1:13]\n" +
|
||||
"s0-' '->:s3=>3\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testIDnotEnum() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(84);
|
||||
grammarBuilder.append("lexer grammar L;\n");
|
||||
grammarBuilder.append("ENUM : [a-z]+ { false }? ;\n");
|
||||
grammarBuilder.append("ID : [a-z]+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
String input ="enum abc enum";
|
||||
String found = execLexer("L.g4", grammar, "L", input, true);
|
||||
assertEquals(
|
||||
"[@0,0:3='enum',<2>,1:0]\n" +
|
||||
"[@1,5:7='abc',<2>,1:5]\n" +
|
||||
"[@2,9:12='enum',<2>,1:9]\n" +
|
||||
"[@3,13:12='<EOF>',<-1>,1:13]\n" +
|
||||
"s0-' '->:s2=>3\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testIDvsEnum() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(85);
|
||||
grammarBuilder.append("lexer grammar L;\n");
|
||||
grammarBuilder.append("ENUM : 'enum' { false }? ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
String input ="enum abc enum";
|
||||
String found = execLexer("L.g4", grammar, "L", input, true);
|
||||
assertEquals(
|
||||
"[@0,0:3='enum',<2>,1:0]\n" +
|
||||
"[@1,5:7='abc',<2>,1:5]\n" +
|
||||
"[@2,9:12='enum',<2>,1:9]\n" +
|
||||
"[@3,13:12='<EOF>',<-1>,1:13]\n" +
|
||||
"s0-' '->:s5=>3\n" +
|
||||
"s0-'a'->:s4=>2\n" +
|
||||
"s0-'e'->:s1=>2\n" +
|
||||
":s1=>2-'n'->:s2=>2\n" +
|
||||
":s2=>2-'u'->:s3=>2\n" +
|
||||
":s4=>2-'b'->:s4=>2\n" +
|
||||
":s4=>2-'c'->:s4=>2\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testIndent() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(163);
|
||||
grammarBuilder.append("lexer grammar L;\n");
|
||||
grammarBuilder.append("ID : [a-z]+ ;\n");
|
||||
grammarBuilder.append("INDENT : [ \\t]+ { tokenStartCharPositionInLine == 0 }?\n");
|
||||
grammarBuilder.append(" { std::cout << \"INDENT\" << std::endl; } ;\n");
|
||||
grammarBuilder.append("NL : '\\n';\n");
|
||||
grammarBuilder.append("WS : [ \\t]+ ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
String input =
|
||||
"abc\n" +
|
||||
" def \n";
|
||||
String found = execLexer("L.g4", grammar, "L", input, true);
|
||||
assertEquals(
|
||||
"INDENT\n" +
|
||||
"[@0,0:2='abc',<1>,1:0]\n" +
|
||||
"[@1,3:3='\\n',<3>,1:3]\n" +
|
||||
"[@2,4:5=' ',<2>,2:0]\n" +
|
||||
"[@3,6:8='def',<1>,2:2]\n" +
|
||||
"[@4,9:10=' ',<4>,2:5]\n" +
|
||||
"[@5,11:11='\\n',<3>,2:7]\n" +
|
||||
"[@6,12:11='<EOF>',<-1>,3:0]\n" +
|
||||
"s0-'\n" +
|
||||
"'->:s2=>3\n" +
|
||||
"s0-'a'->:s1=>1\n" +
|
||||
"s0-'d'->:s1=>1\n" +
|
||||
":s1=>1-'b'->:s1=>1\n" +
|
||||
":s1=>1-'c'->:s1=>1\n" +
|
||||
":s1=>1-'e'->:s1=>1\n" +
|
||||
":s1=>1-'f'->:s1=>1\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testLexerInputPositionSensitivePredicates() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(270);
|
||||
grammarBuilder.append("lexer grammar L;\n");
|
||||
grammarBuilder.append("WORD1 : ID1+ { std::cout << getText() << std::endl; } ;\n");
|
||||
grammarBuilder.append("WORD2 : ID2+ { std::cout << getText() << std::endl; } ;\n");
|
||||
grammarBuilder.append("fragment ID1 : { getCharPositionInLine() < 2 }? [a-zA-Z];\n");
|
||||
grammarBuilder.append("fragment ID2 : { getCharPositionInLine() >= 2 }? [a-zA-Z];\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
String input =
|
||||
"a cde\n" +
|
||||
"abcde\n";
|
||||
String found = execLexer("L.g4", grammar, "L", input, true);
|
||||
assertEquals(
|
||||
"a\n" +
|
||||
"cde\n" +
|
||||
"ab\n" +
|
||||
"cde\n" +
|
||||
"[@0,0:0='a',<1>,1:0]\n" +
|
||||
"[@1,2:4='cde',<2>,1:2]\n" +
|
||||
"[@2,6:7='ab',<1>,2:0]\n" +
|
||||
"[@3,8:10='cde',<2>,2:2]\n" +
|
||||
"[@4,12:11='<EOF>',<-1>,3:0]\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testPredicatedKeywords() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(184);
|
||||
grammarBuilder.append("lexer grammar L;\n");
|
||||
grammarBuilder.append("ENUM : [a-z]+ { getText() == \"enum\" }? { std::cout << \"enum!\" << std::endl; } ;\n");
|
||||
grammarBuilder.append("ID : [a-z]+ { std::cout << \"ID \" + getText() << std::endl; } ;\n");
|
||||
grammarBuilder.append("WS : [ \\n] -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
String input ="enum enu a";
|
||||
String found = execLexer("L.g4", grammar, "L", input, false);
|
||||
assertEquals(
|
||||
"enum!\n" +
|
||||
"ID enu\n" +
|
||||
"ID a\n" +
|
||||
"[@0,0:3='enum',<1>,1:0]\n" +
|
||||
"[@1,5:7='enu',<2>,1:5]\n" +
|
||||
"[@2,9:9='a',<2>,1:9]\n" +
|
||||
"[@3,10:9='<EOF>',<-1>,1:10]\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,761 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.cpp;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestSemPredEvalParser extends BaseCppTest {
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void test2UnpredicatedAlts() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(374);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : {getInterpreter<atn::ParserATNSimulator>()->setPredictionMode(atn::PredictionMode::LL_EXACT_AMBIG_DETECTION);} a ';' a; // do 2x: once in ATN, next in DFA\n");
|
||||
grammarBuilder.append("a : ID {std::cout << \"alt 1\" << std::endl;}\n");
|
||||
grammarBuilder.append(" | ID {std::cout << \"alt 2\" << std::endl;}\n");
|
||||
grammarBuilder.append(" | {false}? ID {std::cout << \"alt 3\" << std::endl;}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="x; y";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, true);
|
||||
|
||||
assertEquals(
|
||||
"alt 1\n" +
|
||||
"alt 1\n", found);
|
||||
|
||||
assertEquals(
|
||||
"line 1:0 reportAttemptingFullContext d=0 (a), input='x'\n" +
|
||||
"line 1:0 reportAmbiguity d=0 (a): ambigAlts={1, 2}, input='x'\n" +
|
||||
"line 1:3 reportAttemptingFullContext d=0 (a), input='y'\n" +
|
||||
"line 1:3 reportAmbiguity d=0 (a): ambigAlts={1, 2}, input='y'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void test2UnpredicatedAltsAndOneOrthogonalAlt() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(439);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : {getInterpreter<atn::ParserATNSimulator>()->setPredictionMode(atn::PredictionMode::LL_EXACT_AMBIG_DETECTION);} a ';' a ';' a;\n");
|
||||
grammarBuilder.append("a : INT {std::cout << \"alt 1\" << std::endl;}\n");
|
||||
grammarBuilder.append(" | ID {std::cout << \"alt 2\" << std::endl;} // must pick this one for ID since pred is false\n");
|
||||
grammarBuilder.append(" | ID {std::cout << \"alt 3\" << std::endl;}\n");
|
||||
grammarBuilder.append(" | {false}? ID {std::cout << \"alt 4\" << std::endl;}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="34; x; y";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, true);
|
||||
|
||||
assertEquals(
|
||||
"alt 1\n" +
|
||||
"alt 2\n" +
|
||||
"alt 2\n", found);
|
||||
|
||||
assertEquals(
|
||||
"line 1:4 reportAttemptingFullContext d=0 (a), input='x'\n" +
|
||||
"line 1:4 reportAmbiguity d=0 (a): ambigAlts={2, 3}, input='x'\n" +
|
||||
"line 1:7 reportAttemptingFullContext d=0 (a), input='y'\n" +
|
||||
"line 1:7 reportAmbiguity d=0 (a): ambigAlts={2, 3}, input='y'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testActionHidesPreds() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(231);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@members {int i = 0;}\n");
|
||||
grammarBuilder.append("s : a+ ;\n");
|
||||
grammarBuilder.append("a : {i = 1;} ID {i == 1}? {std::cout << \"alt 1\" << std::endl;}\n");
|
||||
grammarBuilder.append(" | {i = 2;} ID {i == 2}? {std::cout << \"alt 2\" << std::endl;}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="x x y";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals(
|
||||
"alt 1\n" +
|
||||
"alt 1\n" +
|
||||
"alt 1\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testActionsHidePredsInGlobalFOLLOW() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(308);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@members {\n");
|
||||
grammarBuilder.append("bool pred(bool v) {\n");
|
||||
grammarBuilder.append(" std::cout << \"eval=\" << std::boolalpha << v << std::endl;\n");
|
||||
grammarBuilder.append(" return v;\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("s : e {} {pred(true)}? {std::cout << \"parse\" << std::endl;} '!' ;\n");
|
||||
grammarBuilder.append("t : e {} {pred(false)}? ID ;\n");
|
||||
grammarBuilder.append("e : ID | ; // non-LL(1) so we use ATN\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="a!";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals(
|
||||
"eval=true\n" +
|
||||
"parse\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testAtomWithClosureInTranslatedLRRule() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(94);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("start : e[0] EOF;\n");
|
||||
grammarBuilder.append("e[int _p]\n");
|
||||
grammarBuilder.append(" : ( 'a' | 'b'+ ) ( {3 >= $_p}? '+' e[4] )*\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="a+b+a";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "start", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testDepedentPredsInGlobalFOLLOW() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(335);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@members {\n");
|
||||
grammarBuilder.append("bool pred(bool v) {\n");
|
||||
grammarBuilder.append(" std::cout << \"eval=\" << std::boolalpha << v << std::endl;\n");
|
||||
grammarBuilder.append(" return v;\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("s : a[99] ;\n");
|
||||
grammarBuilder.append("a[int i] : e {pred($i == 99)}? {std::cout << \"parse\" << std::endl;} '!' ;\n");
|
||||
grammarBuilder.append("b[int i] : e {pred($i == 99)}? ID ;\n");
|
||||
grammarBuilder.append("e : ID | ; // non-LL(1) so we use ATN\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="a!";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals(
|
||||
"eval=true\n" +
|
||||
"parse\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testDependentPredNotInOuterCtxShouldBeIgnored() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(300);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : b[2] ';' | b[2] '.' ; // decision in s drills down to ctx-dependent pred in a;\n");
|
||||
grammarBuilder.append("b[int i] : a[i] ;\n");
|
||||
grammarBuilder.append("a[int i]\n");
|
||||
grammarBuilder.append(" : {$i == 1}? ID {std::cout << \"alt 1\" << std::endl;}\n");
|
||||
grammarBuilder.append(" | {$i == 2}? ID {std::cout << \"alt 2\" << std::endl;}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;\n");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="a;";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals("alt 2\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testDisabledAlternative() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(121);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("cppCompilationUnit : content+ EOF;\n");
|
||||
grammarBuilder.append("content: anything | {false}? .;\n");
|
||||
grammarBuilder.append("anything: ANY_CHAR;\n");
|
||||
grammarBuilder.append("ANY_CHAR: [_a-zA-Z0-9];");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="hello";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "cppCompilationUnit", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testIndependentPredNotPassedOuterCtxToAvoidCastException() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(209);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : b ';' | b '.' ;\n");
|
||||
grammarBuilder.append("b : a ;\n");
|
||||
grammarBuilder.append("a\n");
|
||||
grammarBuilder.append(" : {false}? ID {std::cout << \"alt 1\" << std::endl;}\n");
|
||||
grammarBuilder.append(" | {true}? ID {std::cout << \"alt 2\" << std::endl;}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="a;";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals("alt 2\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testNoTruePredsThrowsNoViableAlt() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(197);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : a a;\n");
|
||||
grammarBuilder.append("a : {false}? ID INT {std::cout << \"alt 1\" << std::endl;}\n");
|
||||
grammarBuilder.append(" | {false}? ID INT {std::cout << \"alt 2\" << std::endl;}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="y 3 x 4";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals("line 1:0 no viable alternative at input 'y'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testOrder() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(323);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : a {} a; // do 2x: once in ATN, next in DFA;\n");
|
||||
grammarBuilder.append("// action blocks lookahead from falling off of 'a'\n");
|
||||
grammarBuilder.append("// and looking into 2nd 'a' ref. !ctx dependent pred\n");
|
||||
grammarBuilder.append("a : ID {std::cout << \"alt 1\" << std::endl;}\n");
|
||||
grammarBuilder.append(" | {true}? ID {std::cout << \"alt 2\" << std::endl;}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="x y";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals(
|
||||
"alt 1\n" +
|
||||
"alt 1\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testPredFromAltTestedInLoopBack_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(217);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("file_\n");
|
||||
grammarBuilder.append("@after {std::cout << $ctx->toStringTree(this) << std::endl;}\n");
|
||||
grammarBuilder.append(" : para para EOF ;\n");
|
||||
grammarBuilder.append("para: paraContent NL NL ;\n");
|
||||
grammarBuilder.append("paraContent : ('s'|'x'|{_input->LA(2) != TParser::NL}? NL)+ ;\n");
|
||||
grammarBuilder.append("NL : '\\n' ;\n");
|
||||
grammarBuilder.append("s : 's' ;\n");
|
||||
grammarBuilder.append("X : 'x' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input =
|
||||
"s\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"x\n";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "file_", input, true);
|
||||
|
||||
assertEquals("(file_ (para (paraContent s) \\n \\n) (para (paraContent \\n x \\n)) <EOF>)\n", found);
|
||||
|
||||
assertEquals(
|
||||
"line 5:0 mismatched input '<EOF>' expecting '\n" +
|
||||
"'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testPredFromAltTestedInLoopBack_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(217);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("file_\n");
|
||||
grammarBuilder.append("@after {std::cout << $ctx->toStringTree(this) << std::endl;}\n");
|
||||
grammarBuilder.append(" : para para EOF ;\n");
|
||||
grammarBuilder.append("para: paraContent NL NL ;\n");
|
||||
grammarBuilder.append("paraContent : ('s'|'x'|{_input->LA(2) != TParser::NL}? NL)+ ;\n");
|
||||
grammarBuilder.append("NL : '\\n' ;\n");
|
||||
grammarBuilder.append("s : 's' ;\n");
|
||||
grammarBuilder.append("X : 'x' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input =
|
||||
"s\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"x\n" +
|
||||
"\n";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "file_", input, true);
|
||||
|
||||
assertEquals("(file_ (para (paraContent s) \\n \\n) (para (paraContent \\n x) \\n \\n) <EOF>)\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testPredTestedEvenWhenUnAmbig_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(222);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@members {bool enumKeyword = true;}\n");
|
||||
grammarBuilder.append("primary\n");
|
||||
grammarBuilder.append(" : ID {std::cout << \"ID \"+$ID.text << std::endl;}\n");
|
||||
grammarBuilder.append(" | {!enumKeyword}? 'enum' {std::cout << \"enum\" << std::endl;}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : [a-z]+ ;\n");
|
||||
grammarBuilder.append("WS : [ \\t\\n\\r]+ -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="abc";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "primary", input, false);
|
||||
|
||||
assertEquals("ID abc\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testPredTestedEvenWhenUnAmbig_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(222);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@members {bool enumKeyword = true;}\n");
|
||||
grammarBuilder.append("primary\n");
|
||||
grammarBuilder.append(" : ID {std::cout << \"ID \"+$ID.text << std::endl;}\n");
|
||||
grammarBuilder.append(" | {!enumKeyword}? 'enum' {std::cout << \"enum\" << std::endl;}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : [a-z]+ ;\n");
|
||||
grammarBuilder.append("WS : [ \\t\\n\\r]+ -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="enum";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "primary", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals("line 1:0 no viable alternative at input 'enum'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testPredicateDependentOnArg() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(230);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@members {int i = 0;}\n");
|
||||
grammarBuilder.append("s : a[2] a[1];\n");
|
||||
grammarBuilder.append("a[int i]\n");
|
||||
grammarBuilder.append(" : {$i == 1}? ID {std::cout << \"alt 1\" << std::endl;}\n");
|
||||
grammarBuilder.append(" | {$i == 2}? ID {std::cout << \"alt 2\" << std::endl;}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="a b";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals(
|
||||
"alt 2\n" +
|
||||
"alt 1\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testPredicateDependentOnArg2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(158);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@members {int i = 0;}\n");
|
||||
grammarBuilder.append("s : a[2] a[1];\n");
|
||||
grammarBuilder.append("a[int i]\n");
|
||||
grammarBuilder.append(" : {$i == 1}? ID \n");
|
||||
grammarBuilder.append(" | {$i == 2}? ID \n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="a b";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testPredsInGlobalFOLLOW() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(302);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@members {\n");
|
||||
grammarBuilder.append("bool pred(bool v) {\n");
|
||||
grammarBuilder.append(" std::cout << \"eval=\" << std::boolalpha << v << std::endl;\n");
|
||||
grammarBuilder.append(" return v;\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("s : e {pred(true)}? {std::cout << \"parse\" << std::endl;} '!' ;\n");
|
||||
grammarBuilder.append("t : e {pred(false)}? ID ;\n");
|
||||
grammarBuilder.append("e : ID | ; // non-LL(1) so we use ATN\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="a!";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals(
|
||||
"eval=true\n" +
|
||||
"parse\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testRewindBeforePredEval() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(249);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : a a;\n");
|
||||
grammarBuilder.append("a : {_input->LT(1)->getText() == \"x\"}? ID INT {std::cout << \"alt 1\" << std::endl;}\n");
|
||||
grammarBuilder.append(" | {_input->LT(1)->getText() == \"y\"}? ID INT {std::cout << \"alt 2\" << std::endl;}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="y 3 x 4";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals(
|
||||
"alt 2\n" +
|
||||
"alt 1\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testSimple() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(295);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : a a a; // do 3x: once in ATN, next in DFA then INT in ATN\n");
|
||||
grammarBuilder.append("a : {false}? ID {std::cout << \"alt 1\" << std::endl;}\n");
|
||||
grammarBuilder.append(" | {true}? ID {std::cout << \"alt 2\" << std::endl;}\n");
|
||||
grammarBuilder.append(" | INT {std::cout << \"alt 3\" << std::endl;}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="x y 3";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals(
|
||||
"alt 2\n" +
|
||||
"alt 2\n" +
|
||||
"alt 3\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testSimpleValidate() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(190);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : a ;\n");
|
||||
grammarBuilder.append("a : {false}? ID {std::cout << \"alt 1\" << std::endl;}\n");
|
||||
grammarBuilder.append(" | {true}? INT {std::cout << \"alt 2\" << std::endl;}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="x";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals("line 1:0 no viable alternative at input 'x'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testSimpleValidate2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(193);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : a a a;\n");
|
||||
grammarBuilder.append("a : {false}? ID {std::cout << \"alt 1\" << std::endl;}\n");
|
||||
grammarBuilder.append(" | {true}? INT {std::cout << \"alt 2\" << std::endl;}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="3 4 x";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals(
|
||||
"alt 2\n" +
|
||||
"alt 2\n", found);
|
||||
|
||||
assertEquals("line 1:4 no viable alternative at input 'x'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testToLeft() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(190);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append(" s : a+ ;\n");
|
||||
grammarBuilder.append("a : {false}? ID {std::cout << \"alt 1\" << std::endl;}\n");
|
||||
grammarBuilder.append(" | {true}? ID {std::cout << \"alt 2\" << std::endl;}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="x x y";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals(
|
||||
"alt 2\n" +
|
||||
"alt 2\n" +
|
||||
"alt 2\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testToLeftWithVaryingPredicate() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(271);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@members {int i = 0;}\n");
|
||||
grammarBuilder.append("s : ({i += 1;\n");
|
||||
grammarBuilder.append(" std::cout << \"i=\" << i << std::endl;} a)+ ;\n");
|
||||
grammarBuilder.append("a : {i % 2 == 0}? ID {std::cout << \"alt 1\" << std::endl;}\n");
|
||||
grammarBuilder.append(" | {i % 2 != 0}? ID {std::cout << \"alt 2\" << std::endl;}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="x x y";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals(
|
||||
"i=1\n" +
|
||||
"alt 2\n" +
|
||||
"i=2\n" +
|
||||
"alt 1\n" +
|
||||
"i=3\n" +
|
||||
"alt 2\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testUnpredicatedPathsInAlt() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(209);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : a {std::cout << \"alt 1\" << std::endl;}\n");
|
||||
grammarBuilder.append(" | b {std::cout << \"alt 2\" << std::endl;}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("a : {false}? ID INT\n");
|
||||
grammarBuilder.append(" | ID INT\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("b : ID ID\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="x 4";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals("alt 1\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testValidateInDFA() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(358);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : a ';' a;\n");
|
||||
grammarBuilder.append("// ';' helps us to resynchronize without consuming\n");
|
||||
grammarBuilder.append("// 2nd 'a' reference. We our testing that the DFA also\n");
|
||||
grammarBuilder.append("// throws an exception if the validating predicate fails\n");
|
||||
grammarBuilder.append("a : {false}? ID {std::cout << \"alt 1\" << std::endl;}\n");
|
||||
grammarBuilder.append(" | {true}? INT {std::cout << \"alt 2\" << std::endl;}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="x ; y";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "s", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals(
|
||||
"line 1:0 no viable alternative at input 'x'\n" +
|
||||
"line 1:4 no viable alternative at input 'y'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,476 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.cpp;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestSets extends BaseCppTest {
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testCharSetLiteral() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(98);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : (A {std::cout << $A.text << std::endl;})+ ;\n");
|
||||
grammarBuilder.append("A : [AaBb] ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n')+ -> skip ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="A a B b";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals(
|
||||
"A\n" +
|
||||
"a\n" +
|
||||
"B\n" +
|
||||
"b\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testComplementSet() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(51);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("parse : ~NEW_LINE;\n");
|
||||
grammarBuilder.append("NEW_LINE: '\\r'? '\\n';");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="a";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "parse", input, false);
|
||||
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals(
|
||||
"line 1:0 token recognition error at: 'a'\n" +
|
||||
"line 1:1 missing {} at '<EOF>'\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testLexerOptionalSet() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(86);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : A {std::cout << _input->getText() << std::endl;} ;\n");
|
||||
grammarBuilder.append("A : ('a'|'b')? 'c' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="ac";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("ac\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testLexerPlusSet() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(86);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : A {std::cout << _input->getText() << std::endl;} ;\n");
|
||||
grammarBuilder.append("A : ('a'|'b')+ 'c' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="abaac";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("abaac\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testLexerStarSet() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(86);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : A {std::cout << _input->getText() << std::endl;} ;\n");
|
||||
grammarBuilder.append("A : ('a'|'b')* 'c' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="abaac";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("abaac\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testNotChar() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(66);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : A {std::cout << $A.text << std::endl;} ;\n");
|
||||
grammarBuilder.append("A : ~'b' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="x";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("x\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testNotCharSet() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(72);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : A {std::cout << $A.text << std::endl;} ;\n");
|
||||
grammarBuilder.append("A : ~('b'|'c') ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="x";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("x\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testNotCharSetWithLabel() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(74);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : A {std::cout << $A.text << std::endl;} ;\n");
|
||||
grammarBuilder.append("A : h=~('b'|'c') ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="x";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("x\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testNotCharSetWithRuleRef3() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(138);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : A {std::cout << $A.text << std::endl;} ;\n");
|
||||
grammarBuilder.append("A : ('a'|B) ; // this doesn't collapse to set but works\n");
|
||||
grammarBuilder.append("fragment\n");
|
||||
grammarBuilder.append("B : ~('a'|'c') ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="x";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("x\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testOptionalLexerSingleElement() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(80);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : A {std::cout << _input->getText() << std::endl;} ;\n");
|
||||
grammarBuilder.append("A : 'b'? 'c' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="bc";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("bc\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testOptionalSet() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(78);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : ('a'|'b')? 'c' {std::cout << _input->getText() << std::endl;} ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="ac";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("ac\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testOptionalSingleElement() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(80);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : A? 'c' {std::cout << _input->getText() << std::endl;} ;\n");
|
||||
grammarBuilder.append("A : 'b' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="bc";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("bc\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testParserNotSet() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(70);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : t=~('x'|'y') 'z' {std::cout << $t.text << std::endl;} ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="zz";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("z\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testParserNotToken() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(72);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : ~'x' 'z' {std::cout << _input->getText() << std::endl;} ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="zz";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("zz\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testParserNotTokenWithLabel() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(64);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : t=~'x' 'z' {std::cout << $t.text << std::endl;} ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="zz";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("z\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testParserSet() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(65);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : t=('x'|'y') {std::cout << $t.text << std::endl;} ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="x";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("x\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testPlusLexerSingleElement() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(80);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : A {std::cout << _input->getText() << std::endl;} ;\n");
|
||||
grammarBuilder.append("A : 'b'+ 'c' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="bbbbc";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("bbbbc\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testPlusSet() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(78);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : ('a'|'b')+ 'c' {std::cout << _input->getText() << std::endl;} ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="abaac";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("abaac\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testRuleAsSet() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(85);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a @after {std::cout << _input->getText() << std::endl;} : 'a' | 'b' |'c' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="b";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("b\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testSeqDoesNotBecomeSet() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(122);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : C {std::cout << _input->getText() << std::endl;} ;\n");
|
||||
grammarBuilder.append("fragment A : '1' | '2';\n");
|
||||
grammarBuilder.append("fragment B : '3' '4';\n");
|
||||
grammarBuilder.append("C : A | B;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="34";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("34\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testStarLexerSingleElement_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(80);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : A {std::cout << _input->getText() << std::endl;} ;\n");
|
||||
grammarBuilder.append("A : 'b'* 'c' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="bbbbc";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("bbbbc\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testStarLexerSingleElement_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(80);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : A {std::cout << _input->getText() << std::endl;} ;\n");
|
||||
grammarBuilder.append("A : 'b'* 'c' ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="c";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("c\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
public void testStarSet() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(78);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("a : ('a'|'b')* 'c' {std::cout << _input->getText() << std::endl;} ;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
String input ="abaac";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false);
|
||||
|
||||
assertEquals("abaac\n", found);
|
||||
assertNull(this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1553,7 +1553,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
@Test
|
||||
public void testMultipleActionsPredicatesOptions_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(246);
|
||||
StringBuilder grammarBuilder = new StringBuilder(245);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s @after {Console.WriteLine($ctx.ToStringTree(this));} : e ;\n");
|
||||
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{true}?\n");
|
||||
|
@ -1562,7 +1562,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
String input ="4";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "s", input, false);
|
||||
|
@ -1574,7 +1574,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
@Test
|
||||
public void testMultipleActionsPredicatesOptions_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(246);
|
||||
StringBuilder grammarBuilder = new StringBuilder(245);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s @after {Console.WriteLine($ctx.ToStringTree(this));} : e ;\n");
|
||||
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{true}?\n");
|
||||
|
@ -1583,7 +1583,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
String input ="1*2/3";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "s", input, false);
|
||||
|
@ -1595,7 +1595,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
@Test
|
||||
public void testMultipleActionsPredicatesOptions_3() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(246);
|
||||
StringBuilder grammarBuilder = new StringBuilder(245);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s @after {Console.WriteLine($ctx.ToStringTree(this));} : e ;\n");
|
||||
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{true}?\n");
|
||||
|
@ -1604,7 +1604,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
String input ="(1/2)*3";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "s", input, false);
|
||||
|
@ -1676,7 +1676,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
@Test
|
||||
public void testMultipleAlternativesWithCommonLabel_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(741);
|
||||
StringBuilder grammarBuilder = new StringBuilder(740);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {Console.WriteLine($e.v);};\n");
|
||||
grammarBuilder.append("e returns [int v]\n");
|
||||
|
@ -1692,7 +1692,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("INC : '++' ;\n");
|
||||
grammarBuilder.append("DEC : '--' ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
String input ="4";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "s", input, false);
|
||||
|
@ -1704,7 +1704,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
@Test
|
||||
public void testMultipleAlternativesWithCommonLabel_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(741);
|
||||
StringBuilder grammarBuilder = new StringBuilder(740);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {Console.WriteLine($e.v);};\n");
|
||||
grammarBuilder.append("e returns [int v]\n");
|
||||
|
@ -1720,7 +1720,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("INC : '++' ;\n");
|
||||
grammarBuilder.append("DEC : '--' ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
String input ="1+2";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "s", input, false);
|
||||
|
@ -1732,7 +1732,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
@Test
|
||||
public void testMultipleAlternativesWithCommonLabel_3() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(741);
|
||||
StringBuilder grammarBuilder = new StringBuilder(740);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {Console.WriteLine($e.v);};\n");
|
||||
grammarBuilder.append("e returns [int v]\n");
|
||||
|
@ -1748,7 +1748,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("INC : '++' ;\n");
|
||||
grammarBuilder.append("DEC : '--' ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
String input ="1+2*3";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "s", input, false);
|
||||
|
@ -1760,7 +1760,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
@Test
|
||||
public void testMultipleAlternativesWithCommonLabel_4() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(741);
|
||||
StringBuilder grammarBuilder = new StringBuilder(740);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {Console.WriteLine($e.v);};\n");
|
||||
grammarBuilder.append("e returns [int v]\n");
|
||||
|
@ -1776,7 +1776,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("INC : '++' ;\n");
|
||||
grammarBuilder.append("DEC : '--' ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
String input ="i++*3";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "s", input, false);
|
||||
|
|
|
@ -11,10 +11,8 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testBasic() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(458);
|
||||
StringBuilder grammarBuilder = new StringBuilder(438);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("public class LeafListener : TBaseListener {\n");
|
||||
|
@ -53,10 +51,8 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testLR() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(612);
|
||||
StringBuilder grammarBuilder = new StringBuilder(592);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("public class LeafListener : TBaseListener {\n");
|
||||
|
@ -103,10 +99,8 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testLRWithLabels() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(636);
|
||||
StringBuilder grammarBuilder = new StringBuilder(616);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("public class LeafListener : TBaseListener {\n");
|
||||
|
@ -151,10 +145,8 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testRuleGetters_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(634);
|
||||
StringBuilder grammarBuilder = new StringBuilder(614);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("public class LeafListener : TBaseListener {\n");
|
||||
|
@ -197,10 +189,8 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testRuleGetters_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(634);
|
||||
StringBuilder grammarBuilder = new StringBuilder(614);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("public class LeafListener : TBaseListener {\n");
|
||||
|
@ -243,10 +233,8 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testTokenGetters_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(801);
|
||||
StringBuilder grammarBuilder = new StringBuilder(781);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("public class LeafListener : TBaseListener {\n");
|
||||
|
@ -297,10 +285,8 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testTokenGetters_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(801);
|
||||
StringBuilder grammarBuilder = new StringBuilder(781);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("public class LeafListener : TBaseListener {\n");
|
||||
|
|
|
@ -552,11 +552,11 @@ public class TestSemPredEvalParser extends BaseTest {
|
|||
@Test
|
||||
public void testToLeftWithVaryingPredicate() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(268);
|
||||
StringBuilder grammarBuilder = new StringBuilder(261);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@members {int i = 0;}\n");
|
||||
grammarBuilder.append("s : ({this.i += 1;\n");
|
||||
grammarBuilder.append("Console.WriteLine(\"i=\" + this.i);} a)+ ;\n");
|
||||
grammarBuilder.append("Console.WriteLine(\"i=\"+i);} a)+ ;\n");
|
||||
grammarBuilder.append("a : {this.i % 2 == 0}? ID {Console.WriteLine(\"alt 1\");}\n");
|
||||
grammarBuilder.append(" | {this.i % 2 != 0}? ID {Console.WriteLine(\"alt 2\");}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
|
|
|
@ -1715,7 +1715,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
public void testMultipleActionsPredicatesOptions_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(247);
|
||||
StringBuilder grammarBuilder = new StringBuilder(246);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s @after {System.out.println($ctx.toStringTree(this));} : e ;\n");
|
||||
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{true}?\n");
|
||||
|
@ -1724,7 +1724,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
|
@ -1740,7 +1740,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
public void testMultipleActionsPredicatesOptions_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(247);
|
||||
StringBuilder grammarBuilder = new StringBuilder(246);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s @after {System.out.println($ctx.toStringTree(this));} : e ;\n");
|
||||
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{true}?\n");
|
||||
|
@ -1749,7 +1749,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
|
@ -1765,7 +1765,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
public void testMultipleActionsPredicatesOptions_3() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(247);
|
||||
StringBuilder grammarBuilder = new StringBuilder(246);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s @after {System.out.println($ctx.toStringTree(this));} : e ;\n");
|
||||
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{true}?\n");
|
||||
|
@ -1774,7 +1774,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
|
@ -1862,7 +1862,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
public void testMultipleAlternativesWithCommonLabel_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(730);
|
||||
StringBuilder grammarBuilder = new StringBuilder(729);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {System.out.println($e.v);};\n");
|
||||
grammarBuilder.append("e returns [int v]\n");
|
||||
|
@ -1878,7 +1878,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("INC : '++' ;\n");
|
||||
grammarBuilder.append("DEC : '--' ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
|
@ -1894,7 +1894,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
public void testMultipleAlternativesWithCommonLabel_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(730);
|
||||
StringBuilder grammarBuilder = new StringBuilder(729);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {System.out.println($e.v);};\n");
|
||||
grammarBuilder.append("e returns [int v]\n");
|
||||
|
@ -1910,7 +1910,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("INC : '++' ;\n");
|
||||
grammarBuilder.append("DEC : '--' ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
|
@ -1926,7 +1926,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
public void testMultipleAlternativesWithCommonLabel_3() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(730);
|
||||
StringBuilder grammarBuilder = new StringBuilder(729);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {System.out.println($e.v);};\n");
|
||||
grammarBuilder.append("e returns [int v]\n");
|
||||
|
@ -1942,7 +1942,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("INC : '++' ;\n");
|
||||
grammarBuilder.append("DEC : '--' ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
|
@ -1958,7 +1958,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
public void testMultipleAlternativesWithCommonLabel_4() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(730);
|
||||
StringBuilder grammarBuilder = new StringBuilder(729);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {System.out.println($e.v);};\n");
|
||||
grammarBuilder.append("e returns [int v]\n");
|
||||
|
@ -1974,7 +1974,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("INC : '++' ;\n");
|
||||
grammarBuilder.append("DEC : '--' ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
|
|
|
@ -13,10 +13,8 @@ public class TestListeners extends BaseTest {
|
|||
public void testBasic() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(473);
|
||||
StringBuilder grammarBuilder = new StringBuilder(453);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("public static class LeafListener extends TBaseListener {\n");
|
||||
|
@ -59,10 +57,8 @@ public class TestListeners extends BaseTest {
|
|||
public void testLR() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(653);
|
||||
StringBuilder grammarBuilder = new StringBuilder(633);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("public static class LeafListener extends TBaseListener {\n");
|
||||
|
@ -113,10 +109,8 @@ public class TestListeners extends BaseTest {
|
|||
public void testLRWithLabels() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(650);
|
||||
StringBuilder grammarBuilder = new StringBuilder(630);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("public static class LeafListener extends TBaseListener {\n");
|
||||
|
@ -165,10 +159,8 @@ public class TestListeners extends BaseTest {
|
|||
public void testRuleGetters_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(670);
|
||||
StringBuilder grammarBuilder = new StringBuilder(650);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("public static class LeafListener extends TBaseListener {\n");
|
||||
|
@ -215,10 +207,8 @@ public class TestListeners extends BaseTest {
|
|||
public void testRuleGetters_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(670);
|
||||
StringBuilder grammarBuilder = new StringBuilder(650);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("public static class LeafListener extends TBaseListener {\n");
|
||||
|
@ -265,10 +255,8 @@ public class TestListeners extends BaseTest {
|
|||
public void testTokenGetters_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(615);
|
||||
StringBuilder grammarBuilder = new StringBuilder(595);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("public static class LeafListener extends TBaseListener {\n");
|
||||
|
@ -314,10 +302,8 @@ public class TestListeners extends BaseTest {
|
|||
public void testTokenGetters_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(615);
|
||||
StringBuilder grammarBuilder = new StringBuilder(595);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("public static class LeafListener extends TBaseListener {\n");
|
||||
|
|
|
@ -646,11 +646,11 @@ public class TestSemPredEvalParser extends BaseTest {
|
|||
public void testToLeftWithVaryingPredicate() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(271);
|
||||
StringBuilder grammarBuilder = new StringBuilder(264);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@members {int i = 0;}\n");
|
||||
grammarBuilder.append("s : ({this.i += 1;\n");
|
||||
grammarBuilder.append("System.out.println(\"i=\" + this.i);} a)+ ;\n");
|
||||
grammarBuilder.append("System.out.println(\"i=\"+i);} a)+ ;\n");
|
||||
grammarBuilder.append("a : {this.i % 2 == 0}? ID {System.out.println(\"alt 1\");}\n");
|
||||
grammarBuilder.append(" | {this.i % 2 != 0}? ID {System.out.println(\"alt 2\");}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
|
|
|
@ -1635,7 +1635,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
@Test
|
||||
public void testMultipleActionsPredicatesOptions_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(246);
|
||||
StringBuilder grammarBuilder = new StringBuilder(245);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s @after {console.log($ctx.toStringTree(null, this));} : e ;\n");
|
||||
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{true}?\n");
|
||||
|
@ -1644,7 +1644,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
String input ="4";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer",
|
||||
|
@ -1658,7 +1658,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
@Test
|
||||
public void testMultipleActionsPredicatesOptions_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(246);
|
||||
StringBuilder grammarBuilder = new StringBuilder(245);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s @after {console.log($ctx.toStringTree(null, this));} : e ;\n");
|
||||
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{true}?\n");
|
||||
|
@ -1667,7 +1667,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
String input ="1*2/3";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer",
|
||||
|
@ -1681,7 +1681,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
@Test
|
||||
public void testMultipleActionsPredicatesOptions_3() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(246);
|
||||
StringBuilder grammarBuilder = new StringBuilder(245);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s @after {console.log($ctx.toStringTree(null, this));} : e ;\n");
|
||||
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{true}?\n");
|
||||
|
@ -1690,7 +1690,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
String input ="(1/2)*3";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer",
|
||||
|
@ -1770,7 +1770,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
@Test
|
||||
public void testMultipleAlternativesWithCommonLabel_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(639);
|
||||
StringBuilder grammarBuilder = new StringBuilder(638);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {console.log($e.v);};\n");
|
||||
grammarBuilder.append("e returns [int v]\n");
|
||||
|
@ -1786,7 +1786,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("INC : '++' ;\n");
|
||||
grammarBuilder.append("DEC : '--' ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
String input ="4";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer",
|
||||
|
@ -1800,7 +1800,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
@Test
|
||||
public void testMultipleAlternativesWithCommonLabel_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(639);
|
||||
StringBuilder grammarBuilder = new StringBuilder(638);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {console.log($e.v);};\n");
|
||||
grammarBuilder.append("e returns [int v]\n");
|
||||
|
@ -1816,7 +1816,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("INC : '++' ;\n");
|
||||
grammarBuilder.append("DEC : '--' ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
String input ="1+2";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer",
|
||||
|
@ -1830,7 +1830,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
@Test
|
||||
public void testMultipleAlternativesWithCommonLabel_3() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(639);
|
||||
StringBuilder grammarBuilder = new StringBuilder(638);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {console.log($e.v);};\n");
|
||||
grammarBuilder.append("e returns [int v]\n");
|
||||
|
@ -1846,7 +1846,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("INC : '++' ;\n");
|
||||
grammarBuilder.append("DEC : '--' ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
String input ="1+2*3";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer",
|
||||
|
@ -1860,7 +1860,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
@Test
|
||||
public void testMultipleAlternativesWithCommonLabel_4() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(639);
|
||||
StringBuilder grammarBuilder = new StringBuilder(638);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {console.log($e.v);};\n");
|
||||
grammarBuilder.append("e returns [int v]\n");
|
||||
|
@ -1876,7 +1876,7 @@ public class TestLeftRecursion extends BaseTest {
|
|||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("INC : '++' ;\n");
|
||||
grammarBuilder.append("DEC : '--' ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
String input ="i++*3";
|
||||
String found = execParser("T.g4", grammar, "TParser", "TLexer",
|
||||
|
|
|
@ -13,12 +13,12 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testBasic() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(633);
|
||||
StringBuilder grammarBuilder = new StringBuilder(632);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("var TListener = require('./TListener').TListener;\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("this.LeafListener = function() {\n");
|
||||
grammarBuilder.append(" this.visitTerminal = function(node) {\n");
|
||||
|
@ -28,7 +28,6 @@ public class TestListeners extends BaseTest {
|
|||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("this.LeafListener.prototype = Object.create(TListener.prototype);\n");
|
||||
grammarBuilder.append("this.LeafListener.prototype.constructor = this.LeafListener;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -62,12 +61,12 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testLR() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(843);
|
||||
StringBuilder grammarBuilder = new StringBuilder(842);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("var TListener = require('./TListener').TListener;\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("this.LeafListener = function() {\n");
|
||||
grammarBuilder.append(" this.exitE = function(ctx) {\n");
|
||||
|
@ -83,7 +82,6 @@ public class TestListeners extends BaseTest {
|
|||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("this.LeafListener.prototype = Object.create(TListener.prototype);\n");
|
||||
grammarBuilder.append("this.LeafListener.prototype.constructor = this.LeafListener;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -121,12 +119,12 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testLRWithLabels() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(833);
|
||||
StringBuilder grammarBuilder = new StringBuilder(832);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("var TListener = require('./TListener').TListener;\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("this.LeafListener = function() {\n");
|
||||
grammarBuilder.append(" this.exitCall = function(ctx) {\n");
|
||||
|
@ -141,7 +139,6 @@ public class TestListeners extends BaseTest {
|
|||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("this.LeafListener.prototype = Object.create(TListener.prototype);\n");
|
||||
grammarBuilder.append("this.LeafListener.prototype.constructor = this.LeafListener;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -178,12 +175,12 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testRuleGetters_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(868);
|
||||
StringBuilder grammarBuilder = new StringBuilder(867);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("var TListener = require('./TListener').TListener;\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("this.LeafListener = function() {\n");
|
||||
grammarBuilder.append(" this.exitA = function(ctx) {\n");
|
||||
|
@ -199,7 +196,6 @@ public class TestListeners extends BaseTest {
|
|||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("this.LeafListener.prototype = Object.create(TListener.prototype);\n");
|
||||
grammarBuilder.append("this.LeafListener.prototype.constructor = this.LeafListener;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -233,12 +229,12 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testRuleGetters_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(868);
|
||||
StringBuilder grammarBuilder = new StringBuilder(867);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("var TListener = require('./TListener').TListener;\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("this.LeafListener = function() {\n");
|
||||
grammarBuilder.append(" this.exitA = function(ctx) {\n");
|
||||
|
@ -254,7 +250,6 @@ public class TestListeners extends BaseTest {
|
|||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("this.LeafListener.prototype = Object.create(TListener.prototype);\n");
|
||||
grammarBuilder.append("this.LeafListener.prototype.constructor = this.LeafListener;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -288,12 +283,12 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testTokenGetters_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(855);
|
||||
StringBuilder grammarBuilder = new StringBuilder(854);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("var TListener = require('./TListener').TListener;\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("this.LeafListener = function() {\n");
|
||||
grammarBuilder.append(" this.exitA = function(ctx) {\n");
|
||||
|
@ -309,7 +304,6 @@ public class TestListeners extends BaseTest {
|
|||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("this.LeafListener.prototype = Object.create(TListener.prototype);\n");
|
||||
grammarBuilder.append("this.LeafListener.prototype.constructor = this.LeafListener;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -342,12 +336,12 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testTokenGetters_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(855);
|
||||
StringBuilder grammarBuilder = new StringBuilder(854);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("var TListener = require('./TListener').TListener;\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("this.LeafListener = function() {\n");
|
||||
grammarBuilder.append(" this.exitA = function(ctx) {\n");
|
||||
|
@ -363,7 +357,6 @@ public class TestListeners extends BaseTest {
|
|||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("this.LeafListener.prototype = Object.create(TListener.prototype);\n");
|
||||
grammarBuilder.append("this.LeafListener.prototype.constructor = this.LeafListener;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
|
|
@ -600,11 +600,11 @@ public class TestSemPredEvalParser extends BaseTest {
|
|||
@Test
|
||||
public void testToLeftWithVaryingPredicate() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(252);
|
||||
StringBuilder grammarBuilder = new StringBuilder(245);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@members {this.i = 0;}\n");
|
||||
grammarBuilder.append("s : ({this.i += 1;\n");
|
||||
grammarBuilder.append("console.log(\"i=\" + this.i);} a)+ ;\n");
|
||||
grammarBuilder.append("console.log(\"i=\"+i);} a)+ ;\n");
|
||||
grammarBuilder.append("a : {this.i % 2 === 0}? ID {console.log(\"alt 1\");}\n");
|
||||
grammarBuilder.append(" | {this.i % 2 != 0}? ID {console.log(\"alt 2\");}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
|
|
|
@ -1755,7 +1755,7 @@ public class TestLeftRecursion extends BasePython2Test {
|
|||
public void testMultipleActionsPredicatesOptions_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(239);
|
||||
StringBuilder grammarBuilder = new StringBuilder(238);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s @after {print($ctx.toStringTree(recog=self))} : e ;\n");
|
||||
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{True}?\n");
|
||||
|
@ -1764,7 +1764,7 @@ public class TestLeftRecursion extends BasePython2Test {
|
|||
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
|
@ -1781,7 +1781,7 @@ public class TestLeftRecursion extends BasePython2Test {
|
|||
public void testMultipleActionsPredicatesOptions_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(239);
|
||||
StringBuilder grammarBuilder = new StringBuilder(238);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s @after {print($ctx.toStringTree(recog=self))} : e ;\n");
|
||||
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{True}?\n");
|
||||
|
@ -1790,7 +1790,7 @@ public class TestLeftRecursion extends BasePython2Test {
|
|||
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
|
@ -1807,7 +1807,7 @@ public class TestLeftRecursion extends BasePython2Test {
|
|||
public void testMultipleActionsPredicatesOptions_3() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(239);
|
||||
StringBuilder grammarBuilder = new StringBuilder(238);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s @after {print($ctx.toStringTree(recog=self))} : e ;\n");
|
||||
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{True}?\n");
|
||||
|
@ -1816,7 +1816,7 @@ public class TestLeftRecursion extends BasePython2Test {
|
|||
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
|
@ -1908,7 +1908,7 @@ public class TestLeftRecursion extends BasePython2Test {
|
|||
public void testMultipleAlternativesWithCommonLabel_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(561);
|
||||
StringBuilder grammarBuilder = new StringBuilder(560);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {print($e.v)};\n");
|
||||
grammarBuilder.append("e returns [int v]\n");
|
||||
|
@ -1924,7 +1924,7 @@ public class TestLeftRecursion extends BasePython2Test {
|
|||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("INC : '++' ;\n");
|
||||
grammarBuilder.append("DEC : '--' ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
|
@ -1941,7 +1941,7 @@ public class TestLeftRecursion extends BasePython2Test {
|
|||
public void testMultipleAlternativesWithCommonLabel_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(561);
|
||||
StringBuilder grammarBuilder = new StringBuilder(560);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {print($e.v)};\n");
|
||||
grammarBuilder.append("e returns [int v]\n");
|
||||
|
@ -1957,7 +1957,7 @@ public class TestLeftRecursion extends BasePython2Test {
|
|||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("INC : '++' ;\n");
|
||||
grammarBuilder.append("DEC : '--' ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
|
@ -1974,7 +1974,7 @@ public class TestLeftRecursion extends BasePython2Test {
|
|||
public void testMultipleAlternativesWithCommonLabel_3() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(561);
|
||||
StringBuilder grammarBuilder = new StringBuilder(560);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {print($e.v)};\n");
|
||||
grammarBuilder.append("e returns [int v]\n");
|
||||
|
@ -1990,7 +1990,7 @@ public class TestLeftRecursion extends BasePython2Test {
|
|||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("INC : '++' ;\n");
|
||||
grammarBuilder.append("DEC : '--' ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
|
@ -2007,7 +2007,7 @@ public class TestLeftRecursion extends BasePython2Test {
|
|||
public void testMultipleAlternativesWithCommonLabel_4() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(561);
|
||||
StringBuilder grammarBuilder = new StringBuilder(560);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {print($e.v)};\n");
|
||||
grammarBuilder.append("e returns [int v]\n");
|
||||
|
@ -2023,7 +2023,7 @@ public class TestLeftRecursion extends BasePython2Test {
|
|||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("INC : '++' ;\n");
|
||||
grammarBuilder.append("DEC : '--' ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
|
|
|
@ -13,10 +13,8 @@ public class TestListeners extends BasePython2Test {
|
|||
public void testBasic() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(511);
|
||||
StringBuilder grammarBuilder = new StringBuilder(490);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("if __name__ is not None and \".\" in __name__:\n");
|
||||
|
@ -27,7 +25,6 @@ public class TestListeners extends BasePython2Test {
|
|||
grammarBuilder.append("class LeafListener(TListener):\n");
|
||||
grammarBuilder.append(" def visitTerminal(self, node):\n");
|
||||
grammarBuilder.append(" print(node.symbol.text)\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -64,10 +61,8 @@ public class TestListeners extends BasePython2Test {
|
|||
public void testLR() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(672);
|
||||
StringBuilder grammarBuilder = new StringBuilder(651);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("if __name__ is not None and \".\" in __name__:\n");
|
||||
|
@ -81,7 +76,6 @@ public class TestListeners extends BasePython2Test {
|
|||
grammarBuilder.append(" print(ctx.e(0).start.text + ' ' + ctx.e(1).start.text + ' ' + ctx.e()[0].start.text)\n");
|
||||
grammarBuilder.append(" else:\n");
|
||||
grammarBuilder.append(" print(ctx.INT().symbol.text)\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -122,10 +116,8 @@ public class TestListeners extends BasePython2Test {
|
|||
public void testLRWithLabels() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(652);
|
||||
StringBuilder grammarBuilder = new StringBuilder(631);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("if __name__ is not None and \".\" in __name__:\n");
|
||||
|
@ -138,7 +130,6 @@ public class TestListeners extends BasePython2Test {
|
|||
grammarBuilder.append(" print(ctx.e().start.text + ' ' + str(ctx.eList()))\n");
|
||||
grammarBuilder.append(" def exitInt(self, ctx):\n");
|
||||
grammarBuilder.append(" print(ctx.INT().symbol.text)\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -178,10 +169,8 @@ public class TestListeners extends BasePython2Test {
|
|||
public void testRuleGetters_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(697);
|
||||
StringBuilder grammarBuilder = new StringBuilder(676);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("if __name__ is not None and \".\" in __name__:\n");
|
||||
|
@ -195,7 +184,6 @@ public class TestListeners extends BasePython2Test {
|
|||
grammarBuilder.append(" print(ctx.b(0).start.text + ' ' + ctx.b(1).start.text + ' ' + ctx.b()[0].start.text)\n");
|
||||
grammarBuilder.append(" else:\n");
|
||||
grammarBuilder.append(" print(ctx.b(0).start.text)\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -232,10 +220,8 @@ public class TestListeners extends BasePython2Test {
|
|||
public void testRuleGetters_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(697);
|
||||
StringBuilder grammarBuilder = new StringBuilder(676);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("if __name__ is not None and \".\" in __name__:\n");
|
||||
|
@ -249,7 +235,6 @@ public class TestListeners extends BasePython2Test {
|
|||
grammarBuilder.append(" print(ctx.b(0).start.text + ' ' + ctx.b(1).start.text + ' ' + ctx.b()[0].start.text)\n");
|
||||
grammarBuilder.append(" else:\n");
|
||||
grammarBuilder.append(" print(ctx.b(0).start.text)\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -286,10 +271,8 @@ public class TestListeners extends BasePython2Test {
|
|||
public void testTokenGetters_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(660);
|
||||
StringBuilder grammarBuilder = new StringBuilder(639);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("if __name__ is not None and \".\" in __name__:\n");
|
||||
|
@ -303,7 +286,6 @@ public class TestListeners extends BasePython2Test {
|
|||
grammarBuilder.append(" print(ctx.INT(0).symbol.text + ' ' + ctx.INT(1).symbol.text + ' ' + str_list(ctx.INT()))\n");
|
||||
grammarBuilder.append(" else:\n");
|
||||
grammarBuilder.append(" print(str(ctx.ID().symbol))\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -339,10 +321,8 @@ public class TestListeners extends BasePython2Test {
|
|||
public void testTokenGetters_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(660);
|
||||
StringBuilder grammarBuilder = new StringBuilder(639);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("if __name__ is not None and \".\" in __name__:\n");
|
||||
|
@ -356,7 +336,6 @@ public class TestListeners extends BasePython2Test {
|
|||
grammarBuilder.append(" print(ctx.INT(0).symbol.text + ' ' + ctx.INT(1).symbol.text + ' ' + str_list(ctx.INT()))\n");
|
||||
grammarBuilder.append(" else:\n");
|
||||
grammarBuilder.append(" print(str(ctx.ID().symbol))\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
|
|
@ -669,11 +669,11 @@ public class TestSemPredEvalParser extends BasePython2Test {
|
|||
public void testToLeftWithVaryingPredicate() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(228);
|
||||
StringBuilder grammarBuilder = new StringBuilder(226);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@members {i = 0}\n");
|
||||
grammarBuilder.append("s : ({self.i += 1\n");
|
||||
grammarBuilder.append("print(\"i=\" + str(self.i))} a)+ ;\n");
|
||||
grammarBuilder.append("print(str(\"i=\")+str(i))} a)+ ;\n");
|
||||
grammarBuilder.append("a : {self.i % 2 == 0}? ID {print(\"alt 1\")}\n");
|
||||
grammarBuilder.append(" | {self.i % 2 != 0}? ID {print(\"alt 2\")}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
|
|
|
@ -1755,7 +1755,7 @@ public class TestLeftRecursion extends BasePython3Test {
|
|||
public void testMultipleActionsPredicatesOptions_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(239);
|
||||
StringBuilder grammarBuilder = new StringBuilder(238);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s @after {print($ctx.toStringTree(recog=self))} : e ;\n");
|
||||
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{True}?\n");
|
||||
|
@ -1764,7 +1764,7 @@ public class TestLeftRecursion extends BasePython3Test {
|
|||
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
|
@ -1781,7 +1781,7 @@ public class TestLeftRecursion extends BasePython3Test {
|
|||
public void testMultipleActionsPredicatesOptions_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(239);
|
||||
StringBuilder grammarBuilder = new StringBuilder(238);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s @after {print($ctx.toStringTree(recog=self))} : e ;\n");
|
||||
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{True}?\n");
|
||||
|
@ -1790,7 +1790,7 @@ public class TestLeftRecursion extends BasePython3Test {
|
|||
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
|
@ -1807,7 +1807,7 @@ public class TestLeftRecursion extends BasePython3Test {
|
|||
public void testMultipleActionsPredicatesOptions_3() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(239);
|
||||
StringBuilder grammarBuilder = new StringBuilder(238);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s @after {print($ctx.toStringTree(recog=self))} : e ;\n");
|
||||
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{True}?\n");
|
||||
|
@ -1816,7 +1816,7 @@ public class TestLeftRecursion extends BasePython3Test {
|
|||
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
|
@ -1908,7 +1908,7 @@ public class TestLeftRecursion extends BasePython3Test {
|
|||
public void testMultipleAlternativesWithCommonLabel_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(561);
|
||||
StringBuilder grammarBuilder = new StringBuilder(560);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {print($e.v)};\n");
|
||||
grammarBuilder.append("e returns [int v]\n");
|
||||
|
@ -1924,7 +1924,7 @@ public class TestLeftRecursion extends BasePython3Test {
|
|||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("INC : '++' ;\n");
|
||||
grammarBuilder.append("DEC : '--' ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
|
@ -1941,7 +1941,7 @@ public class TestLeftRecursion extends BasePython3Test {
|
|||
public void testMultipleAlternativesWithCommonLabel_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(561);
|
||||
StringBuilder grammarBuilder = new StringBuilder(560);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {print($e.v)};\n");
|
||||
grammarBuilder.append("e returns [int v]\n");
|
||||
|
@ -1957,7 +1957,7 @@ public class TestLeftRecursion extends BasePython3Test {
|
|||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("INC : '++' ;\n");
|
||||
grammarBuilder.append("DEC : '--' ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
|
@ -1974,7 +1974,7 @@ public class TestLeftRecursion extends BasePython3Test {
|
|||
public void testMultipleAlternativesWithCommonLabel_3() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(561);
|
||||
StringBuilder grammarBuilder = new StringBuilder(560);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {print($e.v)};\n");
|
||||
grammarBuilder.append("e returns [int v]\n");
|
||||
|
@ -1990,7 +1990,7 @@ public class TestLeftRecursion extends BasePython3Test {
|
|||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("INC : '++' ;\n");
|
||||
grammarBuilder.append("DEC : '--' ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
|
@ -2007,7 +2007,7 @@ public class TestLeftRecursion extends BasePython3Test {
|
|||
public void testMultipleAlternativesWithCommonLabel_4() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(561);
|
||||
StringBuilder grammarBuilder = new StringBuilder(560);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {print($e.v)};\n");
|
||||
grammarBuilder.append("e returns [int v]\n");
|
||||
|
@ -2023,7 +2023,7 @@ public class TestLeftRecursion extends BasePython3Test {
|
|||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||
grammarBuilder.append("INC : '++' ;\n");
|
||||
grammarBuilder.append("DEC : '--' ;\n");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||
String grammar = grammarBuilder.toString();
|
||||
|
||||
|
||||
|
|
|
@ -13,18 +13,17 @@ public class TestListeners extends BasePython3Test {
|
|||
public void testBasic() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(588);
|
||||
StringBuilder grammarBuilder = new StringBuilder(587);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("class MockListener:\n");
|
||||
grammarBuilder.append(" pass\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("class LeafListener(MockListener):\n");
|
||||
grammarBuilder.append(" def visitTerminal(self, node):\n");
|
||||
grammarBuilder.append(" print(node.symbol.text)\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -66,13 +65,13 @@ public class TestListeners extends BasePython3Test {
|
|||
public void testLR() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(749);
|
||||
StringBuilder grammarBuilder = new StringBuilder(748);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("class MockListener:\n");
|
||||
grammarBuilder.append(" pass\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("class LeafListener(MockListener):\n");
|
||||
grammarBuilder.append(" def exitE(self, ctx):\n");
|
||||
|
@ -80,7 +79,6 @@ public class TestListeners extends BasePython3Test {
|
|||
grammarBuilder.append(" print(ctx.e(0).start.text + ' ' + ctx.e(1).start.text + ' ' + ctx.e()[0].start.text)\n");
|
||||
grammarBuilder.append(" else:\n");
|
||||
grammarBuilder.append(" print(ctx.INT().symbol.text)\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -126,20 +124,19 @@ public class TestListeners extends BasePython3Test {
|
|||
public void testLRWithLabels() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(729);
|
||||
StringBuilder grammarBuilder = new StringBuilder(728);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("class MockListener:\n");
|
||||
grammarBuilder.append(" pass\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("class LeafListener(MockListener):\n");
|
||||
grammarBuilder.append(" def exitCall(self, ctx):\n");
|
||||
grammarBuilder.append(" print(ctx.e().start.text + ' ' + str(ctx.eList()))\n");
|
||||
grammarBuilder.append(" def exitInt(self, ctx):\n");
|
||||
grammarBuilder.append(" print(ctx.INT().symbol.text)\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -184,13 +181,13 @@ public class TestListeners extends BasePython3Test {
|
|||
public void testRuleGetters_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(774);
|
||||
StringBuilder grammarBuilder = new StringBuilder(773);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("class MockListener:\n");
|
||||
grammarBuilder.append(" pass\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("class LeafListener(MockListener):\n");
|
||||
grammarBuilder.append(" def exitA(self, ctx):\n");
|
||||
|
@ -198,7 +195,6 @@ public class TestListeners extends BasePython3Test {
|
|||
grammarBuilder.append(" print(ctx.b(0).start.text + ' ' + ctx.b(1).start.text + ' ' + ctx.b()[0].start.text)\n");
|
||||
grammarBuilder.append(" else:\n");
|
||||
grammarBuilder.append(" print(ctx.b(0).start.text)\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -240,13 +236,13 @@ public class TestListeners extends BasePython3Test {
|
|||
public void testRuleGetters_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(774);
|
||||
StringBuilder grammarBuilder = new StringBuilder(773);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("class MockListener:\n");
|
||||
grammarBuilder.append(" pass\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("class LeafListener(MockListener):\n");
|
||||
grammarBuilder.append(" def exitA(self, ctx):\n");
|
||||
|
@ -254,7 +250,6 @@ public class TestListeners extends BasePython3Test {
|
|||
grammarBuilder.append(" print(ctx.b(0).start.text + ' ' + ctx.b(1).start.text + ' ' + ctx.b()[0].start.text)\n");
|
||||
grammarBuilder.append(" else:\n");
|
||||
grammarBuilder.append(" print(ctx.b(0).start.text)\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -296,13 +291,13 @@ public class TestListeners extends BasePython3Test {
|
|||
public void testTokenGetters_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(737);
|
||||
StringBuilder grammarBuilder = new StringBuilder(736);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("class MockListener:\n");
|
||||
grammarBuilder.append(" pass\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("class LeafListener(MockListener):\n");
|
||||
grammarBuilder.append(" def exitA(self, ctx):\n");
|
||||
|
@ -310,7 +305,6 @@ public class TestListeners extends BasePython3Test {
|
|||
grammarBuilder.append(" print(ctx.INT(0).symbol.text + ' ' + ctx.INT(1).symbol.text + ' ' + str_list(ctx.INT()))\n");
|
||||
grammarBuilder.append(" else:\n");
|
||||
grammarBuilder.append(" print(str(ctx.ID().symbol))\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -351,13 +345,13 @@ public class TestListeners extends BasePython3Test {
|
|||
public void testTokenGetters_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(737);
|
||||
StringBuilder grammarBuilder = new StringBuilder(736);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("class MockListener:\n");
|
||||
grammarBuilder.append(" pass\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("class LeafListener(MockListener):\n");
|
||||
grammarBuilder.append(" def exitA(self, ctx):\n");
|
||||
|
@ -365,7 +359,6 @@ public class TestListeners extends BasePython3Test {
|
|||
grammarBuilder.append(" print(ctx.INT(0).symbol.text + ' ' + ctx.INT(1).symbol.text + ' ' + str_list(ctx.INT()))\n");
|
||||
grammarBuilder.append(" else:\n");
|
||||
grammarBuilder.append(" print(str(ctx.ID().symbol))\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
|
|
@ -669,11 +669,11 @@ public class TestSemPredEvalParser extends BasePython3Test {
|
|||
public void testToLeftWithVaryingPredicate() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(228);
|
||||
StringBuilder grammarBuilder = new StringBuilder(226);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@members {i = 0}\n");
|
||||
grammarBuilder.append("s : ({self.i += 1\n");
|
||||
grammarBuilder.append("print(\"i=\" + str(self.i))} a)+ ;\n");
|
||||
grammarBuilder.append("print(str(\"i=\")+str(i))} a)+ ;\n");
|
||||
grammarBuilder.append("a : {self.i % 2 == 0}? ID {print(\"alt 1\")}\n");
|
||||
grammarBuilder.append(" | {self.i % 2 != 0}? ID {print(\"alt 2\")}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
|
|
|
@ -14,9 +14,9 @@ ANTLR 4 is the result of substantial effort of the following people:
|
|||
|
||||
The C++ target has been the work of the following people:
|
||||
|
||||
* Dan McLaughlin, dan.mclaughlin@gmail.com C++ Target project leader
|
||||
* David Sisson, dsisson@google.com
|
||||
* [Mike Lischke](www.soft-gems.net), mike@lischke-online.de
|
||||
* Dan McLaughlin, dan.mclaughlin@gmail.com (initial port, got code to compile)
|
||||
* David Sisson, dsisson@google.com (initial port, made the runtime C++ tests runnable)
|
||||
* [Mike Lischke](www.soft-gems.net), mike@lischke-online.de (brought the initial port to a working library, made most runtime tests passing)
|
||||
|
||||
## Other contributors
|
||||
|
||||
|
@ -30,6 +30,7 @@ The C++ target has been the work of the following people:
|
|||
* Some unit tests in the OSX project, for important base classes with almost 100% code coverage.
|
||||
* All memory allocations checked
|
||||
* Simple command line demo application working on all supported platforms.
|
||||
* All runtime tests pass.
|
||||
|
||||
### Build + Usage Notes
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
4.0.0
|
||||
4.5.4
|
||||
|
|
|
@ -12,10 +12,9 @@
|
|||
#include "TParser.h"
|
||||
|
||||
using namespace antlrcpptest;
|
||||
using namespace org::antlr::v4::runtime;
|
||||
using namespace antlr4;
|
||||
|
||||
int main(int , const char **) {
|
||||
|
||||
ANTLRInputStream input(u8"🍴 = 🍐 + \"😎\";(((x * π))) * µ + ∰; a + (x * (y ? 0 : 1) + z);");
|
||||
TLexer lexer(&input);
|
||||
CommonTokenStream tokens(&lexer);
|
||||
|
|
|
@ -36,8 +36,8 @@
|
|||
#include "StringUtils.h"
|
||||
|
||||
using namespace antlrcpp;
|
||||
using namespace org::antlr::v4::runtime;
|
||||
using namespace org::antlr::v4::runtime::misc;
|
||||
using namespace antlr4;
|
||||
using namespace antlr4::misc;
|
||||
|
||||
@interface InputHandlingTests : XCTestCase
|
||||
|
||||
|
|
|
@ -37,8 +37,8 @@
|
|||
#include "Lexer.h"
|
||||
#include "CPPUtils.h"
|
||||
|
||||
using namespace org::antlr::v4::runtime;
|
||||
using namespace org::antlr::v4::runtime::misc;
|
||||
using namespace antlr4;
|
||||
using namespace antlr4::misc;
|
||||
using namespace antlrcpp;
|
||||
|
||||
@interface MiscClassTests : XCTestCase
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
using namespace org::antlr::v4::runtime;
|
||||
using namespace antlr4;
|
||||
|
||||
@interface antlrcpp_Tests : XCTestCase
|
||||
|
||||
|
@ -59,7 +59,7 @@ using namespace org::antlr::v4::runtime;
|
|||
std::vector<dfa::DFA> decisionToDFA;
|
||||
atn::ATN atn;
|
||||
|
||||
org::antlr::v4::runtime::atn::ParserATNSimulator foo(nullptr, atn, decisionToDFA, nullptr);
|
||||
antlr4::atn::ParserATNSimulator foo(nullptr, atn, decisionToDFA, nullptr);
|
||||
}
|
||||
catch (std::exception &e) {
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@
|
|||
27A23EA11CC2A8D60036D8A3 /* TLexer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TLexer.cpp; path = ../generated/TLexer.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
27A23EA21CC2A8D60036D8A3 /* TLexer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TLexer.h; path = ../generated/TLexer.h; sourceTree = "<group>"; };
|
||||
27C66A671C9591280021E494 /* antlr4-cpp-demo */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "antlr4-cpp-demo"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
27C66A691C9591280021E494 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
|
||||
27C66A691C9591280021E494 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
27C66A731C9592400021E494 /* TLexer.g4 */ = {isa = PBXFileReference; lastKnownFileType = text; name = TLexer.g4; path = ../../TLexer.g4; sourceTree = "<group>"; };
|
||||
27C66A741C9592400021E494 /* TParser.g4 */ = {isa = PBXFileReference; lastKnownFileType = text; name = TParser.g4; path = ../../TParser.g4; sourceTree = "<group>"; };
|
||||
27C6E1741C972FFC0079AF06 /* TParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TParser.cpp; path = ../generated/TParser.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Demo application for the ANTLR 4 C++ target
|
||||
## Demo application for the ANTLR 4 C++ target
|
||||
|
||||
This demo app shows how to build the ANTLR runtime both as dynamic and static library and how to use a parser generated from a simple demo grammar.
|
||||
|
||||
|
@ -10,4 +10,4 @@ A few steps are necessary to get this to work:
|
|||
- Open the project in the folder that matches your system.
|
||||
- Compile and run.
|
||||
|
||||
Compilation is done as described in the runtime/cpp/readme.md file.
|
||||
Compilation is done as described in the [runtime/cpp/readme.md](../README.md) file.
|
||||
|
|
|
@ -29,6 +29,7 @@ int main(int argc, const char * argv[]) {
|
|||
|
||||
std::wstring s = antlrcpp::s2ws(tree->toStringTree(&parser)) + L"\n";
|
||||
OutputDebugString(s.data());
|
||||
std::wcout << "Parse Tree: " << s << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -18,10 +18,9 @@ file(GLOB libantlrcpp_SRC
|
|||
"${PROJECT_SOURCE_DIR}/runtime/src/support/*.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/runtime/src/tree/*.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/runtime/src/tree/pattern/*.cpp"
|
||||
"${PROJECT_SOURCE_DIR}/runtime/src/tree/xpath/*.cpp"
|
||||
)
|
||||
|
||||
list(REMOVE_ITEM libantlrcpp_SRC ${PROJECT_SOURCE_DIR}/runtime/src/misc/TestRig.cpp)
|
||||
|
||||
add_library(antlr4_shared SHARED ${libantlrcpp_SRC})
|
||||
add_library(antlr4_static STATIC ${libantlrcpp_SRC})
|
||||
|
||||
|
|
|
@ -283,6 +283,16 @@
|
|||
<ClCompile Include="src\tree\TerminalNodeImpl.cpp" />
|
||||
<ClCompile Include="src\tree\Tree.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\VocabularyImpl.cpp" />
|
||||
|
@ -432,7 +442,16 @@
|
|||
<ClInclude Include="src\tree\TerminalNodeImpl.h" />
|
||||
<ClInclude Include="src\tree\Tree.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" />
|
||||
|
|
|
@ -507,6 +507,33 @@
|
|||
<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>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\ANTLRFileStream.cpp">
|
||||
|
@ -878,5 +905,35 @@
|
|||
<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>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -582,12 +582,6 @@
|
|||
276E5F741CDB57AA003FF4B4 /* Predicate.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5CD11CDB57AA003FF4B4 /* Predicate.h */; };
|
||||
276E5F751CDB57AA003FF4B4 /* Predicate.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5CD11CDB57AA003FF4B4 /* Predicate.h */; };
|
||||
276E5F761CDB57AA003FF4B4 /* Predicate.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5CD11CDB57AA003FF4B4 /* Predicate.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
276E5F771CDB57AA003FF4B4 /* TestRig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5CD21CDB57AA003FF4B4 /* TestRig.cpp */; };
|
||||
276E5F781CDB57AA003FF4B4 /* TestRig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5CD21CDB57AA003FF4B4 /* TestRig.cpp */; };
|
||||
276E5F791CDB57AA003FF4B4 /* TestRig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5CD21CDB57AA003FF4B4 /* TestRig.cpp */; };
|
||||
276E5F7A1CDB57AA003FF4B4 /* TestRig.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5CD31CDB57AA003FF4B4 /* TestRig.h */; };
|
||||
276E5F7B1CDB57AA003FF4B4 /* TestRig.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5CD31CDB57AA003FF4B4 /* TestRig.h */; };
|
||||
276E5F7C1CDB57AA003FF4B4 /* TestRig.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5CD31CDB57AA003FF4B4 /* TestRig.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
276E5F7D1CDB57AA003FF4B4 /* NoViableAltException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5CD41CDB57AA003FF4B4 /* NoViableAltException.cpp */; };
|
||||
276E5F7E1CDB57AA003FF4B4 /* NoViableAltException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5CD41CDB57AA003FF4B4 /* NoViableAltException.cpp */; };
|
||||
276E5F7F1CDB57AA003FF4B4 /* NoViableAltException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5CD41CDB57AA003FF4B4 /* NoViableAltException.cpp */; };
|
||||
|
@ -804,15 +798,12 @@
|
|||
276E60641CDB57AA003FF4B4 /* UnbufferedTokenStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5D251CDB57AA003FF4B4 /* UnbufferedTokenStream.h */; };
|
||||
276E60651CDB57AA003FF4B4 /* UnbufferedTokenStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5D251CDB57AA003FF4B4 /* UnbufferedTokenStream.h */; };
|
||||
276E60661CDB57AA003FF4B4 /* UnbufferedTokenStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5D251CDB57AA003FF4B4 /* UnbufferedTokenStream.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
276E60671CDB57AA003FF4B4 /* Vocabulary.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5D261CDB57AA003FF4B4 /* Vocabulary.h */; };
|
||||
276E60681CDB57AA003FF4B4 /* Vocabulary.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5D261CDB57AA003FF4B4 /* Vocabulary.h */; };
|
||||
276E60691CDB57AA003FF4B4 /* Vocabulary.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5D261CDB57AA003FF4B4 /* Vocabulary.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
276E606A1CDB57AA003FF4B4 /* VocabularyImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5D271CDB57AA003FF4B4 /* VocabularyImpl.cpp */; };
|
||||
276E606B1CDB57AA003FF4B4 /* VocabularyImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5D271CDB57AA003FF4B4 /* VocabularyImpl.cpp */; };
|
||||
276E606C1CDB57AA003FF4B4 /* VocabularyImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5D271CDB57AA003FF4B4 /* VocabularyImpl.cpp */; };
|
||||
276E606D1CDB57AA003FF4B4 /* VocabularyImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5D281CDB57AA003FF4B4 /* VocabularyImpl.h */; };
|
||||
276E606E1CDB57AA003FF4B4 /* VocabularyImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5D281CDB57AA003FF4B4 /* VocabularyImpl.h */; };
|
||||
276E606F1CDB57AA003FF4B4 /* VocabularyImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5D281CDB57AA003FF4B4 /* VocabularyImpl.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
276E606A1CDB57AA003FF4B4 /* Vocabulary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5D271CDB57AA003FF4B4 /* Vocabulary.cpp */; };
|
||||
276E606B1CDB57AA003FF4B4 /* Vocabulary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5D271CDB57AA003FF4B4 /* Vocabulary.cpp */; };
|
||||
276E606C1CDB57AA003FF4B4 /* Vocabulary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 276E5D271CDB57AA003FF4B4 /* Vocabulary.cpp */; };
|
||||
276E606D1CDB57AA003FF4B4 /* Vocabulary.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5D281CDB57AA003FF4B4 /* Vocabulary.h */; };
|
||||
276E606E1CDB57AA003FF4B4 /* Vocabulary.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5D281CDB57AA003FF4B4 /* Vocabulary.h */; };
|
||||
276E606F1CDB57AA003FF4B4 /* Vocabulary.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5D281CDB57AA003FF4B4 /* Vocabulary.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
276E60731CDB57AA003FF4B4 /* WritableToken.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5D2A1CDB57AA003FF4B4 /* WritableToken.h */; };
|
||||
276E60741CDB57AA003FF4B4 /* WritableToken.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5D2A1CDB57AA003FF4B4 /* WritableToken.h */; };
|
||||
276E60751CDB57AA003FF4B4 /* WritableToken.h in Headers */ = {isa = PBXBuildFile; fileRef = 276E5D2A1CDB57AA003FF4B4 /* WritableToken.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
|
@ -836,6 +827,66 @@
|
|||
27AC52D01CE773A80093AAAB /* antlr4-runtime.h in Headers */ = {isa = PBXBuildFile; fileRef = 27AC52CF1CE773A80093AAAB /* antlr4-runtime.h */; };
|
||||
27AC52D11CE773A80093AAAB /* antlr4-runtime.h in Headers */ = {isa = PBXBuildFile; fileRef = 27AC52CF1CE773A80093AAAB /* antlr4-runtime.h */; };
|
||||
27AC52D21CE773A80093AAAB /* antlr4-runtime.h in Headers */ = {isa = PBXBuildFile; fileRef = 27AC52CF1CE773A80093AAAB /* antlr4-runtime.h */; };
|
||||
27DB449D1D045537007E790B /* XPath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB448B1D045537007E790B /* XPath.cpp */; };
|
||||
27DB449E1D045537007E790B /* XPath.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB448C1D045537007E790B /* XPath.h */; };
|
||||
27DB449F1D045537007E790B /* XPathElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB448D1D045537007E790B /* XPathElement.cpp */; };
|
||||
27DB44A01D045537007E790B /* XPathElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB448E1D045537007E790B /* XPathElement.h */; };
|
||||
27DB44A11D045537007E790B /* XPathLexerErrorListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB448F1D045537007E790B /* XPathLexerErrorListener.cpp */; };
|
||||
27DB44A21D045537007E790B /* XPathLexerErrorListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB44901D045537007E790B /* XPathLexerErrorListener.h */; };
|
||||
27DB44A31D045537007E790B /* XPathRuleAnywhereElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB44911D045537007E790B /* XPathRuleAnywhereElement.cpp */; };
|
||||
27DB44A41D045537007E790B /* XPathRuleAnywhereElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB44921D045537007E790B /* XPathRuleAnywhereElement.h */; };
|
||||
27DB44A51D045537007E790B /* XPathRuleElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB44931D045537007E790B /* XPathRuleElement.cpp */; };
|
||||
27DB44A61D045537007E790B /* XPathRuleElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB44941D045537007E790B /* XPathRuleElement.h */; };
|
||||
27DB44A71D045537007E790B /* XPathTokenAnywhereElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB44951D045537007E790B /* XPathTokenAnywhereElement.cpp */; };
|
||||
27DB44A81D045537007E790B /* XPathTokenAnywhereElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB44961D045537007E790B /* XPathTokenAnywhereElement.h */; };
|
||||
27DB44A91D045537007E790B /* XPathTokenElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB44971D045537007E790B /* XPathTokenElement.cpp */; };
|
||||
27DB44AA1D045537007E790B /* XPathTokenElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB44981D045537007E790B /* XPathTokenElement.h */; };
|
||||
27DB44AB1D045537007E790B /* XPathWildcardAnywhereElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB44991D045537007E790B /* XPathWildcardAnywhereElement.cpp */; };
|
||||
27DB44AC1D045537007E790B /* XPathWildcardAnywhereElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB449A1D045537007E790B /* XPathWildcardAnywhereElement.h */; };
|
||||
27DB44AD1D045537007E790B /* XPathWildcardElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB449B1D045537007E790B /* XPathWildcardElement.cpp */; };
|
||||
27DB44AE1D045537007E790B /* XPathWildcardElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB449C1D045537007E790B /* XPathWildcardElement.h */; };
|
||||
27DB44B11D0463CC007E790B /* XPathLexer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB44AF1D0463CC007E790B /* XPathLexer.cpp */; };
|
||||
27DB44B21D0463CC007E790B /* XPathLexer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB44AF1D0463CC007E790B /* XPathLexer.cpp */; };
|
||||
27DB44B31D0463CC007E790B /* XPathLexer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB44AF1D0463CC007E790B /* XPathLexer.cpp */; };
|
||||
27DB44B41D0463CC007E790B /* XPathLexer.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB44B01D0463CC007E790B /* XPathLexer.h */; };
|
||||
27DB44B51D0463CC007E790B /* XPathLexer.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB44B01D0463CC007E790B /* XPathLexer.h */; };
|
||||
27DB44B61D0463CC007E790B /* XPathLexer.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB44B01D0463CC007E790B /* XPathLexer.h */; };
|
||||
27DB44B71D0463DA007E790B /* XPath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB448B1D045537007E790B /* XPath.cpp */; };
|
||||
27DB44B81D0463DA007E790B /* XPath.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB448C1D045537007E790B /* XPath.h */; };
|
||||
27DB44B91D0463DA007E790B /* XPathElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB448D1D045537007E790B /* XPathElement.cpp */; };
|
||||
27DB44BA1D0463DA007E790B /* XPathElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB448E1D045537007E790B /* XPathElement.h */; };
|
||||
27DB44BB1D0463DA007E790B /* XPathLexerErrorListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB448F1D045537007E790B /* XPathLexerErrorListener.cpp */; };
|
||||
27DB44BC1D0463DA007E790B /* XPathLexerErrorListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB44901D045537007E790B /* XPathLexerErrorListener.h */; };
|
||||
27DB44BD1D0463DA007E790B /* XPathRuleAnywhereElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB44911D045537007E790B /* XPathRuleAnywhereElement.cpp */; };
|
||||
27DB44BE1D0463DA007E790B /* XPathRuleAnywhereElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB44921D045537007E790B /* XPathRuleAnywhereElement.h */; };
|
||||
27DB44BF1D0463DA007E790B /* XPathRuleElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB44931D045537007E790B /* XPathRuleElement.cpp */; };
|
||||
27DB44C01D0463DA007E790B /* XPathRuleElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB44941D045537007E790B /* XPathRuleElement.h */; };
|
||||
27DB44C11D0463DA007E790B /* XPathTokenAnywhereElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB44951D045537007E790B /* XPathTokenAnywhereElement.cpp */; };
|
||||
27DB44C21D0463DA007E790B /* XPathTokenAnywhereElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB44961D045537007E790B /* XPathTokenAnywhereElement.h */; };
|
||||
27DB44C31D0463DA007E790B /* XPathTokenElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB44971D045537007E790B /* XPathTokenElement.cpp */; };
|
||||
27DB44C41D0463DA007E790B /* XPathTokenElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB44981D045537007E790B /* XPathTokenElement.h */; };
|
||||
27DB44C51D0463DA007E790B /* XPathWildcardAnywhereElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB44991D045537007E790B /* XPathWildcardAnywhereElement.cpp */; };
|
||||
27DB44C61D0463DA007E790B /* XPathWildcardAnywhereElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB449A1D045537007E790B /* XPathWildcardAnywhereElement.h */; };
|
||||
27DB44C71D0463DA007E790B /* XPathWildcardElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB449B1D045537007E790B /* XPathWildcardElement.cpp */; };
|
||||
27DB44C81D0463DA007E790B /* XPathWildcardElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB449C1D045537007E790B /* XPathWildcardElement.h */; };
|
||||
27DB44C91D0463DB007E790B /* XPath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB448B1D045537007E790B /* XPath.cpp */; };
|
||||
27DB44CA1D0463DB007E790B /* XPath.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB448C1D045537007E790B /* XPath.h */; };
|
||||
27DB44CB1D0463DB007E790B /* XPathElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB448D1D045537007E790B /* XPathElement.cpp */; };
|
||||
27DB44CC1D0463DB007E790B /* XPathElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB448E1D045537007E790B /* XPathElement.h */; };
|
||||
27DB44CD1D0463DB007E790B /* XPathLexerErrorListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB448F1D045537007E790B /* XPathLexerErrorListener.cpp */; };
|
||||
27DB44CE1D0463DB007E790B /* XPathLexerErrorListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB44901D045537007E790B /* XPathLexerErrorListener.h */; };
|
||||
27DB44CF1D0463DB007E790B /* XPathRuleAnywhereElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB44911D045537007E790B /* XPathRuleAnywhereElement.cpp */; };
|
||||
27DB44D01D0463DB007E790B /* XPathRuleAnywhereElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB44921D045537007E790B /* XPathRuleAnywhereElement.h */; };
|
||||
27DB44D11D0463DB007E790B /* XPathRuleElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB44931D045537007E790B /* XPathRuleElement.cpp */; };
|
||||
27DB44D21D0463DB007E790B /* XPathRuleElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB44941D045537007E790B /* XPathRuleElement.h */; };
|
||||
27DB44D31D0463DB007E790B /* XPathTokenAnywhereElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB44951D045537007E790B /* XPathTokenAnywhereElement.cpp */; };
|
||||
27DB44D41D0463DB007E790B /* XPathTokenAnywhereElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB44961D045537007E790B /* XPathTokenAnywhereElement.h */; };
|
||||
27DB44D51D0463DB007E790B /* XPathTokenElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB44971D045537007E790B /* XPathTokenElement.cpp */; };
|
||||
27DB44D61D0463DB007E790B /* XPathTokenElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB44981D045537007E790B /* XPathTokenElement.h */; };
|
||||
27DB44D71D0463DB007E790B /* XPathWildcardAnywhereElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB44991D045537007E790B /* XPathWildcardAnywhereElement.cpp */; };
|
||||
27DB44D81D0463DB007E790B /* XPathWildcardAnywhereElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB449A1D045537007E790B /* XPathWildcardAnywhereElement.h */; };
|
||||
27DB44D91D0463DB007E790B /* XPathWildcardElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27DB449B1D045537007E790B /* XPathWildcardElement.cpp */; };
|
||||
27DB44DA1D0463DB007E790B /* XPathWildcardElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 27DB449C1D045537007E790B /* XPathWildcardElement.h */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
|
@ -962,7 +1013,7 @@
|
|||
276E5C841CDB57AA003FF4B4 /* RuleStopState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RuleStopState.h; sourceTree = "<group>"; };
|
||||
276E5C851CDB57AA003FF4B4 /* RuleTransition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RuleTransition.cpp; sourceTree = "<group>"; };
|
||||
276E5C861CDB57AA003FF4B4 /* RuleTransition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RuleTransition.h; sourceTree = "<group>"; };
|
||||
276E5C871CDB57AA003FF4B4 /* SemanticContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SemanticContext.cpp; sourceTree = "<group>"; };
|
||||
276E5C871CDB57AA003FF4B4 /* SemanticContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SemanticContext.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
276E5C881CDB57AA003FF4B4 /* SemanticContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SemanticContext.h; sourceTree = "<group>"; };
|
||||
276E5C891CDB57AA003FF4B4 /* SetTransition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SetTransition.cpp; sourceTree = "<group>"; };
|
||||
276E5C8A1CDB57AA003FF4B4 /* SetTransition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SetTransition.h; sourceTree = "<group>"; };
|
||||
|
@ -1000,7 +1051,7 @@
|
|||
276E5CAA1CDB57AA003FF4B4 /* DefaultErrorStrategy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DefaultErrorStrategy.h; sourceTree = "<group>"; };
|
||||
276E5CAC1CDB57AA003FF4B4 /* DFA.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DFA.cpp; sourceTree = "<group>"; };
|
||||
276E5CAD1CDB57AA003FF4B4 /* DFA.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DFA.h; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
276E5CAE1CDB57AA003FF4B4 /* DFASerializer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DFASerializer.cpp; sourceTree = "<group>"; };
|
||||
276E5CAE1CDB57AA003FF4B4 /* DFASerializer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DFASerializer.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
276E5CAF1CDB57AA003FF4B4 /* DFASerializer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DFASerializer.h; sourceTree = "<group>"; };
|
||||
276E5CB01CDB57AA003FF4B4 /* DFAState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DFAState.cpp; sourceTree = "<group>"; };
|
||||
276E5CB11CDB57AA003FF4B4 /* DFAState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DFAState.h; sourceTree = "<group>"; };
|
||||
|
@ -1034,20 +1085,18 @@
|
|||
276E5CCE1CDB57AA003FF4B4 /* MurmurHash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MurmurHash.cpp; sourceTree = "<group>"; };
|
||||
276E5CCF1CDB57AA003FF4B4 /* MurmurHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MurmurHash.h; sourceTree = "<group>"; };
|
||||
276E5CD11CDB57AA003FF4B4 /* Predicate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Predicate.h; sourceTree = "<group>"; };
|
||||
276E5CD21CDB57AA003FF4B4 /* TestRig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestRig.cpp; sourceTree = "<group>"; };
|
||||
276E5CD31CDB57AA003FF4B4 /* TestRig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestRig.h; sourceTree = "<group>"; };
|
||||
276E5CD41CDB57AA003FF4B4 /* NoViableAltException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NoViableAltException.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
276E5CD51CDB57AA003FF4B4 /* NoViableAltException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NoViableAltException.h; sourceTree = "<group>"; };
|
||||
276E5CD61CDB57AA003FF4B4 /* Parser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Parser.cpp; sourceTree = "<group>"; };
|
||||
276E5CD71CDB57AA003FF4B4 /* Parser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Parser.h; sourceTree = "<group>"; };
|
||||
276E5CD81CDB57AA003FF4B4 /* ParserInterpreter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParserInterpreter.cpp; sourceTree = "<group>"; };
|
||||
276E5CD91CDB57AA003FF4B4 /* ParserInterpreter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParserInterpreter.h; sourceTree = "<group>"; };
|
||||
276E5CD81CDB57AA003FF4B4 /* ParserInterpreter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParserInterpreter.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
276E5CD91CDB57AA003FF4B4 /* ParserInterpreter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParserInterpreter.h; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
276E5CDA1CDB57AA003FF4B4 /* ParserRuleContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParserRuleContext.cpp; sourceTree = "<group>"; };
|
||||
276E5CDB1CDB57AA003FF4B4 /* ParserRuleContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParserRuleContext.h; sourceTree = "<group>"; };
|
||||
276E5CDC1CDB57AA003FF4B4 /* ProxyErrorListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProxyErrorListener.cpp; sourceTree = "<group>"; };
|
||||
276E5CDD1CDB57AA003FF4B4 /* ProxyErrorListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProxyErrorListener.h; sourceTree = "<group>"; };
|
||||
276E5CDE1CDB57AA003FF4B4 /* RecognitionException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RecognitionException.cpp; sourceTree = "<group>"; };
|
||||
276E5CDF1CDB57AA003FF4B4 /* RecognitionException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RecognitionException.h; sourceTree = "<group>"; };
|
||||
276E5CDF1CDB57AA003FF4B4 /* RecognitionException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RecognitionException.h; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
276E5CE01CDB57AA003FF4B4 /* Recognizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Recognizer.cpp; sourceTree = "<group>"; };
|
||||
276E5CE11CDB57AA003FF4B4 /* Recognizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Recognizer.h; sourceTree = "<group>"; };
|
||||
276E5CE21CDB57AA003FF4B4 /* RuleContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RuleContext.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
|
@ -1108,9 +1157,8 @@
|
|||
276E5D231CDB57AA003FF4B4 /* UnbufferedCharStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnbufferedCharStream.h; sourceTree = "<group>"; };
|
||||
276E5D241CDB57AA003FF4B4 /* UnbufferedTokenStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UnbufferedTokenStream.cpp; sourceTree = "<group>"; };
|
||||
276E5D251CDB57AA003FF4B4 /* UnbufferedTokenStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnbufferedTokenStream.h; sourceTree = "<group>"; };
|
||||
276E5D261CDB57AA003FF4B4 /* Vocabulary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Vocabulary.h; sourceTree = "<group>"; };
|
||||
276E5D271CDB57AA003FF4B4 /* VocabularyImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VocabularyImpl.cpp; sourceTree = "<group>"; };
|
||||
276E5D281CDB57AA003FF4B4 /* VocabularyImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VocabularyImpl.h; sourceTree = "<group>"; };
|
||||
276E5D271CDB57AA003FF4B4 /* Vocabulary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Vocabulary.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
276E5D281CDB57AA003FF4B4 /* Vocabulary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Vocabulary.h; sourceTree = "<group>"; };
|
||||
276E5D2A1CDB57AA003FF4B4 /* WritableToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WritableToken.h; sourceTree = "<group>"; };
|
||||
27745EF91CE49C000067C6A3 /* RuleContextWithAltNum.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RuleContextWithAltNum.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
27745EFA1CE49C000067C6A3 /* RuleContextWithAltNum.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RuleContextWithAltNum.h; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
|
@ -1119,6 +1167,26 @@
|
|||
27874F1D1CCB7A0700AF1C53 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
|
||||
2794D8551CE7821B00FADD0F /* antlr4-common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "antlr4-common.h"; sourceTree = "<group>"; };
|
||||
27AC52CF1CE773A80093AAAB /* antlr4-runtime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "antlr4-runtime.h"; sourceTree = "<group>"; };
|
||||
27DB448B1D045537007E790B /* XPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XPath.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
27DB448C1D045537007E790B /* XPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPath.h; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
27DB448D1D045537007E790B /* XPathElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XPathElement.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
27DB448E1D045537007E790B /* XPathElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPathElement.h; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
27DB448F1D045537007E790B /* XPathLexerErrorListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XPathLexerErrorListener.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
27DB44901D045537007E790B /* XPathLexerErrorListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPathLexerErrorListener.h; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
27DB44911D045537007E790B /* XPathRuleAnywhereElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XPathRuleAnywhereElement.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
27DB44921D045537007E790B /* XPathRuleAnywhereElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPathRuleAnywhereElement.h; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
27DB44931D045537007E790B /* XPathRuleElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XPathRuleElement.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
27DB44941D045537007E790B /* XPathRuleElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPathRuleElement.h; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
27DB44951D045537007E790B /* XPathTokenAnywhereElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XPathTokenAnywhereElement.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
27DB44961D045537007E790B /* XPathTokenAnywhereElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPathTokenAnywhereElement.h; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
27DB44971D045537007E790B /* XPathTokenElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XPathTokenElement.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
27DB44981D045537007E790B /* XPathTokenElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPathTokenElement.h; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
27DB44991D045537007E790B /* XPathWildcardAnywhereElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XPathWildcardAnywhereElement.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
27DB449A1D045537007E790B /* XPathWildcardAnywhereElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPathWildcardAnywhereElement.h; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
27DB449B1D045537007E790B /* XPathWildcardElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XPathWildcardElement.cpp; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
27DB449C1D045537007E790B /* XPathWildcardElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPathWildcardElement.h; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
27DB44AF1D0463CC007E790B /* XPathLexer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XPathLexer.cpp; sourceTree = "<group>"; };
|
||||
27DB44B01D0463CC007E790B /* XPathLexer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPathLexer.h; sourceTree = "<group>"; wrapsLines = 0; };
|
||||
37C147171B4D5A04008EDDDB /* libantlrcpp_static.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libantlrcpp_static.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
37D727AA1867AF1E007B6D10 /* antlrcpp.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = antlrcpp.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
/* End PBXFileReference section */
|
||||
|
@ -1247,9 +1315,8 @@
|
|||
276E5D231CDB57AA003FF4B4 /* UnbufferedCharStream.h */,
|
||||
276E5D241CDB57AA003FF4B4 /* UnbufferedTokenStream.cpp */,
|
||||
276E5D251CDB57AA003FF4B4 /* UnbufferedTokenStream.h */,
|
||||
276E5D261CDB57AA003FF4B4 /* Vocabulary.h */,
|
||||
276E5D271CDB57AA003FF4B4 /* VocabularyImpl.cpp */,
|
||||
276E5D281CDB57AA003FF4B4 /* VocabularyImpl.h */,
|
||||
276E5D271CDB57AA003FF4B4 /* Vocabulary.cpp */,
|
||||
276E5D281CDB57AA003FF4B4 /* Vocabulary.h */,
|
||||
276E5D2A1CDB57AA003FF4B4 /* WritableToken.h */,
|
||||
);
|
||||
name = runtime;
|
||||
|
@ -1419,8 +1486,6 @@
|
|||
276E5CCE1CDB57AA003FF4B4 /* MurmurHash.cpp */,
|
||||
276E5CCF1CDB57AA003FF4B4 /* MurmurHash.h */,
|
||||
276E5CD11CDB57AA003FF4B4 /* Predicate.h */,
|
||||
276E5CD21CDB57AA003FF4B4 /* TestRig.cpp */,
|
||||
276E5CD31CDB57AA003FF4B4 /* TestRig.h */,
|
||||
);
|
||||
path = misc;
|
||||
sourceTree = "<group>";
|
||||
|
@ -1446,6 +1511,7 @@
|
|||
isa = PBXGroup;
|
||||
children = (
|
||||
276E5D061CDB57AA003FF4B4 /* pattern */,
|
||||
27DB448A1D045537007E790B /* xpath */,
|
||||
276E5CFA1CDB57AA003FF4B4 /* AbstractParseTreeVisitor.h */,
|
||||
276E5CFB1CDB57AA003FF4B4 /* ErrorNode.h */,
|
||||
276E5CFC1CDB57AA003FF4B4 /* ErrorNodeImpl.cpp */,
|
||||
|
@ -1500,6 +1566,33 @@
|
|||
name = "Linked Frameworks";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
27DB448A1D045537007E790B /* xpath */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
27DB448B1D045537007E790B /* XPath.cpp */,
|
||||
27DB448C1D045537007E790B /* XPath.h */,
|
||||
27DB448D1D045537007E790B /* XPathElement.cpp */,
|
||||
27DB448E1D045537007E790B /* XPathElement.h */,
|
||||
27DB44AF1D0463CC007E790B /* XPathLexer.cpp */,
|
||||
27DB44B01D0463CC007E790B /* XPathLexer.h */,
|
||||
27DB448F1D045537007E790B /* XPathLexerErrorListener.cpp */,
|
||||
27DB44901D045537007E790B /* XPathLexerErrorListener.h */,
|
||||
27DB44911D045537007E790B /* XPathRuleAnywhereElement.cpp */,
|
||||
27DB44921D045537007E790B /* XPathRuleAnywhereElement.h */,
|
||||
27DB44931D045537007E790B /* XPathRuleElement.cpp */,
|
||||
27DB44941D045537007E790B /* XPathRuleElement.h */,
|
||||
27DB44951D045537007E790B /* XPathTokenAnywhereElement.cpp */,
|
||||
27DB44961D045537007E790B /* XPathTokenAnywhereElement.h */,
|
||||
27DB44971D045537007E790B /* XPathTokenElement.cpp */,
|
||||
27DB44981D045537007E790B /* XPathTokenElement.h */,
|
||||
27DB44991D045537007E790B /* XPathWildcardAnywhereElement.cpp */,
|
||||
27DB449A1D045537007E790B /* XPathWildcardAnywhereElement.h */,
|
||||
27DB449B1D045537007E790B /* XPathWildcardElement.cpp */,
|
||||
27DB449C1D045537007E790B /* XPathWildcardElement.h */,
|
||||
);
|
||||
path = xpath;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
37D727A11867AF1E007B6D10 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
@ -1537,8 +1630,10 @@
|
|||
276E5DA81CDB57AA003FF4B4 /* BlockStartState.h in Headers */,
|
||||
276E5FE21CDB57AA003FF4B4 /* TokenStream.h in Headers */,
|
||||
276E5D6F1CDB57AA003FF4B4 /* ATNDeserializationOptions.h in Headers */,
|
||||
27DB44CA1D0463DB007E790B /* XPath.h in Headers */,
|
||||
276E5EDD1CDB57AA003FF4B4 /* BaseErrorListener.h in Headers */,
|
||||
276E5DB71CDB57AA003FF4B4 /* DecisionEventInfo.h in Headers */,
|
||||
27DB44D01D0463DB007E790B /* XPathRuleAnywhereElement.h in Headers */,
|
||||
27AC52D21CE773A80093AAAB /* antlr4-runtime.h in Headers */,
|
||||
276E5E2C1CDB57AA003FF4B4 /* LL1Analyzer.h in Headers */,
|
||||
276E5D7B1CDB57AA003FF4B4 /* ATNSerializer.h in Headers */,
|
||||
|
@ -1546,6 +1641,7 @@
|
|||
276E5E1A1CDB57AA003FF4B4 /* LexerPushModeAction.h in Headers */,
|
||||
276E5ECB1CDB57AA003FF4B4 /* Transition.h in Headers */,
|
||||
276E5EA11CDB57AA003FF4B4 /* SemanticContext.h in Headers */,
|
||||
27DB44DA1D0463DB007E790B /* XPathWildcardElement.h in Headers */,
|
||||
276E5F5E1CDB57AA003FF4B4 /* ListTokenSource.h in Headers */,
|
||||
276E5F8E1CDB57AA003FF4B4 /* ParserInterpreter.h in Headers */,
|
||||
276E603C1CDB57AA003FF4B4 /* RuleNode.h in Headers */,
|
||||
|
@ -1602,15 +1698,17 @@
|
|||
276E5F251CDB57AA003FF4B4 /* DiagnosticErrorListener.h in Headers */,
|
||||
276E5E141CDB57AA003FF4B4 /* LexerPopModeAction.h in Headers */,
|
||||
276E5ED71CDB57AA003FF4B4 /* BailErrorStrategy.h in Headers */,
|
||||
27DB44CE1D0463DB007E790B /* XPathLexerErrorListener.h in Headers */,
|
||||
276E5DCF1CDB57AA003FF4B4 /* EpsilonTransition.h in Headers */,
|
||||
276E5FBE1CDB57AA003FF4B4 /* Declarations.h in Headers */,
|
||||
276E600C1CDB57AA003FF4B4 /* ParseTreeWalker.h in Headers */,
|
||||
276E5E771CDB57AA003FF4B4 /* PredictionContext.h in Headers */,
|
||||
276E60151CDB57AA003FF4B4 /* ParseTreeMatch.h in Headers */,
|
||||
276E5F7C1CDB57AA003FF4B4 /* TestRig.h in Headers */,
|
||||
27DB44CC1D0463DB007E790B /* XPathElement.h in Headers */,
|
||||
276E5F581CDB57AA003FF4B4 /* LexerNoViableAltException.h in Headers */,
|
||||
276E5D811CDB57AA003FF4B4 /* ATNSimulator.h in Headers */,
|
||||
276E5F461CDB57AA003FF4B4 /* IRecognizer.h in Headers */,
|
||||
27DB44B61D0463CC007E790B /* XPathLexer.h in Headers */,
|
||||
276E5FC41CDB57AA003FF4B4 /* guid.h in Headers */,
|
||||
276E602D1CDB57AA003FF4B4 /* TagChunk.h in Headers */,
|
||||
276E5E951CDB57AA003FF4B4 /* RuleStopState.h in Headers */,
|
||||
|
@ -1625,16 +1723,16 @@
|
|||
276E5D931CDB57AA003FF4B4 /* AtomTransition.h in Headers */,
|
||||
276E604E1CDB57AA003FF4B4 /* Tree.h in Headers */,
|
||||
276E5F521CDB57AA003FF4B4 /* LexerInterpreter.h in Headers */,
|
||||
276E60691CDB57AA003FF4B4 /* Vocabulary.h in Headers */,
|
||||
276E5F311CDB57AA003FF4B4 /* FailedPredicateException.h in Headers */,
|
||||
276E5E321CDB57AA003FF4B4 /* LookaheadEventInfo.h in Headers */,
|
||||
276E5F0D1CDB57AA003FF4B4 /* DFA.h in Headers */,
|
||||
276E606F1CDB57AA003FF4B4 /* VocabularyImpl.h in Headers */,
|
||||
276E606F1CDB57AA003FF4B4 /* Vocabulary.h in Headers */,
|
||||
276E60541CDB57AA003FF4B4 /* Trees.h in Headers */,
|
||||
276E5FB51CDB57AA003FF4B4 /* BitSet.h in Headers */,
|
||||
276E5F9A1CDB57AA003FF4B4 /* ProxyErrorListener.h in Headers */,
|
||||
276E5E411CDB57AA003FF4B4 /* NotSetTransition.h in Headers */,
|
||||
276E5E891CDB57AA003FF4B4 /* RangeTransition.h in Headers */,
|
||||
27DB44D21D0463DB007E790B /* XPathRuleElement.h in Headers */,
|
||||
276E601B1CDB57AA003FF4B4 /* ParseTreePattern.h in Headers */,
|
||||
276E5DFC1CDB57AA003FF4B4 /* LexerCustomAction.h in Headers */,
|
||||
276E5FE81CDB57AA003FF4B4 /* TokenStreamRewriter.h in Headers */,
|
||||
|
@ -1642,6 +1740,7 @@
|
|||
276E5DAB1CDB57AA003FF4B4 /* ConfigLookup.h in Headers */,
|
||||
276E5DD51CDB57AA003FF4B4 /* ErrorInfo.h in Headers */,
|
||||
276E5E261CDB57AA003FF4B4 /* LexerTypeAction.h in Headers */,
|
||||
27DB44D61D0463DB007E790B /* XPathTokenElement.h in Headers */,
|
||||
276E5DE41CDB57AA003FF4B4 /* LexerActionType.h in Headers */,
|
||||
276E5D511CDB57AA003FF4B4 /* AmbiguityInfo.h in Headers */,
|
||||
276E5E711CDB57AA003FF4B4 /* PredicateTransition.h in Headers */,
|
||||
|
@ -1670,6 +1769,8 @@
|
|||
276E5F701CDB57AA003FF4B4 /* MurmurHash.h in Headers */,
|
||||
276E60211CDB57AA003FF4B4 /* ParseTreePatternMatcher.h in Headers */,
|
||||
276E5D631CDB57AA003FF4B4 /* ATNConfig.h in Headers */,
|
||||
27DB44D41D0463DB007E790B /* XPathTokenAnywhereElement.h in Headers */,
|
||||
27DB44D81D0463DB007E790B /* XPathWildcardAnywhereElement.h in Headers */,
|
||||
276E5E4D1CDB57AA003FF4B4 /* ParseInfo.h in Headers */,
|
||||
276E5F881CDB57AA003FF4B4 /* Parser.h in Headers */,
|
||||
276E603F1CDB57AA003FF4B4 /* SyntaxTree.h in Headers */,
|
||||
|
@ -1701,6 +1802,7 @@
|
|||
276E5EDC1CDB57AA003FF4B4 /* BaseErrorListener.h in Headers */,
|
||||
276E5DB61CDB57AA003FF4B4 /* DecisionEventInfo.h in Headers */,
|
||||
276E5E2B1CDB57AA003FF4B4 /* LL1Analyzer.h in Headers */,
|
||||
27DB44BA1D0463DA007E790B /* XPathElement.h in Headers */,
|
||||
276E5D7A1CDB57AA003FF4B4 /* ATNSerializer.h in Headers */,
|
||||
276E5EAC1CDB57AA003FF4B4 /* SingletonPredictionContext.h in Headers */,
|
||||
276E5E191CDB57AA003FF4B4 /* LexerPushModeAction.h in Headers */,
|
||||
|
@ -1713,9 +1815,12 @@
|
|||
276E5F4B1CDB57AA003FF4B4 /* Lexer.h in Headers */,
|
||||
276E5F631CDB57AA003FF4B4 /* Interval.h in Headers */,
|
||||
276E5DA41CDB57AA003FF4B4 /* BlockEndState.h in Headers */,
|
||||
27DB44C21D0463DA007E790B /* XPathTokenAnywhereElement.h in Headers */,
|
||||
276E5E821CDB57AA003FF4B4 /* ProfilingATNSimulator.h in Headers */,
|
||||
27DB44C41D0463DA007E790B /* XPathTokenElement.h in Headers */,
|
||||
276E5D981CDB57AA003FF4B4 /* BasicBlockStartState.h in Headers */,
|
||||
276E5E9A1CDB57AA003FF4B4 /* RuleTransition.h in Headers */,
|
||||
27DB44B81D0463DA007E790B /* XPath.h in Headers */,
|
||||
276E60021CDB57AA003FF4B4 /* ParseTreeProperty.h in Headers */,
|
||||
276E5D8C1CDB57AA003FF4B4 /* ATNType.h in Headers */,
|
||||
276E5FFC1CDB57AA003FF4B4 /* ParseTreeListener.h in Headers */,
|
||||
|
@ -1731,6 +1836,7 @@
|
|||
276E5E371CDB57AA003FF4B4 /* LoopEndState.h in Headers */,
|
||||
276E5D681CDB57AA003FF4B4 /* ATNConfigSet.h in Headers */,
|
||||
276E5D381CDB57AA003FF4B4 /* ANTLRFileStream.h in Headers */,
|
||||
27DB44C01D0463DA007E790B /* XPathRuleElement.h in Headers */,
|
||||
276E5D2F1CDB57AA003FF4B4 /* ANTLRErrorListener.h in Headers */,
|
||||
276E5FC91CDB57AA003FF4B4 /* StringUtils.h in Headers */,
|
||||
276E5EF41CDB57AA003FF4B4 /* CommonTokenFactory.h in Headers */,
|
||||
|
@ -1741,10 +1847,12 @@
|
|||
276E5FCF1CDB57AA003FF4B4 /* Token.h in Headers */,
|
||||
276E60411CDB57AA003FF4B4 /* TerminalNode.h in Headers */,
|
||||
276E5D741CDB57AA003FF4B4 /* ATNDeserializer.h in Headers */,
|
||||
27DB44B51D0463CC007E790B /* XPathLexer.h in Headers */,
|
||||
276E5D861CDB57AA003FF4B4 /* ATNState.h in Headers */,
|
||||
276E5E7C1CDB57AA003FF4B4 /* PredictionMode.h in Headers */,
|
||||
276E5EBE1CDB57AA003FF4B4 /* StarLoopEntryState.h in Headers */,
|
||||
276E5F9F1CDB57AA003FF4B4 /* RecognitionException.h in Headers */,
|
||||
27DB44BE1D0463DA007E790B /* XPathRuleAnywhereElement.h in Headers */,
|
||||
27745F071CE49C000067C6A3 /* RuntimeMetaData.h in Headers */,
|
||||
276E5EA61CDB57AA003FF4B4 /* SetTransition.h in Headers */,
|
||||
276E5F1E1CDB57AA003FF4B4 /* LexerDFASerializer.h in Headers */,
|
||||
|
@ -1759,6 +1867,7 @@
|
|||
276E5DC81CDB57AA003FF4B4 /* EmptyPredictionContext.h in Headers */,
|
||||
276E5D441CDB57AA003FF4B4 /* AbstractPredicateTransition.h in Headers */,
|
||||
276E5F2A1CDB57AA003FF4B4 /* Exceptions.h in Headers */,
|
||||
27DB44C61D0463DA007E790B /* XPathWildcardAnywhereElement.h in Headers */,
|
||||
276E5F241CDB57AA003FF4B4 /* DiagnosticErrorListener.h in Headers */,
|
||||
276E5E131CDB57AA003FF4B4 /* LexerPopModeAction.h in Headers */,
|
||||
276E5ED61CDB57AA003FF4B4 /* BailErrorStrategy.h in Headers */,
|
||||
|
@ -1767,7 +1876,6 @@
|
|||
276E600B1CDB57AA003FF4B4 /* ParseTreeWalker.h in Headers */,
|
||||
276E5E761CDB57AA003FF4B4 /* PredictionContext.h in Headers */,
|
||||
276E60141CDB57AA003FF4B4 /* ParseTreeMatch.h in Headers */,
|
||||
276E5F7B1CDB57AA003FF4B4 /* TestRig.h in Headers */,
|
||||
276E5F571CDB57AA003FF4B4 /* LexerNoViableAltException.h in Headers */,
|
||||
276E5D801CDB57AA003FF4B4 /* ATNSimulator.h in Headers */,
|
||||
276E5F451CDB57AA003FF4B4 /* IRecognizer.h in Headers */,
|
||||
|
@ -1784,11 +1892,10 @@
|
|||
276E5D921CDB57AA003FF4B4 /* AtomTransition.h in Headers */,
|
||||
276E604D1CDB57AA003FF4B4 /* Tree.h in Headers */,
|
||||
276E5F511CDB57AA003FF4B4 /* LexerInterpreter.h in Headers */,
|
||||
276E60681CDB57AA003FF4B4 /* Vocabulary.h in Headers */,
|
||||
276E5F301CDB57AA003FF4B4 /* FailedPredicateException.h in Headers */,
|
||||
276E5E311CDB57AA003FF4B4 /* LookaheadEventInfo.h in Headers */,
|
||||
276E5F0C1CDB57AA003FF4B4 /* DFA.h in Headers */,
|
||||
276E606E1CDB57AA003FF4B4 /* VocabularyImpl.h in Headers */,
|
||||
276E606E1CDB57AA003FF4B4 /* Vocabulary.h in Headers */,
|
||||
276E60531CDB57AA003FF4B4 /* Trees.h in Headers */,
|
||||
276E5FB41CDB57AA003FF4B4 /* BitSet.h in Headers */,
|
||||
276E5F991CDB57AA003FF4B4 /* ProxyErrorListener.h in Headers */,
|
||||
|
@ -1814,6 +1921,7 @@
|
|||
276E5E641CDB57AA003FF4B4 /* PrecedencePredicateTransition.h in Headers */,
|
||||
276E5F061CDB57AA003FF4B4 /* DefaultErrorStrategy.h in Headers */,
|
||||
276E5F3C1CDB57AA003FF4B4 /* InterpreterRuleContext.h in Headers */,
|
||||
27DB44BC1D0463DA007E790B /* XPathLexerErrorListener.h in Headers */,
|
||||
276E5F121CDB57AA003FF4B4 /* DFASerializer.h in Headers */,
|
||||
276E5F361CDB57AA003FF4B4 /* InputMismatchException.h in Headers */,
|
||||
276E5FDB1CDB57AA003FF4B4 /* TokenSource.h in Headers */,
|
||||
|
@ -1827,6 +1935,7 @@
|
|||
276E5EFA1CDB57AA003FF4B4 /* CommonTokenStream.h in Headers */,
|
||||
276E5EB21CDB57AA003FF4B4 /* StarBlockStartState.h in Headers */,
|
||||
276E5F6F1CDB57AA003FF4B4 /* MurmurHash.h in Headers */,
|
||||
27DB44C81D0463DA007E790B /* XPathWildcardElement.h in Headers */,
|
||||
276E60201CDB57AA003FF4B4 /* ParseTreePatternMatcher.h in Headers */,
|
||||
276E5D621CDB57AA003FF4B4 /* ATNConfig.h in Headers */,
|
||||
276E5E4C1CDB57AA003FF4B4 /* ParseInfo.h in Headers */,
|
||||
|
@ -1846,11 +1955,13 @@
|
|||
files = (
|
||||
276E5FE91CDB57AA003FF4B4 /* AbstractParseTreeVisitor.h in Headers */,
|
||||
27745F001CE49C000067C6A3 /* RuleContextWithAltNum.h in Headers */,
|
||||
27DB44AC1D045537007E790B /* XPathWildcardAnywhereElement.h in Headers */,
|
||||
276E60311CDB57AA003FF4B4 /* TextChunk.h in Headers */,
|
||||
276E5F411CDB57AA003FF4B4 /* IntStream.h in Headers */,
|
||||
276E5D5B1CDB57AA003FF4B4 /* ATN.h in Headers */,
|
||||
276E605E1CDB57AA003FF4B4 /* UnbufferedCharStream.h in Headers */,
|
||||
276E5DD61CDB57AA003FF4B4 /* LexerAction.h in Headers */,
|
||||
27DB44A41D045537007E790B /* XPathRuleAnywhereElement.h in Headers */,
|
||||
276E5FF51CDB57AA003FF4B4 /* ParseTree.h in Headers */,
|
||||
27AC52D01CE773A80093AAAB /* antlr4-runtime.h in Headers */,
|
||||
276E5DA61CDB57AA003FF4B4 /* BlockStartState.h in Headers */,
|
||||
|
@ -1889,6 +2000,7 @@
|
|||
276E5E361CDB57AA003FF4B4 /* LoopEndState.h in Headers */,
|
||||
276E5D671CDB57AA003FF4B4 /* ATNConfigSet.h in Headers */,
|
||||
276E5D371CDB57AA003FF4B4 /* ANTLRFileStream.h in Headers */,
|
||||
27DB44B41D0463CC007E790B /* XPathLexer.h in Headers */,
|
||||
276E5D2E1CDB57AA003FF4B4 /* ANTLRErrorListener.h in Headers */,
|
||||
276E5FC81CDB57AA003FF4B4 /* StringUtils.h in Headers */,
|
||||
276E5EF31CDB57AA003FF4B4 /* CommonTokenFactory.h in Headers */,
|
||||
|
@ -1918,6 +2030,7 @@
|
|||
276E5D431CDB57AA003FF4B4 /* AbstractPredicateTransition.h in Headers */,
|
||||
276E5F291CDB57AA003FF4B4 /* Exceptions.h in Headers */,
|
||||
276E5F231CDB57AA003FF4B4 /* DiagnosticErrorListener.h in Headers */,
|
||||
27DB449E1D045537007E790B /* XPath.h in Headers */,
|
||||
276E5E121CDB57AA003FF4B4 /* LexerPopModeAction.h in Headers */,
|
||||
276E5ED51CDB57AA003FF4B4 /* BailErrorStrategy.h in Headers */,
|
||||
276E5DCD1CDB57AA003FF4B4 /* EpsilonTransition.h in Headers */,
|
||||
|
@ -1925,7 +2038,6 @@
|
|||
276E600A1CDB57AA003FF4B4 /* ParseTreeWalker.h in Headers */,
|
||||
276E5E751CDB57AA003FF4B4 /* PredictionContext.h in Headers */,
|
||||
276E60131CDB57AA003FF4B4 /* ParseTreeMatch.h in Headers */,
|
||||
276E5F7A1CDB57AA003FF4B4 /* TestRig.h in Headers */,
|
||||
276E5F561CDB57AA003FF4B4 /* LexerNoViableAltException.h in Headers */,
|
||||
276E5D7F1CDB57AA003FF4B4 /* ATNSimulator.h in Headers */,
|
||||
276E5F441CDB57AA003FF4B4 /* IRecognizer.h in Headers */,
|
||||
|
@ -1942,13 +2054,14 @@
|
|||
276E5D911CDB57AA003FF4B4 /* AtomTransition.h in Headers */,
|
||||
276E604C1CDB57AA003FF4B4 /* Tree.h in Headers */,
|
||||
276E5F501CDB57AA003FF4B4 /* LexerInterpreter.h in Headers */,
|
||||
276E60671CDB57AA003FF4B4 /* Vocabulary.h in Headers */,
|
||||
27DB44AE1D045537007E790B /* XPathWildcardElement.h in Headers */,
|
||||
276E5F2F1CDB57AA003FF4B4 /* FailedPredicateException.h in Headers */,
|
||||
276E5E301CDB57AA003FF4B4 /* LookaheadEventInfo.h in Headers */,
|
||||
276E5F0B1CDB57AA003FF4B4 /* DFA.h in Headers */,
|
||||
276E606D1CDB57AA003FF4B4 /* VocabularyImpl.h in Headers */,
|
||||
276E606D1CDB57AA003FF4B4 /* Vocabulary.h in Headers */,
|
||||
276E60521CDB57AA003FF4B4 /* Trees.h in Headers */,
|
||||
276E5FB31CDB57AA003FF4B4 /* BitSet.h in Headers */,
|
||||
27DB44AA1D045537007E790B /* XPathTokenElement.h in Headers */,
|
||||
276E5F981CDB57AA003FF4B4 /* ProxyErrorListener.h in Headers */,
|
||||
276E5E3F1CDB57AA003FF4B4 /* NotSetTransition.h in Headers */,
|
||||
276E5E871CDB57AA003FF4B4 /* RangeTransition.h in Headers */,
|
||||
|
@ -1957,6 +2070,7 @@
|
|||
276E5FE61CDB57AA003FF4B4 /* TokenStreamRewriter.h in Headers */,
|
||||
276E5DEE1CDB57AA003FF4B4 /* LexerATNSimulator.h in Headers */,
|
||||
276E5DA91CDB57AA003FF4B4 /* ConfigLookup.h in Headers */,
|
||||
27DB44A61D045537007E790B /* XPathRuleElement.h in Headers */,
|
||||
276E5DD31CDB57AA003FF4B4 /* ErrorInfo.h in Headers */,
|
||||
276E5E241CDB57AA003FF4B4 /* LexerTypeAction.h in Headers */,
|
||||
276E5DE21CDB57AA003FF4B4 /* LexerActionType.h in Headers */,
|
||||
|
@ -1981,15 +2095,18 @@
|
|||
276E5EE11CDB57AA003FF4B4 /* BufferedTokenStream.h in Headers */,
|
||||
276E5DAF1CDB57AA003FF4B4 /* ContextSensitivityInfo.h in Headers */,
|
||||
276E5E001CDB57AA003FF4B4 /* LexerIndexedCustomAction.h in Headers */,
|
||||
27DB44A81D045537007E790B /* XPathTokenAnywhereElement.h in Headers */,
|
||||
276E5FD41CDB57AA003FF4B4 /* TokenFactory.h in Headers */,
|
||||
276E5EF91CDB57AA003FF4B4 /* CommonTokenStream.h in Headers */,
|
||||
276E5EB11CDB57AA003FF4B4 /* StarBlockStartState.h in Headers */,
|
||||
276E5F6E1CDB57AA003FF4B4 /* MurmurHash.h in Headers */,
|
||||
276E601F1CDB57AA003FF4B4 /* ParseTreePatternMatcher.h in Headers */,
|
||||
276E5D611CDB57AA003FF4B4 /* ATNConfig.h in Headers */,
|
||||
27DB44A21D045537007E790B /* XPathLexerErrorListener.h in Headers */,
|
||||
276E5E4B1CDB57AA003FF4B4 /* ParseInfo.h in Headers */,
|
||||
276E5F861CDB57AA003FF4B4 /* Parser.h in Headers */,
|
||||
276E603D1CDB57AA003FF4B4 /* SyntaxTree.h in Headers */,
|
||||
27DB44A01D045537007E790B /* XPathElement.h in Headers */,
|
||||
276E5DBB1CDB57AA003FF4B4 /* DecisionInfo.h in Headers */,
|
||||
276E5DC11CDB57AA003FF4B4 /* DecisionState.h in Headers */,
|
||||
276E5E691CDB57AA003FF4B4 /* PredicateEvalInfo.h in Headers */,
|
||||
|
@ -2129,6 +2246,7 @@
|
|||
276E5E051CDB57AA003FF4B4 /* LexerModeAction.cpp in Sources */,
|
||||
276E5F491CDB57AA003FF4B4 /* Lexer.cpp in Sources */,
|
||||
276E5EDA1CDB57AA003FF4B4 /* BaseErrorListener.cpp in Sources */,
|
||||
27DB44C91D0463DB007E790B /* XPath.cpp in Sources */,
|
||||
276E5DBA1CDB57AA003FF4B4 /* DecisionInfo.cpp in Sources */,
|
||||
276E5F611CDB57AA003FF4B4 /* Interval.cpp in Sources */,
|
||||
276E5F911CDB57AA003FF4B4 /* ParserRuleContext.cpp in Sources */,
|
||||
|
@ -2137,7 +2255,9 @@
|
|||
276E5E7A1CDB57AA003FF4B4 /* PredictionMode.cpp in Sources */,
|
||||
276E605D1CDB57AA003FF4B4 /* UnbufferedCharStream.cpp in Sources */,
|
||||
276E5F341CDB57AA003FF4B4 /* InputMismatchException.cpp in Sources */,
|
||||
27DB44D91D0463DB007E790B /* XPathWildcardElement.cpp in Sources */,
|
||||
276E5E741CDB57AA003FF4B4 /* PredictionContext.cpp in Sources */,
|
||||
27DB44CB1D0463DB007E790B /* XPathElement.cpp in Sources */,
|
||||
276E5E171CDB57AA003FF4B4 /* LexerPushModeAction.cpp in Sources */,
|
||||
276E5DA21CDB57AA003FF4B4 /* BlockEndState.cpp in Sources */,
|
||||
276E5EF21CDB57AA003FF4B4 /* CommonTokenFactory.cpp in Sources */,
|
||||
|
@ -2156,8 +2276,10 @@
|
|||
276E5FA31CDB57AA003FF4B4 /* Recognizer.cpp in Sources */,
|
||||
276E5D6C1CDB57AA003FF4B4 /* ATNDeserializationOptions.cpp in Sources */,
|
||||
276E60361CDB57AA003FF4B4 /* TokenTagToken.cpp in Sources */,
|
||||
27DB44D51D0463DB007E790B /* XPathTokenElement.cpp in Sources */,
|
||||
27DB44D11D0463DB007E790B /* XPathRuleElement.cpp in Sources */,
|
||||
276E5DED1CDB57AA003FF4B4 /* LexerATNSimulator.cpp in Sources */,
|
||||
276E606C1CDB57AA003FF4B4 /* VocabularyImpl.cpp in Sources */,
|
||||
276E606C1CDB57AA003FF4B4 /* Vocabulary.cpp in Sources */,
|
||||
276E5F1C1CDB57AA003FF4B4 /* LexerDFASerializer.cpp in Sources */,
|
||||
276E60181CDB57AA003FF4B4 /* ParseTreePattern.cpp in Sources */,
|
||||
276E5DE71CDB57AA003FF4B4 /* LexerATNConfig.cpp in Sources */,
|
||||
|
@ -2167,6 +2289,7 @@
|
|||
276E5D4E1CDB57AA003FF4B4 /* AmbiguityInfo.cpp in Sources */,
|
||||
276E5F161CDB57AA003FF4B4 /* DFAState.cpp in Sources */,
|
||||
276E60091CDB57AA003FF4B4 /* ParseTreeWalker.cpp in Sources */,
|
||||
27DB44CD1D0463DB007E790B /* XPathLexerErrorListener.cpp in Sources */,
|
||||
276E5F9D1CDB57AA003FF4B4 /* RecognitionException.cpp in Sources */,
|
||||
276E5E8C1CDB57AA003FF4B4 /* RuleStartState.cpp in Sources */,
|
||||
276E5EA41CDB57AA003FF4B4 /* SetTransition.cpp in Sources */,
|
||||
|
@ -2184,7 +2307,6 @@
|
|||
276E5ECE1CDB57AA003FF4B4 /* WildcardTransition.cpp in Sources */,
|
||||
276E5E861CDB57AA003FF4B4 /* RangeTransition.cpp in Sources */,
|
||||
276E5D7E1CDB57AA003FF4B4 /* ATNSimulator.cpp in Sources */,
|
||||
276E5F791CDB57AA003FF4B4 /* TestRig.cpp in Sources */,
|
||||
276E5D9C1CDB57AA003FF4B4 /* BasicState.cpp in Sources */,
|
||||
276E5FC11CDB57AA003FF4B4 /* guid.cpp in Sources */,
|
||||
276E5E801CDB57AA003FF4B4 /* ProfilingATNSimulator.cpp in Sources */,
|
||||
|
@ -2193,10 +2315,13 @@
|
|||
276E5F6D1CDB57AA003FF4B4 /* MurmurHash.cpp in Sources */,
|
||||
276E5FDF1CDB57AA003FF4B4 /* TokenStream.cpp in Sources */,
|
||||
276E5FF11CDB57AA003FF4B4 /* ErrorNodeImpl.cpp in Sources */,
|
||||
27DB44D71D0463DB007E790B /* XPathWildcardAnywhereElement.cpp in Sources */,
|
||||
276E5D961CDB57AA003FF4B4 /* BasicBlockStartState.cpp in Sources */,
|
||||
276E5E4A1CDB57AA003FF4B4 /* ParseInfo.cpp in Sources */,
|
||||
276E5E3E1CDB57AA003FF4B4 /* NotSetTransition.cpp in Sources */,
|
||||
27DB44B31D0463CC007E790B /* XPathLexer.cpp in Sources */,
|
||||
276E60301CDB57AA003FF4B4 /* TextChunk.cpp in Sources */,
|
||||
27DB44CF1D0463DB007E790B /* XPathRuleAnywhereElement.cpp in Sources */,
|
||||
276E5E441CDB57AA003FF4B4 /* OrderedATNConfigSet.cpp in Sources */,
|
||||
276E5DCC1CDB57AA003FF4B4 /* EpsilonTransition.cpp in Sources */,
|
||||
276E5D5A1CDB57AA003FF4B4 /* ATN.cpp in Sources */,
|
||||
|
@ -2227,6 +2352,7 @@
|
|||
276E5F4F1CDB57AA003FF4B4 /* LexerInterpreter.cpp in Sources */,
|
||||
276E5E291CDB57AA003FF4B4 /* LL1Analyzer.cpp in Sources */,
|
||||
276E5EB01CDB57AA003FF4B4 /* StarBlockStartState.cpp in Sources */,
|
||||
27DB44D31D0463DB007E790B /* XPathTokenAnywhereElement.cpp in Sources */,
|
||||
276E5FB81CDB57AA003FF4B4 /* CPPUtils.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
@ -2260,6 +2386,7 @@
|
|||
276E5E041CDB57AA003FF4B4 /* LexerModeAction.cpp in Sources */,
|
||||
276E5F481CDB57AA003FF4B4 /* Lexer.cpp in Sources */,
|
||||
276E5ED91CDB57AA003FF4B4 /* BaseErrorListener.cpp in Sources */,
|
||||
27DB44B71D0463DA007E790B /* XPath.cpp in Sources */,
|
||||
276E5DB91CDB57AA003FF4B4 /* DecisionInfo.cpp in Sources */,
|
||||
276E5F601CDB57AA003FF4B4 /* Interval.cpp in Sources */,
|
||||
276E5F901CDB57AA003FF4B4 /* ParserRuleContext.cpp in Sources */,
|
||||
|
@ -2268,7 +2395,9 @@
|
|||
276E5E791CDB57AA003FF4B4 /* PredictionMode.cpp in Sources */,
|
||||
276E605C1CDB57AA003FF4B4 /* UnbufferedCharStream.cpp in Sources */,
|
||||
276E5F331CDB57AA003FF4B4 /* InputMismatchException.cpp in Sources */,
|
||||
27DB44C71D0463DA007E790B /* XPathWildcardElement.cpp in Sources */,
|
||||
276E5E731CDB57AA003FF4B4 /* PredictionContext.cpp in Sources */,
|
||||
27DB44B91D0463DA007E790B /* XPathElement.cpp in Sources */,
|
||||
276E5E161CDB57AA003FF4B4 /* LexerPushModeAction.cpp in Sources */,
|
||||
276E5DA11CDB57AA003FF4B4 /* BlockEndState.cpp in Sources */,
|
||||
276E5EF11CDB57AA003FF4B4 /* CommonTokenFactory.cpp in Sources */,
|
||||
|
@ -2287,8 +2416,10 @@
|
|||
276E5FA21CDB57AA003FF4B4 /* Recognizer.cpp in Sources */,
|
||||
276E5D6B1CDB57AA003FF4B4 /* ATNDeserializationOptions.cpp in Sources */,
|
||||
276E60351CDB57AA003FF4B4 /* TokenTagToken.cpp in Sources */,
|
||||
27DB44C31D0463DA007E790B /* XPathTokenElement.cpp in Sources */,
|
||||
27DB44BF1D0463DA007E790B /* XPathRuleElement.cpp in Sources */,
|
||||
276E5DEC1CDB57AA003FF4B4 /* LexerATNSimulator.cpp in Sources */,
|
||||
276E606B1CDB57AA003FF4B4 /* VocabularyImpl.cpp in Sources */,
|
||||
276E606B1CDB57AA003FF4B4 /* Vocabulary.cpp in Sources */,
|
||||
276E5F1B1CDB57AA003FF4B4 /* LexerDFASerializer.cpp in Sources */,
|
||||
276E60171CDB57AA003FF4B4 /* ParseTreePattern.cpp in Sources */,
|
||||
276E5DE61CDB57AA003FF4B4 /* LexerATNConfig.cpp in Sources */,
|
||||
|
@ -2298,6 +2429,7 @@
|
|||
276E5D4D1CDB57AA003FF4B4 /* AmbiguityInfo.cpp in Sources */,
|
||||
276E5F151CDB57AA003FF4B4 /* DFAState.cpp in Sources */,
|
||||
276E60081CDB57AA003FF4B4 /* ParseTreeWalker.cpp in Sources */,
|
||||
27DB44BB1D0463DA007E790B /* XPathLexerErrorListener.cpp in Sources */,
|
||||
276E5F9C1CDB57AA003FF4B4 /* RecognitionException.cpp in Sources */,
|
||||
276E5E8B1CDB57AA003FF4B4 /* RuleStartState.cpp in Sources */,
|
||||
276E5EA31CDB57AA003FF4B4 /* SetTransition.cpp in Sources */,
|
||||
|
@ -2315,7 +2447,6 @@
|
|||
276E5ECD1CDB57AA003FF4B4 /* WildcardTransition.cpp in Sources */,
|
||||
276E5E851CDB57AA003FF4B4 /* RangeTransition.cpp in Sources */,
|
||||
276E5D7D1CDB57AA003FF4B4 /* ATNSimulator.cpp in Sources */,
|
||||
276E5F781CDB57AA003FF4B4 /* TestRig.cpp in Sources */,
|
||||
276E5D9B1CDB57AA003FF4B4 /* BasicState.cpp in Sources */,
|
||||
276E5FC01CDB57AA003FF4B4 /* guid.cpp in Sources */,
|
||||
276E5E7F1CDB57AA003FF4B4 /* ProfilingATNSimulator.cpp in Sources */,
|
||||
|
@ -2324,10 +2455,13 @@
|
|||
276E5F6C1CDB57AA003FF4B4 /* MurmurHash.cpp in Sources */,
|
||||
276E5FDE1CDB57AA003FF4B4 /* TokenStream.cpp in Sources */,
|
||||
276E5FF01CDB57AA003FF4B4 /* ErrorNodeImpl.cpp in Sources */,
|
||||
27DB44C51D0463DA007E790B /* XPathWildcardAnywhereElement.cpp in Sources */,
|
||||
276E5D951CDB57AA003FF4B4 /* BasicBlockStartState.cpp in Sources */,
|
||||
276E5E491CDB57AA003FF4B4 /* ParseInfo.cpp in Sources */,
|
||||
276E5E3D1CDB57AA003FF4B4 /* NotSetTransition.cpp in Sources */,
|
||||
27DB44B21D0463CC007E790B /* XPathLexer.cpp in Sources */,
|
||||
276E602F1CDB57AA003FF4B4 /* TextChunk.cpp in Sources */,
|
||||
27DB44BD1D0463DA007E790B /* XPathRuleAnywhereElement.cpp in Sources */,
|
||||
276E5E431CDB57AA003FF4B4 /* OrderedATNConfigSet.cpp in Sources */,
|
||||
276E5DCB1CDB57AA003FF4B4 /* EpsilonTransition.cpp in Sources */,
|
||||
276E5D591CDB57AA003FF4B4 /* ATN.cpp in Sources */,
|
||||
|
@ -2358,6 +2492,7 @@
|
|||
276E5F4E1CDB57AA003FF4B4 /* LexerInterpreter.cpp in Sources */,
|
||||
276E5E281CDB57AA003FF4B4 /* LL1Analyzer.cpp in Sources */,
|
||||
276E5EAF1CDB57AA003FF4B4 /* StarBlockStartState.cpp in Sources */,
|
||||
27DB44C11D0463DA007E790B /* XPathTokenAnywhereElement.cpp in Sources */,
|
||||
276E5FB71CDB57AA003FF4B4 /* CPPUtils.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
@ -2374,6 +2509,7 @@
|
|||
276E5D521CDB57AA003FF4B4 /* ArrayPredictionContext.cpp in Sources */,
|
||||
276E5F081CDB57AA003FF4B4 /* DFA.cpp in Sources */,
|
||||
276E5E211CDB57AA003FF4B4 /* LexerTypeAction.cpp in Sources */,
|
||||
27DB449F1D045537007E790B /* XPathElement.cpp in Sources */,
|
||||
276E5EC01CDB57AA003FF4B4 /* TokensStartState.cpp in Sources */,
|
||||
276E5DB21CDB57AA003FF4B4 /* DecisionEventInfo.cpp in Sources */,
|
||||
276E60431CDB57AA003FF4B4 /* TerminalNodeImpl.cpp in Sources */,
|
||||
|
@ -2388,6 +2524,7 @@
|
|||
276E604F1CDB57AA003FF4B4 /* Trees.cpp in Sources */,
|
||||
276E5EB41CDB57AA003FF4B4 /* StarLoopbackState.cpp in Sources */,
|
||||
276E5E601CDB57AA003FF4B4 /* PrecedencePredicateTransition.cpp in Sources */,
|
||||
27DB44A31D045537007E790B /* XPathRuleAnywhereElement.cpp in Sources */,
|
||||
276E5E031CDB57AA003FF4B4 /* LexerModeAction.cpp in Sources */,
|
||||
276E5F471CDB57AA003FF4B4 /* Lexer.cpp in Sources */,
|
||||
276E5ED81CDB57AA003FF4B4 /* BaseErrorListener.cpp in Sources */,
|
||||
|
@ -2407,9 +2544,12 @@
|
|||
276E5E901CDB57AA003FF4B4 /* RuleStopState.cpp in Sources */,
|
||||
276E60611CDB57AA003FF4B4 /* UnbufferedTokenStream.cpp in Sources */,
|
||||
276E5DD91CDB57AA003FF4B4 /* LexerActionExecutor.cpp in Sources */,
|
||||
27DB449D1D045537007E790B /* XPath.cpp in Sources */,
|
||||
276E5E9C1CDB57AA003FF4B4 /* SemanticContext.cpp in Sources */,
|
||||
27DB44AD1D045537007E790B /* XPathWildcardElement.cpp in Sources */,
|
||||
276E5EC61CDB57AA003FF4B4 /* Transition.cpp in Sources */,
|
||||
276E601C1CDB57AA003FF4B4 /* ParseTreePatternMatcher.cpp in Sources */,
|
||||
27DB44A51D045537007E790B /* XPathRuleElement.cpp in Sources */,
|
||||
276E5F201CDB57AA003FF4B4 /* DiagnosticErrorListener.cpp in Sources */,
|
||||
276E5D461CDB57AA003FF4B4 /* ActionTransition.cpp in Sources */,
|
||||
276E60491CDB57AA003FF4B4 /* Tree.cpp in Sources */,
|
||||
|
@ -2419,12 +2559,13 @@
|
|||
276E5D6A1CDB57AA003FF4B4 /* ATNDeserializationOptions.cpp in Sources */,
|
||||
276E60341CDB57AA003FF4B4 /* TokenTagToken.cpp in Sources */,
|
||||
276E5DEB1CDB57AA003FF4B4 /* LexerATNSimulator.cpp in Sources */,
|
||||
276E606A1CDB57AA003FF4B4 /* VocabularyImpl.cpp in Sources */,
|
||||
276E606A1CDB57AA003FF4B4 /* Vocabulary.cpp in Sources */,
|
||||
276E5F1A1CDB57AA003FF4B4 /* LexerDFASerializer.cpp in Sources */,
|
||||
276E60161CDB57AA003FF4B4 /* ParseTreePattern.cpp in Sources */,
|
||||
276E5DE51CDB57AA003FF4B4 /* LexerATNConfig.cpp in Sources */,
|
||||
276E5F0E1CDB57AA003FF4B4 /* DFASerializer.cpp in Sources */,
|
||||
276E5F2C1CDB57AA003FF4B4 /* FailedPredicateException.cpp in Sources */,
|
||||
27DB44A71D045537007E790B /* XPathTokenAnywhereElement.cpp in Sources */,
|
||||
276E5F891CDB57AA003FF4B4 /* ParserInterpreter.cpp in Sources */,
|
||||
276E5D4C1CDB57AA003FF4B4 /* AmbiguityInfo.cpp in Sources */,
|
||||
276E5F141CDB57AA003FF4B4 /* DFAState.cpp in Sources */,
|
||||
|
@ -2446,7 +2587,6 @@
|
|||
276E5ECC1CDB57AA003FF4B4 /* WildcardTransition.cpp in Sources */,
|
||||
276E5E841CDB57AA003FF4B4 /* RangeTransition.cpp in Sources */,
|
||||
276E5D7C1CDB57AA003FF4B4 /* ATNSimulator.cpp in Sources */,
|
||||
276E5F771CDB57AA003FF4B4 /* TestRig.cpp in Sources */,
|
||||
276E5D9A1CDB57AA003FF4B4 /* BasicState.cpp in Sources */,
|
||||
276E5FBF1CDB57AA003FF4B4 /* guid.cpp in Sources */,
|
||||
276E5E7E1CDB57AA003FF4B4 /* ProfilingATNSimulator.cpp in Sources */,
|
||||
|
@ -2463,13 +2603,16 @@
|
|||
276E5DCA1CDB57AA003FF4B4 /* EpsilonTransition.cpp in Sources */,
|
||||
276E5D581CDB57AA003FF4B4 /* ATN.cpp in Sources */,
|
||||
276E5EE41CDB57AA003FF4B4 /* CharStream.cpp in Sources */,
|
||||
27DB44AB1D045537007E790B /* XPathWildcardAnywhereElement.cpp in Sources */,
|
||||
276E5EDE1CDB57AA003FF4B4 /* BufferedTokenStream.cpp in Sources */,
|
||||
276E5F021CDB57AA003FF4B4 /* DefaultErrorStrategy.cpp in Sources */,
|
||||
276E5D401CDB57AA003FF4B4 /* AbstractPredicateTransition.cpp in Sources */,
|
||||
276E5E5A1CDB57AA003FF4B4 /* PlusLoopbackState.cpp in Sources */,
|
||||
276E5E331CDB57AA003FF4B4 /* LoopEndState.cpp in Sources */,
|
||||
276E5FE31CDB57AA003FF4B4 /* TokenStreamRewriter.cpp in Sources */,
|
||||
27DB44A11D045537007E790B /* XPathLexerErrorListener.cpp in Sources */,
|
||||
276E5FA71CDB57AA003FF4B4 /* RuleContext.cpp in Sources */,
|
||||
27DB44B11D0463CC007E790B /* XPathLexer.cpp in Sources */,
|
||||
276E5D5E1CDB57AA003FF4B4 /* ATNConfig.cpp in Sources */,
|
||||
276E5EFC1CDB57AA003FF4B4 /* ConsoleErrorListener.cpp in Sources */,
|
||||
276E5EA81CDB57AA003FF4B4 /* SingletonPredictionContext.cpp in Sources */,
|
||||
|
@ -2489,6 +2632,7 @@
|
|||
276E5F4D1CDB57AA003FF4B4 /* LexerInterpreter.cpp in Sources */,
|
||||
276E5E271CDB57AA003FF4B4 /* LL1Analyzer.cpp in Sources */,
|
||||
276E5EAE1CDB57AA003FF4B4 /* StarBlockStartState.cpp in Sources */,
|
||||
27DB44A91D045537007E790B /* XPathTokenElement.cpp in Sources */,
|
||||
276E5FB61CDB57AA003FF4B4 /* CPPUtils.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
|
|
@ -37,10 +37,7 @@ namespace antlrcpp {
|
|||
class BitSet;
|
||||
}
|
||||
|
||||
namespace org {
|
||||
namespace antlr {
|
||||
namespace v4 {
|
||||
namespace runtime {
|
||||
namespace antlr4 {
|
||||
|
||||
/// How to emit recognition errors (an interface in Java).
|
||||
class ANTLR4CPP_PUBLIC ANTLRErrorListener {
|
||||
|
@ -193,7 +190,4 @@ namespace runtime {
|
|||
int prediction, Ref<atn::ATNConfigSet> configs) = 0;
|
||||
};
|
||||
|
||||
} // namespace runtime
|
||||
} // namespace v4
|
||||
} // namespace antlr
|
||||
} // namespace org
|
||||
} // namespace antlr4
|
||||
|
|
|
@ -33,10 +33,7 @@
|
|||
|
||||
#include "Token.h"
|
||||
|
||||
namespace org {
|
||||
namespace antlr {
|
||||
namespace v4 {
|
||||
namespace runtime {
|
||||
namespace antlr4 {
|
||||
|
||||
/// <summary>
|
||||
/// The interface for defining strategies to deal with syntax errors encountered
|
||||
|
@ -146,7 +143,4 @@ namespace runtime {
|
|||
virtual void reportError(Parser *recognizer, const RecognitionException &e) = 0;
|
||||
};
|
||||
|
||||
} // namespace runtime
|
||||
} // namespace v4
|
||||
} // namespace antlr
|
||||
} // namespace org
|
||||
} // namespace antlr4
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
#include "ANTLRFileStream.h"
|
||||
|
||||
using namespace org::antlr::v4::runtime;
|
||||
using namespace antlr4;
|
||||
|
||||
ANTLRFileStream::ANTLRFileStream(const std::string &fileName) {
|
||||
_fileName = fileName;
|
||||
|
|
|
@ -33,10 +33,7 @@
|
|||
|
||||
#include "ANTLRInputStream.h"
|
||||
|
||||
namespace org {
|
||||
namespace antlr {
|
||||
namespace v4 {
|
||||
namespace runtime {
|
||||
namespace antlr4 {
|
||||
|
||||
/// This is an ANTLRInputStream that is loaded from a file all at once
|
||||
/// when you construct the object (or call load()).
|
||||
|
@ -53,7 +50,4 @@ namespace runtime {
|
|||
virtual std::string getSourceName() const override;
|
||||
};
|
||||
|
||||
} // namespace runtime
|
||||
} // namespace v4
|
||||
} // namespace antlr
|
||||
} // namespace org
|
||||
} // namespace antlr4
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
#include "ANTLRInputStream.h"
|
||||
|
||||
using namespace org::antlr::v4::runtime;
|
||||
using namespace antlr4;
|
||||
using namespace antlrcpp;
|
||||
|
||||
using misc::Interval;
|
||||
|
@ -150,9 +150,14 @@ void ANTLRInputStream::seek(size_t index) {
|
|||
}
|
||||
|
||||
std::string ANTLRInputStream::getText(const Interval &interval) {
|
||||
if (interval.a < 0 || interval.b < 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
size_t start = (size_t)interval.a;
|
||||
size_t stop = (size_t)interval.b;
|
||||
|
||||
|
||||
if (stop >= data.size()) {
|
||||
stop = data.size() - 1;
|
||||
}
|
||||
|
|
|
@ -33,10 +33,7 @@
|
|||
|
||||
#include "CharStream.h"
|
||||
|
||||
namespace org {
|
||||
namespace antlr {
|
||||
namespace v4 {
|
||||
namespace runtime {
|
||||
namespace antlr4 {
|
||||
|
||||
// Vacuum all input from a stream and then treat it
|
||||
// like a string. Can also pass in a string or char[] to use.
|
||||
|
@ -94,7 +91,4 @@ namespace runtime {
|
|||
void InitializeInstanceFields();
|
||||
};
|
||||
|
||||
} // namespace runtime
|
||||
} // namespace v4
|
||||
} // namespace antlr
|
||||
} // namespace org
|
||||
} // namespace antlr4
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
#include "BailErrorStrategy.h"
|
||||
|
||||
using namespace org::antlr::v4::runtime;
|
||||
using namespace antlr4;
|
||||
|
||||
void BailErrorStrategy::recover(Parser *recognizer, std::exception_ptr e) {
|
||||
Ref<ParserRuleContext> context = recognizer->getContext();
|
||||
|
@ -47,16 +47,15 @@ void BailErrorStrategy::recover(Parser *recognizer, std::exception_ptr e) {
|
|||
context = context->getParent().lock();
|
||||
} while (true);
|
||||
|
||||
#if defined(_MSC_FULL_VER) && _MSC_FULL_VER < 190023026
|
||||
// throw_with_nested is not available before VS 2015.
|
||||
std::rethrow_exception(e);
|
||||
#else
|
||||
try {
|
||||
std::rethrow_exception(e); // Throw the exception to be able to catch and rethrow nested.
|
||||
} catch (RecognitionException &inner) {
|
||||
#if defined(_MSC_FULL_VER) && _MSC_FULL_VER < 190023026
|
||||
throw ParseCancellationException(inner.what());
|
||||
#else
|
||||
std::throw_with_nested(ParseCancellationException());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Ref<Token> BailErrorStrategy::recoverInline(Parser *recognizer) {
|
||||
|
@ -71,15 +70,15 @@ Ref<Token> BailErrorStrategy::recoverInline(Parser *recognizer) {
|
|||
context = context->getParent().lock();
|
||||
} while (true);
|
||||
|
||||
#if defined(_MSC_FULL_VER) && _MSC_FULL_VER < 190023026
|
||||
throw e;
|
||||
#else
|
||||
try {
|
||||
throw e;
|
||||
} catch (InputMismatchException &inner) {
|
||||
#if defined(_MSC_FULL_VER) && _MSC_FULL_VER < 190023026
|
||||
throw ParseCancellationException(inner.what());
|
||||
#else
|
||||
std::throw_with_nested(ParseCancellationException());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void BailErrorStrategy::sync(Parser * /*recognizer*/) {
|
||||
|
|
|
@ -33,10 +33,7 @@
|
|||
|
||||
#include "DefaultErrorStrategy.h"
|
||||
|
||||
namespace org {
|
||||
namespace antlr {
|
||||
namespace v4 {
|
||||
namespace runtime {
|
||||
namespace antlr4 {
|
||||
|
||||
/**
|
||||
* This implementation of {@link ANTLRErrorStrategy} responds to syntax errors
|
||||
|
@ -87,7 +84,4 @@ namespace runtime {
|
|||
virtual void sync(Parser *recognizer) override;
|
||||
};
|
||||
|
||||
} // namespace runtime
|
||||
} // namespace v4
|
||||
} // namespace antlr
|
||||
} // namespace org
|
||||
} // namespace antlr4
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "BaseErrorListener.h"
|
||||
#include "RecognitionException.h"
|
||||
|
||||
using namespace org::antlr::v4::runtime;
|
||||
using namespace antlr4;
|
||||
|
||||
void BaseErrorListener::syntaxError(IRecognizer * /*recognizer*/, Ref<Token> /*offendingSymbol*/, size_t /*line*/,
|
||||
int /*charPositionInLine*/, const std::string &/*msg*/, std::exception_ptr /*e*/) {
|
||||
|
|
|
@ -37,10 +37,7 @@ namespace antlrcpp {
|
|||
class BitSet;
|
||||
}
|
||||
|
||||
namespace org {
|
||||
namespace antlr {
|
||||
namespace v4 {
|
||||
namespace runtime {
|
||||
namespace antlr4 {
|
||||
|
||||
/**
|
||||
* Provides an empty default implementation of {@link ANTLRErrorListener}. The
|
||||
|
@ -62,7 +59,4 @@ namespace runtime {
|
|||
int prediction, Ref<atn::ATNConfigSet> configs) override;
|
||||
};
|
||||
|
||||
} // namespace runtime
|
||||
} // namespace v4
|
||||
} // namespace antlr
|
||||
} // namespace org
|
||||
} // namespace antlr4
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
#include "BufferedTokenStream.h"
|
||||
|
||||
using namespace org::antlr::v4::runtime;
|
||||
using namespace antlr4;
|
||||
using namespace antlrcpp;
|
||||
|
||||
BufferedTokenStream::BufferedTokenStream(TokenSource *tokenSource) : _tokenSource(tokenSource){
|
||||
|
|
|
@ -33,10 +33,7 @@
|
|||
|
||||
#include "TokenStream.h"
|
||||
|
||||
namespace org {
|
||||
namespace antlr {
|
||||
namespace v4 {
|
||||
namespace runtime {
|
||||
namespace antlr4 {
|
||||
|
||||
/**
|
||||
* This implementation of {@link TokenStream} loads tokens from a
|
||||
|
@ -224,7 +221,4 @@ namespace runtime {
|
|||
void InitializeInstanceFields();
|
||||
};
|
||||
|
||||
} // namespace runtime
|
||||
} // namespace v4
|
||||
} // namespace antlr
|
||||
} // namespace org
|
||||
} // namespace antlr4
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
#include "CharStream.h"
|
||||
|
||||
using namespace org::antlr::v4::runtime;
|
||||
using namespace antlr4;
|
||||
|
||||
CharStream::~CharStream() {
|
||||
}
|
||||
|
|
|
@ -34,10 +34,7 @@
|
|||
#include "IntStream.h"
|
||||
#include "misc/Interval.h"
|
||||
|
||||
namespace org {
|
||||
namespace antlr {
|
||||
namespace v4 {
|
||||
namespace runtime {
|
||||
namespace antlr4 {
|
||||
|
||||
/// A source of characters for an ANTLR lexer.
|
||||
class ANTLR4CPP_PUBLIC CharStream : public IntStream {
|
||||
|
@ -63,7 +60,4 @@ namespace runtime {
|
|||
virtual std::string toString() const = 0;
|
||||
};
|
||||
|
||||
} // namespace runtime
|
||||
} // namespace v4
|
||||
} // namespace antlr
|
||||
} // namespace org
|
||||
} // namespace antlr4
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
#include "CommonToken.h"
|
||||
|
||||
using namespace org::antlr::v4::runtime;
|
||||
using namespace antlr4;
|
||||
using namespace antlrcpp;
|
||||
|
||||
const std::pair<TokenSource*, CharStream*> CommonToken::EMPTY_SOURCE;
|
||||
|
@ -164,11 +164,11 @@ void CommonToken::setTokenIndex(int index) {
|
|||
_index = index;
|
||||
}
|
||||
|
||||
org::antlr::v4::runtime::TokenSource *CommonToken::getTokenSource() const {
|
||||
antlr4::TokenSource *CommonToken::getTokenSource() const {
|
||||
return _source.first;
|
||||
}
|
||||
|
||||
org::antlr::v4::runtime::CharStream *CommonToken::getInputStream() const {
|
||||
antlr4::CharStream *CommonToken::getInputStream() const {
|
||||
return _source.second;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,10 +33,7 @@
|
|||
|
||||
#include "WritableToken.h"
|
||||
|
||||
namespace org {
|
||||
namespace antlr {
|
||||
namespace v4 {
|
||||
namespace runtime {
|
||||
namespace antlr4 {
|
||||
|
||||
class ANTLR4CPP_PUBLIC CommonToken : public WritableToken {
|
||||
protected:
|
||||
|
@ -183,7 +180,4 @@ namespace runtime {
|
|||
void InitializeInstanceFields();
|
||||
};
|
||||
|
||||
} // namespace runtime
|
||||
} // namespace v4
|
||||
} // namespace antlr
|
||||
} // namespace org
|
||||
} // namespace antlr4
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
#include "CommonTokenFactory.h"
|
||||
|
||||
using namespace org::antlr::v4::runtime;
|
||||
using namespace antlr4;
|
||||
|
||||
const Ref<TokenFactory<CommonToken>> CommonTokenFactory::DEFAULT = std::make_shared<CommonTokenFactory>();
|
||||
|
||||
|
|
|
@ -33,10 +33,7 @@
|
|||
|
||||
#include "TokenFactory.h"
|
||||
|
||||
namespace org {
|
||||
namespace antlr {
|
||||
namespace v4 {
|
||||
namespace runtime {
|
||||
namespace antlr4 {
|
||||
|
||||
/**
|
||||
* This default implementation of {@link TokenFactory} creates
|
||||
|
@ -100,7 +97,4 @@ namespace runtime {
|
|||
virtual Ref<CommonToken> create(int type, const std::string &text) override;
|
||||
};
|
||||
|
||||
} // namespace runtime
|
||||
} // namespace v4
|
||||
} // namespace antlr
|
||||
} // namespace org
|
||||
} // namespace antlr4
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
#include "CommonTokenStream.h"
|
||||
|
||||
using namespace org::antlr::v4::runtime;
|
||||
using namespace antlr4;
|
||||
|
||||
CommonTokenStream::CommonTokenStream(TokenSource *tokenSource) : BufferedTokenStream(tokenSource) {
|
||||
InitializeInstanceFields();
|
||||
|
|
|
@ -33,10 +33,7 @@
|
|||
|
||||
#include "BufferedTokenStream.h"
|
||||
|
||||
namespace org {
|
||||
namespace antlr {
|
||||
namespace v4 {
|
||||
namespace runtime {
|
||||
namespace antlr4 {
|
||||
|
||||
/**
|
||||
* This class extends {@link BufferedTokenStream} with functionality to filter
|
||||
|
@ -109,7 +106,4 @@ namespace runtime {
|
|||
void InitializeInstanceFields();
|
||||
};
|
||||
|
||||
} // namespace runtime
|
||||
} // namespace v4
|
||||
} // namespace antlr
|
||||
} // namespace org
|
||||
} // namespace antlr4
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
#include "ConsoleErrorListener.h"
|
||||
|
||||
using namespace org::antlr::v4::runtime;
|
||||
using namespace antlr4;
|
||||
|
||||
ConsoleErrorListener ConsoleErrorListener::INSTANCE;
|
||||
|
||||
|
|
|
@ -33,10 +33,7 @@
|
|||
|
||||
#include "BaseErrorListener.h"
|
||||
|
||||
namespace org {
|
||||
namespace antlr {
|
||||
namespace v4 {
|
||||
namespace runtime {
|
||||
namespace antlr4 {
|
||||
|
||||
class ANTLR4CPP_PUBLIC ConsoleErrorListener : public BaseErrorListener {
|
||||
public:
|
||||
|
@ -61,7 +58,4 @@ namespace runtime {
|
|||
const std::string &msg, std::exception_ptr e) override;
|
||||
};
|
||||
|
||||
} // namespace runtime
|
||||
} // namespace v4
|
||||
} // namespace antlr
|
||||
} // namespace org
|
||||
} // namespace antlr4
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
#include "DefaultErrorStrategy.h"
|
||||
|
||||
using namespace org::antlr::v4::runtime;
|
||||
using namespace antlr4;
|
||||
using namespace antlrcpp;
|
||||
|
||||
void DefaultErrorStrategy::reset(Parser *recognizer) {
|
||||
|
@ -269,7 +269,7 @@ Ref<Token> DefaultErrorStrategy::getMissingSymbol(Parser *recognizer) {
|
|||
if (expectedTokenType == Token::EOF) {
|
||||
tokenText = "<missing EOF>";
|
||||
} else {
|
||||
tokenText = "<missing " + recognizer->getVocabulary()->getDisplayName(expectedTokenType) + ">";
|
||||
tokenText = "<missing " + recognizer->getVocabulary().getDisplayName(expectedTokenType) + ">";
|
||||
}
|
||||
Ref<Token> current = currentSymbol;
|
||||
Ref<Token> lookback = recognizer->getTokenStream()->LT(-1);
|
||||
|
|
|
@ -34,10 +34,7 @@
|
|||
#include "ANTLRErrorStrategy.h"
|
||||
#include "misc/IntervalSet.h"
|
||||
|
||||
namespace org {
|
||||
namespace antlr {
|
||||
namespace v4 {
|
||||
namespace runtime {
|
||||
namespace antlr4 {
|
||||
|
||||
/**
|
||||
* This is the default implementation of {@link ANTLRErrorStrategy} used for
|
||||
|
@ -490,7 +487,4 @@ namespace runtime {
|
|||
|
||||
};
|
||||
|
||||
} // namespace runtime
|
||||
} // namespace v4
|
||||
} // namespace antlr
|
||||
} // namespace org
|
||||
} // namespace antlr4
|
||||
|
|
|
@ -38,9 +38,9 @@
|
|||
|
||||
#include "DiagnosticErrorListener.h"
|
||||
|
||||
using namespace org::antlr::v4::runtime;
|
||||
using namespace antlr4;
|
||||
|
||||
DiagnosticErrorListener::DiagnosticErrorListener() : exactOnly(true) {
|
||||
DiagnosticErrorListener::DiagnosticErrorListener() : DiagnosticErrorListener(true) {
|
||||
}
|
||||
|
||||
DiagnosticErrorListener::DiagnosticErrorListener(bool exactOnly) : exactOnly(exactOnly) {
|
||||
|
@ -55,8 +55,8 @@ void DiagnosticErrorListener::reportAmbiguity(Parser *recognizer, const dfa::DFA
|
|||
std::string decision = getDecisionDescription(recognizer, dfa);
|
||||
antlrcpp::BitSet conflictingAlts = getConflictingAlts(ambigAlts, configs);
|
||||
std::string text = recognizer->getTokenStream()->getText(misc::Interval((int)startIndex, (int)stopIndex));
|
||||
std::string message = "reportAmbiguity d = " + decision + ": ambigAlts = " + conflictingAlts.toString() +
|
||||
", input = '" + text + "'";
|
||||
std::string message = "reportAmbiguity d=" + decision + ": ambigAlts=" + conflictingAlts.toString() +
|
||||
", input='" + text + "'";
|
||||
|
||||
recognizer->notifyErrorListeners(message);
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ void DiagnosticErrorListener::reportAttemptingFullContext(Parser *recognizer, co
|
|||
size_t stopIndex, const antlrcpp::BitSet &/*conflictingAlts*/, Ref<atn::ATNConfigSet> /*configs*/) {
|
||||
std::string decision = getDecisionDescription(recognizer, dfa);
|
||||
std::string text = recognizer->getTokenStream()->getText(misc::Interval((int)startIndex, (int)stopIndex));
|
||||
std::string message = "reportAttemptingFullContext d = " + decision + ", input = '" + text + "'";
|
||||
std::string message = "reportAttemptingFullContext d=" + decision + ", input='" + text + "'";
|
||||
recognizer->notifyErrorListeners(message);
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ void DiagnosticErrorListener::reportContextSensitivity(Parser *recognizer, const
|
|||
size_t stopIndex, int /*prediction*/, Ref<atn::ATNConfigSet> /*configs*/) {
|
||||
std::string decision = getDecisionDescription(recognizer, dfa);
|
||||
std::string text = recognizer->getTokenStream()->getText(misc::Interval((int)startIndex, (int)stopIndex));
|
||||
std::string message = "reportContextSensitivity d = " + decision + ", input = '" + text + "'";
|
||||
std::string message = "reportContextSensitivity d=" + decision + ", input='" + text + "'";
|
||||
recognizer->notifyErrorListeners(message);
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ std::string DiagnosticErrorListener::getDecisionDescription(Parser *recognizer,
|
|||
return std::to_string(decision);
|
||||
}
|
||||
|
||||
return std::to_string(decision) + "(" + ruleName + ")";
|
||||
return std::to_string(decision) + " (" + ruleName + ")";
|
||||
}
|
||||
|
||||
antlrcpp::BitSet DiagnosticErrorListener::getConflictingAlts(const antlrcpp::BitSet &reportedAlts,
|
||||
|
|
|
@ -33,10 +33,7 @@
|
|||
|
||||
#include "BaseErrorListener.h"
|
||||
|
||||
namespace org {
|
||||
namespace antlr {
|
||||
namespace v4 {
|
||||
namespace runtime {
|
||||
namespace antlr4 {
|
||||
|
||||
/// <summary>
|
||||
/// This implementation of <seealso cref="ANTLRErrorListener"/> can be used to identify
|
||||
|
@ -71,7 +68,7 @@ namespace runtime {
|
|||
/// reports exact ambiguities.
|
||||
/// </summary>
|
||||
public:
|
||||
DiagnosticErrorListener(); //this(true);
|
||||
DiagnosticErrorListener();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <seealso cref="DiagnosticErrorListener"/>, specifying
|
||||
|
@ -106,7 +103,4 @@ namespace runtime {
|
|||
virtual antlrcpp::BitSet getConflictingAlts(const antlrcpp::BitSet &reportedAlts, Ref<atn::ATNConfigSet> configs);
|
||||
};
|
||||
|
||||
} // namespace runtime
|
||||
} // namespace v4
|
||||
} // namespace antlr
|
||||
} // namespace org
|
||||
} // namespace antlr4
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
#include "Exceptions.h"
|
||||
|
||||
using namespace org::antlr::v4::runtime;
|
||||
using namespace antlr4;
|
||||
|
||||
RuntimeException::RuntimeException(const std::string &msg) : std::exception(), _message(msg) {
|
||||
}
|
||||
|
|
|
@ -32,10 +32,7 @@
|
|||
|
||||
#include "antlr4-common.h"
|
||||
|
||||
namespace org {
|
||||
namespace antlr {
|
||||
namespace v4 {
|
||||
namespace runtime {
|
||||
namespace antlr4 {
|
||||
|
||||
// An exception hierarchy modelled loosely after java.lang.* exceptions.
|
||||
class ANTLR4CPP_PUBLIC RuntimeException : public std::exception {
|
||||
|
@ -99,7 +96,4 @@ namespace runtime {
|
|||
ParseCancellationException(const std::string &msg = "") : CancellationException(msg) {};
|
||||
};
|
||||
|
||||
} // namespace runtime
|
||||
} // namespace v4
|
||||
} // namespace antlr
|
||||
} // namespace org
|
||||
} // namespace antlr4
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue