Updated generation a bit.
This commit is contained in:
parent
3e21e0b6e3
commit
bebb63a126
|
@ -157,15 +157,15 @@ string(text) ::= <<
|
||||||
|
|
||||||
writeBoolean(o) ::= "<if(o && !isEmpty.(o))>true<else>false<endif>"
|
writeBoolean(o) ::= "<if(o && !isEmpty.(o))>true<else>false<endif>"
|
||||||
|
|
||||||
writeln(s) ::= "cout << <s> << \"\\n\";"
|
writeln(s) ::= "std::cout \<\< <s> \<\< \"\\n\";"
|
||||||
|
|
||||||
write(s) ::= "cout << <s>;"
|
write(s) ::= "std::cout \<\< <s>;"
|
||||||
|
|
||||||
False() ::= "False"
|
False() ::= "false"
|
||||||
|
|
||||||
True() ::= "True"
|
True() ::= "True"
|
||||||
|
|
||||||
Not(v) ::= "not <v>"
|
Not(v) ::= "!<v>"
|
||||||
|
|
||||||
Assert(s) ::= ""
|
Assert(s) ::= ""
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ ModMemberNotEquals(n,m,v) ::= <%self.<n> % <m> != <v>%>
|
||||||
|
|
||||||
DumpDFA() ::= "self.dumpDFA()"
|
DumpDFA() ::= "self.dumpDFA()"
|
||||||
|
|
||||||
Pass() ::= "pass"
|
Pass() ::= "/* do nothing */"
|
||||||
|
|
||||||
StringList() ::= ""
|
StringList() ::= ""
|
||||||
|
|
||||||
|
@ -303,7 +303,7 @@ else:
|
||||||
|
|
||||||
class LeafListener(TListener):
|
class LeafListener(TListener):
|
||||||
def visitTerminal(self, node):
|
def visitTerminal(self, node):
|
||||||
cout << node.symbol.text;
|
std::cout \<\< node.symbol.text;
|
||||||
|
|
||||||
>>
|
>>
|
||||||
|
|
||||||
|
@ -334,9 +334,9 @@ else:
|
||||||
class LeafListener(TListener):
|
class LeafListener(TListener):
|
||||||
def exitA(self, ctx):
|
def exitA(self, ctx):
|
||||||
if (ctx.getChildCount()==2) {
|
if (ctx.getChildCount()==2) {
|
||||||
cout << ctx.INT(0).symbol.text << ' ' << ctx.INT(1).symbol.text << ' ' << str_list(ctx.INT());
|
std::cout \<\< ctx.INT(0).symbol.text \<\< " " \<\< ctx.INT(1).symbol.text \<\< " " \<\< str_list(ctx.INT());
|
||||||
} else {
|
} else {
|
||||||
cout << str(ctx.ID().symbol);
|
std::cout \<\< str(ctx.ID().symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
>>
|
>>
|
||||||
|
@ -350,9 +350,9 @@ else:
|
||||||
class LeafListener(TListener):
|
class LeafListener(TListener):
|
||||||
def exitA(self, ctx):
|
def exitA(self, ctx):
|
||||||
if (ctx.getChildCount()==2) {
|
if (ctx.getChildCount()==2) {
|
||||||
cout << ctx.b(0).start.text + ' ' + ctx.b(1).start.text + ' ' + ctx.b()[0].start.text;
|
std::cout \<\< ctx.b(0).start.text \<\< " " \<\< ctx.b(1).start.text \<\< " " \<\< ctx.b()[0].start.text;
|
||||||
} else {
|
} else {
|
||||||
cout << ctx.b(0).start.text;
|
std::cout \<\< ctx.b(0).start.text;
|
||||||
}
|
}
|
||||||
|
|
||||||
>>
|
>>
|
||||||
|
@ -367,9 +367,9 @@ else:
|
||||||
class LeafListener(TListener):
|
class LeafListener(TListener):
|
||||||
def exitE(self, ctx):
|
def exitE(self, ctx):
|
||||||
if ctx.getChildCount()==3:
|
if ctx.getChildCount()==3:
|
||||||
cout << ctx.e(0).start.text + ' ' + ctx.e(1).start.text + ' ' + ctx.e()[0].start.text;
|
std::cout \<\< ctx.e(0).start.text \<\< " " \<\< ctx.e(1).start.text \<\< " " \<\< ctx.e()[0].start.text;
|
||||||
else:
|
else:
|
||||||
cout << ctx.INT().symbol.text;
|
std::cout \<\< ctx.INT().symbol.text;
|
||||||
|
|
||||||
>>
|
>>
|
||||||
|
|
||||||
|
@ -381,9 +381,9 @@ else:
|
||||||
|
|
||||||
class LeafListener(TListener):
|
class LeafListener(TListener):
|
||||||
def exitCall(self, ctx):
|
def exitCall(self, ctx):
|
||||||
cout << ctx.e().start.text << ' ' << str(ctx.eList());
|
std::cout \<\< ctx.e().start.text \<\< " " \<\< str(ctx.eList());
|
||||||
def exitInt(self, ctx):
|
def exitInt(self, ctx):
|
||||||
cout << ctx.INT().symbol.text;
|
std::cout \<\< ctx.INT().symbol.text;
|
||||||
|
|
||||||
>>
|
>>
|
||||||
|
|
||||||
|
@ -395,13 +395,13 @@ def foo():
|
||||||
>>
|
>>
|
||||||
|
|
||||||
Declare_foo() ::= <<def foo(self):
|
Declare_foo() ::= <<def foo(self):
|
||||||
cout << 'foo';
|
std::cout \<\< "foo";
|
||||||
>>
|
>>
|
||||||
|
|
||||||
Invoke_foo() ::= "self.foo()"
|
Invoke_foo() ::= "self.foo()"
|
||||||
|
|
||||||
Declare_pred() ::= <<def pred(self, v):
|
Declare_pred() ::= <<def pred(self, v):
|
||||||
cout << "eval=" << str(v).lower();
|
std::cout \<\< "eval=" \<\< str(v).lower();
|
||||||
return v
|
return v
|
||||||
|
|
||||||
>>
|
>>
|
||||||
|
|
|
@ -15,7 +15,7 @@ public class TestCompositeLexers extends BaseCppTest {
|
||||||
|
|
||||||
String slave_S =
|
String slave_S =
|
||||||
"lexer grammar S;\n" +
|
"lexer grammar S;\n" +
|
||||||
"A : 'a' {};\n" +
|
"A : 'a' {std::cout << \"S.A\" << \"\\n\";};\n" +
|
||||||
"C : 'c' ;";
|
"C : 'c' ;";
|
||||||
writeFile(tmpdir, "S.g4", slave_S);
|
writeFile(tmpdir, "S.g4", slave_S);
|
||||||
|
|
||||||
|
@ -45,14 +45,14 @@ public class TestCompositeLexers extends BaseCppTest {
|
||||||
|
|
||||||
String slave_S =
|
String slave_S =
|
||||||
"lexer grammar S;\n" +
|
"lexer grammar S;\n" +
|
||||||
"A : 'a' {} ;\n" +
|
"A : 'a' {std::cout << \"S.A\" << \"\\n\";} ;\n" +
|
||||||
"B : 'b' {} ;";
|
"B : 'b' {std::cout << \"S.B\" << \"\\n\";} ;";
|
||||||
writeFile(tmpdir, "S.g4", slave_S);
|
writeFile(tmpdir, "S.g4", slave_S);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(67);
|
StringBuilder grammarBuilder = new StringBuilder(94);
|
||||||
grammarBuilder.append("lexer grammar M;\n");
|
grammarBuilder.append("lexer grammar M;\n");
|
||||||
grammarBuilder.append("import S;\n");
|
grammarBuilder.append("import S;\n");
|
||||||
grammarBuilder.append("A : 'a' B {} ;\n");
|
grammarBuilder.append("A : 'a' B {std::cout << \"M.A\" << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ public class TestCompositeParsers extends BaseCppTest {
|
||||||
|
|
||||||
String slave_S =
|
String slave_S =
|
||||||
"parser grammar S;\n" +
|
"parser grammar S;\n" +
|
||||||
"a : '=' 'a' {cout \"S.a\";};";
|
"a : '=' 'a' {std::cout << \"S.a\";};";
|
||||||
writeFile(tmpdir, "S.g4", slave_S);
|
writeFile(tmpdir, "S.g4", slave_S);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(54);
|
StringBuilder grammarBuilder = new StringBuilder(54);
|
||||||
|
@ -45,7 +45,7 @@ public class TestCompositeParsers extends BaseCppTest {
|
||||||
String slave_S =
|
String slave_S =
|
||||||
"parser grammar S;\n" +
|
"parser grammar S;\n" +
|
||||||
"tokens { A, B, C }\n" +
|
"tokens { A, B, C }\n" +
|
||||||
"x : 'x' INT {};\n" +
|
"x : 'x' INT {std::cout << \"S.x\" << \"\\n\";};\n" +
|
||||||
"INT : '0'..'9'+ ;\n" +
|
"INT : '0'..'9'+ ;\n" +
|
||||||
"WS : (' '|'\\n') -> skip ;";
|
"WS : (' '|'\\n') -> skip ;";
|
||||||
writeFile(tmpdir, "S.g4", slave_S);
|
writeFile(tmpdir, "S.g4", slave_S);
|
||||||
|
@ -78,13 +78,13 @@ public class TestCompositeParsers extends BaseCppTest {
|
||||||
String slave_S =
|
String slave_S =
|
||||||
"parser grammar S;\n" +
|
"parser grammar S;\n" +
|
||||||
"tokens { A, B, C }\n" +
|
"tokens { A, B, C }\n" +
|
||||||
"x : A {};";
|
"x : A {std::cout << \"S.x\" << \"\\n\";};";
|
||||||
writeFile(tmpdir, "S.g4", slave_S);
|
writeFile(tmpdir, "S.g4", slave_S);
|
||||||
|
|
||||||
String slave_T =
|
String slave_T =
|
||||||
"parser grammar T;\n" +
|
"parser grammar T;\n" +
|
||||||
"tokens { C, B, A } // reverse order\n" +
|
"tokens { C, B, A } // reverse order\n" +
|
||||||
"y : A {};";
|
"y : A {std::cout << \"T.y\" << \"\\n\";};";
|
||||||
writeFile(tmpdir, "T.g4", slave_T);
|
writeFile(tmpdir, "T.g4", slave_T);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(598);
|
StringBuilder grammarBuilder = new StringBuilder(598);
|
||||||
|
@ -137,6 +137,8 @@ public class TestCompositeParsers extends BaseCppTest {
|
||||||
String slave_S =
|
String slave_S =
|
||||||
"parser grammar S;\n" +
|
"parser grammar S;\n" +
|
||||||
"@parser::members {\n" +
|
"@parser::members {\n" +
|
||||||
|
"def foo(self):\n" +
|
||||||
|
" std::cout << \"foo\";\n" +
|
||||||
"}\n" +
|
"}\n" +
|
||||||
"a : B;";
|
"a : B;";
|
||||||
writeFile(tmpdir, "S.g4", slave_S);
|
writeFile(tmpdir, "S.g4", slave_S);
|
||||||
|
@ -164,7 +166,7 @@ public class TestCompositeParsers extends BaseCppTest {
|
||||||
|
|
||||||
String slave_S =
|
String slave_S =
|
||||||
"parser grammar S;\n" +
|
"parser grammar S;\n" +
|
||||||
"a : B {};";
|
"a : B {std::cout << \"S.a\" << \"\\n\";};";
|
||||||
writeFile(tmpdir, "S.g4", slave_S);
|
writeFile(tmpdir, "S.g4", slave_S);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(104);
|
StringBuilder grammarBuilder = new StringBuilder(104);
|
||||||
|
@ -191,13 +193,13 @@ public class TestCompositeParsers extends BaseCppTest {
|
||||||
|
|
||||||
String slave_S =
|
String slave_S =
|
||||||
"parser grammar S;\n" +
|
"parser grammar S;\n" +
|
||||||
"a[int x] returns [int y] : B {cout \"S.a\";} {$y=1000;} ;";
|
"a[int x] returns [int y] : B {std::cout << \"S.a\";} {$y=1000;} ;";
|
||||||
writeFile(tmpdir, "S.g4", slave_S);
|
writeFile(tmpdir, "S.g4", slave_S);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(116);
|
StringBuilder grammarBuilder = new StringBuilder(146);
|
||||||
grammarBuilder.append("grammar M;\n");
|
grammarBuilder.append("grammar M;\n");
|
||||||
grammarBuilder.append("import S;\n");
|
grammarBuilder.append("import S;\n");
|
||||||
grammarBuilder.append("s : label=a[3] {} ;\n");
|
grammarBuilder.append("s : label=a[3] {std::cout << $label.y << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("B : 'b' ; // defines B from inherited token space\n");
|
grammarBuilder.append("B : 'b' ; // defines B from inherited token space\n");
|
||||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
@ -218,13 +220,13 @@ public class TestCompositeParsers extends BaseCppTest {
|
||||||
|
|
||||||
String slave_S =
|
String slave_S =
|
||||||
"parser grammar S;\n" +
|
"parser grammar S;\n" +
|
||||||
"a : B {cout \"S.a\";} ;";
|
"a : B {std::cout << \"S.a\";} ;";
|
||||||
writeFile(tmpdir, "S.g4", slave_S);
|
writeFile(tmpdir, "S.g4", slave_S);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(120);
|
StringBuilder grammarBuilder = new StringBuilder(128);
|
||||||
grammarBuilder.append("grammar M;\n");
|
grammarBuilder.append("grammar M;\n");
|
||||||
grammarBuilder.append("import S;\n");
|
grammarBuilder.append("import S;\n");
|
||||||
grammarBuilder.append("s : a {cout $a.text;} ;\n");
|
grammarBuilder.append("s : a {std::cout << $a.text;} ;\n");
|
||||||
grammarBuilder.append("B : 'b' ; // defines B from inherited token space\n");
|
grammarBuilder.append("B : 'b' ; // defines B from inherited token space\n");
|
||||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
@ -245,13 +247,13 @@ public class TestCompositeParsers extends BaseCppTest {
|
||||||
|
|
||||||
String slave_S =
|
String slave_S =
|
||||||
"parser grammar S;\n" +
|
"parser grammar S;\n" +
|
||||||
"a : b {};\n" +
|
"a : b {std::cout << \"S.a\" << \"\\n\";};\n" +
|
||||||
"b : B;";
|
"b : B;";
|
||||||
writeFile(tmpdir, "S.g4", slave_S);
|
writeFile(tmpdir, "S.g4", slave_S);
|
||||||
|
|
||||||
String slave_T =
|
String slave_T =
|
||||||
"parser grammar T;\n" +
|
"parser grammar T;\n" +
|
||||||
"a : B {};";
|
"a : B {std::cout << \"T.a\" << \"\\n\";};";
|
||||||
writeFile(tmpdir, "T.g4", slave_T);
|
writeFile(tmpdir, "T.g4", slave_T);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(106);
|
StringBuilder grammarBuilder = new StringBuilder(106);
|
||||||
|
@ -278,7 +280,7 @@ public class TestCompositeParsers extends BaseCppTest {
|
||||||
|
|
||||||
String slave_S =
|
String slave_S =
|
||||||
"parser grammar S;\n" +
|
"parser grammar S;\n" +
|
||||||
"a : b {cout \"S.a\";};\n" +
|
"a : b {std::cout << \"S.a\";};\n" +
|
||||||
"b : B ;";
|
"b : B ;";
|
||||||
writeFile(tmpdir, "S.g4", slave_S);
|
writeFile(tmpdir, "S.g4", slave_S);
|
||||||
|
|
||||||
|
@ -305,20 +307,20 @@ public class TestCompositeParsers extends BaseCppTest {
|
||||||
|
|
||||||
String slave_S =
|
String slave_S =
|
||||||
"parser grammar S;\n" +
|
"parser grammar S;\n" +
|
||||||
"a : b {};\n" +
|
"a : b {std::cout << \"S.a\" << \"\\n\";};\n" +
|
||||||
"b : 'b' ;";
|
"b : 'b' ;";
|
||||||
writeFile(tmpdir, "S.g4", slave_S);
|
writeFile(tmpdir, "S.g4", slave_S);
|
||||||
|
|
||||||
String slave_T =
|
String slave_T =
|
||||||
"parser grammar T;\n" +
|
"parser grammar T;\n" +
|
||||||
"tokens { A }\n" +
|
"tokens { A }\n" +
|
||||||
"b : 'b' {};";
|
"b : 'b' {std::cout << \"T.b\" << \"\\n\";};";
|
||||||
writeFile(tmpdir, "T.g4", slave_T);
|
writeFile(tmpdir, "T.g4", slave_T);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(69);
|
StringBuilder grammarBuilder = new StringBuilder(96);
|
||||||
grammarBuilder.append("grammar M;\n");
|
grammarBuilder.append("grammar M;\n");
|
||||||
grammarBuilder.append("import S, T;\n");
|
grammarBuilder.append("import S, T;\n");
|
||||||
grammarBuilder.append("b : 'b'|'c' {}|B|A;\n");
|
grammarBuilder.append("b : 'b'|'c' {std::cout << \"M.b\" << \"\\n\";}|B|A;\n");
|
||||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
@ -342,7 +344,7 @@ public class TestCompositeParsers extends BaseCppTest {
|
||||||
"parser grammar S;\n" +
|
"parser grammar S;\n" +
|
||||||
"type_ : 'int' ;\n" +
|
"type_ : 'int' ;\n" +
|
||||||
"decl : type_ ID ';'\n" +
|
"decl : type_ ID ';'\n" +
|
||||||
" | type_ ID init ';' {cout \"JavaDecl: \" + $text;};\n" +
|
" | type_ ID init ';' {std::cout << \"JavaDecl: \" + $text;};\n" +
|
||||||
"init : '=' INT;";
|
"init : '=' INT;";
|
||||||
writeFile(tmpdir, "S.g4", slave_S);
|
writeFile(tmpdir, "S.g4", slave_S);
|
||||||
|
|
||||||
|
@ -463,11 +465,11 @@ public class TestCompositeParsers extends BaseCppTest {
|
||||||
"ID : 'a'..'z'+;";
|
"ID : 'a'..'z'+;";
|
||||||
writeFile(tmpdir, "S.g4", slave_S);
|
writeFile(tmpdir, "S.g4", slave_S);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(70);
|
StringBuilder grammarBuilder = new StringBuilder(136);
|
||||||
grammarBuilder.append("grammar M;\n");
|
grammarBuilder.append("grammar M;\n");
|
||||||
grammarBuilder.append("import S;\n");
|
grammarBuilder.append("import S;\n");
|
||||||
grammarBuilder.append("a : A {};\n");
|
grammarBuilder.append("a : A {std::cout << \"M.a: \" + str($A) << \"\\n\";};\n");
|
||||||
grammarBuilder.append("A : 'abc' {};\n");
|
grammarBuilder.append("A : 'abc' {std::cout << \"M.A\" << \"\\n\";};\n");
|
||||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
|
|
@ -38,11 +38,11 @@ public class TestFullContextParsing extends BaseCppTest {
|
||||||
public void testAmbiguityNoLoop() throws Exception {
|
public void testAmbiguityNoLoop() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(192);
|
StringBuilder grammarBuilder = new StringBuilder(221);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("prog\n");
|
grammarBuilder.append("prog\n");
|
||||||
grammarBuilder.append("@init {self._interp.predictionMode = PredictionMode.LL_EXACT_AMBIG_DETECTION}\n");
|
grammarBuilder.append("@init {self._interp.predictionMode = PredictionMode.LL_EXACT_AMBIG_DETECTION}\n");
|
||||||
grammarBuilder.append(" : expr expr {}\n");
|
grammarBuilder.append(" : expr expr {std::cout << \"alt 1\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" | expr\n");
|
grammarBuilder.append(" | expr\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
grammarBuilder.append("expr: '@'\n");
|
grammarBuilder.append("expr: '@'\n");
|
||||||
|
@ -170,11 +170,11 @@ public class TestFullContextParsing extends BaseCppTest {
|
||||||
public void testExprAmbiguity_1() throws Exception {
|
public void testExprAmbiguity_1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(245);
|
StringBuilder grammarBuilder = new StringBuilder(301);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s\n");
|
grammarBuilder.append("s\n");
|
||||||
grammarBuilder.append("@init {self._interp.predictionMode = PredictionMode.LL_EXACT_AMBIG_DETECTION}\n");
|
grammarBuilder.append("@init {self._interp.predictionMode = PredictionMode.LL_EXACT_AMBIG_DETECTION}\n");
|
||||||
grammarBuilder.append(": expr[0] {};\n");
|
grammarBuilder.append(": expr[0] {std::cout << $expr.ctx.toStringTree(recog=self) << \"\\n\";};\n");
|
||||||
grammarBuilder.append(" expr[int _p]\n");
|
grammarBuilder.append(" expr[int _p]\n");
|
||||||
grammarBuilder.append(" : ID \n");
|
grammarBuilder.append(" : ID \n");
|
||||||
grammarBuilder.append(" ( \n");
|
grammarBuilder.append(" ( \n");
|
||||||
|
@ -203,11 +203,11 @@ public class TestFullContextParsing extends BaseCppTest {
|
||||||
public void testExprAmbiguity_2() throws Exception {
|
public void testExprAmbiguity_2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(245);
|
StringBuilder grammarBuilder = new StringBuilder(301);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s\n");
|
grammarBuilder.append("s\n");
|
||||||
grammarBuilder.append("@init {self._interp.predictionMode = PredictionMode.LL_EXACT_AMBIG_DETECTION}\n");
|
grammarBuilder.append("@init {self._interp.predictionMode = PredictionMode.LL_EXACT_AMBIG_DETECTION}\n");
|
||||||
grammarBuilder.append(": expr[0] {};\n");
|
grammarBuilder.append(": expr[0] {std::cout << $expr.ctx.toStringTree(recog=self) << \"\\n\";};\n");
|
||||||
grammarBuilder.append(" expr[int _p]\n");
|
grammarBuilder.append(" expr[int _p]\n");
|
||||||
grammarBuilder.append(" : ID \n");
|
grammarBuilder.append(" : ID \n");
|
||||||
grammarBuilder.append(" ( \n");
|
grammarBuilder.append(" ( \n");
|
||||||
|
@ -440,14 +440,14 @@ public class TestFullContextParsing extends BaseCppTest {
|
||||||
public void testLoopsSimulateTailRecursion() throws Exception {
|
public void testLoopsSimulateTailRecursion() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(259);
|
StringBuilder grammarBuilder = new StringBuilder(329);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("prog\n");
|
grammarBuilder.append("prog\n");
|
||||||
grammarBuilder.append("@init {self._interp.predictionMode = PredictionMode.LL_EXACT_AMBIG_DETECTION}\n");
|
grammarBuilder.append("@init {self._interp.predictionMode = PredictionMode.LL_EXACT_AMBIG_DETECTION}\n");
|
||||||
grammarBuilder.append(" : expr_or_assign*;\n");
|
grammarBuilder.append(" : expr_or_assign*;\n");
|
||||||
grammarBuilder.append("expr_or_assign\n");
|
grammarBuilder.append("expr_or_assign\n");
|
||||||
grammarBuilder.append(" : expr '++' {}\n");
|
grammarBuilder.append(" : expr '++' {std::cout << \"fail.\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" | expr {}\n");
|
grammarBuilder.append(" | expr {std::cout << \"pass: \"+$expr.text << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
grammarBuilder.append("expr: expr_primary ('<-' ID)?;\n");
|
grammarBuilder.append("expr: expr_primary ('<-' ID)?;\n");
|
||||||
grammarBuilder.append("expr_primary\n");
|
grammarBuilder.append("expr_primary\n");
|
||||||
|
|
|
@ -203,9 +203,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testDeclarations_1() throws Exception {
|
public void testDeclarations_1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(355);
|
StringBuilder grammarBuilder = new StringBuilder(406);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : declarator EOF ; // must indicate EOF can follow\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : declarator EOF ; // must indicate EOF can follow\n");
|
||||||
grammarBuilder.append("declarator\n");
|
grammarBuilder.append("declarator\n");
|
||||||
grammarBuilder.append(" : declarator '[' e ']'\n");
|
grammarBuilder.append(" : declarator '[' e ']'\n");
|
||||||
grammarBuilder.append(" | declarator '[' ']'\n");
|
grammarBuilder.append(" | declarator '[' ']'\n");
|
||||||
|
@ -234,9 +234,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testDeclarations_10() throws Exception {
|
public void testDeclarations_10() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(355);
|
StringBuilder grammarBuilder = new StringBuilder(406);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : declarator EOF ; // must indicate EOF can follow\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : declarator EOF ; // must indicate EOF can follow\n");
|
||||||
grammarBuilder.append("declarator\n");
|
grammarBuilder.append("declarator\n");
|
||||||
grammarBuilder.append(" : declarator '[' e ']'\n");
|
grammarBuilder.append(" : declarator '[' e ']'\n");
|
||||||
grammarBuilder.append(" | declarator '[' ']'\n");
|
grammarBuilder.append(" | declarator '[' ']'\n");
|
||||||
|
@ -265,9 +265,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testDeclarations_2() throws Exception {
|
public void testDeclarations_2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(355);
|
StringBuilder grammarBuilder = new StringBuilder(406);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : declarator EOF ; // must indicate EOF can follow\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : declarator EOF ; // must indicate EOF can follow\n");
|
||||||
grammarBuilder.append("declarator\n");
|
grammarBuilder.append("declarator\n");
|
||||||
grammarBuilder.append(" : declarator '[' e ']'\n");
|
grammarBuilder.append(" : declarator '[' e ']'\n");
|
||||||
grammarBuilder.append(" | declarator '[' ']'\n");
|
grammarBuilder.append(" | declarator '[' ']'\n");
|
||||||
|
@ -296,9 +296,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testDeclarations_3() throws Exception {
|
public void testDeclarations_3() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(355);
|
StringBuilder grammarBuilder = new StringBuilder(406);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : declarator EOF ; // must indicate EOF can follow\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : declarator EOF ; // must indicate EOF can follow\n");
|
||||||
grammarBuilder.append("declarator\n");
|
grammarBuilder.append("declarator\n");
|
||||||
grammarBuilder.append(" : declarator '[' e ']'\n");
|
grammarBuilder.append(" : declarator '[' e ']'\n");
|
||||||
grammarBuilder.append(" | declarator '[' ']'\n");
|
grammarBuilder.append(" | declarator '[' ']'\n");
|
||||||
|
@ -327,9 +327,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testDeclarations_4() throws Exception {
|
public void testDeclarations_4() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(355);
|
StringBuilder grammarBuilder = new StringBuilder(406);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : declarator EOF ; // must indicate EOF can follow\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : declarator EOF ; // must indicate EOF can follow\n");
|
||||||
grammarBuilder.append("declarator\n");
|
grammarBuilder.append("declarator\n");
|
||||||
grammarBuilder.append(" : declarator '[' e ']'\n");
|
grammarBuilder.append(" : declarator '[' e ']'\n");
|
||||||
grammarBuilder.append(" | declarator '[' ']'\n");
|
grammarBuilder.append(" | declarator '[' ']'\n");
|
||||||
|
@ -358,9 +358,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testDeclarations_5() throws Exception {
|
public void testDeclarations_5() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(355);
|
StringBuilder grammarBuilder = new StringBuilder(406);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : declarator EOF ; // must indicate EOF can follow\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : declarator EOF ; // must indicate EOF can follow\n");
|
||||||
grammarBuilder.append("declarator\n");
|
grammarBuilder.append("declarator\n");
|
||||||
grammarBuilder.append(" : declarator '[' e ']'\n");
|
grammarBuilder.append(" : declarator '[' e ']'\n");
|
||||||
grammarBuilder.append(" | declarator '[' ']'\n");
|
grammarBuilder.append(" | declarator '[' ']'\n");
|
||||||
|
@ -389,9 +389,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testDeclarations_6() throws Exception {
|
public void testDeclarations_6() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(355);
|
StringBuilder grammarBuilder = new StringBuilder(406);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : declarator EOF ; // must indicate EOF can follow\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : declarator EOF ; // must indicate EOF can follow\n");
|
||||||
grammarBuilder.append("declarator\n");
|
grammarBuilder.append("declarator\n");
|
||||||
grammarBuilder.append(" : declarator '[' e ']'\n");
|
grammarBuilder.append(" : declarator '[' e ']'\n");
|
||||||
grammarBuilder.append(" | declarator '[' ']'\n");
|
grammarBuilder.append(" | declarator '[' ']'\n");
|
||||||
|
@ -420,9 +420,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testDeclarations_7() throws Exception {
|
public void testDeclarations_7() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(355);
|
StringBuilder grammarBuilder = new StringBuilder(406);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : declarator EOF ; // must indicate EOF can follow\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : declarator EOF ; // must indicate EOF can follow\n");
|
||||||
grammarBuilder.append("declarator\n");
|
grammarBuilder.append("declarator\n");
|
||||||
grammarBuilder.append(" : declarator '[' e ']'\n");
|
grammarBuilder.append(" : declarator '[' e ']'\n");
|
||||||
grammarBuilder.append(" | declarator '[' ']'\n");
|
grammarBuilder.append(" | declarator '[' ']'\n");
|
||||||
|
@ -451,9 +451,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testDeclarations_8() throws Exception {
|
public void testDeclarations_8() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(355);
|
StringBuilder grammarBuilder = new StringBuilder(406);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : declarator EOF ; // must indicate EOF can follow\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : declarator EOF ; // must indicate EOF can follow\n");
|
||||||
grammarBuilder.append("declarator\n");
|
grammarBuilder.append("declarator\n");
|
||||||
grammarBuilder.append(" : declarator '[' e ']'\n");
|
grammarBuilder.append(" : declarator '[' e ']'\n");
|
||||||
grammarBuilder.append(" | declarator '[' ']'\n");
|
grammarBuilder.append(" | declarator '[' ']'\n");
|
||||||
|
@ -482,9 +482,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testDeclarations_9() throws Exception {
|
public void testDeclarations_9() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(355);
|
StringBuilder grammarBuilder = new StringBuilder(406);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : declarator EOF ; // must indicate EOF can follow\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : declarator EOF ; // must indicate EOF can follow\n");
|
||||||
grammarBuilder.append("declarator\n");
|
grammarBuilder.append("declarator\n");
|
||||||
grammarBuilder.append(" : declarator '[' e ']'\n");
|
grammarBuilder.append(" : declarator '[' e ']'\n");
|
||||||
grammarBuilder.append(" | declarator '[' ']'\n");
|
grammarBuilder.append(" | declarator '[' ']'\n");
|
||||||
|
@ -513,9 +513,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testDirectCallToLeftRecursiveRule_1() throws Exception {
|
public void testDirectCallToLeftRecursiveRule_1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(83);
|
StringBuilder grammarBuilder = new StringBuilder(134);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a @after {} : a ID\n");
|
grammarBuilder.append("a @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : a ID\n");
|
||||||
grammarBuilder.append(" | ID\n");
|
grammarBuilder.append(" | ID\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
|
@ -536,9 +536,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testDirectCallToLeftRecursiveRule_2() throws Exception {
|
public void testDirectCallToLeftRecursiveRule_2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(83);
|
StringBuilder grammarBuilder = new StringBuilder(134);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a @after {} : a ID\n");
|
grammarBuilder.append("a @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : a ID\n");
|
||||||
grammarBuilder.append(" | ID\n");
|
grammarBuilder.append(" | ID\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
|
@ -559,9 +559,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testDirectCallToLeftRecursiveRule_3() throws Exception {
|
public void testDirectCallToLeftRecursiveRule_3() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(83);
|
StringBuilder grammarBuilder = new StringBuilder(134);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a @after {} : a ID\n");
|
grammarBuilder.append("a @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : a ID\n");
|
||||||
grammarBuilder.append(" | ID\n");
|
grammarBuilder.append(" | ID\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
|
@ -582,9 +582,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testExpressions_1() throws Exception {
|
public void testExpressions_1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(214);
|
StringBuilder grammarBuilder = new StringBuilder(265);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF ; // must indicate EOF can follow\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF ; // must indicate EOF can follow\n");
|
||||||
grammarBuilder.append("e : e '.' ID\n");
|
grammarBuilder.append("e : e '.' ID\n");
|
||||||
grammarBuilder.append(" | e '.' 'this'\n");
|
grammarBuilder.append(" | e '.' 'this'\n");
|
||||||
grammarBuilder.append(" | '-' e\n");
|
grammarBuilder.append(" | '-' e\n");
|
||||||
|
@ -612,9 +612,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testExpressions_2() throws Exception {
|
public void testExpressions_2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(214);
|
StringBuilder grammarBuilder = new StringBuilder(265);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF ; // must indicate EOF can follow\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF ; // must indicate EOF can follow\n");
|
||||||
grammarBuilder.append("e : e '.' ID\n");
|
grammarBuilder.append("e : e '.' ID\n");
|
||||||
grammarBuilder.append(" | e '.' 'this'\n");
|
grammarBuilder.append(" | e '.' 'this'\n");
|
||||||
grammarBuilder.append(" | '-' e\n");
|
grammarBuilder.append(" | '-' e\n");
|
||||||
|
@ -642,9 +642,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testExpressions_3() throws Exception {
|
public void testExpressions_3() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(214);
|
StringBuilder grammarBuilder = new StringBuilder(265);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF ; // must indicate EOF can follow\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF ; // must indicate EOF can follow\n");
|
||||||
grammarBuilder.append("e : e '.' ID\n");
|
grammarBuilder.append("e : e '.' ID\n");
|
||||||
grammarBuilder.append(" | e '.' 'this'\n");
|
grammarBuilder.append(" | e '.' 'this'\n");
|
||||||
grammarBuilder.append(" | '-' e\n");
|
grammarBuilder.append(" | '-' e\n");
|
||||||
|
@ -672,9 +672,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testExpressions_4() throws Exception {
|
public void testExpressions_4() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(214);
|
StringBuilder grammarBuilder = new StringBuilder(265);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF ; // must indicate EOF can follow\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF ; // must indicate EOF can follow\n");
|
||||||
grammarBuilder.append("e : e '.' ID\n");
|
grammarBuilder.append("e : e '.' ID\n");
|
||||||
grammarBuilder.append(" | e '.' 'this'\n");
|
grammarBuilder.append(" | e '.' 'this'\n");
|
||||||
grammarBuilder.append(" | '-' e\n");
|
grammarBuilder.append(" | '-' e\n");
|
||||||
|
@ -702,9 +702,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testExpressions_5() throws Exception {
|
public void testExpressions_5() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(214);
|
StringBuilder grammarBuilder = new StringBuilder(265);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF ; // must indicate EOF can follow\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF ; // must indicate EOF can follow\n");
|
||||||
grammarBuilder.append("e : e '.' ID\n");
|
grammarBuilder.append("e : e '.' ID\n");
|
||||||
grammarBuilder.append(" | e '.' 'this'\n");
|
grammarBuilder.append(" | e '.' 'this'\n");
|
||||||
grammarBuilder.append(" | '-' e\n");
|
grammarBuilder.append(" | '-' e\n");
|
||||||
|
@ -732,9 +732,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testExpressions_6() throws Exception {
|
public void testExpressions_6() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(214);
|
StringBuilder grammarBuilder = new StringBuilder(265);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF ; // must indicate EOF can follow\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF ; // must indicate EOF can follow\n");
|
||||||
grammarBuilder.append("e : e '.' ID\n");
|
grammarBuilder.append("e : e '.' ID\n");
|
||||||
grammarBuilder.append(" | e '.' 'this'\n");
|
grammarBuilder.append(" | e '.' 'this'\n");
|
||||||
grammarBuilder.append(" | '-' e\n");
|
grammarBuilder.append(" | '-' e\n");
|
||||||
|
@ -762,9 +762,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testExpressions_7() throws Exception {
|
public void testExpressions_7() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(214);
|
StringBuilder grammarBuilder = new StringBuilder(265);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF ; // must indicate EOF can follow\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF ; // must indicate EOF can follow\n");
|
||||||
grammarBuilder.append("e : e '.' ID\n");
|
grammarBuilder.append("e : e '.' ID\n");
|
||||||
grammarBuilder.append(" | e '.' 'this'\n");
|
grammarBuilder.append(" | e '.' 'this'\n");
|
||||||
grammarBuilder.append(" | '-' e\n");
|
grammarBuilder.append(" | '-' e\n");
|
||||||
|
@ -792,9 +792,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testJavaExpressions_1() throws Exception {
|
public void testJavaExpressions_1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(1211);
|
StringBuilder grammarBuilder = new StringBuilder(1262);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF ; // must indicate EOF can follow\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF ; // must indicate EOF can follow\n");
|
||||||
grammarBuilder.append("expressionList\n");
|
grammarBuilder.append("expressionList\n");
|
||||||
grammarBuilder.append(" : e (',' e)*\n");
|
grammarBuilder.append(" : e (',' e)*\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
|
@ -866,9 +866,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testJavaExpressions_10() throws Exception {
|
public void testJavaExpressions_10() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(1211);
|
StringBuilder grammarBuilder = new StringBuilder(1262);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF ; // must indicate EOF can follow\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF ; // must indicate EOF can follow\n");
|
||||||
grammarBuilder.append("expressionList\n");
|
grammarBuilder.append("expressionList\n");
|
||||||
grammarBuilder.append(" : e (',' e)*\n");
|
grammarBuilder.append(" : e (',' e)*\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
|
@ -940,9 +940,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testJavaExpressions_11() throws Exception {
|
public void testJavaExpressions_11() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(1211);
|
StringBuilder grammarBuilder = new StringBuilder(1262);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF ; // must indicate EOF can follow\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF ; // must indicate EOF can follow\n");
|
||||||
grammarBuilder.append("expressionList\n");
|
grammarBuilder.append("expressionList\n");
|
||||||
grammarBuilder.append(" : e (',' e)*\n");
|
grammarBuilder.append(" : e (',' e)*\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
|
@ -1014,9 +1014,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testJavaExpressions_12() throws Exception {
|
public void testJavaExpressions_12() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(1211);
|
StringBuilder grammarBuilder = new StringBuilder(1262);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF ; // must indicate EOF can follow\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF ; // must indicate EOF can follow\n");
|
||||||
grammarBuilder.append("expressionList\n");
|
grammarBuilder.append("expressionList\n");
|
||||||
grammarBuilder.append(" : e (',' e)*\n");
|
grammarBuilder.append(" : e (',' e)*\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
|
@ -1088,9 +1088,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testJavaExpressions_2() throws Exception {
|
public void testJavaExpressions_2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(1211);
|
StringBuilder grammarBuilder = new StringBuilder(1262);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF ; // must indicate EOF can follow\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF ; // must indicate EOF can follow\n");
|
||||||
grammarBuilder.append("expressionList\n");
|
grammarBuilder.append("expressionList\n");
|
||||||
grammarBuilder.append(" : e (',' e)*\n");
|
grammarBuilder.append(" : e (',' e)*\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
|
@ -1162,9 +1162,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testJavaExpressions_3() throws Exception {
|
public void testJavaExpressions_3() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(1211);
|
StringBuilder grammarBuilder = new StringBuilder(1262);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF ; // must indicate EOF can follow\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF ; // must indicate EOF can follow\n");
|
||||||
grammarBuilder.append("expressionList\n");
|
grammarBuilder.append("expressionList\n");
|
||||||
grammarBuilder.append(" : e (',' e)*\n");
|
grammarBuilder.append(" : e (',' e)*\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
|
@ -1236,9 +1236,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testJavaExpressions_4() throws Exception {
|
public void testJavaExpressions_4() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(1211);
|
StringBuilder grammarBuilder = new StringBuilder(1262);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF ; // must indicate EOF can follow\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF ; // must indicate EOF can follow\n");
|
||||||
grammarBuilder.append("expressionList\n");
|
grammarBuilder.append("expressionList\n");
|
||||||
grammarBuilder.append(" : e (',' e)*\n");
|
grammarBuilder.append(" : e (',' e)*\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
|
@ -1310,9 +1310,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testJavaExpressions_5() throws Exception {
|
public void testJavaExpressions_5() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(1211);
|
StringBuilder grammarBuilder = new StringBuilder(1262);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF ; // must indicate EOF can follow\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF ; // must indicate EOF can follow\n");
|
||||||
grammarBuilder.append("expressionList\n");
|
grammarBuilder.append("expressionList\n");
|
||||||
grammarBuilder.append(" : e (',' e)*\n");
|
grammarBuilder.append(" : e (',' e)*\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
|
@ -1384,9 +1384,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testJavaExpressions_6() throws Exception {
|
public void testJavaExpressions_6() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(1211);
|
StringBuilder grammarBuilder = new StringBuilder(1262);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF ; // must indicate EOF can follow\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF ; // must indicate EOF can follow\n");
|
||||||
grammarBuilder.append("expressionList\n");
|
grammarBuilder.append("expressionList\n");
|
||||||
grammarBuilder.append(" : e (',' e)*\n");
|
grammarBuilder.append(" : e (',' e)*\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
|
@ -1458,9 +1458,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testJavaExpressions_7() throws Exception {
|
public void testJavaExpressions_7() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(1211);
|
StringBuilder grammarBuilder = new StringBuilder(1262);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF ; // must indicate EOF can follow\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF ; // must indicate EOF can follow\n");
|
||||||
grammarBuilder.append("expressionList\n");
|
grammarBuilder.append("expressionList\n");
|
||||||
grammarBuilder.append(" : e (',' e)*\n");
|
grammarBuilder.append(" : e (',' e)*\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
|
@ -1532,9 +1532,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testJavaExpressions_8() throws Exception {
|
public void testJavaExpressions_8() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(1211);
|
StringBuilder grammarBuilder = new StringBuilder(1262);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF ; // must indicate EOF can follow\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF ; // must indicate EOF can follow\n");
|
||||||
grammarBuilder.append("expressionList\n");
|
grammarBuilder.append("expressionList\n");
|
||||||
grammarBuilder.append(" : e (',' e)*\n");
|
grammarBuilder.append(" : e (',' e)*\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
|
@ -1606,9 +1606,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testJavaExpressions_9() throws Exception {
|
public void testJavaExpressions_9() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(1211);
|
StringBuilder grammarBuilder = new StringBuilder(1262);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF ; // must indicate EOF can follow\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF ; // must indicate EOF can follow\n");
|
||||||
grammarBuilder.append("expressionList\n");
|
grammarBuilder.append("expressionList\n");
|
||||||
grammarBuilder.append(" : e (',' e)*\n");
|
grammarBuilder.append(" : e (',' e)*\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
|
@ -1680,9 +1680,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testLabelsOnOpSubrule_1() throws Exception {
|
public void testLabelsOnOpSubrule_1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(134);
|
StringBuilder grammarBuilder = new StringBuilder(185);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e;\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e;\n");
|
||||||
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}\n");
|
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}\n");
|
||||||
grammarBuilder.append(" | INT {}\n");
|
grammarBuilder.append(" | INT {}\n");
|
||||||
grammarBuilder.append(" | '(' x=e ')' {}\n");
|
grammarBuilder.append(" | '(' x=e ')' {}\n");
|
||||||
|
@ -1705,9 +1705,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testLabelsOnOpSubrule_2() throws Exception {
|
public void testLabelsOnOpSubrule_2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(134);
|
StringBuilder grammarBuilder = new StringBuilder(185);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e;\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e;\n");
|
||||||
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}\n");
|
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}\n");
|
||||||
grammarBuilder.append(" | INT {}\n");
|
grammarBuilder.append(" | INT {}\n");
|
||||||
grammarBuilder.append(" | '(' x=e ')' {}\n");
|
grammarBuilder.append(" | '(' x=e ')' {}\n");
|
||||||
|
@ -1730,9 +1730,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testLabelsOnOpSubrule_3() throws Exception {
|
public void testLabelsOnOpSubrule_3() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(134);
|
StringBuilder grammarBuilder = new StringBuilder(185);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e;\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e;\n");
|
||||||
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}\n");
|
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}\n");
|
||||||
grammarBuilder.append(" | INT {}\n");
|
grammarBuilder.append(" | INT {}\n");
|
||||||
grammarBuilder.append(" | '(' x=e ')' {}\n");
|
grammarBuilder.append(" | '(' x=e ')' {}\n");
|
||||||
|
@ -1755,9 +1755,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testMultipleActionsPredicatesOptions_1() throws Exception {
|
public void testMultipleActionsPredicatesOptions_1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(203);
|
StringBuilder grammarBuilder = new StringBuilder(254);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e ;\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e ;\n");
|
||||||
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{True}?\n");
|
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{True}?\n");
|
||||||
grammarBuilder.append(" | a=e op=('+'|'-') b=e {}<p=3>{True}?<fail='Message'>\n");
|
grammarBuilder.append(" | a=e op=('+'|'-') b=e {}<p=3>{True}?<fail='Message'>\n");
|
||||||
grammarBuilder.append(" | INT {}{}\n");
|
grammarBuilder.append(" | INT {}{}\n");
|
||||||
|
@ -1781,9 +1781,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testMultipleActionsPredicatesOptions_2() throws Exception {
|
public void testMultipleActionsPredicatesOptions_2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(203);
|
StringBuilder grammarBuilder = new StringBuilder(254);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e ;\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e ;\n");
|
||||||
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{True}?\n");
|
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{True}?\n");
|
||||||
grammarBuilder.append(" | a=e op=('+'|'-') b=e {}<p=3>{True}?<fail='Message'>\n");
|
grammarBuilder.append(" | a=e op=('+'|'-') b=e {}<p=3>{True}?<fail='Message'>\n");
|
||||||
grammarBuilder.append(" | INT {}{}\n");
|
grammarBuilder.append(" | INT {}{}\n");
|
||||||
|
@ -1807,9 +1807,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testMultipleActionsPredicatesOptions_3() throws Exception {
|
public void testMultipleActionsPredicatesOptions_3() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(203);
|
StringBuilder grammarBuilder = new StringBuilder(254);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e ;\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e ;\n");
|
||||||
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{True}?\n");
|
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{True}?\n");
|
||||||
grammarBuilder.append(" | a=e op=('+'|'-') b=e {}<p=3>{True}?<fail='Message'>\n");
|
grammarBuilder.append(" | a=e op=('+'|'-') b=e {}<p=3>{True}?<fail='Message'>\n");
|
||||||
grammarBuilder.append(" | INT {}{}\n");
|
grammarBuilder.append(" | INT {}{}\n");
|
||||||
|
@ -1833,9 +1833,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testMultipleActions_1() throws Exception {
|
public void testMultipleActions_1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(141);
|
StringBuilder grammarBuilder = new StringBuilder(192);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e ;\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e ;\n");
|
||||||
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{}\n");
|
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{}\n");
|
||||||
grammarBuilder.append(" | INT {}{}\n");
|
grammarBuilder.append(" | INT {}{}\n");
|
||||||
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
|
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
|
||||||
|
@ -1858,9 +1858,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testMultipleActions_2() throws Exception {
|
public void testMultipleActions_2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(141);
|
StringBuilder grammarBuilder = new StringBuilder(192);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e ;\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e ;\n");
|
||||||
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{}\n");
|
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{}\n");
|
||||||
grammarBuilder.append(" | INT {}{}\n");
|
grammarBuilder.append(" | INT {}{}\n");
|
||||||
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
|
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
|
||||||
|
@ -1883,9 +1883,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testMultipleActions_3() throws Exception {
|
public void testMultipleActions_3() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(141);
|
StringBuilder grammarBuilder = new StringBuilder(192);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e ;\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e ;\n");
|
||||||
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{}\n");
|
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{}\n");
|
||||||
grammarBuilder.append(" | INT {}{}\n");
|
grammarBuilder.append(" | INT {}{}\n");
|
||||||
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
|
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
|
||||||
|
@ -1908,9 +1908,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testMultipleAlternativesWithCommonLabel_1() throws Exception {
|
public void testMultipleAlternativesWithCommonLabel_1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(550);
|
StringBuilder grammarBuilder = new StringBuilder(576);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s : e {};\n");
|
grammarBuilder.append("s : e {std::cout << $e.v << \"\\n\";};\n");
|
||||||
grammarBuilder.append("e returns [int v]\n");
|
grammarBuilder.append("e returns [int v]\n");
|
||||||
grammarBuilder.append(" : e '*' e {$v = $ctx.e(0).v * $ctx.e(1).v;} # binary\n");
|
grammarBuilder.append(" : e '*' e {$v = $ctx.e(0).v * $ctx.e(1).v;} # binary\n");
|
||||||
grammarBuilder.append(" | e '+' e {$v = $ctx.e(0).v + $ctx.e(1).v;} # binary\n");
|
grammarBuilder.append(" | e '+' e {$v = $ctx.e(0).v + $ctx.e(1).v;} # binary\n");
|
||||||
|
@ -1941,9 +1941,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testMultipleAlternativesWithCommonLabel_2() throws Exception {
|
public void testMultipleAlternativesWithCommonLabel_2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(550);
|
StringBuilder grammarBuilder = new StringBuilder(576);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s : e {};\n");
|
grammarBuilder.append("s : e {std::cout << $e.v << \"\\n\";};\n");
|
||||||
grammarBuilder.append("e returns [int v]\n");
|
grammarBuilder.append("e returns [int v]\n");
|
||||||
grammarBuilder.append(" : e '*' e {$v = $ctx.e(0).v * $ctx.e(1).v;} # binary\n");
|
grammarBuilder.append(" : e '*' e {$v = $ctx.e(0).v * $ctx.e(1).v;} # binary\n");
|
||||||
grammarBuilder.append(" | e '+' e {$v = $ctx.e(0).v + $ctx.e(1).v;} # binary\n");
|
grammarBuilder.append(" | e '+' e {$v = $ctx.e(0).v + $ctx.e(1).v;} # binary\n");
|
||||||
|
@ -1974,9 +1974,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testMultipleAlternativesWithCommonLabel_3() throws Exception {
|
public void testMultipleAlternativesWithCommonLabel_3() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(550);
|
StringBuilder grammarBuilder = new StringBuilder(576);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s : e {};\n");
|
grammarBuilder.append("s : e {std::cout << $e.v << \"\\n\";};\n");
|
||||||
grammarBuilder.append("e returns [int v]\n");
|
grammarBuilder.append("e returns [int v]\n");
|
||||||
grammarBuilder.append(" : e '*' e {$v = $ctx.e(0).v * $ctx.e(1).v;} # binary\n");
|
grammarBuilder.append(" : e '*' e {$v = $ctx.e(0).v * $ctx.e(1).v;} # binary\n");
|
||||||
grammarBuilder.append(" | e '+' e {$v = $ctx.e(0).v + $ctx.e(1).v;} # binary\n");
|
grammarBuilder.append(" | e '+' e {$v = $ctx.e(0).v + $ctx.e(1).v;} # binary\n");
|
||||||
|
@ -2007,9 +2007,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testMultipleAlternativesWithCommonLabel_4() throws Exception {
|
public void testMultipleAlternativesWithCommonLabel_4() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(550);
|
StringBuilder grammarBuilder = new StringBuilder(576);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s : e {};\n");
|
grammarBuilder.append("s : e {std::cout << $e.v << \"\\n\";};\n");
|
||||||
grammarBuilder.append("e returns [int v]\n");
|
grammarBuilder.append("e returns [int v]\n");
|
||||||
grammarBuilder.append(" : e '*' e {$v = $ctx.e(0).v * $ctx.e(1).v;} # binary\n");
|
grammarBuilder.append(" : e '*' e {$v = $ctx.e(0).v * $ctx.e(1).v;} # binary\n");
|
||||||
grammarBuilder.append(" | e '+' e {$v = $ctx.e(0).v + $ctx.e(1).v;} # binary\n");
|
grammarBuilder.append(" | e '+' e {$v = $ctx.e(0).v + $ctx.e(1).v;} # binary\n");
|
||||||
|
@ -2040,10 +2040,10 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testPrecedenceFilterConsidersContext() throws Exception {
|
public void testPrecedenceFilterConsidersContext() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(106);
|
StringBuilder grammarBuilder = new StringBuilder(157);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("prog \n");
|
grammarBuilder.append("prog \n");
|
||||||
grammarBuilder.append("@after {}\n");
|
grammarBuilder.append("@after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";}\n");
|
||||||
grammarBuilder.append(": statement* EOF {};\n");
|
grammarBuilder.append(": statement* EOF {};\n");
|
||||||
grammarBuilder.append("statement: letterA | statement letterA 'b' ;\n");
|
grammarBuilder.append("statement: letterA | statement letterA 'b' ;\n");
|
||||||
grammarBuilder.append("letterA: 'a';");
|
grammarBuilder.append("letterA: 'a';");
|
||||||
|
@ -2063,9 +2063,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testPrefixAndOtherAlt_1() throws Exception {
|
public void testPrefixAndOtherAlt_1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(180);
|
StringBuilder grammarBuilder = new StringBuilder(231);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : expr EOF ; \n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : expr EOF ; \n");
|
||||||
grammarBuilder.append("expr : literal\n");
|
grammarBuilder.append("expr : literal\n");
|
||||||
grammarBuilder.append(" | op expr\n");
|
grammarBuilder.append(" | op expr\n");
|
||||||
grammarBuilder.append(" | expr op expr\n");
|
grammarBuilder.append(" | expr op expr\n");
|
||||||
|
@ -2090,9 +2090,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testPrefixAndOtherAlt_2() throws Exception {
|
public void testPrefixAndOtherAlt_2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(180);
|
StringBuilder grammarBuilder = new StringBuilder(231);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : expr EOF ; \n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : expr EOF ; \n");
|
||||||
grammarBuilder.append("expr : literal\n");
|
grammarBuilder.append("expr : literal\n");
|
||||||
grammarBuilder.append(" | op expr\n");
|
grammarBuilder.append(" | op expr\n");
|
||||||
grammarBuilder.append(" | expr op expr\n");
|
grammarBuilder.append(" | expr op expr\n");
|
||||||
|
@ -2117,9 +2117,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testPrefixOpWithActionAndLabel_1() throws Exception {
|
public void testPrefixOpWithActionAndLabel_1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(313);
|
StringBuilder grammarBuilder = new StringBuilder(344);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s : e {} ;\n");
|
grammarBuilder.append("s : e {std::cout << $e.result << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("e returns [String result]\n");
|
grammarBuilder.append("e returns [String result]\n");
|
||||||
grammarBuilder.append(" : ID '=' e1=e {$result = \"(\" + $ID.text + \"=\" + $e1.result + \")\";}\n");
|
grammarBuilder.append(" : ID '=' e1=e {$result = \"(\" + $ID.text + \"=\" + $e1.result + \")\";}\n");
|
||||||
grammarBuilder.append(" | ID {$result = $ID.text;}\n");
|
grammarBuilder.append(" | ID {$result = $ID.text;}\n");
|
||||||
|
@ -2144,9 +2144,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testPrefixOpWithActionAndLabel_2() throws Exception {
|
public void testPrefixOpWithActionAndLabel_2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(313);
|
StringBuilder grammarBuilder = new StringBuilder(344);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s : e {} ;\n");
|
grammarBuilder.append("s : e {std::cout << $e.result << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("e returns [String result]\n");
|
grammarBuilder.append("e returns [String result]\n");
|
||||||
grammarBuilder.append(" : ID '=' e1=e {$result = \"(\" + $ID.text + \"=\" + $e1.result + \")\";}\n");
|
grammarBuilder.append(" : ID '=' e1=e {$result = \"(\" + $ID.text + \"=\" + $e1.result + \")\";}\n");
|
||||||
grammarBuilder.append(" | ID {$result = $ID.text;}\n");
|
grammarBuilder.append(" | ID {$result = $ID.text;}\n");
|
||||||
|
@ -2171,9 +2171,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testPrefixOpWithActionAndLabel_3() throws Exception {
|
public void testPrefixOpWithActionAndLabel_3() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(313);
|
StringBuilder grammarBuilder = new StringBuilder(344);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s : e {} ;\n");
|
grammarBuilder.append("s : e {std::cout << $e.result << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("e returns [String result]\n");
|
grammarBuilder.append("e returns [String result]\n");
|
||||||
grammarBuilder.append(" : ID '=' e1=e {$result = \"(\" + $ID.text + \"=\" + $e1.result + \")\";}\n");
|
grammarBuilder.append(" : ID '=' e1=e {$result = \"(\" + $ID.text + \"=\" + $e1.result + \")\";}\n");
|
||||||
grammarBuilder.append(" | ID {$result = $ID.text;}\n");
|
grammarBuilder.append(" | ID {$result = $ID.text;}\n");
|
||||||
|
@ -2198,9 +2198,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testReturnValueAndActionsAndLabels_1() throws Exception {
|
public void testReturnValueAndActionsAndLabels_1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(436);
|
StringBuilder grammarBuilder = new StringBuilder(462);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s : q=e {}; \n");
|
grammarBuilder.append("s : q=e {std::cout << $e.v << \"\\n\";}; \n");
|
||||||
grammarBuilder.append("e returns [int v]\n");
|
grammarBuilder.append("e returns [int v]\n");
|
||||||
grammarBuilder.append(" : a=e op='*' b=e {$v = $a.v * $b.v;} # mult\n");
|
grammarBuilder.append(" : a=e op='*' b=e {$v = $a.v * $b.v;} # mult\n");
|
||||||
grammarBuilder.append(" | a=e '+' b=e {$v = $a.v + $b.v;} # add\n");
|
grammarBuilder.append(" | a=e '+' b=e {$v = $a.v + $b.v;} # add\n");
|
||||||
|
@ -2229,9 +2229,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testReturnValueAndActionsAndLabels_2() throws Exception {
|
public void testReturnValueAndActionsAndLabels_2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(436);
|
StringBuilder grammarBuilder = new StringBuilder(462);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s : q=e {}; \n");
|
grammarBuilder.append("s : q=e {std::cout << $e.v << \"\\n\";}; \n");
|
||||||
grammarBuilder.append("e returns [int v]\n");
|
grammarBuilder.append("e returns [int v]\n");
|
||||||
grammarBuilder.append(" : a=e op='*' b=e {$v = $a.v * $b.v;} # mult\n");
|
grammarBuilder.append(" : a=e op='*' b=e {$v = $a.v * $b.v;} # mult\n");
|
||||||
grammarBuilder.append(" | a=e '+' b=e {$v = $a.v + $b.v;} # add\n");
|
grammarBuilder.append(" | a=e '+' b=e {$v = $a.v + $b.v;} # add\n");
|
||||||
|
@ -2260,9 +2260,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testReturnValueAndActionsAndLabels_3() throws Exception {
|
public void testReturnValueAndActionsAndLabels_3() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(436);
|
StringBuilder grammarBuilder = new StringBuilder(462);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s : q=e {}; \n");
|
grammarBuilder.append("s : q=e {std::cout << $e.v << \"\\n\";}; \n");
|
||||||
grammarBuilder.append("e returns [int v]\n");
|
grammarBuilder.append("e returns [int v]\n");
|
||||||
grammarBuilder.append(" : a=e op='*' b=e {$v = $a.v * $b.v;} # mult\n");
|
grammarBuilder.append(" : a=e op='*' b=e {$v = $a.v * $b.v;} # mult\n");
|
||||||
grammarBuilder.append(" | a=e '+' b=e {$v = $a.v + $b.v;} # add\n");
|
grammarBuilder.append(" | a=e '+' b=e {$v = $a.v + $b.v;} # add\n");
|
||||||
|
@ -2291,9 +2291,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testReturnValueAndActionsAndLabels_4() throws Exception {
|
public void testReturnValueAndActionsAndLabels_4() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(436);
|
StringBuilder grammarBuilder = new StringBuilder(462);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s : q=e {}; \n");
|
grammarBuilder.append("s : q=e {std::cout << $e.v << \"\\n\";}; \n");
|
||||||
grammarBuilder.append("e returns [int v]\n");
|
grammarBuilder.append("e returns [int v]\n");
|
||||||
grammarBuilder.append(" : a=e op='*' b=e {$v = $a.v * $b.v;} # mult\n");
|
grammarBuilder.append(" : a=e op='*' b=e {$v = $a.v * $b.v;} # mult\n");
|
||||||
grammarBuilder.append(" | a=e '+' b=e {$v = $a.v + $b.v;} # add\n");
|
grammarBuilder.append(" | a=e '+' b=e {$v = $a.v + $b.v;} # add\n");
|
||||||
|
@ -2322,9 +2322,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testReturnValueAndActionsList1_1() throws Exception {
|
public void testReturnValueAndActionsList1_1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(264);
|
StringBuilder grammarBuilder = new StringBuilder(315);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : expr EOF;\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : expr EOF;\n");
|
||||||
grammarBuilder.append("expr:\n");
|
grammarBuilder.append("expr:\n");
|
||||||
grammarBuilder.append(" a=expr '*' a=expr #Factor\n");
|
grammarBuilder.append(" a=expr '*' a=expr #Factor\n");
|
||||||
grammarBuilder.append(" | b+=expr (',' b+=expr)* '>>' c=expr #Send\n");
|
grammarBuilder.append(" | b+=expr (',' b+=expr)* '>>' c=expr #Send\n");
|
||||||
|
@ -2352,9 +2352,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testReturnValueAndActionsList1_2() throws Exception {
|
public void testReturnValueAndActionsList1_2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(264);
|
StringBuilder grammarBuilder = new StringBuilder(315);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : expr EOF;\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : expr EOF;\n");
|
||||||
grammarBuilder.append("expr:\n");
|
grammarBuilder.append("expr:\n");
|
||||||
grammarBuilder.append(" a=expr '*' a=expr #Factor\n");
|
grammarBuilder.append(" a=expr '*' a=expr #Factor\n");
|
||||||
grammarBuilder.append(" | b+=expr (',' b+=expr)* '>>' c=expr #Send\n");
|
grammarBuilder.append(" | b+=expr (',' b+=expr)* '>>' c=expr #Send\n");
|
||||||
|
@ -2382,9 +2382,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testReturnValueAndActionsList1_3() throws Exception {
|
public void testReturnValueAndActionsList1_3() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(264);
|
StringBuilder grammarBuilder = new StringBuilder(315);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : expr EOF;\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : expr EOF;\n");
|
||||||
grammarBuilder.append("expr:\n");
|
grammarBuilder.append("expr:\n");
|
||||||
grammarBuilder.append(" a=expr '*' a=expr #Factor\n");
|
grammarBuilder.append(" a=expr '*' a=expr #Factor\n");
|
||||||
grammarBuilder.append(" | b+=expr (',' b+=expr)* '>>' c=expr #Send\n");
|
grammarBuilder.append(" | b+=expr (',' b+=expr)* '>>' c=expr #Send\n");
|
||||||
|
@ -2412,9 +2412,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testReturnValueAndActionsList1_4() throws Exception {
|
public void testReturnValueAndActionsList1_4() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(264);
|
StringBuilder grammarBuilder = new StringBuilder(315);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : expr EOF;\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : expr EOF;\n");
|
||||||
grammarBuilder.append("expr:\n");
|
grammarBuilder.append("expr:\n");
|
||||||
grammarBuilder.append(" a=expr '*' a=expr #Factor\n");
|
grammarBuilder.append(" a=expr '*' a=expr #Factor\n");
|
||||||
grammarBuilder.append(" | b+=expr (',' b+=expr)* '>>' c=expr #Send\n");
|
grammarBuilder.append(" | b+=expr (',' b+=expr)* '>>' c=expr #Send\n");
|
||||||
|
@ -2442,9 +2442,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testReturnValueAndActionsList2_1() throws Exception {
|
public void testReturnValueAndActionsList2_1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(281);
|
StringBuilder grammarBuilder = new StringBuilder(332);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : expr EOF;\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : expr EOF;\n");
|
||||||
grammarBuilder.append("expr:\n");
|
grammarBuilder.append("expr:\n");
|
||||||
grammarBuilder.append(" a=expr '*' a=expr #Factor\n");
|
grammarBuilder.append(" a=expr '*' a=expr #Factor\n");
|
||||||
grammarBuilder.append(" | b+=expr ',' b+=expr #Comma\n");
|
grammarBuilder.append(" | b+=expr ',' b+=expr #Comma\n");
|
||||||
|
@ -2471,9 +2471,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testReturnValueAndActionsList2_2() throws Exception {
|
public void testReturnValueAndActionsList2_2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(281);
|
StringBuilder grammarBuilder = new StringBuilder(332);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : expr EOF;\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : expr EOF;\n");
|
||||||
grammarBuilder.append("expr:\n");
|
grammarBuilder.append("expr:\n");
|
||||||
grammarBuilder.append(" a=expr '*' a=expr #Factor\n");
|
grammarBuilder.append(" a=expr '*' a=expr #Factor\n");
|
||||||
grammarBuilder.append(" | b+=expr ',' b+=expr #Comma\n");
|
grammarBuilder.append(" | b+=expr ',' b+=expr #Comma\n");
|
||||||
|
@ -2500,9 +2500,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testReturnValueAndActionsList2_3() throws Exception {
|
public void testReturnValueAndActionsList2_3() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(281);
|
StringBuilder grammarBuilder = new StringBuilder(332);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : expr EOF;\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : expr EOF;\n");
|
||||||
grammarBuilder.append("expr:\n");
|
grammarBuilder.append("expr:\n");
|
||||||
grammarBuilder.append(" a=expr '*' a=expr #Factor\n");
|
grammarBuilder.append(" a=expr '*' a=expr #Factor\n");
|
||||||
grammarBuilder.append(" | b+=expr ',' b+=expr #Comma\n");
|
grammarBuilder.append(" | b+=expr ',' b+=expr #Comma\n");
|
||||||
|
@ -2529,9 +2529,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testReturnValueAndActionsList2_4() throws Exception {
|
public void testReturnValueAndActionsList2_4() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(281);
|
StringBuilder grammarBuilder = new StringBuilder(332);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : expr EOF;\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : expr EOF;\n");
|
||||||
grammarBuilder.append("expr:\n");
|
grammarBuilder.append("expr:\n");
|
||||||
grammarBuilder.append(" a=expr '*' a=expr #Factor\n");
|
grammarBuilder.append(" a=expr '*' a=expr #Factor\n");
|
||||||
grammarBuilder.append(" | b+=expr ',' b+=expr #Comma\n");
|
grammarBuilder.append(" | b+=expr ',' b+=expr #Comma\n");
|
||||||
|
@ -2558,9 +2558,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testReturnValueAndActions_1() throws Exception {
|
public void testReturnValueAndActions_1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(224);
|
StringBuilder grammarBuilder = new StringBuilder(250);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s : e {}; \n");
|
grammarBuilder.append("s : e {std::cout << $e.v << \"\\n\";}; \n");
|
||||||
grammarBuilder.append("e returns [int v, ignored]\n");
|
grammarBuilder.append("e returns [int v, ignored]\n");
|
||||||
grammarBuilder.append(" : a=e '*' b=e {$v = $a.v * $b.v;}\n");
|
grammarBuilder.append(" : a=e '*' b=e {$v = $a.v * $b.v;}\n");
|
||||||
grammarBuilder.append(" | a=e '+' b=e {$v = $a.v + $b.v;}\n");
|
grammarBuilder.append(" | a=e '+' b=e {$v = $a.v + $b.v;}\n");
|
||||||
|
@ -2585,9 +2585,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testReturnValueAndActions_2() throws Exception {
|
public void testReturnValueAndActions_2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(224);
|
StringBuilder grammarBuilder = new StringBuilder(250);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s : e {}; \n");
|
grammarBuilder.append("s : e {std::cout << $e.v << \"\\n\";}; \n");
|
||||||
grammarBuilder.append("e returns [int v, ignored]\n");
|
grammarBuilder.append("e returns [int v, ignored]\n");
|
||||||
grammarBuilder.append(" : a=e '*' b=e {$v = $a.v * $b.v;}\n");
|
grammarBuilder.append(" : a=e '*' b=e {$v = $a.v * $b.v;}\n");
|
||||||
grammarBuilder.append(" | a=e '+' b=e {$v = $a.v + $b.v;}\n");
|
grammarBuilder.append(" | a=e '+' b=e {$v = $a.v + $b.v;}\n");
|
||||||
|
@ -2612,9 +2612,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testReturnValueAndActions_3() throws Exception {
|
public void testReturnValueAndActions_3() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(224);
|
StringBuilder grammarBuilder = new StringBuilder(250);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s : e {}; \n");
|
grammarBuilder.append("s : e {std::cout << $e.v << \"\\n\";}; \n");
|
||||||
grammarBuilder.append("e returns [int v, ignored]\n");
|
grammarBuilder.append("e returns [int v, ignored]\n");
|
||||||
grammarBuilder.append(" : a=e '*' b=e {$v = $a.v * $b.v;}\n");
|
grammarBuilder.append(" : a=e '*' b=e {$v = $a.v * $b.v;}\n");
|
||||||
grammarBuilder.append(" | a=e '+' b=e {$v = $a.v + $b.v;}\n");
|
grammarBuilder.append(" | a=e '+' b=e {$v = $a.v + $b.v;}\n");
|
||||||
|
@ -2639,9 +2639,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testReturnValueAndActions_4() throws Exception {
|
public void testReturnValueAndActions_4() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(224);
|
StringBuilder grammarBuilder = new StringBuilder(250);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s : e {}; \n");
|
grammarBuilder.append("s : e {std::cout << $e.v << \"\\n\";}; \n");
|
||||||
grammarBuilder.append("e returns [int v, ignored]\n");
|
grammarBuilder.append("e returns [int v, ignored]\n");
|
||||||
grammarBuilder.append(" : a=e '*' b=e {$v = $a.v * $b.v;}\n");
|
grammarBuilder.append(" : a=e '*' b=e {$v = $a.v * $b.v;}\n");
|
||||||
grammarBuilder.append(" | a=e '+' b=e {$v = $a.v + $b.v;}\n");
|
grammarBuilder.append(" | a=e '+' b=e {$v = $a.v + $b.v;}\n");
|
||||||
|
@ -2666,9 +2666,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testSemPred() throws Exception {
|
public void testSemPred() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(99);
|
StringBuilder grammarBuilder = new StringBuilder(150);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : a ;\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : a ;\n");
|
||||||
grammarBuilder.append("a : a {True}? ID\n");
|
grammarBuilder.append("a : a {True}? ID\n");
|
||||||
grammarBuilder.append(" | ID\n");
|
grammarBuilder.append(" | ID\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
|
@ -2690,10 +2690,10 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testSemPredFailOption() throws Exception {
|
public void testSemPredFailOption() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(123);
|
StringBuilder grammarBuilder = new StringBuilder(174);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : a ;\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : a ;\n");
|
||||||
grammarBuilder.append("a : a ID {False}?<fail='custom message'>\n");
|
grammarBuilder.append("a : a ID {false}?<fail='custom message'>\n");
|
||||||
grammarBuilder.append(" | ID\n");
|
grammarBuilder.append(" | ID\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
|
@ -2715,9 +2715,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testSimple_1() throws Exception {
|
public void testSimple_1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(91);
|
StringBuilder grammarBuilder = new StringBuilder(142);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : a ;\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : a ;\n");
|
||||||
grammarBuilder.append("a : a ID\n");
|
grammarBuilder.append("a : a ID\n");
|
||||||
grammarBuilder.append(" | ID\n");
|
grammarBuilder.append(" | ID\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
|
@ -2739,9 +2739,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testSimple_2() throws Exception {
|
public void testSimple_2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(91);
|
StringBuilder grammarBuilder = new StringBuilder(142);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : a ;\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : a ;\n");
|
||||||
grammarBuilder.append("a : a ID\n");
|
grammarBuilder.append("a : a ID\n");
|
||||||
grammarBuilder.append(" | ID\n");
|
grammarBuilder.append(" | ID\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
|
@ -2763,9 +2763,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testSimple_3() throws Exception {
|
public void testSimple_3() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(91);
|
StringBuilder grammarBuilder = new StringBuilder(142);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : a ;\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : a ;\n");
|
||||||
grammarBuilder.append("a : a ID\n");
|
grammarBuilder.append("a : a ID\n");
|
||||||
grammarBuilder.append(" | ID\n");
|
grammarBuilder.append(" | ID\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
|
@ -2787,9 +2787,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testTernaryExprExplicitAssociativity_1() throws Exception {
|
public void testTernaryExprExplicitAssociativity_1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(247);
|
StringBuilder grammarBuilder = new StringBuilder(298);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
||||||
grammarBuilder.append("e :<assoc=right> e '*' e\n");
|
grammarBuilder.append("e :<assoc=right> e '*' e\n");
|
||||||
grammarBuilder.append(" |<assoc=right> e '+' e\n");
|
grammarBuilder.append(" |<assoc=right> e '+' e\n");
|
||||||
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
||||||
|
@ -2814,9 +2814,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testTernaryExprExplicitAssociativity_2() throws Exception {
|
public void testTernaryExprExplicitAssociativity_2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(247);
|
StringBuilder grammarBuilder = new StringBuilder(298);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
||||||
grammarBuilder.append("e :<assoc=right> e '*' e\n");
|
grammarBuilder.append("e :<assoc=right> e '*' e\n");
|
||||||
grammarBuilder.append(" |<assoc=right> e '+' e\n");
|
grammarBuilder.append(" |<assoc=right> e '+' e\n");
|
||||||
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
||||||
|
@ -2841,9 +2841,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testTernaryExprExplicitAssociativity_3() throws Exception {
|
public void testTernaryExprExplicitAssociativity_3() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(247);
|
StringBuilder grammarBuilder = new StringBuilder(298);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
||||||
grammarBuilder.append("e :<assoc=right> e '*' e\n");
|
grammarBuilder.append("e :<assoc=right> e '*' e\n");
|
||||||
grammarBuilder.append(" |<assoc=right> e '+' e\n");
|
grammarBuilder.append(" |<assoc=right> e '+' e\n");
|
||||||
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
||||||
|
@ -2868,9 +2868,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testTernaryExprExplicitAssociativity_4() throws Exception {
|
public void testTernaryExprExplicitAssociativity_4() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(247);
|
StringBuilder grammarBuilder = new StringBuilder(298);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
||||||
grammarBuilder.append("e :<assoc=right> e '*' e\n");
|
grammarBuilder.append("e :<assoc=right> e '*' e\n");
|
||||||
grammarBuilder.append(" |<assoc=right> e '+' e\n");
|
grammarBuilder.append(" |<assoc=right> e '+' e\n");
|
||||||
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
||||||
|
@ -2895,9 +2895,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testTernaryExprExplicitAssociativity_5() throws Exception {
|
public void testTernaryExprExplicitAssociativity_5() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(247);
|
StringBuilder grammarBuilder = new StringBuilder(298);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
||||||
grammarBuilder.append("e :<assoc=right> e '*' e\n");
|
grammarBuilder.append("e :<assoc=right> e '*' e\n");
|
||||||
grammarBuilder.append(" |<assoc=right> e '+' e\n");
|
grammarBuilder.append(" |<assoc=right> e '+' e\n");
|
||||||
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
||||||
|
@ -2922,9 +2922,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testTernaryExprExplicitAssociativity_6() throws Exception {
|
public void testTernaryExprExplicitAssociativity_6() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(247);
|
StringBuilder grammarBuilder = new StringBuilder(298);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
||||||
grammarBuilder.append("e :<assoc=right> e '*' e\n");
|
grammarBuilder.append("e :<assoc=right> e '*' e\n");
|
||||||
grammarBuilder.append(" |<assoc=right> e '+' e\n");
|
grammarBuilder.append(" |<assoc=right> e '+' e\n");
|
||||||
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
||||||
|
@ -2949,9 +2949,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testTernaryExprExplicitAssociativity_7() throws Exception {
|
public void testTernaryExprExplicitAssociativity_7() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(247);
|
StringBuilder grammarBuilder = new StringBuilder(298);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
||||||
grammarBuilder.append("e :<assoc=right> e '*' e\n");
|
grammarBuilder.append("e :<assoc=right> e '*' e\n");
|
||||||
grammarBuilder.append(" |<assoc=right> e '+' e\n");
|
grammarBuilder.append(" |<assoc=right> e '+' e\n");
|
||||||
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
||||||
|
@ -2976,9 +2976,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testTernaryExprExplicitAssociativity_8() throws Exception {
|
public void testTernaryExprExplicitAssociativity_8() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(247);
|
StringBuilder grammarBuilder = new StringBuilder(298);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
||||||
grammarBuilder.append("e :<assoc=right> e '*' e\n");
|
grammarBuilder.append("e :<assoc=right> e '*' e\n");
|
||||||
grammarBuilder.append(" |<assoc=right> e '+' e\n");
|
grammarBuilder.append(" |<assoc=right> e '+' e\n");
|
||||||
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
||||||
|
@ -3003,9 +3003,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testTernaryExprExplicitAssociativity_9() throws Exception {
|
public void testTernaryExprExplicitAssociativity_9() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(247);
|
StringBuilder grammarBuilder = new StringBuilder(298);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
||||||
grammarBuilder.append("e :<assoc=right> e '*' e\n");
|
grammarBuilder.append("e :<assoc=right> e '*' e\n");
|
||||||
grammarBuilder.append(" |<assoc=right> e '+' e\n");
|
grammarBuilder.append(" |<assoc=right> e '+' e\n");
|
||||||
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
||||||
|
@ -3030,9 +3030,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testTernaryExpr_1() throws Exception {
|
public void testTernaryExpr_1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(222);
|
StringBuilder grammarBuilder = new StringBuilder(273);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF ; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF ; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
||||||
grammarBuilder.append("e : e '*' e\n");
|
grammarBuilder.append("e : e '*' e\n");
|
||||||
grammarBuilder.append(" | e '+' e\n");
|
grammarBuilder.append(" | e '+' e\n");
|
||||||
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
||||||
|
@ -3057,9 +3057,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testTernaryExpr_2() throws Exception {
|
public void testTernaryExpr_2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(222);
|
StringBuilder grammarBuilder = new StringBuilder(273);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF ; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF ; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
||||||
grammarBuilder.append("e : e '*' e\n");
|
grammarBuilder.append("e : e '*' e\n");
|
||||||
grammarBuilder.append(" | e '+' e\n");
|
grammarBuilder.append(" | e '+' e\n");
|
||||||
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
||||||
|
@ -3084,9 +3084,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testTernaryExpr_3() throws Exception {
|
public void testTernaryExpr_3() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(222);
|
StringBuilder grammarBuilder = new StringBuilder(273);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF ; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF ; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
||||||
grammarBuilder.append("e : e '*' e\n");
|
grammarBuilder.append("e : e '*' e\n");
|
||||||
grammarBuilder.append(" | e '+' e\n");
|
grammarBuilder.append(" | e '+' e\n");
|
||||||
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
||||||
|
@ -3111,9 +3111,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testTernaryExpr_4() throws Exception {
|
public void testTernaryExpr_4() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(222);
|
StringBuilder grammarBuilder = new StringBuilder(273);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF ; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF ; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
||||||
grammarBuilder.append("e : e '*' e\n");
|
grammarBuilder.append("e : e '*' e\n");
|
||||||
grammarBuilder.append(" | e '+' e\n");
|
grammarBuilder.append(" | e '+' e\n");
|
||||||
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
||||||
|
@ -3138,9 +3138,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testTernaryExpr_5() throws Exception {
|
public void testTernaryExpr_5() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(222);
|
StringBuilder grammarBuilder = new StringBuilder(273);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF ; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF ; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
||||||
grammarBuilder.append("e : e '*' e\n");
|
grammarBuilder.append("e : e '*' e\n");
|
||||||
grammarBuilder.append(" | e '+' e\n");
|
grammarBuilder.append(" | e '+' e\n");
|
||||||
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
||||||
|
@ -3165,9 +3165,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testTernaryExpr_6() throws Exception {
|
public void testTernaryExpr_6() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(222);
|
StringBuilder grammarBuilder = new StringBuilder(273);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF ; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF ; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
||||||
grammarBuilder.append("e : e '*' e\n");
|
grammarBuilder.append("e : e '*' e\n");
|
||||||
grammarBuilder.append(" | e '+' e\n");
|
grammarBuilder.append(" | e '+' e\n");
|
||||||
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
||||||
|
@ -3192,9 +3192,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testTernaryExpr_7() throws Exception {
|
public void testTernaryExpr_7() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(222);
|
StringBuilder grammarBuilder = new StringBuilder(273);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF ; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF ; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
||||||
grammarBuilder.append("e : e '*' e\n");
|
grammarBuilder.append("e : e '*' e\n");
|
||||||
grammarBuilder.append(" | e '+' e\n");
|
grammarBuilder.append(" | e '+' e\n");
|
||||||
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
||||||
|
@ -3219,9 +3219,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testTernaryExpr_8() throws Exception {
|
public void testTernaryExpr_8() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(222);
|
StringBuilder grammarBuilder = new StringBuilder(273);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF ; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF ; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
||||||
grammarBuilder.append("e : e '*' e\n");
|
grammarBuilder.append("e : e '*' e\n");
|
||||||
grammarBuilder.append(" | e '+' e\n");
|
grammarBuilder.append(" | e '+' e\n");
|
||||||
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
||||||
|
@ -3246,9 +3246,9 @@ public class TestLeftRecursion extends BaseCppTest {
|
||||||
public void testTernaryExpr_9() throws Exception {
|
public void testTernaryExpr_9() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(222);
|
StringBuilder grammarBuilder = new StringBuilder(273);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s @after {} : e EOF ; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
grammarBuilder.append("s @after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";} : e EOF ; // must indicate EOF can follow or 'a<EOF>' won't match\n");
|
||||||
grammarBuilder.append("e : e '*' e\n");
|
grammarBuilder.append("e : e '*' e\n");
|
||||||
grammarBuilder.append(" | e '+' e\n");
|
grammarBuilder.append(" | e '+' e\n");
|
||||||
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
grammarBuilder.append(" |<assoc=right> e '?' e ':' e\n");
|
||||||
|
|
|
@ -13,13 +13,13 @@ public class TestLexerExec extends BaseCppTest {
|
||||||
public void testActionPlacement() throws Exception {
|
public void testActionPlacement() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(92);
|
StringBuilder grammarBuilder = new StringBuilder(303);
|
||||||
grammarBuilder.append("lexer grammar L;\n");
|
grammarBuilder.append("lexer grammar L;\n");
|
||||||
grammarBuilder.append("I : ({} 'a'\n");
|
grammarBuilder.append("I : ({std::cout << \"stuff fail: \" + self.text << \"\\n\";} 'a'\n");
|
||||||
grammarBuilder.append("| {}\n");
|
grammarBuilder.append("| {std::cout << \"stuff0: \" + self.text << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" 'a' {}\n");
|
grammarBuilder.append(" 'a' {std::cout << \"stuff1: \" + self.text << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" 'b' {})\n");
|
grammarBuilder.append(" 'b' {std::cout << \"stuff2: \" + self.text << \"\\n\";})\n");
|
||||||
grammarBuilder.append(" {} ;\n");
|
grammarBuilder.append(" {std::cout << self.text << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;\n");
|
grammarBuilder.append("WS : (' '|'\\n') -> skip ;\n");
|
||||||
grammarBuilder.append("J : .;");
|
grammarBuilder.append("J : .;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
@ -42,9 +42,9 @@ public class TestLexerExec extends BaseCppTest {
|
||||||
public void testCharSet() throws Exception {
|
public void testCharSet() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(62);
|
StringBuilder grammarBuilder = new StringBuilder(87);
|
||||||
grammarBuilder.append("lexer grammar L;\n");
|
grammarBuilder.append("lexer grammar L;\n");
|
||||||
grammarBuilder.append("I : '0'..'9'+ {} ;\n");
|
grammarBuilder.append("I : '0'..'9'+ {std::cout << \"I\" << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("WS : [ \\n\\u000D] -> skip ;");
|
grammarBuilder.append("WS : [ \\n\\u000D] -> skip ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
@ -67,9 +67,9 @@ public class TestLexerExec extends BaseCppTest {
|
||||||
public void testCharSetInSet() throws Exception {
|
public void testCharSetInSet() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(69);
|
StringBuilder grammarBuilder = new StringBuilder(94);
|
||||||
grammarBuilder.append("lexer grammar L;\n");
|
grammarBuilder.append("lexer grammar L;\n");
|
||||||
grammarBuilder.append("I : (~[ab \\n]|'a') {} ;\n");
|
grammarBuilder.append("I : (~[ab \\n]|'a') {std::cout << \"I\" << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("WS : [ \\n\\u000D]+ -> skip ;");
|
grammarBuilder.append("WS : [ \\n\\u000D]+ -> skip ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
@ -90,9 +90,9 @@ public class TestLexerExec extends BaseCppTest {
|
||||||
public void testCharSetNot() throws Exception {
|
public void testCharSetNot() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(72);
|
StringBuilder grammarBuilder = new StringBuilder(97);
|
||||||
grammarBuilder.append("lexer grammar L;\n");
|
grammarBuilder.append("lexer grammar L;\n");
|
||||||
grammarBuilder.append("I : ~[ab \\n] ~[ \\ncd]* {} ;\n");
|
grammarBuilder.append("I : ~[ab \\n] ~[ \\ncd]* {std::cout << \"I\" << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("WS : [ \\n\\u000D]+ -> skip ;");
|
grammarBuilder.append("WS : [ \\n\\u000D]+ -> skip ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
@ -111,9 +111,9 @@ public class TestLexerExec extends BaseCppTest {
|
||||||
public void testCharSetPlus() throws Exception {
|
public void testCharSetPlus() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(63);
|
StringBuilder grammarBuilder = new StringBuilder(88);
|
||||||
grammarBuilder.append("lexer grammar L;\n");
|
grammarBuilder.append("lexer grammar L;\n");
|
||||||
grammarBuilder.append("I : '0'..'9'+ {} ;\n");
|
grammarBuilder.append("I : '0'..'9'+ {std::cout << \"I\" << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("WS : [ \\n\\u000D]+ -> skip ;");
|
grammarBuilder.append("WS : [ \\n\\u000D]+ -> skip ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
@ -136,10 +136,10 @@ public class TestLexerExec extends BaseCppTest {
|
||||||
public void testCharSetRange() throws Exception {
|
public void testCharSetRange() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(94);
|
StringBuilder grammarBuilder = new StringBuilder(145);
|
||||||
grammarBuilder.append("lexer grammar L;\n");
|
grammarBuilder.append("lexer grammar L;\n");
|
||||||
grammarBuilder.append("I : [0-9]+ {} ;\n");
|
grammarBuilder.append("I : [0-9]+ {std::cout << \"I\" << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("ID : [a-zA-Z] [a-zA-Z0-9]* {} ;\n");
|
grammarBuilder.append("ID : [a-zA-Z] [a-zA-Z0-9]* {std::cout << \"ID\" << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("WS : [ \\n\\u0009\\r]+ -> skip ;");
|
grammarBuilder.append("WS : [ \\n\\u0009\\r]+ -> skip ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
@ -167,9 +167,9 @@ public class TestLexerExec extends BaseCppTest {
|
||||||
public void testCharSetWithEscapedChar() throws Exception {
|
public void testCharSetWithEscapedChar() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(63);
|
StringBuilder grammarBuilder = new StringBuilder(96);
|
||||||
grammarBuilder.append("lexer grammar L;\n");
|
grammarBuilder.append("lexer grammar L;\n");
|
||||||
grammarBuilder.append("DASHBRACK : [\\-\\]]+ {} ;\n");
|
grammarBuilder.append("DASHBRACK : [\\-\\]]+ {std::cout << \"DASHBRACK\" << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("WS : [ \\u]+ -> skip ;");
|
grammarBuilder.append("WS : [ \\u]+ -> skip ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
@ -190,9 +190,9 @@ public class TestLexerExec extends BaseCppTest {
|
||||||
public void testCharSetWithMissingEndRange() throws Exception {
|
public void testCharSetWithMissingEndRange() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(59);
|
StringBuilder grammarBuilder = new StringBuilder(84);
|
||||||
grammarBuilder.append("lexer grammar L;\n");
|
grammarBuilder.append("lexer grammar L;\n");
|
||||||
grammarBuilder.append("I : [0-]+ {} ;\n");
|
grammarBuilder.append("I : [0-]+ {std::cout << \"I\" << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("WS : [ \\n\\u000D]+ -> skip ;");
|
grammarBuilder.append("WS : [ \\n\\u000D]+ -> skip ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
@ -211,9 +211,9 @@ public class TestLexerExec extends BaseCppTest {
|
||||||
public void testCharSetWithMissingEscapeChar() throws Exception {
|
public void testCharSetWithMissingEscapeChar() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(54);
|
StringBuilder grammarBuilder = new StringBuilder(79);
|
||||||
grammarBuilder.append("lexer grammar L;\n");
|
grammarBuilder.append("lexer grammar L;\n");
|
||||||
grammarBuilder.append("I : [0-9]+ {} ;\n");
|
grammarBuilder.append("I : [0-9]+ {std::cout << \"I\" << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("WS : [ \\u]+ -> skip ;");
|
grammarBuilder.append("WS : [ \\u]+ -> skip ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
@ -232,9 +232,9 @@ public class TestLexerExec extends BaseCppTest {
|
||||||
public void testCharSetWithQuote1() throws Exception {
|
public void testCharSetWithQuote1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(57);
|
StringBuilder grammarBuilder = new StringBuilder(82);
|
||||||
grammarBuilder.append("lexer grammar L;\n");
|
grammarBuilder.append("lexer grammar L;\n");
|
||||||
grammarBuilder.append("A : [\"a-z]+ {} ;\n");
|
grammarBuilder.append("A : [\"a-z]+ {std::cout << \"A\" << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("WS : [ \\n\\t]+ -> skip ;");
|
grammarBuilder.append("WS : [ \\n\\t]+ -> skip ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
@ -253,9 +253,9 @@ public class TestLexerExec extends BaseCppTest {
|
||||||
public void testCharSetWithQuote2() throws Exception {
|
public void testCharSetWithQuote2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(58);
|
StringBuilder grammarBuilder = new StringBuilder(83);
|
||||||
grammarBuilder.append("lexer grammar L;\n");
|
grammarBuilder.append("lexer grammar L;\n");
|
||||||
grammarBuilder.append("A : [\"\\\\ab]+ {} ;\n");
|
grammarBuilder.append("A : [\"\\\\ab]+ {std::cout << \"A\" << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("WS : [ \\n\\t]+ -> skip ;");
|
grammarBuilder.append("WS : [ \\n\\t]+ -> skip ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
@ -274,9 +274,9 @@ public class TestLexerExec extends BaseCppTest {
|
||||||
public void testCharSetWithReversedRange() throws Exception {
|
public void testCharSetWithReversedRange() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(55);
|
StringBuilder grammarBuilder = new StringBuilder(80);
|
||||||
grammarBuilder.append("lexer grammar L;\n");
|
grammarBuilder.append("lexer grammar L;\n");
|
||||||
grammarBuilder.append("A : [z-a9]+ {} ;\n");
|
grammarBuilder.append("A : [z-a9]+ {std::cout << \"A\" << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("WS : [ \\u]+ -> skip ;");
|
grammarBuilder.append("WS : [ \\u]+ -> skip ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
@ -377,9 +377,9 @@ public class TestLexerExec extends BaseCppTest {
|
||||||
public void testGreedyConfigs() throws Exception {
|
public void testGreedyConfigs() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(71);
|
StringBuilder grammarBuilder = new StringBuilder(102);
|
||||||
grammarBuilder.append("lexer grammar L;\n");
|
grammarBuilder.append("lexer grammar L;\n");
|
||||||
grammarBuilder.append("I : ('a' | 'ab') {} ;\n");
|
grammarBuilder.append("I : ('a' | 'ab') {std::cout << self.text << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;\n");
|
grammarBuilder.append("WS : (' '|'\\n') -> skip ;\n");
|
||||||
grammarBuilder.append("J : .;");
|
grammarBuilder.append("J : .;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
@ -4549,11 +4549,11 @@ public class TestLexerExec extends BaseCppTest {
|
||||||
public void testNonGreedyConfigs() throws Exception {
|
public void testNonGreedyConfigs() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(78);
|
StringBuilder grammarBuilder = new StringBuilder(140);
|
||||||
grammarBuilder.append("lexer grammar L;\n");
|
grammarBuilder.append("lexer grammar L;\n");
|
||||||
grammarBuilder.append("I : .*? ('a' | 'ab') {} ;\n");
|
grammarBuilder.append("I : .*? ('a' | 'ab') {std::cout << self.text << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;\n");
|
grammarBuilder.append("WS : (' '|'\\n') -> skip ;\n");
|
||||||
grammarBuilder.append("J : . {};");
|
grammarBuilder.append("J : . {std::cout << self.text << \"\\n\";};");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
String input ="ab";
|
String input ="ab";
|
||||||
|
|
|
@ -13,16 +13,26 @@ public class TestListeners extends BaseCppTest {
|
||||||
public void testBasic() throws Exception {
|
public void testBasic() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(248);
|
StringBuilder grammarBuilder = new StringBuilder(533);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("@parser::header {\n");
|
grammarBuilder.append("@parser::header {\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append("\n");
|
grammarBuilder.append("\n");
|
||||||
grammarBuilder.append("@parser::members {\n");
|
grammarBuilder.append("@parser::members {\n");
|
||||||
|
grammarBuilder.append("if __name__ is not None and \".\" in __name__:\n");
|
||||||
|
grammarBuilder.append(" from .TListener import TListener\n");
|
||||||
|
grammarBuilder.append("else:\n");
|
||||||
|
grammarBuilder.append(" from TListener import TListener\n");
|
||||||
|
grammarBuilder.append("\n");
|
||||||
|
grammarBuilder.append("class LeafListener(TListener):\n");
|
||||||
|
grammarBuilder.append(" def visitTerminal(self, node):\n");
|
||||||
|
grammarBuilder.append(" std::cout << node.symbol.text;\n");
|
||||||
|
grammarBuilder.append("\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append("\n");
|
grammarBuilder.append("\n");
|
||||||
grammarBuilder.append("s\n");
|
grammarBuilder.append("s\n");
|
||||||
grammarBuilder.append("@after {\n");
|
grammarBuilder.append("@after {\n");
|
||||||
|
grammarBuilder.append("std::cout << $ctx.r.toStringTree(recog=self) << \"\\n\";\n");
|
||||||
grammarBuilder.append("walker = ParseTreeWalker()\n");
|
grammarBuilder.append("walker = ParseTreeWalker()\n");
|
||||||
grammarBuilder.append("walker.walk(TParser.LeafListener(), $ctx.r)\n");
|
grammarBuilder.append("walker.walk(TParser.LeafListener(), $ctx.r)\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
|
@ -54,16 +64,29 @@ public class TestListeners extends BaseCppTest {
|
||||||
public void testLR() throws Exception {
|
public void testLR() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(263);
|
StringBuilder grammarBuilder = new StringBuilder(705);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("@parser::header {\n");
|
grammarBuilder.append("@parser::header {\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append("\n");
|
grammarBuilder.append("\n");
|
||||||
grammarBuilder.append("@parser::members {\n");
|
grammarBuilder.append("@parser::members {\n");
|
||||||
|
grammarBuilder.append("if __name__ is not None and \".\" in __name__:\n");
|
||||||
|
grammarBuilder.append(" from .TListener import TListener\n");
|
||||||
|
grammarBuilder.append("else:\n");
|
||||||
|
grammarBuilder.append(" from TListener import TListener\n");
|
||||||
|
grammarBuilder.append("\n");
|
||||||
|
grammarBuilder.append("class LeafListener(TListener):\n");
|
||||||
|
grammarBuilder.append(" def exitE(self, ctx):\n");
|
||||||
|
grammarBuilder.append(" if ctx.getChildCount()==3:\n");
|
||||||
|
grammarBuilder.append(" std::cout << ctx.e(0).start.text << \" \" << ctx.e(1).start.text << \" \" << ctx.e()[0].start.text;\n");
|
||||||
|
grammarBuilder.append(" else:\n");
|
||||||
|
grammarBuilder.append(" std::cout << ctx.INT().symbol.text;\n");
|
||||||
|
grammarBuilder.append("\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append("\n");
|
grammarBuilder.append("\n");
|
||||||
grammarBuilder.append("s\n");
|
grammarBuilder.append("s\n");
|
||||||
grammarBuilder.append("@after {\n");
|
grammarBuilder.append("@after {\n");
|
||||||
|
grammarBuilder.append("std::cout << $ctx.r.toStringTree(recog=self) << \"\\n\";\n");
|
||||||
grammarBuilder.append("walker = ParseTreeWalker()\n");
|
grammarBuilder.append("walker = ParseTreeWalker()\n");
|
||||||
grammarBuilder.append("walker.walk(TParser.LeafListener(), $ctx.r)\n");
|
grammarBuilder.append("walker.walk(TParser.LeafListener(), $ctx.r)\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
|
@ -99,16 +122,28 @@ public class TestListeners extends BaseCppTest {
|
||||||
public void testLRWithLabels() throws Exception {
|
public void testLRWithLabels() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(303);
|
StringBuilder grammarBuilder = new StringBuilder(683);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("@parser::header {\n");
|
grammarBuilder.append("@parser::header {\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append("\n");
|
grammarBuilder.append("\n");
|
||||||
grammarBuilder.append("@parser::members {\n");
|
grammarBuilder.append("@parser::members {\n");
|
||||||
|
grammarBuilder.append("if __name__ is not None and \".\" in __name__:\n");
|
||||||
|
grammarBuilder.append(" from .TListener import TListener\n");
|
||||||
|
grammarBuilder.append("else:\n");
|
||||||
|
grammarBuilder.append(" from TListener import TListener\n");
|
||||||
|
grammarBuilder.append("\n");
|
||||||
|
grammarBuilder.append("class LeafListener(TListener):\n");
|
||||||
|
grammarBuilder.append(" def exitCall(self, ctx):\n");
|
||||||
|
grammarBuilder.append(" std::cout << ctx.e().start.text << \" \" << str(ctx.eList());\n");
|
||||||
|
grammarBuilder.append(" def exitInt(self, ctx):\n");
|
||||||
|
grammarBuilder.append(" std::cout << ctx.INT().symbol.text;\n");
|
||||||
|
grammarBuilder.append("\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append("\n");
|
grammarBuilder.append("\n");
|
||||||
grammarBuilder.append("s\n");
|
grammarBuilder.append("s\n");
|
||||||
grammarBuilder.append("@after {\n");
|
grammarBuilder.append("@after {\n");
|
||||||
|
grammarBuilder.append("std::cout << $ctx.r.toStringTree(recog=self) << \"\\n\";\n");
|
||||||
grammarBuilder.append("walker = ParseTreeWalker()\n");
|
grammarBuilder.append("walker = ParseTreeWalker()\n");
|
||||||
grammarBuilder.append("walker.walk(TParser.LeafListener(), $ctx.r)\n");
|
grammarBuilder.append("walker.walk(TParser.LeafListener(), $ctx.r)\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
|
@ -143,16 +178,30 @@ public class TestListeners extends BaseCppTest {
|
||||||
public void testRuleGetters_1() throws Exception {
|
public void testRuleGetters_1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(290);
|
StringBuilder grammarBuilder = new StringBuilder(732);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("@parser::header {\n");
|
grammarBuilder.append("@parser::header {\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append("\n");
|
grammarBuilder.append("\n");
|
||||||
grammarBuilder.append("@parser::members {\n");
|
grammarBuilder.append("@parser::members {\n");
|
||||||
|
grammarBuilder.append("if __name__ is not None and \".\" in __name__:\n");
|
||||||
|
grammarBuilder.append(" from .TListener import TListener\n");
|
||||||
|
grammarBuilder.append("else:\n");
|
||||||
|
grammarBuilder.append(" from TListener import TListener\n");
|
||||||
|
grammarBuilder.append("\n");
|
||||||
|
grammarBuilder.append("class LeafListener(TListener):\n");
|
||||||
|
grammarBuilder.append(" def exitA(self, ctx):\n");
|
||||||
|
grammarBuilder.append(" if (ctx.getChildCount()==2) {\n");
|
||||||
|
grammarBuilder.append(" std::cout << ctx.b(0).start.text << \" \" << ctx.b(1).start.text << \" \" << ctx.b()[0].start.text;\n");
|
||||||
|
grammarBuilder.append(" } else {\n");
|
||||||
|
grammarBuilder.append(" std::cout << ctx.b(0).start.text;\n");
|
||||||
|
grammarBuilder.append(" }\n");
|
||||||
|
grammarBuilder.append("\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append("\n");
|
grammarBuilder.append("\n");
|
||||||
grammarBuilder.append("s\n");
|
grammarBuilder.append("s\n");
|
||||||
grammarBuilder.append("@after {\n");
|
grammarBuilder.append("@after {\n");
|
||||||
|
grammarBuilder.append("std::cout << $ctx.r.toStringTree(recog=self) << \"\\n\";\n");
|
||||||
grammarBuilder.append("walker = ParseTreeWalker()\n");
|
grammarBuilder.append("walker = ParseTreeWalker()\n");
|
||||||
grammarBuilder.append("walker.walk(TParser.LeafListener(), $ctx.r)\n");
|
grammarBuilder.append("walker.walk(TParser.LeafListener(), $ctx.r)\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
|
@ -184,16 +233,30 @@ public class TestListeners extends BaseCppTest {
|
||||||
public void testRuleGetters_2() throws Exception {
|
public void testRuleGetters_2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(290);
|
StringBuilder grammarBuilder = new StringBuilder(732);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("@parser::header {\n");
|
grammarBuilder.append("@parser::header {\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append("\n");
|
grammarBuilder.append("\n");
|
||||||
grammarBuilder.append("@parser::members {\n");
|
grammarBuilder.append("@parser::members {\n");
|
||||||
|
grammarBuilder.append("if __name__ is not None and \".\" in __name__:\n");
|
||||||
|
grammarBuilder.append(" from .TListener import TListener\n");
|
||||||
|
grammarBuilder.append("else:\n");
|
||||||
|
grammarBuilder.append(" from TListener import TListener\n");
|
||||||
|
grammarBuilder.append("\n");
|
||||||
|
grammarBuilder.append("class LeafListener(TListener):\n");
|
||||||
|
grammarBuilder.append(" def exitA(self, ctx):\n");
|
||||||
|
grammarBuilder.append(" if (ctx.getChildCount()==2) {\n");
|
||||||
|
grammarBuilder.append(" std::cout << ctx.b(0).start.text << \" \" << ctx.b(1).start.text << \" \" << ctx.b()[0].start.text;\n");
|
||||||
|
grammarBuilder.append(" } else {\n");
|
||||||
|
grammarBuilder.append(" std::cout << ctx.b(0).start.text;\n");
|
||||||
|
grammarBuilder.append(" }\n");
|
||||||
|
grammarBuilder.append("\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append("\n");
|
grammarBuilder.append("\n");
|
||||||
grammarBuilder.append("s\n");
|
grammarBuilder.append("s\n");
|
||||||
grammarBuilder.append("@after {\n");
|
grammarBuilder.append("@after {\n");
|
||||||
|
grammarBuilder.append("std::cout << $ctx.r.toStringTree(recog=self) << \"\\n\";\n");
|
||||||
grammarBuilder.append("walker = ParseTreeWalker()\n");
|
grammarBuilder.append("walker = ParseTreeWalker()\n");
|
||||||
grammarBuilder.append("walker.walk(TParser.LeafListener(), $ctx.r)\n");
|
grammarBuilder.append("walker.walk(TParser.LeafListener(), $ctx.r)\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
|
@ -225,16 +288,30 @@ public class TestListeners extends BaseCppTest {
|
||||||
public void testTokenGetters_1() throws Exception {
|
public void testTokenGetters_1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(248);
|
StringBuilder grammarBuilder = new StringBuilder(702);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("@parser::header {\n");
|
grammarBuilder.append("@parser::header {\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append("\n");
|
grammarBuilder.append("\n");
|
||||||
grammarBuilder.append("@parser::members {\n");
|
grammarBuilder.append("@parser::members {\n");
|
||||||
|
grammarBuilder.append("if __name__ is not None and \".\" in __name__:\n");
|
||||||
|
grammarBuilder.append(" from .TListener import TListener\n");
|
||||||
|
grammarBuilder.append("else:\n");
|
||||||
|
grammarBuilder.append(" from TListener import TListener\n");
|
||||||
|
grammarBuilder.append("\n");
|
||||||
|
grammarBuilder.append("class LeafListener(TListener):\n");
|
||||||
|
grammarBuilder.append(" def exitA(self, ctx):\n");
|
||||||
|
grammarBuilder.append(" if (ctx.getChildCount()==2) {\n");
|
||||||
|
grammarBuilder.append(" std::cout << ctx.INT(0).symbol.text << \" \" << ctx.INT(1).symbol.text << \" \" << str_list(ctx.INT());\n");
|
||||||
|
grammarBuilder.append(" } else {\n");
|
||||||
|
grammarBuilder.append(" std::cout << str(ctx.ID().symbol);\n");
|
||||||
|
grammarBuilder.append(" }\n");
|
||||||
|
grammarBuilder.append("\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append("\n");
|
grammarBuilder.append("\n");
|
||||||
grammarBuilder.append("s\n");
|
grammarBuilder.append("s\n");
|
||||||
grammarBuilder.append("@after {\n");
|
grammarBuilder.append("@after {\n");
|
||||||
|
grammarBuilder.append("std::cout << $ctx.r.toStringTree(recog=self) << \"\\n\";\n");
|
||||||
grammarBuilder.append("walker = ParseTreeWalker()\n");
|
grammarBuilder.append("walker = ParseTreeWalker()\n");
|
||||||
grammarBuilder.append("walker.walk(TParser.LeafListener(), $ctx.r)\n");
|
grammarBuilder.append("walker.walk(TParser.LeafListener(), $ctx.r)\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
|
@ -265,16 +342,30 @@ public class TestListeners extends BaseCppTest {
|
||||||
public void testTokenGetters_2() throws Exception {
|
public void testTokenGetters_2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(248);
|
StringBuilder grammarBuilder = new StringBuilder(702);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("@parser::header {\n");
|
grammarBuilder.append("@parser::header {\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append("\n");
|
grammarBuilder.append("\n");
|
||||||
grammarBuilder.append("@parser::members {\n");
|
grammarBuilder.append("@parser::members {\n");
|
||||||
|
grammarBuilder.append("if __name__ is not None and \".\" in __name__:\n");
|
||||||
|
grammarBuilder.append(" from .TListener import TListener\n");
|
||||||
|
grammarBuilder.append("else:\n");
|
||||||
|
grammarBuilder.append(" from TListener import TListener\n");
|
||||||
|
grammarBuilder.append("\n");
|
||||||
|
grammarBuilder.append("class LeafListener(TListener):\n");
|
||||||
|
grammarBuilder.append(" def exitA(self, ctx):\n");
|
||||||
|
grammarBuilder.append(" if (ctx.getChildCount()==2) {\n");
|
||||||
|
grammarBuilder.append(" std::cout << ctx.INT(0).symbol.text << \" \" << ctx.INT(1).symbol.text << \" \" << str_list(ctx.INT());\n");
|
||||||
|
grammarBuilder.append(" } else {\n");
|
||||||
|
grammarBuilder.append(" std::cout << str(ctx.ID().symbol);\n");
|
||||||
|
grammarBuilder.append(" }\n");
|
||||||
|
grammarBuilder.append("\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append("\n");
|
grammarBuilder.append("\n");
|
||||||
grammarBuilder.append("s\n");
|
grammarBuilder.append("s\n");
|
||||||
grammarBuilder.append("@after {\n");
|
grammarBuilder.append("@after {\n");
|
||||||
|
grammarBuilder.append("std::cout << $ctx.r.toStringTree(recog=self) << \"\\n\";\n");
|
||||||
grammarBuilder.append("walker = ParseTreeWalker()\n");
|
grammarBuilder.append("walker = ParseTreeWalker()\n");
|
||||||
grammarBuilder.append("walker.walk(TParser.LeafListener(), $ctx.r)\n");
|
grammarBuilder.append("walker.walk(TParser.LeafListener(), $ctx.r)\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
|
|
|
@ -13,13 +13,14 @@ public class TestParseTrees extends BaseCppTest {
|
||||||
public void test2AltLoop() throws Exception {
|
public void test2AltLoop() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(97);
|
StringBuilder grammarBuilder = new StringBuilder(151);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s\n");
|
grammarBuilder.append("s\n");
|
||||||
grammarBuilder.append("@init {\n");
|
grammarBuilder.append("@init {\n");
|
||||||
grammarBuilder.append("self._buildParseTrees = True\n");
|
grammarBuilder.append("self._buildParseTrees = True\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append("@after {\n");
|
grammarBuilder.append("@after {\n");
|
||||||
|
grammarBuilder.append("std::cout << $r.ctx.toStringTree(recog=self) << \"\\n\";\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append(" : r=a ;\n");
|
grammarBuilder.append(" : r=a ;\n");
|
||||||
grammarBuilder.append("a : ('x' | 'y')* 'z'\n");
|
grammarBuilder.append("a : ('x' | 'y')* 'z'\n");
|
||||||
|
@ -40,13 +41,14 @@ public class TestParseTrees extends BaseCppTest {
|
||||||
public void test2Alts() throws Exception {
|
public void test2Alts() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(90);
|
StringBuilder grammarBuilder = new StringBuilder(144);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s\n");
|
grammarBuilder.append("s\n");
|
||||||
grammarBuilder.append("@init {\n");
|
grammarBuilder.append("@init {\n");
|
||||||
grammarBuilder.append("self._buildParseTrees = True\n");
|
grammarBuilder.append("self._buildParseTrees = True\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append("@after {\n");
|
grammarBuilder.append("@after {\n");
|
||||||
|
grammarBuilder.append("std::cout << $r.ctx.toStringTree(recog=self) << \"\\n\";\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append(" : r=a ;\n");
|
grammarBuilder.append(" : r=a ;\n");
|
||||||
grammarBuilder.append("a : 'x' | 'y'\n");
|
grammarBuilder.append("a : 'x' | 'y'\n");
|
||||||
|
@ -67,7 +69,7 @@ public class TestParseTrees extends BaseCppTest {
|
||||||
public void testAltNum() throws Exception {
|
public void testAltNum() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(523);
|
StringBuilder grammarBuilder = new StringBuilder(577);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("\n");
|
grammarBuilder.append("\n");
|
||||||
grammarBuilder.append("options { contextSuperClass=MyRuleNode; }\n");
|
grammarBuilder.append("options { contextSuperClass=MyRuleNode; }\n");
|
||||||
|
@ -89,6 +91,7 @@ public class TestParseTrees extends BaseCppTest {
|
||||||
grammarBuilder.append("self._buildParseTrees = True\n");
|
grammarBuilder.append("self._buildParseTrees = True\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append("@after {\n");
|
grammarBuilder.append("@after {\n");
|
||||||
|
grammarBuilder.append("std::cout << $r.ctx.toStringTree(recog=self) << \"\\n\";\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append(" : r=a ;\n");
|
grammarBuilder.append(" : r=a ;\n");
|
||||||
grammarBuilder.append("\n");
|
grammarBuilder.append("\n");
|
||||||
|
@ -114,13 +117,14 @@ public class TestParseTrees extends BaseCppTest {
|
||||||
public void testExtraToken() throws Exception {
|
public void testExtraToken() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(103);
|
StringBuilder grammarBuilder = new StringBuilder(157);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s\n");
|
grammarBuilder.append("s\n");
|
||||||
grammarBuilder.append("@init {\n");
|
grammarBuilder.append("@init {\n");
|
||||||
grammarBuilder.append("self._buildParseTrees = True\n");
|
grammarBuilder.append("self._buildParseTrees = True\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append("@after {\n");
|
grammarBuilder.append("@after {\n");
|
||||||
|
grammarBuilder.append("std::cout << $r.ctx.toStringTree(recog=self) << \"\\n\";\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append(" : r=a ;\n");
|
grammarBuilder.append(" : r=a ;\n");
|
||||||
grammarBuilder.append("a : 'x' 'y'\n");
|
grammarBuilder.append("a : 'x' 'y'\n");
|
||||||
|
@ -145,13 +149,14 @@ public class TestParseTrees extends BaseCppTest {
|
||||||
public void testNoViableAlt() throws Exception {
|
public void testNoViableAlt() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(105);
|
StringBuilder grammarBuilder = new StringBuilder(159);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s\n");
|
grammarBuilder.append("s\n");
|
||||||
grammarBuilder.append("@init {\n");
|
grammarBuilder.append("@init {\n");
|
||||||
grammarBuilder.append("self._buildParseTrees = True\n");
|
grammarBuilder.append("self._buildParseTrees = True\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append("@after {\n");
|
grammarBuilder.append("@after {\n");
|
||||||
|
grammarBuilder.append("std::cout << $r.ctx.toStringTree(recog=self) << \"\\n\";\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append(" : r=a ;\n");
|
grammarBuilder.append(" : r=a ;\n");
|
||||||
grammarBuilder.append("a : 'x' | 'y'\n");
|
grammarBuilder.append("a : 'x' | 'y'\n");
|
||||||
|
@ -176,13 +181,14 @@ public class TestParseTrees extends BaseCppTest {
|
||||||
public void testRuleRef() throws Exception {
|
public void testRuleRef() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(99);
|
StringBuilder grammarBuilder = new StringBuilder(153);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s\n");
|
grammarBuilder.append("s\n");
|
||||||
grammarBuilder.append("@init {\n");
|
grammarBuilder.append("@init {\n");
|
||||||
grammarBuilder.append("self._buildParseTrees = True\n");
|
grammarBuilder.append("self._buildParseTrees = True\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append("@after {\n");
|
grammarBuilder.append("@after {\n");
|
||||||
|
grammarBuilder.append("std::cout << $r.ctx.toStringTree(recog=self) << \"\\n\";\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append(" : r=a ;\n");
|
grammarBuilder.append(" : r=a ;\n");
|
||||||
grammarBuilder.append("a : b 'x'\n");
|
grammarBuilder.append("a : b 'x'\n");
|
||||||
|
@ -205,13 +211,14 @@ public class TestParseTrees extends BaseCppTest {
|
||||||
public void testSync() throws Exception {
|
public void testSync() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(106);
|
StringBuilder grammarBuilder = new StringBuilder(160);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s\n");
|
grammarBuilder.append("s\n");
|
||||||
grammarBuilder.append("@init {\n");
|
grammarBuilder.append("@init {\n");
|
||||||
grammarBuilder.append("self._buildParseTrees = True\n");
|
grammarBuilder.append("self._buildParseTrees = True\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append("@after {\n");
|
grammarBuilder.append("@after {\n");
|
||||||
|
grammarBuilder.append("std::cout << $r.ctx.toStringTree(recog=self) << \"\\n\";\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append(" : r=a ;\n");
|
grammarBuilder.append(" : r=a ;\n");
|
||||||
grammarBuilder.append("a : 'x' 'y'* '!'\n");
|
grammarBuilder.append("a : 'x' 'y'* '!'\n");
|
||||||
|
@ -235,13 +242,14 @@ public class TestParseTrees extends BaseCppTest {
|
||||||
public void testToken2() throws Exception {
|
public void testToken2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(88);
|
StringBuilder grammarBuilder = new StringBuilder(142);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s\n");
|
grammarBuilder.append("s\n");
|
||||||
grammarBuilder.append("@init {\n");
|
grammarBuilder.append("@init {\n");
|
||||||
grammarBuilder.append("self._buildParseTrees = True\n");
|
grammarBuilder.append("self._buildParseTrees = True\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append("@after {\n");
|
grammarBuilder.append("@after {\n");
|
||||||
|
grammarBuilder.append("std::cout << $r.ctx.toStringTree(recog=self) << \"\\n\";\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append(" : r=a ;\n");
|
grammarBuilder.append(" : r=a ;\n");
|
||||||
grammarBuilder.append("a : 'x' 'y'\n");
|
grammarBuilder.append("a : 'x' 'y'\n");
|
||||||
|
@ -262,16 +270,18 @@ public class TestParseTrees extends BaseCppTest {
|
||||||
public void testTokenAndRuleContextString() throws Exception {
|
public void testTokenAndRuleContextString() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(87);
|
StringBuilder grammarBuilder = new StringBuilder(203);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s\n");
|
grammarBuilder.append("s\n");
|
||||||
grammarBuilder.append("@init {\n");
|
grammarBuilder.append("@init {\n");
|
||||||
grammarBuilder.append("self._buildParseTrees = True\n");
|
grammarBuilder.append("self._buildParseTrees = True\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append("@after {\n");
|
grammarBuilder.append("@after {\n");
|
||||||
|
grammarBuilder.append("std::cout << $r.ctx.toStringTree(recog=self) << \"\\n\";\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append(" : r=a ;\n");
|
grammarBuilder.append(" : r=a ;\n");
|
||||||
grammarBuilder.append("a : 'x' { \n");
|
grammarBuilder.append("a : 'x' { \n");
|
||||||
|
grammarBuilder.append("std::cout << str_list(self.getRuleInvocationStack()) << \"\\n\";\n");
|
||||||
grammarBuilder.append("} ;");
|
grammarBuilder.append("} ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,9 @@ public class TestParserErrors extends BaseCppTest {
|
||||||
public void testConjuringUpToken() throws Exception {
|
public void testConjuringUpToken() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(33);
|
StringBuilder grammarBuilder = new StringBuilder(76);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : 'a' x='b' {} 'c' ;");
|
grammarBuilder.append("a : 'a' x='b' {std::cout << \"conjured=\" + str($x) << \"\\n\";} 'c' ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,9 +33,9 @@ public class TestParserErrors extends BaseCppTest {
|
||||||
public void testConjuringUpTokenFromSet() throws Exception {
|
public void testConjuringUpTokenFromSet() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(39);
|
StringBuilder grammarBuilder = new StringBuilder(82);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : 'a' x=('b'|'c') {} 'd' ;");
|
grammarBuilder.append("a : 'a' x=('b'|'c') {std::cout << \"conjured=\" + str($x) << \"\\n\";} 'd' ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ public class TestParserErrors extends BaseCppTest {
|
||||||
public void testContextListGetters() throws Exception {
|
public void testContextListGetters() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(144);
|
StringBuilder grammarBuilder = new StringBuilder(160);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("@parser::members{\n");
|
grammarBuilder.append("@parser::members{\n");
|
||||||
grammarBuilder.append("def foo():\n");
|
grammarBuilder.append("def foo():\n");
|
||||||
|
@ -62,8 +62,8 @@ public class TestParserErrors extends BaseCppTest {
|
||||||
grammarBuilder.append(" b = s.b()\n");
|
grammarBuilder.append(" b = s.b()\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append("s : (a | b)+;\n");
|
grammarBuilder.append("s : (a | b)+;\n");
|
||||||
grammarBuilder.append("a : 'a' {cout 'a';};\n");
|
grammarBuilder.append("a : 'a' {std::cout << 'a';};\n");
|
||||||
grammarBuilder.append("b : 'b' {cout 'b';};");
|
grammarBuilder.append("b : 'b' {std::cout << 'b';};");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
|
||||||
|
@ -168,10 +168,10 @@ public class TestParserErrors extends BaseCppTest {
|
||||||
public void testInvalidATNStateRemoval() throws Exception {
|
public void testInvalidATNStateRemoval() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(102);
|
StringBuilder grammarBuilder = new StringBuilder(114);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("start : ID ':' expr;\n");
|
grammarBuilder.append("start : ID ':' expr;\n");
|
||||||
grammarBuilder.append("expr : primary expr? {pass} | expr '->' ID;\n");
|
grammarBuilder.append("expr : primary expr? {/* do nothing */} | expr '->' ID;\n");
|
||||||
grammarBuilder.append("primary : ID;\n");
|
grammarBuilder.append("primary : ID;\n");
|
||||||
grammarBuilder.append("ID : [a-z]+;");
|
grammarBuilder.append("ID : [a-z]+;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
@ -211,7 +211,7 @@ public class TestParserErrors extends BaseCppTest {
|
||||||
public void testLL1ErrorInfo() throws Exception {
|
public void testLL1ErrorInfo() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(235);
|
StringBuilder grammarBuilder = new StringBuilder(329);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("start : animal (AND acClass)? service EOF;\n");
|
grammarBuilder.append("start : animal (AND acClass)? service EOF;\n");
|
||||||
grammarBuilder.append("animal : (DOG | CAT );\n");
|
grammarBuilder.append("animal : (DOG | CAT );\n");
|
||||||
|
@ -224,7 +224,7 @@ public class TestParserErrors extends BaseCppTest {
|
||||||
grammarBuilder.append("WS : ' ' -> skip ;\n");
|
grammarBuilder.append("WS : ' ' -> skip ;\n");
|
||||||
grammarBuilder.append("acClass\n");
|
grammarBuilder.append("acClass\n");
|
||||||
grammarBuilder.append("@init\n");
|
grammarBuilder.append("@init\n");
|
||||||
grammarBuilder.append("{}\n");
|
grammarBuilder.append("{std::cout << self.getExpectedTokens().toString(self.literalNames, self.symbolicNames) << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" : ;");
|
grammarBuilder.append(" : ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
@ -331,9 +331,9 @@ public class TestParserErrors extends BaseCppTest {
|
||||||
public void testMultiTokenDeletionBeforeLoop2() throws Exception {
|
public void testMultiTokenDeletionBeforeLoop2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(40);
|
StringBuilder grammarBuilder = new StringBuilder(52);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : 'a' ('b'|'z'{pass})* 'c';");
|
grammarBuilder.append("a : 'a' ('b'|'z'{/* do nothing */})* 'c';");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
|
||||||
|
@ -373,9 +373,9 @@ public class TestParserErrors extends BaseCppTest {
|
||||||
public void testMultiTokenDeletionDuringLoop2() throws Exception {
|
public void testMultiTokenDeletionDuringLoop2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(41);
|
StringBuilder grammarBuilder = new StringBuilder(53);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : 'a' ('b'|'z'{pass})* 'c' ;");
|
grammarBuilder.append("a : 'a' ('b'|'z'{/* do nothing */})* 'c' ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
|
||||||
|
@ -440,10 +440,10 @@ public class TestParserErrors extends BaseCppTest {
|
||||||
public void testSingleSetInsertionConsumption() throws Exception {
|
public void testSingleSetInsertionConsumption() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(52);
|
StringBuilder grammarBuilder = new StringBuilder(95);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("myset: ('b'|'c') ;\n");
|
grammarBuilder.append("myset: ('b'|'c') ;\n");
|
||||||
grammarBuilder.append("a: 'a' myset 'd' {} ; ");
|
grammarBuilder.append("a: 'a' myset 'd' {std::cout << \"\" + str($myset.stop) << \"\\n\";} ; ");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
|
||||||
|
@ -526,9 +526,9 @@ public class TestParserErrors extends BaseCppTest {
|
||||||
public void testSingleTokenDeletionBeforeLoop2() throws Exception {
|
public void testSingleTokenDeletionBeforeLoop2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(36);
|
StringBuilder grammarBuilder = new StringBuilder(48);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : 'a' ('b'|'z'{pass})*;");
|
grammarBuilder.append("a : 'a' ('b'|'z'{/* do nothing */})*;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
|
||||||
|
@ -571,10 +571,10 @@ public class TestParserErrors extends BaseCppTest {
|
||||||
public void testSingleTokenDeletionConsumption() throws Exception {
|
public void testSingleTokenDeletionConsumption() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(52);
|
StringBuilder grammarBuilder = new StringBuilder(95);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("myset: ('b'|'c') ;\n");
|
grammarBuilder.append("myset: ('b'|'c') ;\n");
|
||||||
grammarBuilder.append("a: 'a' myset 'd' {} ; ");
|
grammarBuilder.append("a: 'a' myset 'd' {std::cout << \"\" + str($myset.stop) << \"\\n\";} ; ");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
|
||||||
|
@ -612,9 +612,9 @@ public class TestParserErrors extends BaseCppTest {
|
||||||
public void testSingleTokenDeletionDuringLoop2() throws Exception {
|
public void testSingleTokenDeletionDuringLoop2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(41);
|
StringBuilder grammarBuilder = new StringBuilder(53);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : 'a' ('b'|'z'{pass})* 'c' ;");
|
grammarBuilder.append("a : 'a' ('b'|'z'{/* do nothing */})* 'c' ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,10 @@ public class TestParserExec extends BaseCppTest {
|
||||||
public void testAPlus() throws Exception {
|
public void testAPlus() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(64);
|
StringBuilder grammarBuilder = new StringBuilder(92);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : ID+ {\n");
|
grammarBuilder.append("a : ID+ {\n");
|
||||||
|
grammarBuilder.append("std::cout << $text << \"\\n\";\n");
|
||||||
grammarBuilder.append("};\n");
|
grammarBuilder.append("};\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+;\n");
|
grammarBuilder.append("ID : 'a'..'z'+;\n");
|
||||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||||
|
@ -35,9 +36,10 @@ public class TestParserExec extends BaseCppTest {
|
||||||
public void testAStar_1() throws Exception {
|
public void testAStar_1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(64);
|
StringBuilder grammarBuilder = new StringBuilder(92);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : ID* {\n");
|
grammarBuilder.append("a : ID* {\n");
|
||||||
|
grammarBuilder.append("std::cout << $text << \"\\n\";\n");
|
||||||
grammarBuilder.append("};\n");
|
grammarBuilder.append("};\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+;\n");
|
grammarBuilder.append("ID : 'a'..'z'+;\n");
|
||||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||||
|
@ -57,9 +59,10 @@ public class TestParserExec extends BaseCppTest {
|
||||||
public void testAStar_2() throws Exception {
|
public void testAStar_2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(64);
|
StringBuilder grammarBuilder = new StringBuilder(92);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : ID* {\n");
|
grammarBuilder.append("a : ID* {\n");
|
||||||
|
grammarBuilder.append("std::cout << $text << \"\\n\";\n");
|
||||||
grammarBuilder.append("};\n");
|
grammarBuilder.append("};\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+;\n");
|
grammarBuilder.append("ID : 'a'..'z'+;\n");
|
||||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||||
|
@ -79,9 +82,10 @@ public class TestParserExec extends BaseCppTest {
|
||||||
public void testAorAPlus() throws Exception {
|
public void testAorAPlus() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(69);
|
StringBuilder grammarBuilder = new StringBuilder(97);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : (ID|ID)+ {\n");
|
grammarBuilder.append("a : (ID|ID)+ {\n");
|
||||||
|
grammarBuilder.append("std::cout << $text << \"\\n\";\n");
|
||||||
grammarBuilder.append("};\n");
|
grammarBuilder.append("};\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+;\n");
|
grammarBuilder.append("ID : 'a'..'z'+;\n");
|
||||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||||
|
@ -101,9 +105,10 @@ public class TestParserExec extends BaseCppTest {
|
||||||
public void testAorAStar_1() throws Exception {
|
public void testAorAStar_1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(69);
|
StringBuilder grammarBuilder = new StringBuilder(97);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : (ID|ID)* {\n");
|
grammarBuilder.append("a : (ID|ID)* {\n");
|
||||||
|
grammarBuilder.append("std::cout << $text << \"\\n\";\n");
|
||||||
grammarBuilder.append("};\n");
|
grammarBuilder.append("};\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+;\n");
|
grammarBuilder.append("ID : 'a'..'z'+;\n");
|
||||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||||
|
@ -123,9 +128,10 @@ public class TestParserExec extends BaseCppTest {
|
||||||
public void testAorAStar_2() throws Exception {
|
public void testAorAStar_2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(69);
|
StringBuilder grammarBuilder = new StringBuilder(97);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : (ID|ID)* {\n");
|
grammarBuilder.append("a : (ID|ID)* {\n");
|
||||||
|
grammarBuilder.append("std::cout << $text << \"\\n\";\n");
|
||||||
grammarBuilder.append("};\n");
|
grammarBuilder.append("};\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+;\n");
|
grammarBuilder.append("ID : 'a'..'z'+;\n");
|
||||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||||
|
@ -145,10 +151,12 @@ public class TestParserExec extends BaseCppTest {
|
||||||
public void testAorB() throws Exception {
|
public void testAorB() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(92);
|
StringBuilder grammarBuilder = new StringBuilder(152);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : ID {\n");
|
grammarBuilder.append("a : ID {\n");
|
||||||
|
grammarBuilder.append("std::cout << \"alt 1\" << \"\\n\";\n");
|
||||||
grammarBuilder.append("} | INT {\n");
|
grammarBuilder.append("} | INT {\n");
|
||||||
|
grammarBuilder.append("std::cout << \"alt 2\" << \"\\n\";\n");
|
||||||
grammarBuilder.append("};\n");
|
grammarBuilder.append("};\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||||
|
@ -169,10 +177,11 @@ public class TestParserExec extends BaseCppTest {
|
||||||
public void testAorBPlus() throws Exception {
|
public void testAorBPlus() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(92);
|
StringBuilder grammarBuilder = new StringBuilder(120);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : (ID|INT{\n");
|
grammarBuilder.append("a : (ID|INT{\n");
|
||||||
grammarBuilder.append("})+ {\n");
|
grammarBuilder.append("})+ {\n");
|
||||||
|
grammarBuilder.append("std::cout << $text << \"\\n\";\n");
|
||||||
grammarBuilder.append("};\n");
|
grammarBuilder.append("};\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||||
|
@ -193,10 +202,11 @@ public class TestParserExec extends BaseCppTest {
|
||||||
public void testAorBStar_1() throws Exception {
|
public void testAorBStar_1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(92);
|
StringBuilder grammarBuilder = new StringBuilder(120);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : (ID|INT{\n");
|
grammarBuilder.append("a : (ID|INT{\n");
|
||||||
grammarBuilder.append("})* {\n");
|
grammarBuilder.append("})* {\n");
|
||||||
|
grammarBuilder.append("std::cout << $text << \"\\n\";\n");
|
||||||
grammarBuilder.append("};\n");
|
grammarBuilder.append("};\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||||
|
@ -217,10 +227,11 @@ public class TestParserExec extends BaseCppTest {
|
||||||
public void testAorBStar_2() throws Exception {
|
public void testAorBStar_2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(92);
|
StringBuilder grammarBuilder = new StringBuilder(120);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : (ID|INT{\n");
|
grammarBuilder.append("a : (ID|INT{\n");
|
||||||
grammarBuilder.append("})* {\n");
|
grammarBuilder.append("})* {\n");
|
||||||
|
grammarBuilder.append("std::cout << $text << \"\\n\";\n");
|
||||||
grammarBuilder.append("};\n");
|
grammarBuilder.append("};\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||||
|
@ -241,9 +252,10 @@ public class TestParserExec extends BaseCppTest {
|
||||||
public void testBasic() throws Exception {
|
public void testBasic() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(85);
|
StringBuilder grammarBuilder = new StringBuilder(113);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : ID INT {\n");
|
grammarBuilder.append("a : ID INT {\n");
|
||||||
|
grammarBuilder.append("std::cout << $text << \"\\n\";\n");
|
||||||
grammarBuilder.append("};\n");
|
grammarBuilder.append("};\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||||
|
@ -284,11 +296,12 @@ public class TestParserExec extends BaseCppTest {
|
||||||
public void testIfIfElseGreedyBinding1() throws Exception {
|
public void testIfIfElseGreedyBinding1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(173);
|
StringBuilder grammarBuilder = new StringBuilder(201);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("start : statement+ ;\n");
|
grammarBuilder.append("start : statement+ ;\n");
|
||||||
grammarBuilder.append("statement : 'x' | ifStatement;\n");
|
grammarBuilder.append("statement : 'x' | ifStatement;\n");
|
||||||
grammarBuilder.append("ifStatement : 'if' 'y' statement ('else' statement)? {\n");
|
grammarBuilder.append("ifStatement : 'if' 'y' statement ('else' statement)? {\n");
|
||||||
|
grammarBuilder.append("std::cout << $text << \"\\n\";\n");
|
||||||
grammarBuilder.append("};\n");
|
grammarBuilder.append("};\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("WS : (' '|'\\n') -> channel(HIDDEN);");
|
grammarBuilder.append("WS : (' '|'\\n') -> channel(HIDDEN);");
|
||||||
|
@ -310,11 +323,12 @@ public class TestParserExec extends BaseCppTest {
|
||||||
public void testIfIfElseGreedyBinding2() throws Exception {
|
public void testIfIfElseGreedyBinding2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(173);
|
StringBuilder grammarBuilder = new StringBuilder(201);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("start : statement+ ;\n");
|
grammarBuilder.append("start : statement+ ;\n");
|
||||||
grammarBuilder.append("statement : 'x' | ifStatement;\n");
|
grammarBuilder.append("statement : 'x' | ifStatement;\n");
|
||||||
grammarBuilder.append("ifStatement : 'if' 'y' statement ('else' statement|) {\n");
|
grammarBuilder.append("ifStatement : 'if' 'y' statement ('else' statement|) {\n");
|
||||||
|
grammarBuilder.append("std::cout << $text << \"\\n\";\n");
|
||||||
grammarBuilder.append("};\n");
|
grammarBuilder.append("};\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("WS : (' '|'\\n') -> channel(HIDDEN);");
|
grammarBuilder.append("WS : (' '|'\\n') -> channel(HIDDEN);");
|
||||||
|
@ -336,11 +350,12 @@ public class TestParserExec extends BaseCppTest {
|
||||||
public void testIfIfElseNonGreedyBinding1() throws Exception {
|
public void testIfIfElseNonGreedyBinding1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(174);
|
StringBuilder grammarBuilder = new StringBuilder(202);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("start : statement+ ;\n");
|
grammarBuilder.append("start : statement+ ;\n");
|
||||||
grammarBuilder.append("statement : 'x' | ifStatement;\n");
|
grammarBuilder.append("statement : 'x' | ifStatement;\n");
|
||||||
grammarBuilder.append("ifStatement : 'if' 'y' statement ('else' statement)?? {\n");
|
grammarBuilder.append("ifStatement : 'if' 'y' statement ('else' statement)?? {\n");
|
||||||
|
grammarBuilder.append("std::cout << $text << \"\\n\";\n");
|
||||||
grammarBuilder.append("};\n");
|
grammarBuilder.append("};\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("WS : (' '|'\\n') -> channel(HIDDEN);");
|
grammarBuilder.append("WS : (' '|'\\n') -> channel(HIDDEN);");
|
||||||
|
@ -362,11 +377,12 @@ public class TestParserExec extends BaseCppTest {
|
||||||
public void testIfIfElseNonGreedyBinding2() throws Exception {
|
public void testIfIfElseNonGreedyBinding2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(173);
|
StringBuilder grammarBuilder = new StringBuilder(201);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("start : statement+ ;\n");
|
grammarBuilder.append("start : statement+ ;\n");
|
||||||
grammarBuilder.append("statement : 'x' | ifStatement;\n");
|
grammarBuilder.append("statement : 'x' | ifStatement;\n");
|
||||||
grammarBuilder.append("ifStatement : 'if' 'y' statement (|'else' statement) {\n");
|
grammarBuilder.append("ifStatement : 'if' 'y' statement (|'else' statement) {\n");
|
||||||
|
grammarBuilder.append("std::cout << $text << \"\\n\";\n");
|
||||||
grammarBuilder.append("};\n");
|
grammarBuilder.append("};\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("WS : (' '|'\\n') -> channel(HIDDEN);");
|
grammarBuilder.append("WS : (' '|'\\n') -> channel(HIDDEN);");
|
||||||
|
@ -388,9 +404,10 @@ public class TestParserExec extends BaseCppTest {
|
||||||
public void testLL1OptionalBlock_1() throws Exception {
|
public void testLL1OptionalBlock_1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(90);
|
StringBuilder grammarBuilder = new StringBuilder(118);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : (ID|{}INT)? {\n");
|
grammarBuilder.append("a : (ID|{}INT)? {\n");
|
||||||
|
grammarBuilder.append("std::cout << $text << \"\\n\";\n");
|
||||||
grammarBuilder.append("};\n");
|
grammarBuilder.append("};\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+;\n");
|
grammarBuilder.append("ID : 'a'..'z'+;\n");
|
||||||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||||
|
@ -411,9 +428,10 @@ public class TestParserExec extends BaseCppTest {
|
||||||
public void testLL1OptionalBlock_2() throws Exception {
|
public void testLL1OptionalBlock_2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(90);
|
StringBuilder grammarBuilder = new StringBuilder(118);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : (ID|{}INT)? {\n");
|
grammarBuilder.append("a : (ID|{}INT)? {\n");
|
||||||
|
grammarBuilder.append("std::cout << $text << \"\\n\";\n");
|
||||||
grammarBuilder.append("};\n");
|
grammarBuilder.append("};\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+;\n");
|
grammarBuilder.append("ID : 'a'..'z'+;\n");
|
||||||
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
grammarBuilder.append("INT : '0'..'9'+ ;\n");
|
||||||
|
@ -434,12 +452,12 @@ public class TestParserExec extends BaseCppTest {
|
||||||
public void testLabelAliasingAcrossLabeledAlternatives() throws Exception {
|
public void testLabelAliasingAcrossLabeledAlternatives() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(121);
|
StringBuilder grammarBuilder = new StringBuilder(187);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("start : a* EOF;\n");
|
grammarBuilder.append("start : a* EOF;\n");
|
||||||
grammarBuilder.append("a\n");
|
grammarBuilder.append("a\n");
|
||||||
grammarBuilder.append(" : label=subrule {} #One\n");
|
grammarBuilder.append(" : label=subrule {std::cout << $label.text << \"\\n\";} #One\n");
|
||||||
grammarBuilder.append(" | label='y' {} #Two\n");
|
grammarBuilder.append(" | label='y' {std::cout << $label.text << \"\\n\";} #Two\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
grammarBuilder.append("subrule : 'x';\n");
|
grammarBuilder.append("subrule : 'x';\n");
|
||||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||||
|
@ -648,14 +666,14 @@ public class TestParserExec extends BaseCppTest {
|
||||||
public void testParserProperty() throws Exception {
|
public void testParserProperty() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(139);
|
StringBuilder grammarBuilder = new StringBuilder(168);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("@members {\n");
|
grammarBuilder.append("@members {\n");
|
||||||
grammarBuilder.append("def Property(self):\n");
|
grammarBuilder.append("def Property(self):\n");
|
||||||
grammarBuilder.append(" return True\n");
|
grammarBuilder.append(" return True\n");
|
||||||
grammarBuilder.append("\n");
|
grammarBuilder.append("\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append("a : {$parser.Property()}? ID {}\n");
|
grammarBuilder.append("a : {$parser.Property()}? ID {std::cout << \"valid\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||||
|
@ -699,12 +717,13 @@ public class TestParserExec extends BaseCppTest {
|
||||||
public void testPredictionIssue334() throws Exception {
|
public void testPredictionIssue334() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(207);
|
StringBuilder grammarBuilder = new StringBuilder(259);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("file_ @init{\n");
|
grammarBuilder.append("file_ @init{\n");
|
||||||
grammarBuilder.append("self._errHandler = BailErrorStrategy()\n");
|
grammarBuilder.append("self._errHandler = BailErrorStrategy()\n");
|
||||||
grammarBuilder.append("} \n");
|
grammarBuilder.append("} \n");
|
||||||
grammarBuilder.append("@after {\n");
|
grammarBuilder.append("@after {\n");
|
||||||
|
grammarBuilder.append("std::cout << $ctx.toStringTree(recog=self) << \"\\n\";\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append(" : item (SEMICOLON item)* SEMICOLON? EOF ;\n");
|
grammarBuilder.append(" : item (SEMICOLON item)* SEMICOLON? EOF ;\n");
|
||||||
grammarBuilder.append("item : A B?;\n");
|
grammarBuilder.append("item : A B?;\n");
|
||||||
|
@ -728,9 +747,9 @@ public class TestParserExec extends BaseCppTest {
|
||||||
public void testReferenceToATN_1() throws Exception {
|
public void testReferenceToATN_1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(94);
|
StringBuilder grammarBuilder = new StringBuilder(121);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : (ID|ATN)* ATN? {} ;\n");
|
grammarBuilder.append("a : (ID|ATN)* ATN? {std::cout << $text << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("ATN : '0'..'9'+;\n");
|
grammarBuilder.append("ATN : '0'..'9'+;\n");
|
||||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||||
|
@ -750,9 +769,9 @@ public class TestParserExec extends BaseCppTest {
|
||||||
public void testReferenceToATN_2() throws Exception {
|
public void testReferenceToATN_2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(94);
|
StringBuilder grammarBuilder = new StringBuilder(121);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : (ID|ATN)* ATN? {} ;\n");
|
grammarBuilder.append("a : (ID|ATN)* ATN? {std::cout << $text << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("ATN : '0'..'9'+;\n");
|
grammarBuilder.append("ATN : '0'..'9'+;\n");
|
||||||
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
|
||||||
|
|
|
@ -15,7 +15,7 @@ public class TestSemPredEvalLexer extends BaseCppTest {
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(131);
|
StringBuilder grammarBuilder = new StringBuilder(131);
|
||||||
grammarBuilder.append("lexer grammar L;\n");
|
grammarBuilder.append("lexer grammar L;\n");
|
||||||
grammarBuilder.append("E1 : 'enum' { False }? ;\n");
|
grammarBuilder.append("E1 : 'enum' { false }? ;\n");
|
||||||
grammarBuilder.append("E2 : 'enum' { True }? ; // winner not E1 or ID\n");
|
grammarBuilder.append("E2 : 'enum' { True }? ; // winner not E1 or ID\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||||
|
@ -69,7 +69,7 @@ public class TestSemPredEvalLexer extends BaseCppTest {
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(84);
|
StringBuilder grammarBuilder = new StringBuilder(84);
|
||||||
grammarBuilder.append("lexer grammar L;\n");
|
grammarBuilder.append("lexer grammar L;\n");
|
||||||
grammarBuilder.append("ENUM : [a-z]+ { False }? ;\n");
|
grammarBuilder.append("ENUM : [a-z]+ { false }? ;\n");
|
||||||
grammarBuilder.append("ID : [a-z]+ ;\n");
|
grammarBuilder.append("ID : [a-z]+ ;\n");
|
||||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
@ -93,7 +93,7 @@ public class TestSemPredEvalLexer extends BaseCppTest {
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(85);
|
StringBuilder grammarBuilder = new StringBuilder(85);
|
||||||
grammarBuilder.append("lexer grammar L;\n");
|
grammarBuilder.append("lexer grammar L;\n");
|
||||||
grammarBuilder.append("ENUM : 'enum' { False }? ;\n");
|
grammarBuilder.append("ENUM : 'enum' { false }? ;\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
@ -121,11 +121,11 @@ public class TestSemPredEvalLexer extends BaseCppTest {
|
||||||
public void testIndent() throws Exception {
|
public void testIndent() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(120);
|
StringBuilder grammarBuilder = new StringBuilder(150);
|
||||||
grammarBuilder.append("lexer grammar L;\n");
|
grammarBuilder.append("lexer grammar L;\n");
|
||||||
grammarBuilder.append("ID : [a-z]+ ;\n");
|
grammarBuilder.append("ID : [a-z]+ ;\n");
|
||||||
grammarBuilder.append("INDENT : [ \\t]+ { self._tokenStartColumn==0 }?\n");
|
grammarBuilder.append("INDENT : [ \\t]+ { self._tokenStartColumn==0 }?\n");
|
||||||
grammarBuilder.append(" { } ;\n");
|
grammarBuilder.append(" { std::cout << \"INDENT\" << \"\\n\"; } ;\n");
|
||||||
grammarBuilder.append("NL : '\\n';\n");
|
grammarBuilder.append("NL : '\\n';\n");
|
||||||
grammarBuilder.append("WS : [ \\t]+ ;");
|
grammarBuilder.append("WS : [ \\t]+ ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
@ -160,10 +160,10 @@ public class TestSemPredEvalLexer extends BaseCppTest {
|
||||||
public void testLexerInputPositionSensitivePredicates() throws Exception {
|
public void testLexerInputPositionSensitivePredicates() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(174);
|
StringBuilder grammarBuilder = new StringBuilder(236);
|
||||||
grammarBuilder.append("lexer grammar L;\n");
|
grammarBuilder.append("lexer grammar L;\n");
|
||||||
grammarBuilder.append("WORD1 : ID1+ { } ;\n");
|
grammarBuilder.append("WORD1 : ID1+ { std::cout << self.text << \"\\n\"; } ;\n");
|
||||||
grammarBuilder.append("WORD2 : ID2+ { } ;\n");
|
grammarBuilder.append("WORD2 : ID2+ { std::cout << self.text << \"\\n\"; } ;\n");
|
||||||
grammarBuilder.append("fragment ID1 : { self.column < 2 }? [a-zA-Z];\n");
|
grammarBuilder.append("fragment ID1 : { self.column < 2 }? [a-zA-Z];\n");
|
||||||
grammarBuilder.append("fragment ID2 : { self.column >= 2 }? [a-zA-Z];\n");
|
grammarBuilder.append("fragment ID2 : { self.column >= 2 }? [a-zA-Z];\n");
|
||||||
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
|
||||||
|
@ -192,10 +192,10 @@ public class TestSemPredEvalLexer extends BaseCppTest {
|
||||||
public void testPredicatedKeywords() throws Exception {
|
public void testPredicatedKeywords() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(104);
|
StringBuilder grammarBuilder = new StringBuilder(172);
|
||||||
grammarBuilder.append("lexer grammar L;\n");
|
grammarBuilder.append("lexer grammar L;\n");
|
||||||
grammarBuilder.append("ENUM : [a-z]+ { self.text==\"enum\" }? { } ;\n");
|
grammarBuilder.append("ENUM : [a-z]+ { self.text==\"enum\" }? { std::cout << \"enum!\" << \"\\n\"; } ;\n");
|
||||||
grammarBuilder.append("ID : [a-z]+ { } ;\n");
|
grammarBuilder.append("ID : [a-z]+ { std::cout << \"ID \" + self.text << \"\\n\"; } ;\n");
|
||||||
grammarBuilder.append("WS : [ \\n] -> skip ;");
|
grammarBuilder.append("WS : [ \\n] -> skip ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
|
|
@ -13,12 +13,12 @@ public class TestSemPredEvalParser extends BaseCppTest {
|
||||||
public void test2UnpredicatedAlts() throws Exception {
|
public void test2UnpredicatedAlts() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(234);
|
StringBuilder grammarBuilder = new StringBuilder(321);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s : {self._interp.predictionMode = PredictionMode.LL_EXACT_AMBIG_DETECTION} a ';' a; // do 2x: once in ATN, next in DFA\n");
|
grammarBuilder.append("s : {self._interp.predictionMode = PredictionMode.LL_EXACT_AMBIG_DETECTION} a ';' a; // do 2x: once in ATN, next in DFA\n");
|
||||||
grammarBuilder.append("a : ID {}\n");
|
grammarBuilder.append("a : ID {std::cout << \"alt 1\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" | ID {}\n");
|
grammarBuilder.append(" | ID {std::cout << \"alt 2\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" | {False}? ID {}\n");
|
grammarBuilder.append(" | {false}? ID {std::cout << \"alt 3\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||||
|
@ -46,13 +46,13 @@ public class TestSemPredEvalParser extends BaseCppTest {
|
||||||
public void test2UnpredicatedAltsAndOneOrthogonalAlt() throws Exception {
|
public void test2UnpredicatedAltsAndOneOrthogonalAlt() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(265);
|
StringBuilder grammarBuilder = new StringBuilder(381);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s : {self._interp.predictionMode = PredictionMode.LL_EXACT_AMBIG_DETECTION} a ';' a ';' a;\n");
|
grammarBuilder.append("s : {self._interp.predictionMode = PredictionMode.LL_EXACT_AMBIG_DETECTION} a ';' a ';' a;\n");
|
||||||
grammarBuilder.append("a : INT {}\n");
|
grammarBuilder.append("a : INT {std::cout << \"alt 1\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" | ID {} // must pick this one for ID since pred is false\n");
|
grammarBuilder.append(" | ID {std::cout << \"alt 2\" << \"\\n\";} // must pick this one for ID since pred is false\n");
|
||||||
grammarBuilder.append(" | ID {}\n");
|
grammarBuilder.append(" | ID {std::cout << \"alt 3\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" | {False}? ID {}\n");
|
grammarBuilder.append(" | {false}? ID {std::cout << \"alt 4\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||||
|
@ -81,12 +81,12 @@ public class TestSemPredEvalParser extends BaseCppTest {
|
||||||
public void testActionHidesPreds() throws Exception {
|
public void testActionHidesPreds() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(176);
|
StringBuilder grammarBuilder = new StringBuilder(234);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("@members {i = 0}\n");
|
grammarBuilder.append("@members {i = 0}\n");
|
||||||
grammarBuilder.append("s : a+ ;\n");
|
grammarBuilder.append("s : a+ ;\n");
|
||||||
grammarBuilder.append("a : {self.i = 1} ID {self.i == 1}? {}\n");
|
grammarBuilder.append("a : {self.i = 1} ID {self.i == 1}? {std::cout << \"alt 1\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" | {self.i = 2} ID {self.i == 2}? {}\n");
|
grammarBuilder.append(" | {self.i = 2} ID {self.i == 2}? {std::cout << \"alt 2\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||||
|
@ -110,12 +110,16 @@ public class TestSemPredEvalParser extends BaseCppTest {
|
||||||
public void testActionsHidePredsInGlobalFOLLOW() throws Exception {
|
public void testActionsHidePredsInGlobalFOLLOW() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(192);
|
StringBuilder grammarBuilder = new StringBuilder(292);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("@members {\n");
|
grammarBuilder.append("@members {\n");
|
||||||
|
grammarBuilder.append("def pred(self, v):\n");
|
||||||
|
grammarBuilder.append(" std::cout << \"eval=\" << str(v).lower();\n");
|
||||||
|
grammarBuilder.append(" return v\n");
|
||||||
|
grammarBuilder.append("\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append("s : e {} {self.pred(True)}? {} '!' ;\n");
|
grammarBuilder.append("s : e {} {self.pred(True)}? {std::cout << \"parse\" << \"\\n\";} '!' ;\n");
|
||||||
grammarBuilder.append("t : e {} {self.pred(False)}? ID ;\n");
|
grammarBuilder.append("t : e {} {self.pred(false)}? ID ;\n");
|
||||||
grammarBuilder.append("e : ID | ; // non-LL(1) so we use ATN\n");
|
grammarBuilder.append("e : ID | ; // non-LL(1) so we use ATN\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||||
|
@ -160,12 +164,16 @@ public class TestSemPredEvalParser extends BaseCppTest {
|
||||||
public void testDepedentPredsInGlobalFOLLOW() throws Exception {
|
public void testDepedentPredsInGlobalFOLLOW() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(215);
|
StringBuilder grammarBuilder = new StringBuilder(315);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("@members {\n");
|
grammarBuilder.append("@members {\n");
|
||||||
|
grammarBuilder.append("def pred(self, v):\n");
|
||||||
|
grammarBuilder.append(" std::cout << \"eval=\" << str(v).lower();\n");
|
||||||
|
grammarBuilder.append(" return v\n");
|
||||||
|
grammarBuilder.append("\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append("s : a[99] ;\n");
|
grammarBuilder.append("s : a[99] ;\n");
|
||||||
grammarBuilder.append("a[int i] : e {self.pred($i==99)}? {} '!' ;\n");
|
grammarBuilder.append("a[int i] : e {self.pred($i==99)}? {std::cout << \"parse\" << \"\\n\";} '!' ;\n");
|
||||||
grammarBuilder.append("b[int i] : e {self.pred($i==99)}? ID ;\n");
|
grammarBuilder.append("b[int i] : e {self.pred($i==99)}? ID ;\n");
|
||||||
grammarBuilder.append("e : ID | ; // non-LL(1) so we use ATN\n");
|
grammarBuilder.append("e : ID | ; // non-LL(1) so we use ATN\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
|
@ -189,13 +197,13 @@ public class TestSemPredEvalParser extends BaseCppTest {
|
||||||
public void testDependentPredNotInOuterCtxShouldBeIgnored() throws Exception {
|
public void testDependentPredNotInOuterCtxShouldBeIgnored() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(228);
|
StringBuilder grammarBuilder = new StringBuilder(286);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s : b[2] ';' | b[2] '.' ; // decision in s drills down to ctx-dependent pred in a;\n");
|
grammarBuilder.append("s : b[2] ';' | b[2] '.' ; // decision in s drills down to ctx-dependent pred in a;\n");
|
||||||
grammarBuilder.append("b[int i] : a[i] ;\n");
|
grammarBuilder.append("b[int i] : a[i] ;\n");
|
||||||
grammarBuilder.append("a[int i]\n");
|
grammarBuilder.append("a[int i]\n");
|
||||||
grammarBuilder.append(" : {$i==1}? ID {}\n");
|
grammarBuilder.append(" : {$i==1}? ID {std::cout << \"alt 1\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" | {$i==2}? ID {}\n");
|
grammarBuilder.append(" | {$i==2}? ID {std::cout << \"alt 2\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||||
|
@ -219,7 +227,7 @@ public class TestSemPredEvalParser extends BaseCppTest {
|
||||||
StringBuilder grammarBuilder = new StringBuilder(121);
|
StringBuilder grammarBuilder = new StringBuilder(121);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("cppCompilationUnit : content+ EOF;\n");
|
grammarBuilder.append("cppCompilationUnit : content+ EOF;\n");
|
||||||
grammarBuilder.append("content: anything | {False}? .;\n");
|
grammarBuilder.append("content: anything | {false}? .;\n");
|
||||||
grammarBuilder.append("anything: ANY_CHAR;\n");
|
grammarBuilder.append("anything: ANY_CHAR;\n");
|
||||||
grammarBuilder.append("ANY_CHAR: [_a-zA-Z0-9];");
|
grammarBuilder.append("ANY_CHAR: [_a-zA-Z0-9];");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
@ -238,13 +246,13 @@ public class TestSemPredEvalParser extends BaseCppTest {
|
||||||
public void testIndependentPredNotPassedOuterCtxToAvoidCastException() throws Exception {
|
public void testIndependentPredNotPassedOuterCtxToAvoidCastException() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(141);
|
StringBuilder grammarBuilder = new StringBuilder(199);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s : b ';' | b '.' ;\n");
|
grammarBuilder.append("s : b ';' | b '.' ;\n");
|
||||||
grammarBuilder.append("b : a ;\n");
|
grammarBuilder.append("b : a ;\n");
|
||||||
grammarBuilder.append("a\n");
|
grammarBuilder.append("a\n");
|
||||||
grammarBuilder.append(" : {False}? ID {}\n");
|
grammarBuilder.append(" : {false}? ID {std::cout << \"alt 1\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" | {True}? ID {}\n");
|
grammarBuilder.append(" | {True}? ID {std::cout << \"alt 2\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||||
|
@ -265,11 +273,11 @@ public class TestSemPredEvalParser extends BaseCppTest {
|
||||||
public void testNoTruePredsThrowsNoViableAlt() throws Exception {
|
public void testNoTruePredsThrowsNoViableAlt() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(129);
|
StringBuilder grammarBuilder = new StringBuilder(187);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s : a a;\n");
|
grammarBuilder.append("s : a a;\n");
|
||||||
grammarBuilder.append("a : {False}? ID INT {}\n");
|
grammarBuilder.append("a : {false}? ID INT {std::cout << \"alt 1\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" | {False}? ID INT {}\n");
|
grammarBuilder.append(" | {false}? ID INT {std::cout << \"alt 2\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||||
|
@ -291,13 +299,13 @@ public class TestSemPredEvalParser extends BaseCppTest {
|
||||||
public void testOrder() throws Exception {
|
public void testOrder() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(255);
|
StringBuilder grammarBuilder = new StringBuilder(313);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s : a {} a; // do 2x: once in ATN, next in DFA;\n");
|
grammarBuilder.append("s : a {} a; // do 2x: once in ATN, next in DFA;\n");
|
||||||
grammarBuilder.append("// action blocks lookahead from falling off of 'a'\n");
|
grammarBuilder.append("// action blocks lookahead from falling off of 'a'\n");
|
||||||
grammarBuilder.append("// and looking into 2nd 'a' ref. !ctx dependent pred\n");
|
grammarBuilder.append("// and looking into 2nd 'a' ref. !ctx dependent pred\n");
|
||||||
grammarBuilder.append("a : ID {}\n");
|
grammarBuilder.append("a : ID {std::cout << \"alt 1\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" | {True}? ID {}\n");
|
grammarBuilder.append(" | {True}? ID {std::cout << \"alt 2\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||||
|
@ -320,10 +328,10 @@ public class TestSemPredEvalParser extends BaseCppTest {
|
||||||
public void testPredFromAltTestedInLoopBack_1() throws Exception {
|
public void testPredFromAltTestedInLoopBack_1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(167);
|
StringBuilder grammarBuilder = new StringBuilder(218);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("file_\n");
|
grammarBuilder.append("file_\n");
|
||||||
grammarBuilder.append("@after {}\n");
|
grammarBuilder.append("@after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" : para para EOF ;\n");
|
grammarBuilder.append(" : para para EOF ;\n");
|
||||||
grammarBuilder.append("para: paraContent NL NL ;\n");
|
grammarBuilder.append("para: paraContent NL NL ;\n");
|
||||||
grammarBuilder.append("paraContent : ('s'|'x'|{self._input.LA(2)!=TParser.NL}? NL)+ ;\n");
|
grammarBuilder.append("paraContent : ('s'|'x'|{self._input.LA(2)!=TParser.NL}? NL)+ ;\n");
|
||||||
|
@ -353,10 +361,10 @@ public class TestSemPredEvalParser extends BaseCppTest {
|
||||||
public void testPredFromAltTestedInLoopBack_2() throws Exception {
|
public void testPredFromAltTestedInLoopBack_2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(167);
|
StringBuilder grammarBuilder = new StringBuilder(218);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("file_\n");
|
grammarBuilder.append("file_\n");
|
||||||
grammarBuilder.append("@after {}\n");
|
grammarBuilder.append("@after {std::cout << $ctx.toStringTree(recog=self) << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" : para para EOF ;\n");
|
grammarBuilder.append(" : para para EOF ;\n");
|
||||||
grammarBuilder.append("para: paraContent NL NL ;\n");
|
grammarBuilder.append("para: paraContent NL NL ;\n");
|
||||||
grammarBuilder.append("paraContent : ('s'|'x'|{self._input.LA(2)!=TParser.NL}? NL)+ ;\n");
|
grammarBuilder.append("paraContent : ('s'|'x'|{self._input.LA(2)!=TParser.NL}? NL)+ ;\n");
|
||||||
|
@ -384,12 +392,12 @@ public class TestSemPredEvalParser extends BaseCppTest {
|
||||||
public void testPredTestedEvenWhenUnAmbig_1() throws Exception {
|
public void testPredTestedEvenWhenUnAmbig_1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(150);
|
StringBuilder grammarBuilder = new StringBuilder(211);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("@members {enumKeyword = True}\n");
|
grammarBuilder.append("@members {enumKeyword = True}\n");
|
||||||
grammarBuilder.append("primary\n");
|
grammarBuilder.append("primary\n");
|
||||||
grammarBuilder.append(" : ID {}\n");
|
grammarBuilder.append(" : ID {std::cout << \"ID \"+$ID.text << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" | {not self.enumKeyword}? 'enum' {}\n");
|
grammarBuilder.append(" | {!self.enumKeyword}? 'enum' {std::cout << \"enum\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
grammarBuilder.append("ID : [a-z]+ ;\n");
|
grammarBuilder.append("ID : [a-z]+ ;\n");
|
||||||
grammarBuilder.append("WS : [ \\t\\n\\r]+ -> skip ;");
|
grammarBuilder.append("WS : [ \\t\\n\\r]+ -> skip ;");
|
||||||
|
@ -409,12 +417,12 @@ public class TestSemPredEvalParser extends BaseCppTest {
|
||||||
public void testPredTestedEvenWhenUnAmbig_2() throws Exception {
|
public void testPredTestedEvenWhenUnAmbig_2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(150);
|
StringBuilder grammarBuilder = new StringBuilder(211);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("@members {enumKeyword = True}\n");
|
grammarBuilder.append("@members {enumKeyword = True}\n");
|
||||||
grammarBuilder.append("primary\n");
|
grammarBuilder.append("primary\n");
|
||||||
grammarBuilder.append(" : ID {}\n");
|
grammarBuilder.append(" : ID {std::cout << \"ID \"+$ID.text << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" | {not self.enumKeyword}? 'enum' {}\n");
|
grammarBuilder.append(" | {!self.enumKeyword}? 'enum' {std::cout << \"enum\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
grammarBuilder.append("ID : [a-z]+ ;\n");
|
grammarBuilder.append("ID : [a-z]+ ;\n");
|
||||||
grammarBuilder.append("WS : [ \\t\\n\\r]+ -> skip ;");
|
grammarBuilder.append("WS : [ \\t\\n\\r]+ -> skip ;");
|
||||||
|
@ -435,13 +443,13 @@ public class TestSemPredEvalParser extends BaseCppTest {
|
||||||
public void testPredicateDependentOnArg() throws Exception {
|
public void testPredicateDependentOnArg() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(153);
|
StringBuilder grammarBuilder = new StringBuilder(211);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("@members {i = 0}\n");
|
grammarBuilder.append("@members {i = 0}\n");
|
||||||
grammarBuilder.append("s : a[2] a[1];\n");
|
grammarBuilder.append("s : a[2] a[1];\n");
|
||||||
grammarBuilder.append("a[int i]\n");
|
grammarBuilder.append("a[int i]\n");
|
||||||
grammarBuilder.append(" : {$i==1}? ID {}\n");
|
grammarBuilder.append(" : {$i==1}? ID {std::cout << \"alt 1\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" | {$i==2}? ID {}\n");
|
grammarBuilder.append(" | {$i==2}? ID {std::cout << \"alt 2\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||||
|
@ -491,12 +499,16 @@ public class TestSemPredEvalParser extends BaseCppTest {
|
||||||
public void testPredsInGlobalFOLLOW() throws Exception {
|
public void testPredsInGlobalFOLLOW() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(186);
|
StringBuilder grammarBuilder = new StringBuilder(286);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("@members {\n");
|
grammarBuilder.append("@members {\n");
|
||||||
|
grammarBuilder.append("def pred(self, v):\n");
|
||||||
|
grammarBuilder.append(" std::cout << \"eval=\" << str(v).lower();\n");
|
||||||
|
grammarBuilder.append(" return v\n");
|
||||||
|
grammarBuilder.append("\n");
|
||||||
grammarBuilder.append("}\n");
|
grammarBuilder.append("}\n");
|
||||||
grammarBuilder.append("s : e {self.pred(True)}? {} '!' ;\n");
|
grammarBuilder.append("s : e {self.pred(True)}? {std::cout << \"parse\" << \"\\n\";} '!' ;\n");
|
||||||
grammarBuilder.append("t : e {self.pred(False)}? ID ;\n");
|
grammarBuilder.append("t : e {self.pred(false)}? ID ;\n");
|
||||||
grammarBuilder.append("e : ID | ; // non-LL(1) so we use ATN\n");
|
grammarBuilder.append("e : ID | ; // non-LL(1) so we use ATN\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||||
|
@ -519,11 +531,11 @@ public class TestSemPredEvalParser extends BaseCppTest {
|
||||||
public void testRewindBeforePredEval() throws Exception {
|
public void testRewindBeforePredEval() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(173);
|
StringBuilder grammarBuilder = new StringBuilder(231);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s : a a;\n");
|
grammarBuilder.append("s : a a;\n");
|
||||||
grammarBuilder.append("a : {self._input.LT(1).text==\"x\"}? ID INT {}\n");
|
grammarBuilder.append("a : {self._input.LT(1).text==\"x\"}? ID INT {std::cout << \"alt 1\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" | {self._input.LT(1).text==\"y\"}? ID INT {}\n");
|
grammarBuilder.append(" | {self._input.LT(1).text==\"y\"}? ID INT {std::cout << \"alt 2\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||||
|
@ -546,12 +558,12 @@ public class TestSemPredEvalParser extends BaseCppTest {
|
||||||
public void testSimple() throws Exception {
|
public void testSimple() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(193);
|
StringBuilder grammarBuilder = new StringBuilder(280);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s : a a a; // do 3x: once in ATN, next in DFA then INT in ATN\n");
|
grammarBuilder.append("s : a a a; // do 3x: once in ATN, next in DFA then INT in ATN\n");
|
||||||
grammarBuilder.append("a : {False}? ID {}\n");
|
grammarBuilder.append("a : {false}? ID {std::cout << \"alt 1\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" | {True}? ID {}\n");
|
grammarBuilder.append(" | {True}? ID {std::cout << \"alt 2\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" | INT {}\n");
|
grammarBuilder.append(" | INT {std::cout << \"alt 3\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||||
|
@ -575,11 +587,11 @@ public class TestSemPredEvalParser extends BaseCppTest {
|
||||||
public void testSimpleValidate() throws Exception {
|
public void testSimpleValidate() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(122);
|
StringBuilder grammarBuilder = new StringBuilder(180);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s : a ;\n");
|
grammarBuilder.append("s : a ;\n");
|
||||||
grammarBuilder.append("a : {False}? ID {}\n");
|
grammarBuilder.append("a : {false}? ID {std::cout << \"alt 1\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" | {True}? INT {}\n");
|
grammarBuilder.append(" | {True}? INT {std::cout << \"alt 2\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||||
|
@ -601,11 +613,11 @@ public class TestSemPredEvalParser extends BaseCppTest {
|
||||||
public void testSimpleValidate2() throws Exception {
|
public void testSimpleValidate2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(125);
|
StringBuilder grammarBuilder = new StringBuilder(183);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s : a a a;\n");
|
grammarBuilder.append("s : a a a;\n");
|
||||||
grammarBuilder.append("a : {False}? ID {}\n");
|
grammarBuilder.append("a : {false}? ID {std::cout << \"alt 1\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" | {True}? INT {}\n");
|
grammarBuilder.append(" | {True}? INT {std::cout << \"alt 2\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||||
|
@ -629,11 +641,11 @@ public class TestSemPredEvalParser extends BaseCppTest {
|
||||||
public void testToLeft() throws Exception {
|
public void testToLeft() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(122);
|
StringBuilder grammarBuilder = new StringBuilder(180);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append(" s : a+ ;\n");
|
grammarBuilder.append(" s : a+ ;\n");
|
||||||
grammarBuilder.append("a : {False}? ID {}\n");
|
grammarBuilder.append("a : {false}? ID {std::cout << \"alt 1\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" | {True}? ID {}\n");
|
grammarBuilder.append(" | {True}? ID {std::cout << \"alt 2\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||||
|
@ -657,13 +669,13 @@ public class TestSemPredEvalParser extends BaseCppTest {
|
||||||
public void testToLeftWithVaryingPredicate() throws Exception {
|
public void testToLeftWithVaryingPredicate() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(175);
|
StringBuilder grammarBuilder = new StringBuilder(273);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("@members {i = 0}\n");
|
grammarBuilder.append("@members {i = 0}\n");
|
||||||
grammarBuilder.append("s : ({self.i += 1\n");
|
grammarBuilder.append("s : ({self.i += 1\n");
|
||||||
grammarBuilder.append("} a)+ ;\n");
|
grammarBuilder.append("std::cout << \"i=\" + str(self.i) << \"\\n\";} a)+ ;\n");
|
||||||
grammarBuilder.append("a : {self.i % 2 == 0}? ID {}\n");
|
grammarBuilder.append("a : {self.i % 2 == 0}? ID {std::cout << \"alt 1\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" | {self.i % 2 != 0}? ID {}\n");
|
grammarBuilder.append(" | {self.i % 2 != 0}? ID {std::cout << \"alt 2\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||||
|
@ -690,12 +702,12 @@ public class TestSemPredEvalParser extends BaseCppTest {
|
||||||
public void testUnpredicatedPathsInAlt() throws Exception {
|
public void testUnpredicatedPathsInAlt() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(141);
|
StringBuilder grammarBuilder = new StringBuilder(199);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s : a {}\n");
|
grammarBuilder.append("s : a {std::cout << \"alt 1\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" | b {}\n");
|
grammarBuilder.append(" | b {std::cout << \"alt 2\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
grammarBuilder.append("a : {False}? ID INT\n");
|
grammarBuilder.append("a : {false}? ID INT\n");
|
||||||
grammarBuilder.append(" | ID INT\n");
|
grammarBuilder.append(" | ID INT\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
grammarBuilder.append("b : ID ID\n");
|
grammarBuilder.append("b : ID ID\n");
|
||||||
|
@ -719,14 +731,14 @@ public class TestSemPredEvalParser extends BaseCppTest {
|
||||||
public void testValidateInDFA() throws Exception {
|
public void testValidateInDFA() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(290);
|
StringBuilder grammarBuilder = new StringBuilder(348);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("s : a ';' a;\n");
|
grammarBuilder.append("s : a ';' a;\n");
|
||||||
grammarBuilder.append("// ';' helps us to resynchronize without consuming\n");
|
grammarBuilder.append("// ';' helps us to resynchronize without consuming\n");
|
||||||
grammarBuilder.append("// 2nd 'a' reference. We our testing that the DFA also\n");
|
grammarBuilder.append("// 2nd 'a' reference. We our testing that the DFA also\n");
|
||||||
grammarBuilder.append("// throws an exception if the validating predicate fails\n");
|
grammarBuilder.append("// throws an exception if the validating predicate fails\n");
|
||||||
grammarBuilder.append("a : {False}? ID {}\n");
|
grammarBuilder.append("a : {false}? ID {std::cout << \"alt 1\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" | {True}? INT {}\n");
|
grammarBuilder.append(" | {True}? INT {std::cout << \"alt 2\" << \"\\n\";}\n");
|
||||||
grammarBuilder.append(" ;\n");
|
grammarBuilder.append(" ;\n");
|
||||||
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
|
||||||
grammarBuilder.append("INT : '0'..'9'+;\n");
|
grammarBuilder.append("INT : '0'..'9'+;\n");
|
||||||
|
|
|
@ -13,9 +13,9 @@ public class TestSets extends BaseCppTest {
|
||||||
public void testCharSetLiteral() throws Exception {
|
public void testCharSetLiteral() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(64);
|
StringBuilder grammarBuilder = new StringBuilder(93);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : (A {})+ ;\n");
|
grammarBuilder.append("a : (A {std::cout << $A.text << \"\\n\";})+ ;\n");
|
||||||
grammarBuilder.append("A : [AaBb] ;\n");
|
grammarBuilder.append("A : [AaBb] ;\n");
|
||||||
grammarBuilder.append("WS : (' '|'\\n')+ -> skip ;");
|
grammarBuilder.append("WS : (' '|'\\n')+ -> skip ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
@ -61,9 +61,9 @@ public class TestSets extends BaseCppTest {
|
||||||
public void testLexerOptionalSet() throws Exception {
|
public void testLexerOptionalSet() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(42);
|
StringBuilder grammarBuilder = new StringBuilder(85);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : A {} ;\n");
|
grammarBuilder.append("a : A {std::cout << self._input.getText() << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("A : ('a'|'b')? 'c' ;");
|
grammarBuilder.append("A : ('a'|'b')? 'c' ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
@ -81,9 +81,9 @@ public class TestSets extends BaseCppTest {
|
||||||
public void testLexerPlusSet() throws Exception {
|
public void testLexerPlusSet() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(42);
|
StringBuilder grammarBuilder = new StringBuilder(85);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : A {} ;\n");
|
grammarBuilder.append("a : A {std::cout << self._input.getText() << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("A : ('a'|'b')+ 'c' ;");
|
grammarBuilder.append("A : ('a'|'b')+ 'c' ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
@ -101,9 +101,9 @@ public class TestSets extends BaseCppTest {
|
||||||
public void testLexerStarSet() throws Exception {
|
public void testLexerStarSet() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(42);
|
StringBuilder grammarBuilder = new StringBuilder(85);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : A {} ;\n");
|
grammarBuilder.append("a : A {std::cout << self._input.getText() << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("A : ('a'|'b')* 'c' ;");
|
grammarBuilder.append("A : ('a'|'b')* 'c' ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
@ -121,9 +121,9 @@ public class TestSets extends BaseCppTest {
|
||||||
public void testNotChar() throws Exception {
|
public void testNotChar() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(32);
|
StringBuilder grammarBuilder = new StringBuilder(61);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : A {} ;\n");
|
grammarBuilder.append("a : A {std::cout << $A.text << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("A : ~'b' ;");
|
grammarBuilder.append("A : ~'b' ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
@ -141,9 +141,9 @@ public class TestSets extends BaseCppTest {
|
||||||
public void testNotCharSet() throws Exception {
|
public void testNotCharSet() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(38);
|
StringBuilder grammarBuilder = new StringBuilder(67);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : A {} ;\n");
|
grammarBuilder.append("a : A {std::cout << $A.text << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("A : ~('b'|'c') ;");
|
grammarBuilder.append("A : ~('b'|'c') ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
@ -161,9 +161,9 @@ public class TestSets extends BaseCppTest {
|
||||||
public void testNotCharSetWithLabel() throws Exception {
|
public void testNotCharSetWithLabel() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(40);
|
StringBuilder grammarBuilder = new StringBuilder(69);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : A {} ;\n");
|
grammarBuilder.append("a : A {std::cout << $A.text << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("A : h=~('b'|'c') ;");
|
grammarBuilder.append("A : h=~('b'|'c') ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
@ -181,9 +181,9 @@ public class TestSets extends BaseCppTest {
|
||||||
public void testNotCharSetWithRuleRef3() throws Exception {
|
public void testNotCharSetWithRuleRef3() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(104);
|
StringBuilder grammarBuilder = new StringBuilder(133);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : A {} ;\n");
|
grammarBuilder.append("a : A {std::cout << $A.text << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("A : ('a'|B) ; // this doesn't collapse to set but works\n");
|
grammarBuilder.append("A : ('a'|B) ; // this doesn't collapse to set but works\n");
|
||||||
grammarBuilder.append("fragment\n");
|
grammarBuilder.append("fragment\n");
|
||||||
grammarBuilder.append("B : ~('a'|'c') ;");
|
grammarBuilder.append("B : ~('a'|'c') ;");
|
||||||
|
@ -203,9 +203,9 @@ public class TestSets extends BaseCppTest {
|
||||||
public void testOptionalLexerSingleElement() throws Exception {
|
public void testOptionalLexerSingleElement() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(36);
|
StringBuilder grammarBuilder = new StringBuilder(79);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : A {} ;\n");
|
grammarBuilder.append("a : A {std::cout << self._input.getText() << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("A : 'b'? 'c' ;");
|
grammarBuilder.append("A : 'b'? 'c' ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
@ -223,9 +223,9 @@ public class TestSets extends BaseCppTest {
|
||||||
public void testOptionalSet() throws Exception {
|
public void testOptionalSet() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(34);
|
StringBuilder grammarBuilder = new StringBuilder(77);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : ('a'|'b')? 'c' {} ;");
|
grammarBuilder.append("a : ('a'|'b')? 'c' {std::cout << self._input.getText() << \"\\n\";} ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
|
||||||
|
@ -242,9 +242,9 @@ public class TestSets extends BaseCppTest {
|
||||||
public void testOptionalSingleElement() throws Exception {
|
public void testOptionalSingleElement() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(36);
|
StringBuilder grammarBuilder = new StringBuilder(79);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : A? 'c' {} ;\n");
|
grammarBuilder.append("a : A? 'c' {std::cout << self._input.getText() << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("A : 'b' ;");
|
grammarBuilder.append("A : 'b' ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
@ -262,9 +262,9 @@ public class TestSets extends BaseCppTest {
|
||||||
public void testParserNotSet() throws Exception {
|
public void testParserNotSet() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(36);
|
StringBuilder grammarBuilder = new StringBuilder(65);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : t=~('x'|'y') 'z' {} ;");
|
grammarBuilder.append("a : t=~('x'|'y') 'z' {std::cout << $t.text << \"\\n\";} ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
|
||||||
|
@ -281,9 +281,9 @@ public class TestSets extends BaseCppTest {
|
||||||
public void testParserNotToken() throws Exception {
|
public void testParserNotToken() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(28);
|
StringBuilder grammarBuilder = new StringBuilder(71);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : ~'x' 'z' {} ;");
|
grammarBuilder.append("a : ~'x' 'z' {std::cout << self._input.getText() << \"\\n\";} ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
|
||||||
|
@ -300,9 +300,9 @@ public class TestSets extends BaseCppTest {
|
||||||
public void testParserNotTokenWithLabel() throws Exception {
|
public void testParserNotTokenWithLabel() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(30);
|
StringBuilder grammarBuilder = new StringBuilder(59);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : t=~'x' 'z' {} ;");
|
grammarBuilder.append("a : t=~'x' 'z' {std::cout << $t.text << \"\\n\";} ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
|
||||||
|
@ -319,9 +319,9 @@ public class TestSets extends BaseCppTest {
|
||||||
public void testParserSet() throws Exception {
|
public void testParserSet() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(31);
|
StringBuilder grammarBuilder = new StringBuilder(60);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : t=('x'|'y') {} ;");
|
grammarBuilder.append("a : t=('x'|'y') {std::cout << $t.text << \"\\n\";} ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
|
||||||
|
@ -338,9 +338,9 @@ public class TestSets extends BaseCppTest {
|
||||||
public void testPlusLexerSingleElement() throws Exception {
|
public void testPlusLexerSingleElement() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(36);
|
StringBuilder grammarBuilder = new StringBuilder(79);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : A {} ;\n");
|
grammarBuilder.append("a : A {std::cout << self._input.getText() << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("A : 'b'+ 'c' ;");
|
grammarBuilder.append("A : 'b'+ 'c' ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
@ -358,9 +358,9 @@ public class TestSets extends BaseCppTest {
|
||||||
public void testPlusSet() throws Exception {
|
public void testPlusSet() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(34);
|
StringBuilder grammarBuilder = new StringBuilder(77);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : ('a'|'b')+ 'c' {} ;");
|
grammarBuilder.append("a : ('a'|'b')+ 'c' {std::cout << self._input.getText() << \"\\n\";} ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
|
||||||
|
@ -377,9 +377,9 @@ public class TestSets extends BaseCppTest {
|
||||||
public void testRuleAsSet() throws Exception {
|
public void testRuleAsSet() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(41);
|
StringBuilder grammarBuilder = new StringBuilder(84);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a @after {} : 'a' | 'b' |'c' ;");
|
grammarBuilder.append("a @after {std::cout << self._input.getText() << \"\\n\";} : 'a' | 'b' |'c' ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
|
||||||
|
@ -396,9 +396,9 @@ public class TestSets extends BaseCppTest {
|
||||||
public void testSeqDoesNotBecomeSet() throws Exception {
|
public void testSeqDoesNotBecomeSet() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(78);
|
StringBuilder grammarBuilder = new StringBuilder(121);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : C {} ;\n");
|
grammarBuilder.append("a : C {std::cout << self._input.getText() << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("fragment A : '1' | '2';\n");
|
grammarBuilder.append("fragment A : '1' | '2';\n");
|
||||||
grammarBuilder.append("fragment B : '3' '4';\n");
|
grammarBuilder.append("fragment B : '3' '4';\n");
|
||||||
grammarBuilder.append("C : A | B;");
|
grammarBuilder.append("C : A | B;");
|
||||||
|
@ -418,9 +418,9 @@ public class TestSets extends BaseCppTest {
|
||||||
public void testStarLexerSingleElement_1() throws Exception {
|
public void testStarLexerSingleElement_1() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(36);
|
StringBuilder grammarBuilder = new StringBuilder(79);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : A {} ;\n");
|
grammarBuilder.append("a : A {std::cout << self._input.getText() << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("A : 'b'* 'c' ;");
|
grammarBuilder.append("A : 'b'* 'c' ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
@ -438,9 +438,9 @@ public class TestSets extends BaseCppTest {
|
||||||
public void testStarLexerSingleElement_2() throws Exception {
|
public void testStarLexerSingleElement_2() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(36);
|
StringBuilder grammarBuilder = new StringBuilder(79);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : A {} ;\n");
|
grammarBuilder.append("a : A {std::cout << self._input.getText() << \"\\n\";} ;\n");
|
||||||
grammarBuilder.append("A : 'b'* 'c' ;");
|
grammarBuilder.append("A : 'b'* 'c' ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
@ -458,9 +458,9 @@ public class TestSets extends BaseCppTest {
|
||||||
public void testStarSet() throws Exception {
|
public void testStarSet() throws Exception {
|
||||||
mkdir(tmpdir);
|
mkdir(tmpdir);
|
||||||
|
|
||||||
StringBuilder grammarBuilder = new StringBuilder(34);
|
StringBuilder grammarBuilder = new StringBuilder(77);
|
||||||
grammarBuilder.append("grammar T;\n");
|
grammarBuilder.append("grammar T;\n");
|
||||||
grammarBuilder.append("a : ('a'|'b')* 'c' {} ;");
|
grammarBuilder.append("a : ('a'|'b')* 'c' {std::cout << self._input.getText() << \"\\n\";} ;");
|
||||||
String grammar = grammarBuilder.toString();
|
String grammar = grammarBuilder.toString();
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue