Go needs to mimic other tests; regenerated.

This commit is contained in:
parrt 2016-11-07 14:09:31 -08:00
parent 01e3ffa7e5
commit 5fc57fb0b2
2 changed files with 31 additions and 7 deletions

View File

@ -356,6 +356,7 @@ func (m *MyRuleNode) SetAltNumber(altNum int) {
>>
BasicListener(notused) ::= <<
@parser::members {
type LeafListener struct {
*BaseTListener
}
@ -367,6 +368,7 @@ func NewLeafListener() *LeafListener {
func (*LeafListener) VisitTerminal(node antlr.TerminalNode) {
fmt.Println(node.GetSymbol().GetText())
}
}
>>
WalkListener(s) ::= <<
@ -376,6 +378,7 @@ walker.Walk(NewLeafListener(), <s>)
>>
TokenGetterListener(notused) ::= <<
@parser::members {
type LeafListener struct {
*BaseTListener
}
@ -391,9 +394,11 @@ func (*LeafListener) ExitA(ctx *AContext) {
fmt.Println(ctx.ID().GetSymbol())
}
}
}
>>
RuleGetterListener(notused) ::= <<
@parser::members {
type LeafListener struct {
*BaseTListener
}
@ -409,9 +414,11 @@ func (*LeafListener) ExitA(ctx *AContext) {
fmt.Println(ctx.B(0).GetStart().GetText())
}
}
}
>>
LRListener(notused) ::= <<
@parser::members {
type LeafListener struct {
*BaseTListener
}
@ -427,9 +434,11 @@ func (*LeafListener) ExitE(ctx *EContext) {
fmt.Println(ctx.INT().GetSymbol().GetText())
}
}
}
>>
LRWithLabelsListener(notused) ::= <<
@parser::members {
type LeafListener struct {
*BaseTListener
}
@ -445,6 +454,7 @@ func (*LeafListener) ExitCall(ctx *CallContext) {
func (*LeafListener) ExitInt(ctx *IntContext) {
fmt.Println(ctx.INT().GetSymbol().GetText())
}
}
>>
ImportVisitor(X) ::= ""

View File

@ -12,9 +12,10 @@ public class TestListeners extends BaseTest {
@Test
public void testBasic() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(505);
StringBuilder grammarBuilder = new StringBuilder(526);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("\n");
grammarBuilder.append("@parser::members {\n");
grammarBuilder.append("type LeafListener struct {\n");
grammarBuilder.append(" *BaseTListener\n");
grammarBuilder.append("}\n");
@ -26,6 +27,7 @@ public class TestListeners extends BaseTest {
grammarBuilder.append("func (*LeafListener) VisitTerminal(node antlr.TerminalNode) {\n");
grammarBuilder.append(" fmt.Println(node.GetSymbol().GetText())\n");
grammarBuilder.append("}\n");
grammarBuilder.append("}\n");
grammarBuilder.append("\n");
grammarBuilder.append("s\n");
grammarBuilder.append("@after {\n");
@ -58,9 +60,10 @@ public class TestListeners extends BaseTest {
@Test
public void testLR() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(677);
StringBuilder grammarBuilder = new StringBuilder(698);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("\n");
grammarBuilder.append("@parser::members {\n");
grammarBuilder.append("type LeafListener struct {\n");
grammarBuilder.append(" *BaseTListener\n");
grammarBuilder.append("}\n");
@ -76,6 +79,7 @@ public class TestListeners extends BaseTest {
grammarBuilder.append(" fmt.Println(ctx.INT().GetSymbol().GetText())\n");
grammarBuilder.append(" }\n");
grammarBuilder.append("}\n");
grammarBuilder.append("}\n");
grammarBuilder.append("\n");
grammarBuilder.append("s\n");
grammarBuilder.append("@after {\n");
@ -112,9 +116,10 @@ public class TestListeners extends BaseTest {
@Test
public void testLRWithLabels() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(685);
StringBuilder grammarBuilder = new StringBuilder(706);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("\n");
grammarBuilder.append("@parser::members {\n");
grammarBuilder.append("type LeafListener struct {\n");
grammarBuilder.append(" *BaseTListener\n");
grammarBuilder.append("}\n");
@ -130,6 +135,7 @@ public class TestListeners extends BaseTest {
grammarBuilder.append("func (*LeafListener) ExitInt(ctx *IntContext) {\n");
grammarBuilder.append(" fmt.Println(ctx.INT().GetSymbol().GetText())\n");
grammarBuilder.append("}\n");
grammarBuilder.append("}\n");
grammarBuilder.append("\n");
grammarBuilder.append("s\n");
grammarBuilder.append("@after {\n");
@ -165,9 +171,10 @@ public class TestListeners extends BaseTest {
@Test
public void testRuleGetters_1() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(700);
StringBuilder grammarBuilder = new StringBuilder(721);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("\n");
grammarBuilder.append("@parser::members {\n");
grammarBuilder.append("type LeafListener struct {\n");
grammarBuilder.append(" *BaseTListener\n");
grammarBuilder.append("}\n");
@ -183,6 +190,7 @@ public class TestListeners extends BaseTest {
grammarBuilder.append(" fmt.Println(ctx.B(0).GetStart().GetText())\n");
grammarBuilder.append(" }\n");
grammarBuilder.append("}\n");
grammarBuilder.append("}\n");
grammarBuilder.append("\n");
grammarBuilder.append("s\n");
grammarBuilder.append("@after {\n");
@ -215,9 +223,10 @@ public class TestListeners extends BaseTest {
@Test
public void testRuleGetters_2() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(700);
StringBuilder grammarBuilder = new StringBuilder(721);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("\n");
grammarBuilder.append("@parser::members {\n");
grammarBuilder.append("type LeafListener struct {\n");
grammarBuilder.append(" *BaseTListener\n");
grammarBuilder.append("}\n");
@ -233,6 +242,7 @@ public class TestListeners extends BaseTest {
grammarBuilder.append(" fmt.Println(ctx.B(0).GetStart().GetText())\n");
grammarBuilder.append(" }\n");
grammarBuilder.append("}\n");
grammarBuilder.append("}\n");
grammarBuilder.append("\n");
grammarBuilder.append("s\n");
grammarBuilder.append("@after {\n");
@ -265,9 +275,10 @@ public class TestListeners extends BaseTest {
@Test
public void testTokenGetters_1() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(693);
StringBuilder grammarBuilder = new StringBuilder(714);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("\n");
grammarBuilder.append("@parser::members {\n");
grammarBuilder.append("type LeafListener struct {\n");
grammarBuilder.append(" *BaseTListener\n");
grammarBuilder.append("}\n");
@ -283,6 +294,7 @@ public class TestListeners extends BaseTest {
grammarBuilder.append(" fmt.Println(ctx.ID().GetSymbol())\n");
grammarBuilder.append(" }\n");
grammarBuilder.append("}\n");
grammarBuilder.append("}\n");
grammarBuilder.append("\n");
grammarBuilder.append("s\n");
grammarBuilder.append("@after {\n");
@ -314,9 +326,10 @@ public class TestListeners extends BaseTest {
@Test
public void testTokenGetters_2() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(693);
StringBuilder grammarBuilder = new StringBuilder(714);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("\n");
grammarBuilder.append("@parser::members {\n");
grammarBuilder.append("type LeafListener struct {\n");
grammarBuilder.append(" *BaseTListener\n");
grammarBuilder.append("}\n");
@ -332,6 +345,7 @@ public class TestListeners extends BaseTest {
grammarBuilder.append(" fmt.Println(ctx.ID().GetSymbol())\n");
grammarBuilder.append(" }\n");
grammarBuilder.append("}\n");
grammarBuilder.append("}\n");
grammarBuilder.append("\n");
grammarBuilder.append("s\n");
grammarBuilder.append("@after {\n");