forked from jasder/antlr
Merge branch 'master_upstream'
This commit is contained in:
commit
74d094bee7
|
@ -23,7 +23,7 @@ ANTLR project lead and supreme dictator for life
|
|||
* [Official site](http://www.antlr.org/)
|
||||
* [Documentation](https://github.com/antlr/antlr4/blob/master/doc/index.md)
|
||||
* [FAQ](https://github.com/antlr/antlr4/blob/master/doc/faq/index.md)
|
||||
* [ANTLR code generation targets](https://github.com/antlr/antlr4/blob/master/doc/targets.md) (Currently: Java, C#, Python2|3, JavaScript, Go)
|
||||
* [ANTLR code generation targets](https://github.com/antlr/antlr4/blob/master/doc/targets.md)<br>(Currently: Java, C#, Python2|3, JavaScript, Go, C++)
|
||||
* [Java API](http://www.antlr.org/api/Java/index.html)
|
||||
* [ANTLR v3](http://www.antlr3.org/)
|
||||
* [v3 to v4 Migration, differences](https://github.com/antlr/antlr4/blob/master/doc/faq/general.md)
|
||||
|
|
111
doc/go-target.md
111
doc/go-target.md
|
@ -1,14 +1,115 @@
|
|||
# ANTLR4 Language Target, Runtime for Go
|
||||
|
||||
### Getting started
|
||||
### First steps
|
||||
|
||||
1. Get the runtime and install it on your GOPATH: `go get github.com/antlr/antlr4`
|
||||
2. Generate the parser/lexer code: `antlr MyGrammar.g4 -Dlanguage=Go`
|
||||
#### 1. Install ANTLR4
|
||||
|
||||
### Referencing in your code
|
||||
[The getting started guide](getting-started.md) should get you started.
|
||||
|
||||
Reference the go runtime package like this:
|
||||
#### 2. Get the Go ANTLR runtime
|
||||
|
||||
Each target language for ANTLR has a runtime package for running parser generated by ANTLR4. The runtime provides a common set of tools for using your parser.
|
||||
|
||||
Get the runtime and install it on your GOPATH:
|
||||
|
||||
```bash
|
||||
go get github.com/antlr/antlr4
|
||||
```
|
||||
|
||||
#### 3. Set the release tag (optional)
|
||||
|
||||
`go get` has no native way to specify a branch or commit. So, when you run it, you'll download the latest commits. This may or may not be your preference.
|
||||
|
||||
You'll need to use git to set the release. For example, to set the release tag for release 4.6.0:
|
||||
|
||||
```bash
|
||||
cd $GOPATH/src/github.com/antlr/antlr4 # enter the antlr4 source directory
|
||||
git checkout tags/4.6.0 # the go runtime was added in release 4.6.0
|
||||
```
|
||||
|
||||
A complete list of releases can be found on [the release page](https://github.com/antlr/antlr4/releases).
|
||||
|
||||
#### 4. Generate your parser
|
||||
|
||||
You use the ANTLR4 "tool" to generate a parser. These will reference the ANTLR runtime, installed above.
|
||||
|
||||
Suppose you're using a UNIX system and have set up an alias for the ANTLR4 tool as described in [the getting started guide](getting-started.md). To generate your go parser, you'll need to invoke:
|
||||
|
||||
```bash
|
||||
antlr4 -Dlanguage=Go MyGrammar.g4
|
||||
```
|
||||
|
||||
For a full list of antlr4 tool options, please visit the [tool documentation page](tool-options.md).
|
||||
|
||||
### Referencing the Go ANTLR runtime
|
||||
|
||||
You can reference the go ANTLR runtime package like this:
|
||||
|
||||
```go
|
||||
import "github.com/antlr/antlr4/runtime/Go/antlr"
|
||||
```
|
||||
|
||||
### Complete example
|
||||
|
||||
Suppose you're using the JSON grammar from https://github.com/antlr/grammars-v4/tree/master/json.
|
||||
|
||||
Then, invoke `antlr4 -Dlanguage=Go JSON.g4`. The result of this is a collection of .go files in the `parser` directory including:
|
||||
```
|
||||
json_parser.go
|
||||
json_base_listener.go
|
||||
json_lexer.go
|
||||
json_listener.go
|
||||
```
|
||||
|
||||
Another common option to the ANTLR tool is `-visitor`, which generates a parse tree visitor, but we won't be doing that here. For a full list of antlr4 tool options, please visit the [tool documentation page](tool-options.md).
|
||||
|
||||
We'll write a small main func to call the generated parser/lexer (assuming they are separate). This one writes out the encountered `ParseTreeContext`'s. Suppose the gen'ed parser code is in the `parser` directory relative to this code:
|
||||
|
||||
```
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/antlr/antlr4/runtime/Go/antlr"
|
||||
"./parser"
|
||||
"os"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type TreeShapeListener struct {
|
||||
*parser.BaseJSONListener
|
||||
}
|
||||
|
||||
func NewTreeShapeListener() *TreeShapeListener {
|
||||
return new(TreeShapeListener)
|
||||
}
|
||||
|
||||
func (this *TreeShapeListener) EnterEveryRule(ctx antlr.ParserRuleContext) {
|
||||
fmt.Println(ctx.GetText())
|
||||
}
|
||||
|
||||
func main() {
|
||||
input := antlr.NewFileStream(os.Args[1])
|
||||
lexer := parser.NewJSONLexer(input)
|
||||
stream := antlr.NewCommonTokenStream(lexer,0)
|
||||
p := parser.NewJSONParser(stream)
|
||||
p.AddErrorListener(antlr.NewDiagnosticErrorListener(true))
|
||||
p.BuildParseTrees = true
|
||||
tree := p.Json()
|
||||
antlr.ParseTreeWalkerDefault.Walk(NewTreeShapeListener(), tree)
|
||||
}
|
||||
```
|
||||
|
||||
This one expects the input to be passed on the command line:
|
||||
|
||||
```
|
||||
go run test.go input
|
||||
```
|
||||
|
||||
The output is:
|
||||
|
||||
```
|
||||
{"a":1}
|
||||
{"a":1}
|
||||
"a":1
|
||||
1
|
||||
```
|
||||
|
|
|
@ -7,8 +7,8 @@ This page lists the available and upcoming ANTLR runtimes. Please note that you
|
|||
* [Python](python-target.md) (2 and 3)
|
||||
* [JavaScript](javascript-target.md)
|
||||
* [Go](go-target.md)
|
||||
* [C++](cpp-target.md)
|
||||
* Swift (not yet available)
|
||||
* C++ (not yet available)
|
||||
|
||||
## Target feature parity
|
||||
|
||||
|
|
|
@ -354,6 +354,7 @@ func (m *MyRuleNode) SetAltNumber(altNum int) {
|
|||
>>
|
||||
|
||||
BasicListener(notused) ::= <<
|
||||
@parser::members {
|
||||
type LeafListener struct {
|
||||
*BaseTListener
|
||||
}
|
||||
|
@ -365,6 +366,7 @@ func NewLeafListener() *LeafListener {
|
|||
func (*LeafListener) VisitTerminal(node antlr.TerminalNode) {
|
||||
fmt.Println(node.GetSymbol().GetText())
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
WalkListener(s) ::= <<
|
||||
|
@ -374,6 +376,7 @@ walker.Walk(NewLeafListener(), <s>)
|
|||
>>
|
||||
|
||||
TokenGetterListener(notused) ::= <<
|
||||
@parser::members {
|
||||
type LeafListener struct {
|
||||
*BaseTListener
|
||||
}
|
||||
|
@ -389,9 +392,11 @@ func (*LeafListener) ExitA(ctx *AContext) {
|
|||
fmt.Println(ctx.ID().GetSymbol())
|
||||
}
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
RuleGetterListener(notused) ::= <<
|
||||
@parser::members {
|
||||
type LeafListener struct {
|
||||
*BaseTListener
|
||||
}
|
||||
|
@ -407,9 +412,11 @@ func (*LeafListener) ExitA(ctx *AContext) {
|
|||
fmt.Println(ctx.B(0).GetStart().GetText())
|
||||
}
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
LRListener(notused) ::= <<
|
||||
@parser::members {
|
||||
type LeafListener struct {
|
||||
*BaseTListener
|
||||
}
|
||||
|
@ -425,9 +432,11 @@ func (*LeafListener) ExitE(ctx *EContext) {
|
|||
fmt.Println(ctx.INT().GetSymbol().GetText())
|
||||
}
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
LRWithLabelsListener(notused) ::= <<
|
||||
@parser::members {
|
||||
type LeafListener struct {
|
||||
*BaseTListener
|
||||
}
|
||||
|
@ -443,6 +452,7 @@ func (*LeafListener) ExitCall(ctx *CallContext) {
|
|||
func (*LeafListener) ExitInt(ctx *IntContext) {
|
||||
fmt.Println(ctx.INT().GetSymbol().GetText())
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
ImportVisitor(X) ::= ""
|
||||
|
@ -482,7 +492,7 @@ Invoke_pred(v) ::= <<pred(<v>)>>
|
|||
|
||||
ContextRuleFunction(ctx, rule) ::= "<ctx>.<rule>"
|
||||
StringType() ::= "String"
|
||||
ContextMember(ctx, subctx, member) ::= "<ctx>.<subctx>.<member>"
|
||||
ContextMember(ctx, subctx, member) ::= "<ctx>.<subctx>.<member; format={cap}>"
|
||||
|
||||
isEmpty ::= [
|
||||
"": true,
|
||||
|
|
|
@ -21,8 +21,8 @@ grammar(grammarName) ::= <<
|
|||
grammar <grammarName>;
|
||||
s : e {<writeln("$e.v")>};
|
||||
e returns [int v]
|
||||
: e '*' e {$v = <Cast("BinaryContext","$ctx"):ContextMember("e(0)", "v")> * <Cast("BinaryContext","$ctx"):ContextMember({<Production("e")>(1)}, {<Result("v")>})>;} # binary
|
||||
| e '+' e {$v = <Cast("BinaryContext","$ctx"):ContextMember("e(0)", "v")> + <Cast("BinaryContext","$ctx"):ContextMember({<Production("e")>(1)}, {<Result("v")>})>;} # binary
|
||||
: e '*' e {$v = <Cast("BinaryContext","$ctx"):ContextMember({<Production("e")>(0)}, {<Result("v")>})> * <Cast("BinaryContext","$ctx"):ContextMember({<Production("e")>(1)}, {<Result("v")>})>;} # binary
|
||||
| e '+' e {$v = <Cast("BinaryContext","$ctx"):ContextMember({<Production("e")>(0)}, {<Result("v")>})> + <Cast("BinaryContext","$ctx"):ContextMember({<Production("e")>(1)}, {<Result("v")>})>;} # binary
|
||||
| INT {$v = $INT.int;} # anInt
|
||||
| '(' e ')' {$v = $e.v;} # parens
|
||||
| left=e INC {<Cast("UnaryContext","$ctx"):Concat(".INC() != null"):Assert()>$v = $left.v + 1;} # unary
|
||||
|
|
|
@ -33,7 +33,8 @@ grammar(grammarName) ::= <<
|
|||
grammar <grammarName>;
|
||||
@parser::members {<InitIntMember("i","0")>}
|
||||
s : ({<AddMember("i","1")>
|
||||
<writeList(["\"i=\"", "i"])>} a)+ ;
|
||||
<write("\"i=\"")>
|
||||
<writeln(GetMember("i"))>} a)+ ;
|
||||
a : {<ModMemberEquals("i","2","0")>}? ID {<writeln("\"alt 1\"")>}
|
||||
| {<ModMemberNotEquals("i","2","0")>}? ID {<writeln("\"alt 2\"")>}
|
||||
;
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* 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 static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestCompositeLexers extends BaseCppTest {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/* 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;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestCompositeParsers extends BaseCppTest {
|
||||
|
@ -75,18 +75,18 @@ public class TestCompositeParsers extends BaseCppTest {
|
|||
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);
|
||||
|
||||
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);
|
||||
|
||||
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");
|
||||
|
@ -246,17 +246,17 @@ public class TestCompositeParsers extends BaseCppTest {
|
|||
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);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"a : B {std::cout << \"T.a\" << std::endl;};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(106);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S,T;\n");
|
||||
|
@ -306,18 +306,18 @@ public class TestCompositeParsers extends BaseCppTest {
|
|||
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);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { A }\n" +
|
||||
"b : 'b' {std::cout << \"T.b\" << std::endl;};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(101);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S, T;\n");
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* 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 static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestFullContextParsing extends BaseCppTest {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* 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 static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestLeftRecursion extends BaseCppTest {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* 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 static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestLexerErrors extends BaseCppTest {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* 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 static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestLexerExec extends BaseCppTest {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* 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 static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestListeners extends BaseCppTest {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* 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 static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestParseTrees extends BaseCppTest {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* 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 static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestParserErrors extends BaseCppTest {
|
||||
|
@ -711,7 +712,7 @@ public class TestParserErrors extends BaseCppTest {
|
|||
|
||||
assertEquals("", found);
|
||||
|
||||
assertEquals("line 1:2 mismatched input '~FORCE_ERROR~' expecting ')'\n", this.stderrDuringParse);
|
||||
assertEquals("line 1:2 mismatched input '~FORCE_ERROR~' expecting {')', ID}\n", this.stderrDuringParse);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* 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 static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestParserExec extends BaseCppTest {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* 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 static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestPerformance extends BaseCppTest {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* 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 static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestSemPredEvalLexer extends BaseCppTest {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* 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 static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestSemPredEvalParser extends BaseCppTest {
|
||||
|
@ -669,11 +670,12 @@ public class TestSemPredEvalParser extends BaseCppTest {
|
|||
public void testToLeftWithVaryingPredicate() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(279);
|
||||
StringBuilder grammarBuilder = new StringBuilder(289);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::members {int i = 0;}\n");
|
||||
grammarBuilder.append("s : ({i += 1;\n");
|
||||
grammarBuilder.append(" std::cout << \"i=\" << i << std::endl;} a)+ ;\n");
|
||||
grammarBuilder.append("std::cout << \"i=\";\n");
|
||||
grammarBuilder.append("std::cout << 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");
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* 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 static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestSets extends BaseCppTest {
|
||||
|
|
|
@ -3,7 +3,9 @@ package org.antlr.v4.test.runtime.cpp;
|
|||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestVisitors extends BaseCppTest {
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
package org.antlr.v4.test.runtime.csharp;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestCompositeLexers extends BaseTest {
|
||||
|
|
|
@ -2,10 +2,6 @@
|
|||
package org.antlr.v4.test.runtime.csharp;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import org.antlr.v4.test.runtime.java.ErrorQueue;
|
||||
import org.antlr.v4.tool.Grammar;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestCompositeParsers extends BaseTest {
|
||||
|
@ -58,18 +54,18 @@ public class TestCompositeParsers extends BaseTest {
|
|||
@Test
|
||||
public void testDelegatesSeeSameTokenType() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { C, B, A } // reverse order\n" +
|
||||
"y : A {Console.WriteLine(\"T.y\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"tokens { A, B, C }\n" +
|
||||
"x : A {Console.WriteLine(\"S.x\");};";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { C, B, A } // reverse order\n" +
|
||||
"y : A {Console.WriteLine(\"T.y\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
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");
|
||||
|
@ -191,17 +187,17 @@ public class TestCompositeParsers extends BaseTest {
|
|||
@Test
|
||||
public void testDelegatorInvokesFirstVersionOfDelegateRule() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"a : B {Console.WriteLine(\"T.a\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : b {Console.WriteLine(\"S.a\");};\n" +
|
||||
"b : B;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"a : B {Console.WriteLine(\"T.a\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(106);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S,T;\n");
|
||||
|
@ -241,18 +237,18 @@ public class TestCompositeParsers extends BaseTest {
|
|||
@Test
|
||||
public void testDelegatorRuleOverridesDelegates() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { A }\n" +
|
||||
"b : 'b' {Console.WriteLine(\"T.b\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : b {Console.WriteLine(\"S.a\");};\n" +
|
||||
"b : 'b' ;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { A }\n" +
|
||||
"b : 'b' {Console.WriteLine(\"T.b\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(94);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S, T;\n");
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
package org.antlr.v4.test.runtime.csharp;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestFullContextParsing extends BaseTest {
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
package org.antlr.v4.test.runtime.csharp;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestLeftRecursion extends BaseTest {
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
package org.antlr.v4.test.runtime.csharp;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestLexerErrors extends BaseTest {
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
package org.antlr.v4.test.runtime.csharp;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestLexerExec extends BaseTest {
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
package org.antlr.v4.test.runtime.csharp;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestListeners extends BaseTest {
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
package org.antlr.v4.test.runtime.csharp;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestParseTrees extends BaseTest {
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
package org.antlr.v4.test.runtime.csharp;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestParserExec extends BaseTest {
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
package org.antlr.v4.test.runtime.csharp;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestPerformance extends BaseTest {
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
package org.antlr.v4.test.runtime.csharp;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestSemPredEvalLexer extends BaseTest {
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
package org.antlr.v4.test.runtime.csharp;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestSemPredEvalParser extends BaseTest {
|
||||
|
@ -552,11 +551,12 @@ public class TestSemPredEvalParser extends BaseTest {
|
|||
@Test
|
||||
public void testToLeftWithVaryingPredicate() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(269);
|
||||
StringBuilder grammarBuilder = new StringBuilder(290);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::members {int i = 0;}\n");
|
||||
grammarBuilder.append("s : ({this.i += 1;\n");
|
||||
grammarBuilder.append("Console.WriteLine(\"i=\"+i);} a)+ ;\n");
|
||||
grammarBuilder.append("Console.Write(\"i=\");\n");
|
||||
grammarBuilder.append("Console.WriteLine(this.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");
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
package org.antlr.v4.test.runtime.csharp;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestSets extends BaseTest {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.csharp;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestVisitors extends BaseTest {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.go;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestCompositeLexers extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.go;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.antlr.v4.tool.Grammar;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestCompositeParsers extends BaseTest {
|
||||
|
||||
|
@ -60,18 +58,18 @@ public class TestCompositeParsers extends BaseTest {
|
|||
@Test
|
||||
public void testDelegatesSeeSameTokenType() throws Exception {
|
||||
mkdir(parserpkgdir);
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { C, B, A } // reverse order\n" +
|
||||
"y : A {fmt.Println(\"T.y\")};";
|
||||
writeFile(parserpkgdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"tokens { A, B, C }\n" +
|
||||
"x : A {fmt.Println(\"S.x\")};";
|
||||
writeFile(parserpkgdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { C, B, A } // reverse order\n" +
|
||||
"y : A {fmt.Println(\"T.y\")};";
|
||||
writeFile(parserpkgdir, "T.g4", slave_T);
|
||||
|
||||
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");
|
||||
|
@ -200,17 +198,17 @@ public class TestCompositeParsers extends BaseTest {
|
|||
@Test
|
||||
public void testDelegatorInvokesFirstVersionOfDelegateRule() throws Exception {
|
||||
mkdir(parserpkgdir);
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"a : B {fmt.Println(\"T.a\")};";
|
||||
writeFile(parserpkgdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : b {fmt.Println(\"S.a\")};\n" +
|
||||
"b : B;";
|
||||
writeFile(parserpkgdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"a : B {fmt.Println(\"T.a\")};";
|
||||
writeFile(parserpkgdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(106);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S,T;\n");
|
||||
|
@ -252,18 +250,18 @@ public class TestCompositeParsers extends BaseTest {
|
|||
@Test
|
||||
public void testDelegatorRuleOverridesDelegates() throws Exception {
|
||||
mkdir(parserpkgdir);
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { A }\n" +
|
||||
"b : 'b' {fmt.Println(\"T.b\")};";
|
||||
writeFile(parserpkgdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : b {fmt.Println(\"S.a\")};\n" +
|
||||
"b : 'b' ;";
|
||||
writeFile(parserpkgdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { A }\n" +
|
||||
"b : 'b' {fmt.Println(\"T.b\")};";
|
||||
writeFile(parserpkgdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(87);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S, T;\n");
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.go;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestFullContextParsing extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.go;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestLeftRecursion extends BaseTest {
|
||||
|
||||
|
@ -1723,12 +1723,12 @@ public class TestLeftRecursion extends BaseTest {
|
|||
@Test
|
||||
public void testMultipleAlternativesWithCommonLabel_1() throws Exception {
|
||||
mkdir(parserpkgdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(585);
|
||||
StringBuilder grammarBuilder = new StringBuilder(595);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {fmt.Println($e.v)};\n");
|
||||
grammarBuilder.append("e returns [int v]\n");
|
||||
grammarBuilder.append(" : e '*' e {$v = ($ctx).e(0).v * ($ctx).E(1).GetV();} # binary\n");
|
||||
grammarBuilder.append(" | e '+' e {$v = ($ctx).e(0).v + ($ctx).E(1).GetV();} # binary\n");
|
||||
grammarBuilder.append(" : e '*' e {$v = ($ctx).E(0).GetV() * ($ctx).E(1).GetV();} # binary\n");
|
||||
grammarBuilder.append(" | e '+' e {$v = ($ctx).E(0).GetV() + ($ctx).E(1).GetV();} # binary\n");
|
||||
grammarBuilder.append(" | INT {$v = $INT.int;} # anInt\n");
|
||||
grammarBuilder.append(" | '(' e ')' {$v = $e.v;} # parens\n");
|
||||
grammarBuilder.append(" | left=e INC {$v = $left.v + 1;} # unary\n");
|
||||
|
@ -1752,12 +1752,12 @@ public class TestLeftRecursion extends BaseTest {
|
|||
@Test
|
||||
public void testMultipleAlternativesWithCommonLabel_2() throws Exception {
|
||||
mkdir(parserpkgdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(585);
|
||||
StringBuilder grammarBuilder = new StringBuilder(595);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {fmt.Println($e.v)};\n");
|
||||
grammarBuilder.append("e returns [int v]\n");
|
||||
grammarBuilder.append(" : e '*' e {$v = ($ctx).e(0).v * ($ctx).E(1).GetV();} # binary\n");
|
||||
grammarBuilder.append(" | e '+' e {$v = ($ctx).e(0).v + ($ctx).E(1).GetV();} # binary\n");
|
||||
grammarBuilder.append(" : e '*' e {$v = ($ctx).E(0).GetV() * ($ctx).E(1).GetV();} # binary\n");
|
||||
grammarBuilder.append(" | e '+' e {$v = ($ctx).E(0).GetV() + ($ctx).E(1).GetV();} # binary\n");
|
||||
grammarBuilder.append(" | INT {$v = $INT.int;} # anInt\n");
|
||||
grammarBuilder.append(" | '(' e ')' {$v = $e.v;} # parens\n");
|
||||
grammarBuilder.append(" | left=e INC {$v = $left.v + 1;} # unary\n");
|
||||
|
@ -1781,12 +1781,12 @@ public class TestLeftRecursion extends BaseTest {
|
|||
@Test
|
||||
public void testMultipleAlternativesWithCommonLabel_3() throws Exception {
|
||||
mkdir(parserpkgdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(585);
|
||||
StringBuilder grammarBuilder = new StringBuilder(595);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {fmt.Println($e.v)};\n");
|
||||
grammarBuilder.append("e returns [int v]\n");
|
||||
grammarBuilder.append(" : e '*' e {$v = ($ctx).e(0).v * ($ctx).E(1).GetV();} # binary\n");
|
||||
grammarBuilder.append(" | e '+' e {$v = ($ctx).e(0).v + ($ctx).E(1).GetV();} # binary\n");
|
||||
grammarBuilder.append(" : e '*' e {$v = ($ctx).E(0).GetV() * ($ctx).E(1).GetV();} # binary\n");
|
||||
grammarBuilder.append(" | e '+' e {$v = ($ctx).E(0).GetV() + ($ctx).E(1).GetV();} # binary\n");
|
||||
grammarBuilder.append(" | INT {$v = $INT.int;} # anInt\n");
|
||||
grammarBuilder.append(" | '(' e ')' {$v = $e.v;} # parens\n");
|
||||
grammarBuilder.append(" | left=e INC {$v = $left.v + 1;} # unary\n");
|
||||
|
@ -1810,12 +1810,12 @@ public class TestLeftRecursion extends BaseTest {
|
|||
@Test
|
||||
public void testMultipleAlternativesWithCommonLabel_4() throws Exception {
|
||||
mkdir(parserpkgdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(585);
|
||||
StringBuilder grammarBuilder = new StringBuilder(595);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {fmt.Println($e.v)};\n");
|
||||
grammarBuilder.append("e returns [int v]\n");
|
||||
grammarBuilder.append(" : e '*' e {$v = ($ctx).e(0).v * ($ctx).E(1).GetV();} # binary\n");
|
||||
grammarBuilder.append(" | e '+' e {$v = ($ctx).e(0).v + ($ctx).E(1).GetV();} # binary\n");
|
||||
grammarBuilder.append(" : e '*' e {$v = ($ctx).E(0).GetV() * ($ctx).E(1).GetV();} # binary\n");
|
||||
grammarBuilder.append(" | e '+' e {$v = ($ctx).E(0).GetV() + ($ctx).E(1).GetV();} # binary\n");
|
||||
grammarBuilder.append(" | INT {$v = $INT.int;} # anInt\n");
|
||||
grammarBuilder.append(" | '(' e ')' {$v = $e.v;} # parens\n");
|
||||
grammarBuilder.append(" | left=e INC {$v = $left.v + 1;} # unary\n");
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.go;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestLexerErrors extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.go;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestLexerExec extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.go;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestListeners extends BaseTest {
|
||||
|
||||
|
@ -12,9 +12,10 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testBasic() throws Exception {
|
||||
mkdir(parserpkgdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(505);
|
||||
StringBuilder grammarBuilder = new StringBuilder(526);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("type LeafListener struct {\n");
|
||||
grammarBuilder.append(" *BaseTListener\n");
|
||||
grammarBuilder.append("}\n");
|
||||
|
@ -26,6 +27,7 @@ public class TestListeners extends BaseTest {
|
|||
grammarBuilder.append("func (*LeafListener) VisitTerminal(node antlr.TerminalNode) {\n");
|
||||
grammarBuilder.append(" fmt.Println(node.GetSymbol().GetText())\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
|
@ -58,9 +60,10 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testLR() throws Exception {
|
||||
mkdir(parserpkgdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(677);
|
||||
StringBuilder grammarBuilder = new StringBuilder(698);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("type LeafListener struct {\n");
|
||||
grammarBuilder.append(" *BaseTListener\n");
|
||||
grammarBuilder.append("}\n");
|
||||
|
@ -76,6 +79,7 @@ public class TestListeners extends BaseTest {
|
|||
grammarBuilder.append(" fmt.Println(ctx.INT().GetSymbol().GetText())\n");
|
||||
grammarBuilder.append(" }\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
|
@ -112,9 +116,10 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testLRWithLabels() throws Exception {
|
||||
mkdir(parserpkgdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(685);
|
||||
StringBuilder grammarBuilder = new StringBuilder(706);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("type LeafListener struct {\n");
|
||||
grammarBuilder.append(" *BaseTListener\n");
|
||||
grammarBuilder.append("}\n");
|
||||
|
@ -130,6 +135,7 @@ public class TestListeners extends BaseTest {
|
|||
grammarBuilder.append("func (*LeafListener) ExitInt(ctx *IntContext) {\n");
|
||||
grammarBuilder.append(" fmt.Println(ctx.INT().GetSymbol().GetText())\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
|
@ -165,9 +171,10 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testRuleGetters_1() throws Exception {
|
||||
mkdir(parserpkgdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(700);
|
||||
StringBuilder grammarBuilder = new StringBuilder(721);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("type LeafListener struct {\n");
|
||||
grammarBuilder.append(" *BaseTListener\n");
|
||||
grammarBuilder.append("}\n");
|
||||
|
@ -183,6 +190,7 @@ public class TestListeners extends BaseTest {
|
|||
grammarBuilder.append(" fmt.Println(ctx.B(0).GetStart().GetText())\n");
|
||||
grammarBuilder.append(" }\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
|
@ -215,9 +223,10 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testRuleGetters_2() throws Exception {
|
||||
mkdir(parserpkgdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(700);
|
||||
StringBuilder grammarBuilder = new StringBuilder(721);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("type LeafListener struct {\n");
|
||||
grammarBuilder.append(" *BaseTListener\n");
|
||||
grammarBuilder.append("}\n");
|
||||
|
@ -233,6 +242,7 @@ public class TestListeners extends BaseTest {
|
|||
grammarBuilder.append(" fmt.Println(ctx.B(0).GetStart().GetText())\n");
|
||||
grammarBuilder.append(" }\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
|
@ -265,9 +275,10 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testTokenGetters_1() throws Exception {
|
||||
mkdir(parserpkgdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(693);
|
||||
StringBuilder grammarBuilder = new StringBuilder(714);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("type LeafListener struct {\n");
|
||||
grammarBuilder.append(" *BaseTListener\n");
|
||||
grammarBuilder.append("}\n");
|
||||
|
@ -283,6 +294,7 @@ public class TestListeners extends BaseTest {
|
|||
grammarBuilder.append(" fmt.Println(ctx.ID().GetSymbol())\n");
|
||||
grammarBuilder.append(" }\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
|
@ -314,9 +326,10 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testTokenGetters_2() throws Exception {
|
||||
mkdir(parserpkgdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(693);
|
||||
StringBuilder grammarBuilder = new StringBuilder(714);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("type LeafListener struct {\n");
|
||||
grammarBuilder.append(" *BaseTListener\n");
|
||||
grammarBuilder.append("}\n");
|
||||
|
@ -332,6 +345,7 @@ public class TestListeners extends BaseTest {
|
|||
grammarBuilder.append(" fmt.Println(ctx.ID().GetSymbol())\n");
|
||||
grammarBuilder.append(" }\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.go;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestParseTrees extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.go;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestParserExec extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.go;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestPerformance extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.go;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestSemPredEvalLexer extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.go;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestSemPredEvalParser extends BaseTest {
|
||||
|
||||
|
@ -579,11 +579,12 @@ public class TestSemPredEvalParser extends BaseTest {
|
|||
@Test
|
||||
public void testToLeftWithVaryingPredicate() throws Exception {
|
||||
mkdir(parserpkgdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(252);
|
||||
StringBuilder grammarBuilder = new StringBuilder(264);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::members {var i int = 0; var _ int = i; }\n");
|
||||
grammarBuilder.append("s : ({i += 1;\n");
|
||||
grammarBuilder.append("fmt.Print(\"i=\"+i);} a)+ ;\n");
|
||||
grammarBuilder.append("fmt.Print(\"i=\")\n");
|
||||
grammarBuilder.append("fmt.Println(i)} a)+ ;\n");
|
||||
grammarBuilder.append("a : {i % 2 == 0}? ID {fmt.Println(\"alt 1\")}\n");
|
||||
grammarBuilder.append(" | {i % 2 != 0}? ID {fmt.Println(\"alt 2\")}\n");
|
||||
grammarBuilder.append(" ;\n");
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.go;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestSets extends BaseTest {
|
||||
|
||||
|
|
|
@ -4,7 +4,8 @@ package org.antlr.v4.test.runtime.go;
|
|||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestVisitors extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.java;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestCompositeLexers extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.java;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.antlr.v4.tool.Grammar;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.antlr.v4.tool.Grammar;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestCompositeParsers extends BaseTest {
|
||||
|
||||
|
@ -72,18 +71,18 @@ public class TestCompositeParsers extends BaseTest {
|
|||
public void testDelegatesSeeSameTokenType() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { C, B, A } // reverse order\n" +
|
||||
"y : A {System.out.println(\"T.y\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"tokens { A, B, C }\n" +
|
||||
"x : A {System.out.println(\"S.x\");};";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { C, B, A } // reverse order\n" +
|
||||
"y : A {System.out.println(\"T.y\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
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");
|
||||
|
@ -236,17 +235,17 @@ public class TestCompositeParsers extends BaseTest {
|
|||
public void testDelegatorInvokesFirstVersionOfDelegateRule() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"a : B {System.out.println(\"T.a\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : b {System.out.println(\"S.a\");};\n" +
|
||||
"b : B;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"a : B {System.out.println(\"T.a\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(106);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S,T;\n");
|
||||
|
@ -294,18 +293,18 @@ public class TestCompositeParsers extends BaseTest {
|
|||
public void testDelegatorRuleOverridesDelegates() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { A }\n" +
|
||||
"b : 'b' {System.out.println(\"T.b\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : b {System.out.println(\"S.a\");};\n" +
|
||||
"b : 'b' ;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { A }\n" +
|
||||
"b : 'b' {System.out.println(\"T.b\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(95);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S, T;\n");
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.java;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestFullContextParsing extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.java;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestLeftRecursion extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.java;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestLexerErrors extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.java;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestLexerExec extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.java;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestListeners extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.java;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestParseTrees extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.java;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestParserExec extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.java;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestPerformance extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.java;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestSemPredEvalLexer extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.java;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestSemPredEvalParser extends BaseTest {
|
||||
|
||||
|
@ -646,11 +646,12 @@ public class TestSemPredEvalParser extends BaseTest {
|
|||
public void testToLeftWithVaryingPredicate() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(272);
|
||||
StringBuilder grammarBuilder = new StringBuilder(296);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::members {int i = 0;}\n");
|
||||
grammarBuilder.append("s : ({this.i += 1;\n");
|
||||
grammarBuilder.append("System.out.println(\"i=\"+i);} a)+ ;\n");
|
||||
grammarBuilder.append("System.out.print(\"i=\");\n");
|
||||
grammarBuilder.append("System.out.println(this.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");
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.java;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestSets extends BaseTest {
|
||||
|
||||
|
|
|
@ -4,7 +4,8 @@ package org.antlr.v4.test.runtime.java;
|
|||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestVisitors extends BaseTest {
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.javascript.node;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestCompositeLexers extends BaseTest {
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.javascript.node;
|
||||
|
||||
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;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestCompositeParsers extends BaseTest {
|
||||
|
@ -64,18 +61,18 @@ public class TestCompositeParsers extends BaseTest {
|
|||
@Test
|
||||
public void testDelegatesSeeSameTokenType() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { C, B, A } // reverse order\n" +
|
||||
"y : A {console.log(\"T.y\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"tokens { A, B, C }\n" +
|
||||
"x : A {console.log(\"S.x\");};";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { C, B, A } // reverse order\n" +
|
||||
"y : A {console.log(\"T.y\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
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");
|
||||
|
@ -207,17 +204,17 @@ public class TestCompositeParsers extends BaseTest {
|
|||
@Test
|
||||
public void testDelegatorInvokesFirstVersionOfDelegateRule() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"a : B {console.log(\"T.a\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : b {console.log(\"S.a\");};\n" +
|
||||
"b : B;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"a : B {console.log(\"T.a\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(106);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S,T;\n");
|
||||
|
@ -261,18 +258,18 @@ public class TestCompositeParsers extends BaseTest {
|
|||
@Test
|
||||
public void testDelegatorRuleOverridesDelegates() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { A }\n" +
|
||||
"b : 'b' {console.log(\"T.b\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : b {console.log(\"S.a\");};\n" +
|
||||
"b : 'b' ;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { A }\n" +
|
||||
"b : 'b' {console.log(\"T.b\");};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(88);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S, T;\n");
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.javascript.node;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestFullContextParsing extends BaseTest {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.javascript.node;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestLeftRecursion extends BaseTest {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.javascript.node;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestLexerErrors extends BaseTest {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.javascript.node;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestLexerExec extends BaseTest {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.javascript.node;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestListeners extends BaseTest {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.javascript.node;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestParseTrees extends BaseTest {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.javascript.node;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestParserExec extends BaseTest {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.javascript.node;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestPerformance extends BaseTest {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.javascript.node;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestSemPredEvalLexer extends BaseTest {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.javascript.node;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestSemPredEvalParser extends BaseTest {
|
||||
|
@ -600,11 +600,12 @@ public class TestSemPredEvalParser extends BaseTest {
|
|||
@Test
|
||||
public void testToLeftWithVaryingPredicate() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(253);
|
||||
StringBuilder grammarBuilder = new StringBuilder(281);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::members {this.i = 0;}\n");
|
||||
grammarBuilder.append("s : ({this.i += 1;\n");
|
||||
grammarBuilder.append("console.log(\"i=\"+i);} a)+ ;\n");
|
||||
grammarBuilder.append("process.stdout.write(\"i=\");\n");
|
||||
grammarBuilder.append("console.log(this.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");
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.javascript.node;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestSets extends BaseTest {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.javascript.node;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestVisitors extends BaseTest {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.python2;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestCompositeLexers extends BasePython2Test {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.python2;
|
||||
|
||||
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;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestCompositeParsers extends BasePython2Test {
|
||||
|
@ -75,18 +75,18 @@ public class TestCompositeParsers extends BasePython2Test {
|
|||
public void testDelegatesSeeSameTokenType() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { C, B, A } // reverse order\n" +
|
||||
"y : A {print(\"T.y\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"tokens { A, B, C }\n" +
|
||||
"x : A {print(\"S.x\")};";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { C, B, A } // reverse order\n" +
|
||||
"y : A {print(\"T.y\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
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");
|
||||
|
@ -245,17 +245,17 @@ public class TestCompositeParsers extends BasePython2Test {
|
|||
public void testDelegatorInvokesFirstVersionOfDelegateRule() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"a : B {print(\"T.a\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : b {print(\"S.a\")};\n" +
|
||||
"b : B;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"a : B {print(\"T.a\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(106);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S,T;\n");
|
||||
|
@ -305,18 +305,18 @@ public class TestCompositeParsers extends BasePython2Test {
|
|||
public void testDelegatorRuleOverridesDelegates() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { A }\n" +
|
||||
"b : 'b' {print(\"T.b\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : b {print(\"S.a\")};\n" +
|
||||
"b : 'b' ;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { A }\n" +
|
||||
"b : 'b' {print(\"T.b\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(81);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S, T;\n");
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.python2;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestFullContextParsing extends BasePython2Test {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.python2;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestLeftRecursion extends BasePython2Test {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.python2;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestLexerErrors extends BasePython2Test {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.python2;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestLexerExec extends BasePython2Test {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.python2;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestListeners extends BasePython2Test {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.python2;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestParseTrees extends BasePython2Test {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.python2;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestParserExec extends BasePython2Test {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.python2;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestPerformance extends BasePython2Test {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.python2;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestSemPredEvalLexer extends BasePython2Test {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.python2;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestSemPredEvalParser extends BasePython2Test {
|
||||
|
@ -669,11 +670,12 @@ public class TestSemPredEvalParser extends BasePython2Test {
|
|||
public void testToLeftWithVaryingPredicate() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(234);
|
||||
StringBuilder grammarBuilder = new StringBuilder(243);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::members {i = 0}\n");
|
||||
grammarBuilder.append("s : ({self.i += 1\n");
|
||||
grammarBuilder.append("print(str(\"i=\")+str(i))} a)+ ;\n");
|
||||
grammarBuilder.append("print(\"i=\",end='')\n");
|
||||
grammarBuilder.append("print(self.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");
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.python2;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestSets extends BasePython2Test {
|
||||
|
|
|
@ -3,7 +3,9 @@ package org.antlr.v4.test.runtime.python2;
|
|||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestVisitors extends BasePython2Test {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.python3;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestCompositeLexers extends BasePython3Test {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.python3;
|
||||
|
||||
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;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestCompositeParsers extends BasePython3Test {
|
||||
|
@ -75,18 +75,18 @@ public class TestCompositeParsers extends BasePython3Test {
|
|||
public void testDelegatesSeeSameTokenType() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { C, B, A } // reverse order\n" +
|
||||
"y : A {print(\"T.y\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"tokens { A, B, C }\n" +
|
||||
"x : A {print(\"S.x\")};";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { C, B, A } // reverse order\n" +
|
||||
"y : A {print(\"T.y\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
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");
|
||||
|
@ -245,17 +245,17 @@ public class TestCompositeParsers extends BasePython3Test {
|
|||
public void testDelegatorInvokesFirstVersionOfDelegateRule() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"a : B {print(\"T.a\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : b {print(\"S.a\")};\n" +
|
||||
"b : B;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"a : B {print(\"T.a\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(106);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S,T;\n");
|
||||
|
@ -305,18 +305,18 @@ public class TestCompositeParsers extends BasePython3Test {
|
|||
public void testDelegatorRuleOverridesDelegates() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { A }\n" +
|
||||
"b : 'b' {print(\"T.b\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
String slave_S =
|
||||
"parser grammar S;\n" +
|
||||
"a : b {print(\"S.a\")};\n" +
|
||||
"b : 'b' ;";
|
||||
writeFile(tmpdir, "S.g4", slave_S);
|
||||
|
||||
String slave_T =
|
||||
"parser grammar T;\n" +
|
||||
"tokens { A }\n" +
|
||||
"b : 'b' {print(\"T.b\")};";
|
||||
writeFile(tmpdir, "T.g4", slave_T);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(81);
|
||||
grammarBuilder.append("grammar M;\n");
|
||||
grammarBuilder.append("import S, T;\n");
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.python3;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestFullContextParsing extends BasePython3Test {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.python3;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestLeftRecursion extends BasePython3Test {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.python3;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestLexerErrors extends BasePython3Test {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.python3;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestLexerExec extends BasePython3Test {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.python3;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestListeners extends BasePython3Test {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.python3;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestParseTrees extends BasePython3Test {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.python3;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TestParserExec extends BasePython3Test {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue