forked from jasder/antlr
update doc on the runtime test mechanism. change the name of BaseDebugParserTestDescriptor to BaseDiagnosticParserTestDescriptor.
This commit is contained in:
parent
a7ecf0332f
commit
d534efdf9a
|
@ -1,119 +1,125 @@
|
|||
# Adding unit tests
|
||||
|
||||
## Generating Runtime Tests
|
||||
## Introduction
|
||||
|
||||
Because ANTLR supports multiple target languages, the unit tests are broken into two groups: the unit tests that test the tool itself (in `tool-testsuite`) and the unit tests that test the parser runtimes (in antlr4/runtime-testsuite). To avoid a lot of cut-and-paste, we generate all **runtime** tests from a set of templates using [runtime-testsuite/src/org/antlr/v4/testgen/TestGenerator.java](../runtime-testsuite/src/org/antlr/v4/testgen/TestGenerator.java). The `mvn` command is simple to use:
|
||||
Because ANTLR supports multiple target languages, the unit tests are broken into two groups: the unit tests that test the tool itself (in `tool-testsuite`) and the unit tests that test the parser runtimes (in `antlr4/runtime-testsuite`). The tool tests are straightforward because they are Java code testing Java code; see the section at the bottom of this file.
|
||||
|
||||
```
|
||||
$ cd ~/antlr/code/antlr4/runtime-testsuite
|
||||
$ mvn -Pgen generate-test-sources
|
||||
...
|
||||
rootDir = /Users/parrt/antlr/code/antlr4/runtime-testsuite
|
||||
outputDir = /Users/parrt/antlr/code/antlr4/runtime-testsuite/test
|
||||
templates = /Users/parrt/antlr/code/antlr4/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates
|
||||
target = ALL
|
||||
browsers = false
|
||||
viz = false
|
||||
INFO: Generating target Java
|
||||
INFO: Generating target Go
|
||||
INFO: Generating target CSharp
|
||||
INFO: Generating target Python2
|
||||
INFO: Generating target Python3
|
||||
INFO: Generating target JavaScript/Node
|
||||
...
|
||||
The runtime tests must be specified in a generic fashion to work across language targets. Furthermore, we must test the various targets from Java. This usually means Java launching processes to compile, say, C++ and run parsers.
|
||||
|
||||
As of 4.6, we use [a Java descriptor object](https://github.com/antlr/antlr4/blob/master/runtime-testsuite/test/org/antlr/v4/test/runtime/RuntimeTestDescriptor.java) to describe each runtime test. Unit tests are grouped together into categories such as [ParserExecDescriptors](https://github.com/antlr/antlr4/blob/master/runtime-testsuite/test/org/antlr/v4/test/runtime/descriptors/ParserExecDescriptors.java), which has multiple nested descriptor objects, one per test. For example, here is the start of that file:
|
||||
|
||||
```java
|
||||
public class ParserExecDescriptors {
|
||||
public static class APlus extends BaseParserTestDescriptor {
|
||||
public String input = "a b c";
|
||||
public String output = "abc\n";
|
||||
public String errors = "";
|
||||
public String startRule = "a";
|
||||
public String grammarName = "T";
|
||||
|
||||
/**
|
||||
grammar T;
|
||||
a : ID+ {
|
||||
<writeln("$text")>
|
||||
};
|
||||
ID : 'a'..'z'+;
|
||||
WS : (' '|'\n') -> skip;
|
||||
*/
|
||||
@CommentHasStringValue
|
||||
public String grammar;
|
||||
}
|
||||
```
|
||||
|
||||
It basically runs the Java program:
|
||||
The mysterious `@CommentHasStringValue` annotation is a bit of a hack that allows multi-line strings in Java. This kung fu is required so that we can use Java classes rather than StringTemplate group files to specify runtime tests (the legacy system used those and it was hard to get them right). Here are all the [Runtime test descriptors](https://github.com/antlr/antlr4/tree/master/runtime-testsuite/test/org/antlr/v4/test/runtime/descriptors) organized into groups.
|
||||
|
||||
The grammars are strings representing StringTemplates (`ST` objects) so `<writeln("$text")>` will get replace when the unit test file is generated (`Test.java`, `Test.cs`, ...). The `writeln` template must be defined per target. Here are all of the
|
||||
[Target templates for runtime tests](https://github.com/antlr/antlr4/tree/master/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates).
|
||||
|
||||
## Running the runtime tests
|
||||
|
||||
A single test rig is sufficient to test all targets against all descriptors using the [junit parameterized tests](https://github.com/junit-team/junit4/wiki/parameterized-tests) mechanism. But, that is inconvenient because we often want to test just a single target or perhaps even just a single test within a single group of a single target. I have automatically generated a bunch of
|
||||
[Target runtime test rigs](https://github.com/antlr/antlr4/tree/master/runtime-testsuite/test/org/antlr/v4/test/runtime) that allow developers such flexibility. For example, here are the Python3 test rigs in intellij:
|
||||
|
||||
<img src=images/testrigs.png width=300>
|
||||
|
||||
And the result of testing the entire subdirectory:
|
||||
|
||||
<img src=images/python3-tests.png width=400>
|
||||
|
||||
From `mvn`, on the commandline, you will see:
|
||||
|
||||
```bash
|
||||
$ java org.antlr.v4.testgen.TestGenerator \
|
||||
-root ~/antlr/code/antlr4/runtime-testsuite \
|
||||
-outdir ~/antlr/code/antlr4/runtime-testsuite/test \
|
||||
-templates ~/antlr/code/antlr4/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates
|
||||
-------------------------------------------------------
|
||||
T E S T S
|
||||
-------------------------------------------------------
|
||||
Running org.antlr.v4.test.runtime.javascript.node.TestCompositeLexers
|
||||
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.581 sec
|
||||
Running org.antlr.v4.test.runtime.javascript.node.TestLexerErrors
|
||||
Tests run: 12, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.721 sec
|
||||
Running org.antlr.v4.test.runtime.javascript.node.TestSemPredEvalParser
|
||||
Tests run: 26, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 6.084 sec
|
||||
Running org.antlr.v4.test.runtime.javascript.node.TestSets
|
||||
Tests run: 23, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.798 sec
|
||||
Running org.antlr.v4.test.runtime.javascript.node.TestPerformance
|
||||
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.505 sec
|
||||
Running org.antlr.v4.test.runtime.javascript.node.TestSemPredEvalLexer
|
||||
Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.994 sec
|
||||
Running org.antlr.v4.test.runtime.javascript.node.TestLexerExec
|
||||
Tests run: 38, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 8.433 sec
|
||||
...
|
||||
```
|
||||
|
||||
## Adding a runtime test
|
||||
|
||||
For each target, you will find an `Index.stg` file with a dictionary of all test groups. E.g., `runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/Index.stg` looks like:
|
||||
To add a new runtime test, first determine which [group of tests](https://github.com/antlr/antlr4/blob/master/runtime-testsuite/test/org/antlr/v4/test/runtime/descriptors) it belongs to. Then, add a new [RuntimeTestDescriptor](https://github.com/antlr/antlr4/blob/master/runtime-testsuite/test/org/antlr/v4/test/runtime/RuntimeTestDescriptor.java) implementation by subclassing one of:
|
||||
|
||||
```
|
||||
TestFolders ::= [
|
||||
"CompositeLexers": [],
|
||||
"CompositeParsers": [],
|
||||
"FullContextParsing": [],
|
||||
"LeftRecursion": [],
|
||||
"LexerErrors": [],
|
||||
"LexerExec": [],
|
||||
"Listeners": [],
|
||||
"ParserErrors": [],
|
||||
"ParserExec": [],
|
||||
"ParseTrees": [],
|
||||
"Performance": [],
|
||||
"SemPredEvalLexer": [],
|
||||
"SemPredEvalParser": [],
|
||||
"Sets": []
|
||||
]
|
||||
* [BaseParserTestDescriptor](https://github.com/antlr/antlr4/blob/master/runtime-testsuite/test/org/antlr/v4/test/runtime/BaseParserTestDescriptor.java); see example [APlus](https://github.com/antlr/antlr4/blob/master/runtime-testsuite/test/org/antlr/v4/test/runtime/descriptors/ParserExecDescriptors.java#L7).
|
||||
* [BaseDiagnosticParserTestDescriptor](https://github.com/antlr/antlr4/blob/master/runtime-testsuite/test/org/antlr/v4/test/runtime/BaseDiagnosticParserTestDescriptor) if you want to test parser diagnostic output; see [example output](https://github.com/antlr/antlr4/blob/master/runtime-testsuite/test/org/antlr/v4/test/runtime/descriptors/FullContextParsingDescriptors.java#L16).
|
||||
* [BaseCompositeParserTestDescriptor](https://github.com/antlr/antlr4/blob/master/runtime-testsuite/test/org/antlr/v4/test/runtime/BaseCompositeParserTestDescriptor.java); see example [BringInLiteralsFromDelegate](https://github.com/antlr/antlr4/blob/master/runtime-testsuite/test/org/antlr/v4/test/runtime/descriptors/CompositeParsersDescriptors.java#L11)
|
||||
* [BaseLexerTestDescriptor](https://github.com/antlr/antlr4/blob/master/runtime-testsuite/test/org/antlr/v4/test/runtime/BaseLexerTestDescriptor.java); see example [ActionPlacement](https://github.com/antlr/antlr4/blob/master/runtime-testsuite/test/org/antlr/v4/test/runtime/descriptors/LexerExecDescriptors.java#L12).
|
||||
* [BaseCompositeLexerTestDescriptor](https://github.com/antlr/antlr4/blob/master/runtime-testsuite/test/org/antlr/v4/test/runtime/BaseCompositeLexerTestDescriptor.java); see example [LexerDelegatorInvokesDelegateRule](https://github.com/antlr/antlr4/blob/master/runtime-testsuite/test/org/antlr/v4/test/runtime/descriptors/CompositeLexersDescriptors.java#L11)
|
||||
|
||||
|
||||
Each descriptor object describes the following mandatory elements for the test:
|
||||
|
||||
* the test type
|
||||
* the grammar
|
||||
* the start rule
|
||||
* the input text to parse or lex
|
||||
* the expected output
|
||||
* the expected errors
|
||||
|
||||
Your best bet is to find a similar test in the appropriate group and then copy and paste the descriptor object, creating a new nested class within the test group class. Modify the field definitions to suit your new problem.
|
||||
|
||||
If you need to create a whole new group of tests, it requires a new descriptor class; call it `XDescriptors`. Then, in each [target subdirectory](https://github.com/antlr/antlr4/tree/master/runtime-testsuite/test/org/antlr/v4/test/runtime), you need to create a new test rig `TestX.java` file:
|
||||
|
||||
```java
|
||||
package org.antlr.v4.test.runtime.java;
|
||||
|
||||
import org.antlr.v4.test.runtime.BaseRuntimeTest;
|
||||
import org.antlr.v4.test.runtime.RuntimeTestDescriptor;
|
||||
import org.antlr.v4.test.runtime.descriptors.ListenersDescriptors;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class TestX extends BaseRuntimeTest {
|
||||
public TestX(RuntimeTestDescriptor descriptor) {
|
||||
super(descriptor,new Base<TARGET>Test());
|
||||
}
|
||||
|
||||
@Parameterized.Parameters(name="{0}")
|
||||
public static RuntimeTestDescriptor[] getAllTestDescriptors() {
|
||||
return BaseRuntimeTest.getRuntimeTestDescriptors(XDescriptors.class, "<TARGET>");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Then each group has a subdirectory with another index. E.g., `Sets/Index.stg` looks like:
|
||||
|
||||
```
|
||||
TestTemplates ::= [
|
||||
"SeqDoesNotBecomeSet": [],
|
||||
"ParserSet": [],
|
||||
"ParserNotSet": [],
|
||||
"ParserNotToken": [],
|
||||
"ParserNotTokenWithLabel": [],
|
||||
"RuleAsSet": [],
|
||||
"NotChar": [],
|
||||
"OptionalSingleElement": [],
|
||||
...
|
||||
```
|
||||
|
||||
For every name mentioned, you will find a `.stg` file with the actual test template. E.g., `Sets/StarSet.stg`.
|
||||
|
||||
Each `.stg` file descripes the following mandatory elements for the test:
|
||||
- the test type: "Parser" or "Lexer"
|
||||
- some ANTLR options, such as "Debug"
|
||||
- the grammar
|
||||
- the start rule
|
||||
- the input i.e. the text to parse
|
||||
- the expected output
|
||||
- the expected errors
|
||||
|
||||
The grammar can itself contain template expressions such as `<something>`.
|
||||
The test generator replaces these with the corresponding values from the target language template (see below).
|
||||
It then generates a unit test in which the grammar, the input and the expected output and errors are inlined.
|
||||
where `<TARGET>` is replaced with Java, Cpp, CSharp, Python2, ... in the various subdirectories.
|
||||
|
||||
Here is an example test template:
|
||||
|
||||
```
|
||||
TestType() ::= "Parser"
|
||||
|
||||
Options ::= [
|
||||
"Debug": false
|
||||
]
|
||||
|
||||
Grammar ::= [
|
||||
"T": {<grammar("T")>}
|
||||
]
|
||||
|
||||
Input() ::= "abaac"
|
||||
|
||||
Rule() ::= "a"
|
||||
|
||||
Output() ::= <<
|
||||
abaac<\n>
|
||||
>>
|
||||
|
||||
Errors() ::= ""
|
||||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
a : ('a'|'b')* 'c' {<InputText():writeln()>} ;
|
||||
>>
|
||||
```
|
||||
### Ignoring tests
|
||||
|
||||
In order to turn off a test for a particular target, we need to use the `ignore` method. Given a target name, a descriptor object can decide whether to ignore the test. This is not always convenient but it is fully general and works well for the one case we have now where we have to ignore `Visitor` tests in all targets except JavaScript.
|
||||
|
||||
### Cross-language actions embedded within grammars
|
||||
|
||||
|
@ -129,14 +135,16 @@ Use instead the language-neutral:
|
|||
<writeln("$set.stop")>
|
||||
```
|
||||
|
||||
File `runtime-testsuite/resources/org/antlr/v4/test/runtime/java/Java.test.stg` has templates like:
|
||||
Template file [runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/Java.test.stg](https://github.com/antlr/antlr4/tree/master/runtime-testsuite/resources/org/antlr/v4/test/runtime/templates/Java.test.stg) has templates like:
|
||||
|
||||
```
|
||||
writeln(s) ::= <<System.out.println(<s>);>>
|
||||
```
|
||||
|
||||
that translate generic operations to target-specific language statements or expressions.
|
||||
|
||||
## Adding an ANTLR tool unit test
|
||||
|
||||
Just go into the appropriate Java test class in dir `antlr4/tool-testsuite/test/org/antlr/v4/test/tool` and add your unit test.
|
||||
Just go into the appropriate Java test class in dir [antlr4/tool-testsuite/test/org/antlr/v4/test/tool](https://github.com/antlr/antlr4/tree/master/tool-testsuite/test/org/antlr/v4/test/tool) and add your unit test.
|
||||
|
||||
|
||||
|
|
|
@ -9,12 +9,12 @@ Creating a new target involves the following key elements:
|
|||
1. For the tool, create class *X*Target as a subclass of class `Target` in package `org.antlr.v4.codegen.target`. This class describes language specific details about escape characters and strings and so on. There is very little to do here typically.
|
||||
1. Create *X*.stg in directory tool/resources/org/antlr/v4/tool/templates/codegen/*X*/*X*.stg. This is a [StringTemplate](http://www.stringtemplate.org/) group file (`.stg`) that tells ANTLR how to express all of the parsing elements needed to generate code. You will see templates called `ParserFile`, `Parser`, `Lexer`, `CodeBlockForAlt`, `AltBlock`, etc... Each of these must be described how to build the indicated chunk of code. Your best bet is to find the closest existing target, copy that template file, and tweak to suit.
|
||||
1. Create a runtime library to support the parsers generated by ANTLR. Under directory runtime/*X*, you are in complete control of the directory structure as dictated by common usage of that target language. For example, Java has: `runtime/Java/lib` and `runtime/Java/src` directories. Under `src`, you will find a directory structure for package `org.antlr.v4.runtime` and below.
|
||||
1. Create a template file for runtime tests. All you have to do is provide a few simple templates that indicate how to print values and declare variables. Our runtime test mechanism in dir `runtime-testsuite` will automatically generate code in a new target and check the results. All it needs to know is how to generate a test rig (i.e., a `main` program), how to define various class fields, compare members and so on. You must create a *X* directory underneath `runtime-testsuite/resources/org/antlr/v4/test/runtime`. Again, your best bet is to copy the templates from the closest language to your target and tweak it to suit.
|
||||
1. Create a template file for runtime tests. All you have to do is provide a few templates that indicate how to print values and declare variables. Our runtime test mechanism in dir `runtime-testsuite` will automatically generate code using these templates for each target and check the test results. It needs to know how to define various class fields, compare members and so on. You must create a *X*.test.stg file underneath [runtime-testsuite/resources/org/antlr/v4/test/runtime](https://github.com/antlr/antlr4/tree/master/runtime-testsuite/resources/org/antlr/v4/test/runtime). Again, your best bet is to copy the templates from the closest language to your target and tweak it to suit.
|
||||
|
||||
## Getting started
|
||||
|
||||
1. Fork the `antlr/antlr4` repository at github to your own user so that you have repository `username/antlr4`.
|
||||
2. Clone `username/antlr4`, forked repository, to your local disk. Your remote `origin` will be the forked repository on GitHub. Add a remote `upstream` to the original `antlr/antlr4` repository (URL `https://github.com/antlr/antlr4.git`). Changes that you would like to contribute back to the project are done with [pull requests](https://help.github.com/articles/using-pull-requests/).
|
||||
2. Clone `username/antlr4`, the forked repository, to your local disk. Your remote `origin` will be the forked repository on GitHub. Add a remote `upstream` to the original `antlr/antlr4` repository (URL `https://github.com/antlr/antlr4.git`). Changes that you would like to contribute back to the project are done with [pull requests](https://help.github.com/articles/using-pull-requests/).
|
||||
3. Try to build it before doing anything
|
||||
```bash
|
||||
$ mvn compile
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 228 KiB |
Binary file not shown.
After Width: | Height: | Size: 139 KiB |
|
@ -1,6 +1,6 @@
|
|||
package org.antlr.v4.test.runtime;
|
||||
|
||||
public abstract class BaseDebugParserTestDescriptor extends BaseParserTestDescriptor {
|
||||
public abstract class BaseDiagnosticParserTestDescriptor extends BaseParserTestDescriptor {
|
||||
@Override
|
||||
public boolean showDiagnosticErrors() {
|
||||
return true;
|
|
@ -458,7 +458,7 @@ public class CompositeParsersDescriptors {
|
|||
*/
|
||||
public static class ImportLexerWithOnlyFragmentRules extends BaseCompositeParserTestDescriptor {
|
||||
public String input = "test test";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = null;
|
||||
public String startRule = "program";
|
||||
public String grammarName = "Test";
|
||||
|
@ -499,7 +499,7 @@ public class CompositeParsersDescriptors {
|
|||
|
||||
public static class ImportedGrammarWithEmptyOptions extends BaseCompositeParserTestDescriptor {
|
||||
public String input = "b";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = null;
|
||||
public String startRule = "s";
|
||||
public String grammarName = "M";
|
||||
|
@ -533,7 +533,7 @@ public class CompositeParsersDescriptors {
|
|||
|
||||
public static class ImportedRuleWithAction extends BaseCompositeParserTestDescriptor {
|
||||
public String input = "b";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = null;
|
||||
public String startRule = "s";
|
||||
public String grammarName = "M";
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package org.antlr.v4.test.runtime.descriptors;
|
||||
|
||||
import org.antlr.v4.test.runtime.BaseDebugParserTestDescriptor;
|
||||
import org.antlr.v4.test.runtime.BaseDiagnosticParserTestDescriptor;
|
||||
import org.antlr.v4.test.runtime.CommentHasStringValue;
|
||||
|
||||
public class FullContextParsingDescriptors {
|
||||
public static class AmbigYieldsCtxSensitiveDFA extends BaseDebugParserTestDescriptor {
|
||||
public static class AmbigYieldsCtxSensitiveDFA extends BaseDiagnosticParserTestDescriptor {
|
||||
public String input = "abc";
|
||||
/**
|
||||
Decision 0:
|
||||
|
@ -28,7 +28,7 @@ public class FullContextParsingDescriptors {
|
|||
public String grammar;
|
||||
}
|
||||
|
||||
public static class AmbiguityNoLoop extends BaseDebugParserTestDescriptor {
|
||||
public static class AmbiguityNoLoop extends BaseDiagnosticParserTestDescriptor {
|
||||
public String input = "a@";
|
||||
public String output = "alt 1\n";
|
||||
/**
|
||||
|
@ -61,7 +61,7 @@ public class FullContextParsingDescriptors {
|
|||
public String grammar;
|
||||
}
|
||||
|
||||
public static class CtxSensitiveDFATwoDiffInput extends BaseDebugParserTestDescriptor {
|
||||
public static class CtxSensitiveDFATwoDiffInput extends BaseDiagnosticParserTestDescriptor {
|
||||
public String input = "$ 34 abc @ 34 abc";
|
||||
/**
|
||||
Decision 2:
|
||||
|
@ -99,7 +99,7 @@ public class FullContextParsingDescriptors {
|
|||
|
||||
}
|
||||
|
||||
public static abstract class CtxSensitiveDFA extends BaseDebugParserTestDescriptor {
|
||||
public static abstract class CtxSensitiveDFA extends BaseDiagnosticParserTestDescriptor {
|
||||
public String startRule = "s";
|
||||
public String grammarName = "T";
|
||||
|
||||
|
@ -156,7 +156,7 @@ public class FullContextParsingDescriptors {
|
|||
public String errors;
|
||||
}
|
||||
|
||||
public static abstract class ExprAmbiguity extends BaseDebugParserTestDescriptor {
|
||||
public static abstract class ExprAmbiguity extends BaseDiagnosticParserTestDescriptor {
|
||||
public String startRule = "s";
|
||||
public String grammarName = "T";
|
||||
|
||||
|
@ -204,7 +204,7 @@ public class FullContextParsingDescriptors {
|
|||
public String errors;
|
||||
}
|
||||
|
||||
public static abstract class FullContextIF_THEN_ELSEParse extends BaseDebugParserTestDescriptor {
|
||||
public static abstract class FullContextIF_THEN_ELSEParse extends BaseDiagnosticParserTestDescriptor {
|
||||
public String errors = null;
|
||||
public String startRule = "s";
|
||||
public String grammarName = "T";
|
||||
|
@ -346,7 +346,7 @@ public class FullContextParsingDescriptors {
|
|||
* Tests predictions for the following case involving closures.
|
||||
* http://www.antlr.org/wiki/display/~admin/2011/12/29/Flaw+in+ANTLR+v3+LL(*)+analysis+algorithm
|
||||
*/
|
||||
public static class LoopsSimulateTailRecursion extends BaseDebugParserTestDescriptor {
|
||||
public static class LoopsSimulateTailRecursion extends BaseDiagnosticParserTestDescriptor {
|
||||
public String input = "a(i)<-x";
|
||||
public String output = "pass: a(i)<-x\n";
|
||||
/**
|
||||
|
@ -381,7 +381,7 @@ public class FullContextParsingDescriptors {
|
|||
|
||||
}
|
||||
|
||||
public static class SLLSeesEOFInLLGrammar extends BaseDebugParserTestDescriptor {
|
||||
public static class SLLSeesEOFInLLGrammar extends BaseDiagnosticParserTestDescriptor {
|
||||
public String input = "34 abc";
|
||||
/**
|
||||
Decision 0:
|
||||
|
|
|
@ -38,27 +38,27 @@ public class LeftRecursionDescriptors {
|
|||
|
||||
public static class AmbigLR_1 extends AmbigLR {
|
||||
public String input = "1\n";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
}
|
||||
|
||||
public static class AmbigLR_2 extends AmbigLR {
|
||||
public String input = "a = 5\n";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
}
|
||||
|
||||
public static class AmbigLR_3 extends AmbigLR {
|
||||
public String input = "b = 6\n";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
}
|
||||
|
||||
public static class AmbigLR_4 extends AmbigLR {
|
||||
public String input = "a+b*2\n";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
}
|
||||
|
||||
public static class AmbigLR_5 extends AmbigLR {
|
||||
public String input = "(1+2)*3\n";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
}
|
||||
|
||||
public static abstract class Declarations extends BaseParserTestDescriptor {
|
||||
|
@ -1067,7 +1067,7 @@ public class LeftRecursionDescriptors {
|
|||
*/
|
||||
public static abstract class WhitespaceInfluence extends BaseParserTestDescriptor {
|
||||
public String input = "Test(1,3)";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = null;
|
||||
public String startRule = "prog";
|
||||
public String grammarName = "Expr";
|
||||
|
@ -1129,11 +1129,11 @@ public class LeftRecursionDescriptors {
|
|||
|
||||
public static class WhitespaceInfluence_1 extends WhitespaceInfluence {
|
||||
public String input = "Test(1,3)";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
}
|
||||
|
||||
public static class WhitespaceInfluence_2 extends WhitespaceInfluence {
|
||||
public String input = "Test(1, 3)";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public class ParserErrorsDescriptors {
|
|||
}
|
||||
|
||||
public static abstract class DuplicatedLeftRecursiveCall extends BaseParserTestDescriptor {
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = null;
|
||||
public String startRule = "start";
|
||||
public String grammarName = "T";
|
||||
|
@ -105,7 +105,7 @@ public class ParserErrorsDescriptors {
|
|||
*/
|
||||
public static class InvalidATNStateRemoval extends BaseParserTestDescriptor {
|
||||
public String input = "x:x";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = null;
|
||||
public String startRule = "start";
|
||||
public String grammarName = "T";
|
||||
|
@ -128,7 +128,7 @@ public class ParserErrorsDescriptors {
|
|||
*/
|
||||
public static class InvalidEmptyInput extends BaseParserTestDescriptor {
|
||||
public String input = "";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = "line 1:0 missing ID at '<EOF>'\n";
|
||||
public String startRule = "start";
|
||||
public String grammarName = "T";
|
||||
|
@ -173,7 +173,7 @@ public class ParserErrorsDescriptors {
|
|||
|
||||
public static class LL2 extends BaseParserTestDescriptor {
|
||||
public String input = "ae";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = "line 1:1 no viable alternative at input 'ae'\n";
|
||||
public String startRule = "a";
|
||||
public String grammarName = "T";
|
||||
|
@ -192,7 +192,7 @@ public class ParserErrorsDescriptors {
|
|||
|
||||
public static class LL3 extends BaseParserTestDescriptor {
|
||||
public String input = "abe";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = "line 1:2 no viable alternative at input 'abe'\n";
|
||||
public String startRule = "a";
|
||||
public String grammarName = "T";
|
||||
|
@ -211,7 +211,7 @@ public class ParserErrorsDescriptors {
|
|||
|
||||
public static class LLStar extends BaseParserTestDescriptor {
|
||||
public String input = "aaae";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = "line 1:3 no viable alternative at input 'aaae'\n";
|
||||
public String startRule = "a";
|
||||
public String grammarName = "T";
|
||||
|
@ -230,7 +230,7 @@ public class ParserErrorsDescriptors {
|
|||
|
||||
public static class MultiTokenDeletionBeforeLoop extends BaseParserTestDescriptor {
|
||||
public String input = "aacabc";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = "line 1:1 extraneous input 'a' expecting {'b', 'c'}\n";
|
||||
public String startRule = "a";
|
||||
public String grammarName = "T";
|
||||
|
@ -246,7 +246,7 @@ public class ParserErrorsDescriptors {
|
|||
|
||||
public static class MultiTokenDeletionBeforeLoop2 extends BaseParserTestDescriptor {
|
||||
public String input = "aacabc";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = "line 1:1 extraneous input 'a' expecting {'b', 'z', 'c'}\n";
|
||||
public String startRule = "a";
|
||||
public String grammarName = "T";
|
||||
|
@ -262,7 +262,7 @@ public class ParserErrorsDescriptors {
|
|||
|
||||
public static class MultiTokenDeletionDuringLoop extends BaseParserTestDescriptor {
|
||||
public String input = "abaaababc";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
/**
|
||||
line 1:2 extraneous input 'a' expecting {'b', 'c'}
|
||||
line 1:6 extraneous input 'a' expecting {'b', 'c'}
|
||||
|
@ -284,7 +284,7 @@ public class ParserErrorsDescriptors {
|
|||
|
||||
public static class MultiTokenDeletionDuringLoop2 extends BaseParserTestDescriptor {
|
||||
public String input = "abaaababc";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
/**
|
||||
line 1:2 extraneous input 'a' expecting {'b', 'z', 'c'}
|
||||
line 1:6 extraneous input 'a' expecting {'b', 'z', 'c'}
|
||||
|
@ -306,7 +306,7 @@ public class ParserErrorsDescriptors {
|
|||
|
||||
public static class NoViableAltAvoidance extends BaseParserTestDescriptor {
|
||||
public String input = "a.";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = "line 1:1 mismatched input '.' expecting '!'\n";
|
||||
public String startRule = "s";
|
||||
public String grammarName = "T";
|
||||
|
@ -327,7 +327,7 @@ public class ParserErrorsDescriptors {
|
|||
|
||||
public static class SingleSetInsertion extends BaseParserTestDescriptor {
|
||||
public String input = "ad";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = "line 1:1 missing {'b', 'c'} at 'd'\n";
|
||||
public String startRule = "a";
|
||||
public String grammarName = "T";
|
||||
|
@ -360,7 +360,7 @@ public class ParserErrorsDescriptors {
|
|||
|
||||
public static class SingleTokenDeletion extends BaseParserTestDescriptor {
|
||||
public String input = "aab";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = "line 1:1 extraneous input 'a' expecting 'b'\n";
|
||||
public String startRule = "a";
|
||||
public String grammarName = "T";
|
||||
|
@ -376,7 +376,7 @@ public class ParserErrorsDescriptors {
|
|||
|
||||
public static class SingleTokenDeletionBeforeAlt extends BaseParserTestDescriptor {
|
||||
public String input = "ac";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = "line 1:0 extraneous input 'a' expecting {'b', 'c'}\n";
|
||||
public String startRule = "a";
|
||||
public String grammarName = "T";
|
||||
|
@ -395,7 +395,7 @@ public class ParserErrorsDescriptors {
|
|||
|
||||
public static class SingleTokenDeletionBeforeLoop extends BaseParserTestDescriptor {
|
||||
public String input = "aabc";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
/**
|
||||
line 1:1 extraneous input 'a' expecting {<EOF>, 'b'}
|
||||
line 1:3 token recognition error at: 'c'
|
||||
|
@ -417,7 +417,7 @@ public class ParserErrorsDescriptors {
|
|||
|
||||
public static class SingleTokenDeletionBeforeLoop2 extends BaseParserTestDescriptor {
|
||||
public String input = "aabc";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
/**
|
||||
line 1:1 extraneous input 'a' expecting {<EOF>, 'b', 'z'}
|
||||
line 1:3 token recognition error at: 'c'
|
||||
|
@ -439,7 +439,7 @@ public class ParserErrorsDescriptors {
|
|||
|
||||
public static class SingleTokenDeletionBeforePredict extends BaseParserTestDescriptor {
|
||||
public String input = "caaab";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = "line 1:0 extraneous input 'c' expecting 'a'\n";
|
||||
public String startRule = "a";
|
||||
public String grammarName = "T";
|
||||
|
@ -475,7 +475,7 @@ public class ParserErrorsDescriptors {
|
|||
|
||||
public static class SingleTokenDeletionDuringLoop extends BaseParserTestDescriptor {
|
||||
public String input = "ababbc";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = "line 1:2 extraneous input 'a' expecting {'b', 'c'}\n";
|
||||
public String startRule = "a";
|
||||
public String grammarName = "T";
|
||||
|
@ -491,7 +491,7 @@ public class ParserErrorsDescriptors {
|
|||
|
||||
public static class SingleTokenDeletionDuringLoop2 extends BaseParserTestDescriptor {
|
||||
public String input = "ababbc";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = "line 1:2 extraneous input 'a' expecting {'b', 'z', 'c'}\n";
|
||||
public String startRule = "a";
|
||||
public String grammarName = "T";
|
||||
|
@ -507,7 +507,7 @@ public class ParserErrorsDescriptors {
|
|||
|
||||
public static class SingleTokenDeletionExpectingSet extends BaseParserTestDescriptor {
|
||||
public String input = "aab";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = "line 1:1 extraneous input 'a' expecting {'b', 'c'}\n";
|
||||
public String startRule = "a";
|
||||
public String grammarName = "T";
|
||||
|
@ -523,7 +523,7 @@ public class ParserErrorsDescriptors {
|
|||
|
||||
public static class SingleTokenInsertion extends BaseParserTestDescriptor {
|
||||
public String input = "ac";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = "line 1:1 missing 'b' at 'c'\n";
|
||||
public String startRule = "a";
|
||||
public String grammarName = "T";
|
||||
|
@ -539,7 +539,7 @@ public class ParserErrorsDescriptors {
|
|||
|
||||
public static class TokenMismatch extends BaseParserTestDescriptor {
|
||||
public String input = "aa";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = "line 1:1 mismatched input 'a' expecting 'b'\n";
|
||||
public String startRule = "a";
|
||||
public String grammarName = "T";
|
||||
|
@ -555,7 +555,7 @@ public class ParserErrorsDescriptors {
|
|||
|
||||
public static class TokenMismatch2 extends BaseParserTestDescriptor {
|
||||
public String input = "( ~FORCE_ERROR~ ";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = "line 1:2 mismatched input '~FORCE_ERROR~' expecting {')', ID}\n";
|
||||
public String startRule = "stat";
|
||||
public String grammarName = "T";
|
||||
|
|
|
@ -241,7 +241,7 @@ public class ParserExecDescriptors {
|
|||
*/
|
||||
public static class EOFInClosure extends BaseParserTestDescriptor {
|
||||
public String input = "x";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = null;
|
||||
public String startRule = "prog";
|
||||
public String grammarName = "T";
|
||||
|
@ -445,7 +445,7 @@ public class ParserExecDescriptors {
|
|||
|
||||
public static class Labels extends BaseParserTestDescriptor {
|
||||
public String input = "abc 34;";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = null;
|
||||
public String startRule = "a";
|
||||
public String grammarName = "T";
|
||||
|
@ -470,7 +470,7 @@ public class ParserExecDescriptors {
|
|||
*/
|
||||
public static class ListLabelForClosureContext extends BaseParserTestDescriptor {
|
||||
public String input = "a";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = null;
|
||||
public String startRule = "expression";
|
||||
public String grammarName = "T";
|
||||
|
@ -509,7 +509,7 @@ public class ParserExecDescriptors {
|
|||
*/
|
||||
public static class ListLabelsOnSet extends BaseParserTestDescriptor {
|
||||
public String input = "abc 34;";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = null;
|
||||
public String startRule = "a";
|
||||
public String grammarName = "T";
|
||||
|
@ -535,7 +535,7 @@ public class ParserExecDescriptors {
|
|||
*/
|
||||
public static class MultipleEOFHandling extends BaseParserTestDescriptor {
|
||||
public String input = "x";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = null;
|
||||
public String startRule = "prog";
|
||||
public String grammarName = "T";
|
||||
|
@ -555,7 +555,7 @@ public class ParserExecDescriptors {
|
|||
*/
|
||||
public static class Optional_1 extends BaseParserTestDescriptor {
|
||||
public String input = "x";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = null;
|
||||
public String startRule = "stat";
|
||||
public String grammarName = "T";
|
||||
|
@ -573,7 +573,7 @@ public class ParserExecDescriptors {
|
|||
|
||||
public static class Optional_2 extends BaseParserTestDescriptor {
|
||||
public String input = "if x";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = null;
|
||||
public String startRule = "stat";
|
||||
public String grammarName = "T";
|
||||
|
@ -591,7 +591,7 @@ public class ParserExecDescriptors {
|
|||
|
||||
public static class Optional_3 extends BaseParserTestDescriptor {
|
||||
public String input = "if x else x";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = null;
|
||||
public String startRule = "stat";
|
||||
public String grammarName = "T";
|
||||
|
@ -609,7 +609,7 @@ public class ParserExecDescriptors {
|
|||
|
||||
public static class Optional_4 extends BaseParserTestDescriptor {
|
||||
public String input = "if if x else x";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = null;
|
||||
public String startRule = "stat";
|
||||
public String grammarName = "T";
|
||||
|
@ -656,7 +656,7 @@ public class ParserExecDescriptors {
|
|||
*/
|
||||
public static class PredicatedIfIfElse extends BaseParserTestDescriptor {
|
||||
public String input = "if x if x a else b";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = null;
|
||||
public String startRule = "s";
|
||||
public String grammarName = "T";
|
||||
|
|
|
@ -10,7 +10,7 @@ public class PerformanceDescriptors {
|
|||
* https://github.com/antlr/antlr4/issues/192
|
||||
*/
|
||||
public static abstract class ExpressionGrammar extends BaseParserTestDescriptor {
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = null;
|
||||
public String startRule = "program";
|
||||
public String grammarName = "Expr";
|
||||
|
|
|
@ -76,7 +76,7 @@ public class SemPredEvalParserDescriptors {
|
|||
*/
|
||||
public static class AtomWithClosureInTranslatedLRRule extends BaseParserTestDescriptor {
|
||||
public String input = "a+b+a";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = null;
|
||||
public String startRule = "start";
|
||||
public String grammarName = "T";
|
||||
|
@ -159,7 +159,7 @@ public class SemPredEvalParserDescriptors {
|
|||
*/
|
||||
public static class DisabledAlternative extends BaseParserTestDescriptor {
|
||||
public String input = "hello";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = null;
|
||||
public String startRule = "cppCompilationUnit";
|
||||
public String grammarName = "T";
|
||||
|
@ -202,7 +202,7 @@ public class SemPredEvalParserDescriptors {
|
|||
|
||||
public static class NoTruePredsThrowsNoViableAlt extends BaseParserTestDescriptor {
|
||||
public String input = "y 3 x 4";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = "line 1:0 no viable alternative at input 'y'\n";
|
||||
public String startRule = "s";
|
||||
public String grammarName = "T";
|
||||
|
@ -317,7 +317,7 @@ public class SemPredEvalParserDescriptors {
|
|||
|
||||
public static class PredTestedEvenWhenUnAmbig_2 extends PredTestedEvenWhenUnAmbig {
|
||||
public String input = "enum";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = "line 1:0 no viable alternative at input 'enum'\n";
|
||||
}
|
||||
|
||||
|
@ -369,7 +369,7 @@ public class SemPredEvalParserDescriptors {
|
|||
*/
|
||||
public static class PredicateDependentOnArg2 extends BaseParserTestDescriptor {
|
||||
public String input = "a b";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = null;
|
||||
public String startRule = "s";
|
||||
public String grammarName = "T";
|
||||
|
@ -484,7 +484,7 @@ public class SemPredEvalParserDescriptors {
|
|||
|
||||
public static class SimpleValidate extends BaseParserTestDescriptor {
|
||||
public String input = "x";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
public String errors = "line 1:0 no viable alternative at input 'x'\n";
|
||||
public String startRule = "s";
|
||||
public String grammarName = "T";
|
||||
|
@ -709,7 +709,7 @@ public class SemPredEvalParserDescriptors {
|
|||
|
||||
public static class ValidateInDFA extends BaseParserTestDescriptor {
|
||||
public String input = "x ; y";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
/**
|
||||
line 1:0 no viable alternative at input 'x'
|
||||
line 1:4 no viable alternative at input 'y'
|
||||
|
|
|
@ -32,7 +32,7 @@ public class SetsDescriptors {
|
|||
|
||||
public static class ComplementSet extends BaseParserTestDescriptor {
|
||||
public String input = "a";
|
||||
public String output = "";
|
||||
public String output = null;
|
||||
/**
|
||||
line 1:0 token recognition error at: 'a'
|
||||
line 1:1 missing {} at '<EOF>'
|
||||
|
|
Loading…
Reference in New Issue