All tests of TestLeftRecursion.java now pass.
- Fixed all disabled tests and enabled them. - Some more adjustments of the test template + target template was needed. - Worked on semicolon usage in Cpp.stg to avoid double semicolons. Might need more work, tho.
This commit is contained in:
parent
86014ac3a6
commit
6bf1193839
|
@ -1,15 +1,4 @@
|
|||
IgnoredTests ::= [
|
||||
"LeftRecursion.MultipleAlternativesWithCommonLabel_1": true, // $ctx.e(0).v
|
||||
"LeftRecursion.MultipleAlternativesWithCommonLabel_2" : true, // $ctx.e(0).v
|
||||
"LeftRecursion.MultipleAlternativesWithCommonLabel_3": true, // $ctx.e(0).v
|
||||
"LeftRecursion.MultipleAlternativesWithCommonLabel_4" : true, // $ctx.e(0).v
|
||||
"LeftRecursion.ReturnValueAndActions_1" : true, // "ignored" return value
|
||||
"LeftRecursion.ReturnValueAndActions_2" : true, // "ignored" return value
|
||||
"LeftRecursion.ReturnValueAndActions_3" : true, // "ignored" return value
|
||||
"LeftRecursion.ReturnValueAndActions_4" : true, // "ignored" return value
|
||||
"LeftRecursion.PrefixOpWithActionAndLabel_1" : true, // "String" return value
|
||||
"LeftRecursion.PrefixOpWithActionAndLabel_2" : true, // "String" return value
|
||||
"LeftRecursion.PrefixOpWithActionAndLabel_3" : true, // "String" return value
|
||||
default: false
|
||||
]
|
||||
|
||||
|
@ -180,7 +169,7 @@ Not(v) ::= "!<v>"
|
|||
|
||||
Assert(s) ::= ""
|
||||
|
||||
Cast(t,v) ::= "<v>"
|
||||
Cast(t,v) ::= "std::dynamic_pointer_cast\<<t>>(<v>)" // Should actually use a more specific name. We may have to use other casts as well.
|
||||
|
||||
Append(a,b) ::= "<a> + <b>->toString()"
|
||||
|
||||
|
@ -214,7 +203,7 @@ DumpDFA() ::= "dumpDFA();"
|
|||
|
||||
Pass() ::= "/* do nothing */"
|
||||
|
||||
StringList() ::= ""
|
||||
StringList() ::= "std::vector\<std::string>"
|
||||
|
||||
BuildParseTrees() ::= "_buildParseTrees = true;"
|
||||
|
||||
|
@ -449,9 +438,10 @@ void pred(v) {
|
|||
>>
|
||||
|
||||
Invoke_pred(v) ::= <<pred(<v>)>>
|
||||
|
||||
ParserTokenType(t) ::= "Parser::<t>"
|
||||
ContextRuleFunction(ctx, rule) ::= "<ctx>-><rule>"
|
||||
StringType() ::= "std::string"
|
||||
ContextMember(ctx, subctx, member) ::= "<ctx>-><subctx>-><member>"
|
||||
|
||||
isEmpty ::= [
|
||||
"": true,
|
||||
|
|
|
@ -418,9 +418,10 @@ Declare_pred() ::= <<bool pred(bool v) {
|
|||
>>
|
||||
|
||||
Invoke_pred(v) ::= <<this.pred(<v>)>>
|
||||
|
||||
ParserTokenType(t) ::= "Parser.<t>"
|
||||
ContextRuleFunction(ctx, rule) ::= "<ctx>.<rule>"
|
||||
StringType() ::= "String"
|
||||
ContextMember(ctx, subctx, member) ::= "<ctx>.<subctx>.<member>"
|
||||
|
||||
isEmpty ::= [
|
||||
"": true,
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
IgnoredTests ::= [
|
||||
default: false
|
||||
]
|
||||
|
||||
TestFile(file) ::= <<
|
||||
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
package org.antlr.v4.test.runtime.java;
|
||||
|
@ -420,12 +424,10 @@ Declare_pred() ::= <<boolean pred(boolean v) {
|
|||
|
||||
Invoke_pred(v) ::= <<this.pred(<v>)>>
|
||||
|
||||
IgnoredTests ::= [
|
||||
default: false
|
||||
]
|
||||
|
||||
ParserTokenType(t) ::= "Parser.<t>"
|
||||
ContextRuleFunction(ctx, rule) ::= "<ctx>.<rule>"
|
||||
StringType() ::= "String"
|
||||
ContextMember(ctx, subctx, member) ::= "<ctx>.<subctx>.<member>"
|
||||
|
||||
isEmpty ::= [
|
||||
"": true,
|
||||
|
|
|
@ -429,9 +429,10 @@ Declare_pred() ::= <<this.pred = function(v) {
|
|||
>>
|
||||
|
||||
Invoke_pred(v) ::= <<this.pred(<v>)>>
|
||||
|
||||
ParserTokenType(t) ::= "Parser.<t>"
|
||||
ContextRuleFunction(ctx, rule) ::= "<ctx>.<rule>"
|
||||
StringType() ::= "String"
|
||||
ContextMember(ctx, subctx, member) ::= "<ctx>.<subctx>.<member>"
|
||||
|
||||
isEmpty ::= [
|
||||
"": true,
|
||||
|
|
|
@ -431,9 +431,10 @@ Declare_pred() ::= <<this.pred = function(v) {
|
|||
>>
|
||||
|
||||
Invoke_pred(v) ::= <<this.pred(<v>)>>
|
||||
|
||||
ParserTokenType(t) ::= "Parser.<t>"
|
||||
ContextRuleFunction(ctx, rule) ::= "<ctx>.<rule>"
|
||||
StringType() ::= "String"
|
||||
ContextMember(ctx, subctx, member) ::= "<ctx>.<subctx>.<member>"
|
||||
|
||||
isEmpty ::= [
|
||||
"": true,
|
||||
|
|
|
@ -433,9 +433,10 @@ Declare_pred() ::= <<this.pred = function(v) {
|
|||
>>
|
||||
|
||||
Invoke_pred(v) ::= <<this.pred(<v>)>>
|
||||
|
||||
ParserTokenType(t) ::= "Parser.<t>"
|
||||
ContextRuleFunction(ctx, rule) ::= "<ctx>.<rule>"
|
||||
StringType() ::= "String"
|
||||
ContextMember(ctx, subctx, member) ::= "<ctx>.<subctx>.<member>"
|
||||
|
||||
isEmpty ::= [
|
||||
"": true,
|
||||
|
|
|
@ -430,9 +430,10 @@ Declare_pred() ::= <<this.pred = function(v) {
|
|||
>>
|
||||
|
||||
Invoke_pred(v) ::= <<this.pred(<v>)>>
|
||||
|
||||
ParserTokenType(t) ::= "Parser.<t>"
|
||||
ContextRuleFunction(ctx, rule) ::= "<ctx>.<rule>"
|
||||
StringType() ::= "String"
|
||||
ContextMember(ctx, subctx, member) ::= "<ctx>.<subctx>.<member>"
|
||||
|
||||
isEmpty ::= [
|
||||
"": true,
|
||||
|
|
|
@ -407,9 +407,10 @@ Declare_pred() ::= <<def pred(self, v):
|
|||
>>
|
||||
|
||||
Invoke_pred(v) ::= <<self.pred(<v>)>>
|
||||
|
||||
ParserTokenType(t) ::= "Parser.<t>"
|
||||
ContextRuleFunction(ctx, rule) ::= "<ctx>.<rule>"
|
||||
StringType() ::= "String"
|
||||
ContextMember(ctx, subctx, member) ::= "<ctx>.<subctx>.<member>"
|
||||
|
||||
isEmpty ::= [
|
||||
"": true,
|
||||
|
|
|
@ -389,9 +389,10 @@ Declare_pred() ::= <<def pred(self, v):
|
|||
>>
|
||||
|
||||
Invoke_pred(v) ::= <<self.pred(<v>)>>
|
||||
|
||||
ParserTokenType(t) ::= "Parser.<t>"
|
||||
ContextRuleFunction(ctx, rule) ::= "<ctx>.<rule>"
|
||||
StringType() ::= "String"
|
||||
ContextMember(ctx, subctx, member) ::= "<ctx>.<subctx>.<member>"
|
||||
|
||||
isEmpty ::= [
|
||||
"": true,
|
||||
|
|
|
@ -21,8 +21,8 @@ grammar(grammarName) ::= <<
|
|||
grammar <grammarName>;
|
||||
s : e {<writeln("$e.v")>};
|
||||
e returns [int v]
|
||||
: e '*' e {$v = <Cast("BinaryContext","$ctx")>.e(0).v * <Cast("BinaryContext","$ctx")>.e(1).v;} # binary
|
||||
| e '+' e {$v = <Cast("BinaryContext","$ctx")>.e(0).v + <Cast("BinaryContext","$ctx")>.e(1).v;} # binary
|
||||
: e '*' e {$v = <Cast("BinaryContext","$ctx"):ContextMember("e(0)", "v")> * <Cast("BinaryContext","$ctx"):ContextMember("e(1)", "v")>;} # binary
|
||||
| e '+' e {$v = <Cast("BinaryContext","$ctx"):ContextMember("e(0)", "v")> + <Cast("BinaryContext","$ctx"):ContextMember("e(1)", "v")>;} # binary
|
||||
| INT {$v = $INT.int;} # anInt
|
||||
| '(' e ')' {$v = $e.v;} # parens
|
||||
| left=e INC {<Cast("UnaryContext","$ctx"):Concat(".INC() != null"):Assert()>$v = $left.v + 1;} # unary
|
||||
|
|
|
@ -13,7 +13,7 @@ Rule() ::= "s"
|
|||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
s : e {<writeln("$e.result")>} ;
|
||||
e returns [String result]
|
||||
e returns [<StringType()> result]
|
||||
: ID '=' e1=e {$result = "(" + $ID.text + "=" + $e1.result + ")";}
|
||||
| ID {$result = $ID.text;}
|
||||
| e1=e '+' e2=e {$result = "(" + $e1.result + "+" + $e2.result + ")";}
|
||||
|
|
|
@ -1905,16 +1905,15 @@ public class TestLeftRecursion extends BaseCppTest {
|
|||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
@Ignore("true")
|
||||
public void testMultipleAlternativesWithCommonLabel_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(581);
|
||||
StringBuilder grammarBuilder = new StringBuilder(757);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {std::cout << $e.v << std::endl;};\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 = std::dynamic_pointer_cast<BinaryContext>($ctx)->e(0)->v * std::dynamic_pointer_cast<BinaryContext>($ctx)->e(1)->v;} # binary\n");
|
||||
grammarBuilder.append(" | e '+' e {$v = std::dynamic_pointer_cast<BinaryContext>($ctx)->e(0)->v + std::dynamic_pointer_cast<BinaryContext>($ctx)->e(1)->v;} # binary\n");
|
||||
grammarBuilder.append(" | INT {$v = $INT.int;} # anInt\n");
|
||||
grammarBuilder.append(" | '(' e ')' {$v = $e.v;} # parens\n");
|
||||
grammarBuilder.append(" | left=e INC {$v = $left.v + 1;} # unary\n");
|
||||
|
@ -1939,16 +1938,15 @@ public class TestLeftRecursion extends BaseCppTest {
|
|||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
@Ignore("true")
|
||||
public void testMultipleAlternativesWithCommonLabel_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(581);
|
||||
StringBuilder grammarBuilder = new StringBuilder(757);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {std::cout << $e.v << std::endl;};\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 = std::dynamic_pointer_cast<BinaryContext>($ctx)->e(0)->v * std::dynamic_pointer_cast<BinaryContext>($ctx)->e(1)->v;} # binary\n");
|
||||
grammarBuilder.append(" | e '+' e {$v = std::dynamic_pointer_cast<BinaryContext>($ctx)->e(0)->v + std::dynamic_pointer_cast<BinaryContext>($ctx)->e(1)->v;} # binary\n");
|
||||
grammarBuilder.append(" | INT {$v = $INT.int;} # anInt\n");
|
||||
grammarBuilder.append(" | '(' e ')' {$v = $e.v;} # parens\n");
|
||||
grammarBuilder.append(" | left=e INC {$v = $left.v + 1;} # unary\n");
|
||||
|
@ -1973,16 +1971,15 @@ public class TestLeftRecursion extends BaseCppTest {
|
|||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
@Ignore("true")
|
||||
public void testMultipleAlternativesWithCommonLabel_3() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(581);
|
||||
StringBuilder grammarBuilder = new StringBuilder(757);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {std::cout << $e.v << std::endl;};\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 = std::dynamic_pointer_cast<BinaryContext>($ctx)->e(0)->v * std::dynamic_pointer_cast<BinaryContext>($ctx)->e(1)->v;} # binary\n");
|
||||
grammarBuilder.append(" | e '+' e {$v = std::dynamic_pointer_cast<BinaryContext>($ctx)->e(0)->v + std::dynamic_pointer_cast<BinaryContext>($ctx)->e(1)->v;} # binary\n");
|
||||
grammarBuilder.append(" | INT {$v = $INT.int;} # anInt\n");
|
||||
grammarBuilder.append(" | '(' e ')' {$v = $e.v;} # parens\n");
|
||||
grammarBuilder.append(" | left=e INC {$v = $left.v + 1;} # unary\n");
|
||||
|
@ -2007,16 +2004,15 @@ public class TestLeftRecursion extends BaseCppTest {
|
|||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
@Ignore("true")
|
||||
public void testMultipleAlternativesWithCommonLabel_4() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(581);
|
||||
StringBuilder grammarBuilder = new StringBuilder(757);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {std::cout << $e.v << std::endl;};\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 = std::dynamic_pointer_cast<BinaryContext>($ctx)->e(0)->v * std::dynamic_pointer_cast<BinaryContext>($ctx)->e(1)->v;} # binary\n");
|
||||
grammarBuilder.append(" | e '+' e {$v = std::dynamic_pointer_cast<BinaryContext>($ctx)->e(0)->v + std::dynamic_pointer_cast<BinaryContext>($ctx)->e(1)->v;} # binary\n");
|
||||
grammarBuilder.append(" | INT {$v = $INT.int;} # anInt\n");
|
||||
grammarBuilder.append(" | '(' e ')' {$v = $e.v;} # parens\n");
|
||||
grammarBuilder.append(" | left=e INC {$v = $left.v + 1;} # unary\n");
|
||||
|
@ -2118,14 +2114,13 @@ public class TestLeftRecursion extends BaseCppTest {
|
|||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
@Ignore("true")
|
||||
public void testPrefixOpWithActionAndLabel_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(349);
|
||||
StringBuilder grammarBuilder = new StringBuilder(354);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {std::cout << $e.result << std::endl;} ;\n");
|
||||
grammarBuilder.append("e returns [String result]\n");
|
||||
grammarBuilder.append("e returns [std::string result]\n");
|
||||
grammarBuilder.append(" : ID '=' e1=e {$result = \"(\" + $ID.text + \"=\" + $e1.result + \")\";}\n");
|
||||
grammarBuilder.append(" | ID {$result = $ID.text;}\n");
|
||||
grammarBuilder.append(" | e1=e '+' e2=e {$result = \"(\" + $e1.result + \"+\" + $e2.result + \")\";}\n");
|
||||
|
@ -2146,14 +2141,13 @@ public class TestLeftRecursion extends BaseCppTest {
|
|||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
@Ignore("true")
|
||||
public void testPrefixOpWithActionAndLabel_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(349);
|
||||
StringBuilder grammarBuilder = new StringBuilder(354);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {std::cout << $e.result << std::endl;} ;\n");
|
||||
grammarBuilder.append("e returns [String result]\n");
|
||||
grammarBuilder.append("e returns [std::string result]\n");
|
||||
grammarBuilder.append(" : ID '=' e1=e {$result = \"(\" + $ID.text + \"=\" + $e1.result + \")\";}\n");
|
||||
grammarBuilder.append(" | ID {$result = $ID.text;}\n");
|
||||
grammarBuilder.append(" | e1=e '+' e2=e {$result = \"(\" + $e1.result + \"+\" + $e2.result + \")\";}\n");
|
||||
|
@ -2174,14 +2168,13 @@ public class TestLeftRecursion extends BaseCppTest {
|
|||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
@Ignore("true")
|
||||
public void testPrefixOpWithActionAndLabel_3() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(349);
|
||||
StringBuilder grammarBuilder = new StringBuilder(354);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {std::cout << $e.result << std::endl;} ;\n");
|
||||
grammarBuilder.append("e returns [String result]\n");
|
||||
grammarBuilder.append("e returns [std::string result]\n");
|
||||
grammarBuilder.append(" : ID '=' e1=e {$result = \"(\" + $ID.text + \"=\" + $e1.result + \")\";}\n");
|
||||
grammarBuilder.append(" | ID {$result = $ID.text;}\n");
|
||||
grammarBuilder.append(" | e1=e '+' e2=e {$result = \"(\" + $e1.result + \"+\" + $e2.result + \")\";}\n");
|
||||
|
@ -2562,14 +2555,13 @@ public class TestLeftRecursion extends BaseCppTest {
|
|||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
@Ignore("true")
|
||||
public void testReturnValueAndActions_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(255);
|
||||
StringBuilder grammarBuilder = new StringBuilder(279);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {std::cout << $e.v << std::endl;}; \n");
|
||||
grammarBuilder.append("e returns [int v, ignored]\n");
|
||||
grammarBuilder.append("e returns [int v, std::vector<std::string> 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(" | INT {$v = $INT.int;}\n");
|
||||
|
@ -2590,14 +2582,13 @@ public class TestLeftRecursion extends BaseCppTest {
|
|||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
@Ignore("true")
|
||||
public void testReturnValueAndActions_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(255);
|
||||
StringBuilder grammarBuilder = new StringBuilder(279);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {std::cout << $e.v << std::endl;}; \n");
|
||||
grammarBuilder.append("e returns [int v, ignored]\n");
|
||||
grammarBuilder.append("e returns [int v, std::vector<std::string> 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(" | INT {$v = $INT.int;}\n");
|
||||
|
@ -2618,14 +2609,13 @@ public class TestLeftRecursion extends BaseCppTest {
|
|||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
@Ignore("true")
|
||||
public void testReturnValueAndActions_3() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(255);
|
||||
StringBuilder grammarBuilder = new StringBuilder(279);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {std::cout << $e.v << std::endl;}; \n");
|
||||
grammarBuilder.append("e returns [int v, ignored]\n");
|
||||
grammarBuilder.append("e returns [int v, std::vector<std::string> 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(" | INT {$v = $INT.int;}\n");
|
||||
|
@ -2646,14 +2636,13 @@ public class TestLeftRecursion extends BaseCppTest {
|
|||
|
||||
/* This file and method are generated by TestGenerator, any edits will be overwritten by the next generation. */
|
||||
@Test
|
||||
@Ignore("true")
|
||||
public void testReturnValueAndActions_4() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(255);
|
||||
StringBuilder grammarBuilder = new StringBuilder(279);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("s : e {std::cout << $e.v << std::endl;}; \n");
|
||||
grammarBuilder.append("e returns [int v, ignored]\n");
|
||||
grammarBuilder.append("e returns [int v, std::vector<std::string> 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(" | INT {$v = $INT.int;}\n");
|
||||
|
|
|
@ -244,7 +244,7 @@ RuleSempredFunction(r, actions) ::= <<
|
|||
<! Called for both lexer and parser. But only one of them is actually available. !>
|
||||
bool <if (parser)><parser.name><else><lexer.name><endif>::<r.name>Sempred(Ref\<<r.ctxType>\> _localctx, int predicateIndex) {
|
||||
switch (predicateIndex) {
|
||||
<actions: {index | case <index>: return <actions.(index)>;}; separator="\n">
|
||||
<actions: {index | case <index>: return <actions.(index)>}; separator="\n">
|
||||
|
||||
default:
|
||||
break;
|
||||
|
@ -618,7 +618,7 @@ _errHandler->sync(this);
|
|||
<preamble; separator="\n">
|
||||
switch (_input->LA(1)) {
|
||||
<choice.altLook, alts: {look, alt | <cases(ttypes = look)> {
|
||||
<alt>;
|
||||
<alt>
|
||||
break;
|
||||
\}
|
||||
}; separator = "\n">
|
||||
|
@ -687,7 +687,7 @@ _errHandler->sync(this);
|
|||
<! TODO: untested !><preamble; separator = "\n">
|
||||
switch (getInterpreter\<atn::ParserATNSimulator>()->adaptivePredict(_input, <choice.decision>, _ctx)) {
|
||||
<alts: {alt | case <i>: {
|
||||
<alt>;
|
||||
<alt>
|
||||
break;
|
||||
\}
|
||||
}; separator="\n">
|
||||
|
@ -701,7 +701,7 @@ _errHandler->sync(this);
|
|||
|
||||
switch (getInterpreter\<atn::ParserATNSimulator>()->adaptivePredict(_input, <choice.decision>, _ctx)) {
|
||||
<alts: {alt | case <i><if (!choice.ast.greedy)>+1<endif>: {
|
||||
<alt>;
|
||||
<alt>
|
||||
break;
|
||||
\}
|
||||
}; separator = "\n">
|
||||
|
@ -824,7 +824,7 @@ setState(<w.stateNumber>);
|
|||
// ACTION STUFF
|
||||
|
||||
ActionHeader(a, foo, chunks) ::= "<chunks>"
|
||||
Action(a, foo, chunks) ::= "<chunks>"
|
||||
Action(a, foo, chunks) ::= "<if (chunks)><chunks>;<endif>"
|
||||
|
||||
ArgAction(a, chunks) ::= "ArgAction(a, chunks) <chunks>"
|
||||
|
||||
|
@ -832,7 +832,6 @@ SemPredHeader(p, chunks, failChunks) ::= "<! Required but unused. !>"
|
|||
SemPred(p, chunks, failChunks) ::= <<
|
||||
setState(<p.stateNumber>);
|
||||
|
||||
<! TODO: failChunks + p.msg untested !>
|
||||
if (!(<chunks>)) throw FailedPredicateException(this, <p.predicate><if (failChunks)>, <failChunks><elseif (p.msg)>, <p.msg><endif>);
|
||||
>>
|
||||
|
||||
|
@ -1060,12 +1059,12 @@ ctx(actionChunk) ::= "std::dynamic_pointer_cast\<<actionChunk.ctx.name>>(_localc
|
|||
// used for left-recursive rules
|
||||
recRuleAltPredicate(ruleName,opPrec) ::= "precpred(_ctx, <opPrec>)"
|
||||
recRuleSetReturnAction(src,name) ::= "recRuleSetReturnAction(src,name) $<name>=$<src>.<name>;"
|
||||
recRuleSetStopToken() ::= "_ctx->stop = _input->LT(-1);"
|
||||
recRuleSetStopToken() ::= "_ctx->stop = _input->LT(-1)"
|
||||
|
||||
recRuleAltStartAction(ruleName, ctxName, label) ::= <<
|
||||
_localctx = std::make_shared\<<ctxName>Context>(parentContext, parentState);
|
||||
<if (label)>_localctx-><label> = previousContext;<endif>
|
||||
pushNewRecursionContext(_localctx, startState, Rule<ruleName; format = "cap">);
|
||||
pushNewRecursionContext(_localctx, startState, Rule<ruleName; format = "cap">)
|
||||
>>
|
||||
|
||||
// Separate context variable to avoid frequent pointer type casts.
|
||||
|
@ -1085,13 +1084,13 @@ pushNewRecursionContext(newContext, startState, Rule<ruleName; format = "cap">);
|
|||
recRuleReplaceContext(ctxName) ::= <<
|
||||
_localctx = std::make_shared\<<ctxName>Context>(_localctx);
|
||||
_ctx = _localctx;
|
||||
previousContext = _localctx;
|
||||
previousContext = _localctx
|
||||
>>
|
||||
|
||||
recRuleSetPrevCtx() ::= <<
|
||||
if (!_parseListeners.empty())
|
||||
triggerExitRuleEvent();
|
||||
previousContext = _localctx;
|
||||
previousContext = _localctx
|
||||
>>
|
||||
|
||||
/** Using a type to init value map, try to init a type; if not in table
|
||||
|
|
Loading…
Reference in New Issue