TestListeners C++ tests pass now.
- Needed a few adjustments in the test templates for this, which required to change target test templates for all other languages too.
This commit is contained in:
parent
28ccc4962b
commit
be2e71130a
|
@ -328,12 +328,14 @@ public:
|
|||
>>
|
||||
|
||||
BasicListener(X) ::= <<
|
||||
@parser::definitions {
|
||||
class LeafListener : public TBaseListener {
|
||||
public:
|
||||
virtual void visitTerminal(Ref\<tree::TerminalNode> node) override {
|
||||
std::cout \<\< node->getSymbol()->getText() \<\< std::endl;
|
||||
}
|
||||
std::cout \<\< node->getSymbol()->getText() \<\< std::endl;
|
||||
}
|
||||
};
|
||||
}
|
||||
>>
|
||||
|
||||
WalkListener(s) ::= <<
|
||||
|
@ -355,61 +357,63 @@ public:
|
|||
>>
|
||||
|
||||
TokenGetterListener(X) ::= <<
|
||||
class LeafListener : TBaseListener {
|
||||
@parser::definitions {
|
||||
class LeafListener : public TBaseListener {
|
||||
public:
|
||||
void exitA(Ref\<TParser::AContext> ctx) {
|
||||
virtual void exitA(TParser::AContext *ctx) override {
|
||||
if (ctx->getChildCount() == 2)
|
||||
std::cout \<\< ctx->INT(0)->getSymbol()->getText() \<\< ctx->INT(1)->getSymbol()->getText() \<\< ctx->INT() \<\< std::endl;
|
||||
std::cout \<\< ctx->INT(0)->getSymbol()->getText() \<\< " " \<\< ctx->INT(1)->getSymbol()->getText()
|
||||
\<\< " " \<\< Arrays::toString(ctx->INT()) \<\< std::endl;
|
||||
else
|
||||
std::cout \<\< ctx->ID()->getSymbol() \<\< std::endl;
|
||||
std::cout \<\< ctx->ID()->getSymbol()->toString() \<\< std::endl;
|
||||
}
|
||||
};
|
||||
}
|
||||
>>
|
||||
|
||||
RuleGetterListener(X) ::= <<
|
||||
if __name__ is not None and "." in __name__:
|
||||
from .<X>Listener import <X>Listener
|
||||
else:
|
||||
from <X>Listener import <X>Listener
|
||||
|
||||
class LeafListener(TListener):
|
||||
def exitA(self, ctx):
|
||||
if (ctx.getChildCount()==2) {
|
||||
std::cout \<\< ctx.b(0).start.text \<\< " " \<\< ctx.b(1).start.text \<\< " " \<\< ctx.b()[0].start.text;
|
||||
} else {
|
||||
std::cout \<\< ctx.b(0).start.text;
|
||||
}
|
||||
|
||||
@parser::definitions {
|
||||
class LeafListener : public TBaseListener {
|
||||
public:
|
||||
virtual void exitA(TParser::AContext *ctx) override {
|
||||
if (ctx->getChildCount() == 2) {
|
||||
std::cout \<\< ctx->b(0)->start->getText() \<\< " " \<\< ctx->b(1)->start->getText() \<\< " " \<\< ctx->b()[0]->start->getText() \<\< std::endl;
|
||||
} else {
|
||||
std::cout \<\< ctx->b(0)->start->getText() \<\< std::endl;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
>>
|
||||
|
||||
|
||||
LRListener(X) ::= <<
|
||||
if __name__ is not None and "." in __name__:
|
||||
from .<X>Listener import <X>Listener
|
||||
else:
|
||||
from <X>Listener import <X>Listener
|
||||
|
||||
class LeafListener(TListener):
|
||||
def exitE(self, ctx):
|
||||
if ctx.getChildCount()==3:
|
||||
std::cout \<\< ctx.e(0).start.text \<\< " " \<\< ctx.e(1).start.text \<\< " " \<\< ctx.e()[0].start.text;
|
||||
else:
|
||||
std::cout \<\< ctx.INT().symbol.text;
|
||||
|
||||
@parser::definitions {
|
||||
class LeafListener : public TBaseListener {
|
||||
public:
|
||||
virtual void exitE(TParser::EContext *ctx) override {
|
||||
if (ctx->getChildCount() == 3) {
|
||||
std::cout \<\< ctx->e(0)->start->getText() \<\< " " \<\< ctx->e(1)->start->getText() \<\< " " \<\< ctx->e()[0]->start->getText() \<\< std::endl;
|
||||
} else {
|
||||
std::cout \<\< ctx->INT()->getSymbol()->getText() \<\< std::endl;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
>>
|
||||
|
||||
LRWithLabelsListener(X) ::= <<
|
||||
if __name__ is not None and "." in __name__:
|
||||
from .<X>Listener import <X>Listener
|
||||
else:
|
||||
from <X>Listener import <X>Listener
|
||||
|
||||
class LeafListener(TListener):
|
||||
def exitCall(self, ctx):
|
||||
std::cout \<\< ctx.e().start.text \<\< " " \<\< str(ctx.eList());
|
||||
def exitInt(self, ctx):
|
||||
std::cout \<\< ctx.INT().symbol.text;
|
||||
|
||||
@parser::definitions {
|
||||
class LeafListener : public TBaseListener {
|
||||
public:
|
||||
virtual void exitCall(TParser::CallContext *ctx) override {
|
||||
std::cout \<\< ctx->e()->start->getText() \<\< " " \<\< ctx->eList()->toString() \<\< std::endl;
|
||||
}
|
||||
virtual void exitInt(TParser::IntContext *ctx) override {
|
||||
std::cout \<\< ctx->INT()->getSymbol()->getText() \<\< std::endl;
|
||||
}
|
||||
};
|
||||
}
|
||||
>>
|
||||
|
||||
DeclareContextListGettersFunction() ::= <<
|
||||
|
|
|
@ -317,11 +317,13 @@ public class PositionAdjustingLexerATNSimulator : LexerATNSimulator {
|
|||
>>
|
||||
|
||||
BasicListener(X) ::= <<
|
||||
@parser::members {
|
||||
public class LeafListener : TBaseListener {
|
||||
public override void VisitTerminal(ITerminalNode node) {
|
||||
Console.WriteLine(node.Symbol.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
WalkListener(s) ::= <<
|
||||
|
@ -343,6 +345,7 @@ public class MyRuleNode : ParserRuleContext {
|
|||
>>
|
||||
|
||||
TokenGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
public class LeafListener : TBaseListener {
|
||||
public override void ExitA(TParser.AContext ctx) {
|
||||
if (ctx.ChildCount==2)
|
||||
|
@ -361,9 +364,11 @@ public class LeafListener : TBaseListener {
|
|||
Console.WriteLine(ctx.ID().Symbol);
|
||||
}
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
RuleGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
public class LeafListener : TBaseListener {
|
||||
public override void ExitA(TParser.AContext ctx) {
|
||||
if (ctx.ChildCount==2) {
|
||||
|
@ -373,10 +378,12 @@ public class LeafListener : TBaseListener {
|
|||
Console.WriteLine(ctx.b(0).Start.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
|
||||
LRListener(X) ::= <<
|
||||
@parser::members {
|
||||
public class LeafListener : TBaseListener {
|
||||
public override void ExitE(TParser.EContext ctx) {
|
||||
if (ctx.ChildCount==3) {
|
||||
|
@ -386,9 +393,11 @@ public class LeafListener : TBaseListener {
|
|||
Console.WriteLine(ctx.INT().Symbol.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
LRWithLabelsListener(X) ::= <<
|
||||
@parser::members {
|
||||
public class LeafListener : TBaseListener {
|
||||
public override void ExitCall(TParser.CallContext ctx) {
|
||||
Console.Write("{0} {1}",ctx.e().Start.Text,ctx.eList());
|
||||
|
@ -397,6 +406,7 @@ public class LeafListener : TBaseListener {
|
|||
Console.WriteLine(ctx.INT().Symbol.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
DeclareContextListGettersFunction() ::= <<
|
||||
|
|
|
@ -329,11 +329,13 @@ protected static class PositionAdjustingLexerATNSimulator extends LexerATNSimula
|
|||
>>
|
||||
|
||||
BasicListener(X) ::= <<
|
||||
@parser::members {
|
||||
public static class LeafListener extends TBaseListener {
|
||||
public void visitTerminal(TerminalNode node) {
|
||||
System.out.println(node.getSymbol().getText());
|
||||
}
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
WalkListener(s) ::= <<
|
||||
|
@ -355,6 +357,7 @@ public static class MyRuleNode extends ParserRuleContext {
|
|||
>>
|
||||
|
||||
TokenGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
public static class LeafListener extends TBaseListener {
|
||||
public void exitA(TParser.AContext ctx) {
|
||||
if (ctx.getChildCount()==2)
|
||||
|
@ -364,9 +367,11 @@ public static class LeafListener extends TBaseListener {
|
|||
System.out.println(ctx.ID().getSymbol());
|
||||
}
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
RuleGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
public static class LeafListener extends TBaseListener {
|
||||
public void exitA(TParser.AContext ctx) {
|
||||
if (ctx.getChildCount()==2) {
|
||||
|
@ -376,10 +381,12 @@ public static class LeafListener extends TBaseListener {
|
|||
System.out.println(ctx.b(0).start.getText());
|
||||
}
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
|
||||
LRListener(X) ::= <<
|
||||
@parser::members {
|
||||
public static class LeafListener extends TBaseListener {
|
||||
public void exitE(TParser.EContext ctx) {
|
||||
if (ctx.getChildCount()==3) {
|
||||
|
@ -389,9 +396,11 @@ public static class LeafListener extends TBaseListener {
|
|||
System.out.println(ctx.INT().getSymbol().getText());
|
||||
}
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
LRWithLabelsListener(X) ::= <<
|
||||
@parser::members {
|
||||
public static class LeafListener extends TBaseListener {
|
||||
public void exitCall(TParser.CallContext ctx) {
|
||||
System.out.printf("%s %s",ctx.e().start.getText(),ctx.eList());
|
||||
|
@ -400,6 +409,7 @@ public static class LeafListener extends TBaseListener {
|
|||
System.out.println(ctx.INT().getSymbol().getText());
|
||||
}
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
DeclareContextListGettersFunction() ::= <<
|
||||
|
|
|
@ -225,7 +225,11 @@ LANotEquals(i, v) ::= <%this._input.LA(<i>)!=<v>%>
|
|||
|
||||
TokenStartColumnEquals(i) ::= <%this._tokenStartColumn===<i>%>
|
||||
|
||||
ImportListener(X) ::= <<var <X>Listener = require('./<X>Listener').<X>Listener;>>
|
||||
ImportListener(X) ::= <<
|
||||
@parser::header {
|
||||
var <X>Listener = require('./<X>Listener').<X>Listener;
|
||||
}
|
||||
>>
|
||||
|
||||
GetExpectedTokenNames() ::= "this.getExpectedTokens().toString(this.literalNames)"
|
||||
|
||||
|
@ -308,6 +312,7 @@ PositionAdjustingLexer.isIdentifierChar = function(c) {
|
|||
>>
|
||||
|
||||
BasicListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.visitTerminal = function(node) {
|
||||
document.getElementById('output').value += node.symbol.text + '\\n';
|
||||
|
@ -316,7 +321,7 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
WalkListener(s) ::= <<
|
||||
|
@ -325,7 +330,6 @@ walker.walk(new this.LeafListener(), <s>);
|
|||
>>
|
||||
|
||||
TreeNodeWithAltNumField(X) ::= <<
|
||||
|
||||
@parser::header {
|
||||
MyRuleNode = function(parent, invokingState) {
|
||||
antlr4.ParserRuleContext.call(this, parent, invokingState);
|
||||
|
@ -339,6 +343,7 @@ MyRuleNode.prototype.constructor = MyRuleNode;
|
|||
>>
|
||||
|
||||
TokenGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitA = function(ctx) {
|
||||
var str;
|
||||
|
@ -353,10 +358,11 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
RuleGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitA = function(ctx) {
|
||||
var str;
|
||||
|
@ -371,11 +377,12 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
|
||||
LRListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitE = function(ctx) {
|
||||
var str;
|
||||
|
@ -390,10 +397,11 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
LRWithLabelsListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitCall = function(ctx) {
|
||||
var str = ctx.e().start.text + ' ' + ctx.eList();
|
||||
|
@ -407,7 +415,7 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
DeclareContextListGettersFunction() ::= <<
|
||||
|
|
|
@ -227,7 +227,11 @@ LANotEquals(i, v) ::= <%this._input.LA(<i>)!=<v>%>
|
|||
|
||||
TokenStartColumnEquals(i) ::= <%this._tokenStartColumn===<i>%>
|
||||
|
||||
ImportListener(X) ::= <<var <X>Listener = require('./<X>Listener').<X>Listener;>>
|
||||
ImportListener(X) ::= <<
|
||||
@parser::header {
|
||||
var <X>Listener = require('./<X>Listener').<X>Listener;
|
||||
}
|
||||
>>
|
||||
|
||||
GetExpectedTokenNames() ::= "this.getExpectedTokens().toString(this.literalNames)"
|
||||
|
||||
|
@ -310,6 +314,7 @@ PositionAdjustingLexer.isIdentifierChar = function(c) {
|
|||
>>
|
||||
|
||||
BasicListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.visitTerminal = function(node) {
|
||||
document.getElementById('output').value += node.symbol.text + '\\n';
|
||||
|
@ -318,7 +323,7 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
WalkListener(s) ::= <<
|
||||
|
@ -327,7 +332,6 @@ walker.walk(new this.LeafListener(), <s>);
|
|||
>>
|
||||
|
||||
TreeNodeWithAltNumField(X) ::= <<
|
||||
|
||||
@parser::header {
|
||||
MyRuleNode = function(parent, invokingState) {
|
||||
antlr4.ParserRuleContext.call(this, parent, invokingState);
|
||||
|
@ -341,6 +345,7 @@ MyRuleNode.prototype.constructor = MyRuleNode;
|
|||
>>
|
||||
|
||||
TokenGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitA = function(ctx) {
|
||||
var str;
|
||||
|
@ -355,10 +360,11 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
RuleGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitA = function(ctx) {
|
||||
var str;
|
||||
|
@ -373,11 +379,12 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
|
||||
LRListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitE = function(ctx) {
|
||||
var str;
|
||||
|
@ -392,10 +399,11 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
LRWithLabelsListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitCall = function(ctx) {
|
||||
var str = ctx.e().start.text + ' ' + ctx.eList();
|
||||
|
@ -409,7 +417,7 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
DeclareContextListGettersFunction() ::= <<
|
||||
|
|
|
@ -225,7 +225,11 @@ LANotEquals(i, v) ::= <%this._input.LA(<i>)!=<v>%>
|
|||
|
||||
TokenStartColumnEquals(i) ::= <%this._tokenStartColumn===<i>%>
|
||||
|
||||
ImportListener(X) ::= <<var <X>Listener = require('./<X>Listener').<X>Listener;>>
|
||||
ImportListener(X) ::= <<
|
||||
@parser::header {
|
||||
var <X>Listener = require('./<X>Listener').<X>Listener;
|
||||
}
|
||||
>>
|
||||
|
||||
GetExpectedTokenNames() ::= "this.getExpectedTokens().toString(this.literalNames)"
|
||||
|
||||
|
@ -308,6 +312,7 @@ PositionAdjustingLexer.isIdentifierChar = function(c) {
|
|||
>>
|
||||
|
||||
BasicListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.visitTerminal = function(node) {
|
||||
console.log(node.symbol.text);
|
||||
|
@ -316,7 +321,7 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
WalkListener(s) ::= <<
|
||||
|
@ -325,7 +330,6 @@ walker.walk(new this.LeafListener(), <s>);
|
|||
>>
|
||||
|
||||
TreeNodeWithAltNumField(X) ::= <<
|
||||
|
||||
@parser::header {
|
||||
MyRuleNode = function(parent, invokingState) {
|
||||
antlr4.ParserRuleContext.call(this, parent, invokingState);
|
||||
|
@ -343,6 +347,7 @@ MyRuleNode.prototype.setAltNumber = function(altNumber) { this.altNum = altNumbe
|
|||
>>
|
||||
|
||||
TokenGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitA = function(ctx) {
|
||||
var str;
|
||||
|
@ -357,10 +362,11 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
RuleGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitA = function(ctx) {
|
||||
var str;
|
||||
|
@ -375,11 +381,12 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
|
||||
LRListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitE = function(ctx) {
|
||||
var str;
|
||||
|
@ -394,10 +401,11 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
LRWithLabelsListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitCall = function(ctx) {
|
||||
var str = ctx.e().start.text + ' ' + ctx.eList();
|
||||
|
@ -411,7 +419,7 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
DeclareContextListGettersFunction() ::= <<
|
||||
|
|
|
@ -225,7 +225,11 @@ LANotEquals(i, v) ::= <%this._input.LA(<i>)!=<v>%>
|
|||
|
||||
TokenStartColumnEquals(i) ::= <%this._tokenStartColumn===<i>%>
|
||||
|
||||
ImportListener(X) ::= <<var <X>Listener = require('./<X>Listener').<X>Listener;>>
|
||||
ImportListener(X) ::= <<
|
||||
@parser::header {
|
||||
var <X>Listener = require('./<X>Listener').<X>Listener;
|
||||
}
|
||||
>>
|
||||
|
||||
GetExpectedTokenNames() ::= "this.getExpectedTokens().toString(this.literalNames)"
|
||||
|
||||
|
@ -308,6 +312,7 @@ PositionAdjustingLexer.isIdentifierChar = function(c) {
|
|||
>>
|
||||
|
||||
BasicListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.visitTerminal = function(node) {
|
||||
document.getElementById('output').value += node.symbol.text + '\\n';
|
||||
|
@ -316,7 +321,7 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
WalkListener(s) ::= <<
|
||||
|
@ -325,7 +330,6 @@ walker.walk(new this.LeafListener(), <s>);
|
|||
>>
|
||||
|
||||
TreeNodeWithAltNumField(X) ::= <<
|
||||
|
||||
@parser::header {
|
||||
MyRuleNode = function(parent, invokingState) {
|
||||
antlr4.ParserRuleContext.call(this, parent, invokingState);
|
||||
|
@ -340,6 +344,7 @@ MyRuleNode.prototype.constructor = MyRuleNode;
|
|||
|
||||
|
||||
TokenGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitA = function(ctx) {
|
||||
var str;
|
||||
|
@ -354,10 +359,11 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
RuleGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitA = function(ctx) {
|
||||
var str;
|
||||
|
@ -372,11 +378,12 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
|
||||
LRListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitE = function(ctx) {
|
||||
var str;
|
||||
|
@ -391,10 +398,11 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
LRWithLabelsListener(X) ::= <<
|
||||
@parser::members {
|
||||
this.LeafListener = function() {
|
||||
this.exitCall = function(ctx) {
|
||||
var str = ctx.e().start.text + ' ' + ctx.eList();
|
||||
|
@ -408,7 +416,7 @@ this.LeafListener = function() {
|
|||
};
|
||||
this.LeafListener.prototype = Object.create(<X>Listener.prototype);
|
||||
this.LeafListener.prototype.constructor = this.LeafListener;
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
DeclareContextListGettersFunction() ::= <<
|
||||
|
|
|
@ -298,6 +298,7 @@ def isIdentifierChar(c):
|
|||
>>
|
||||
|
||||
BasicListener(X) ::= <<
|
||||
@parser::members {
|
||||
if __name__ is not None and "." in __name__:
|
||||
from .<X>Listener import <X>Listener
|
||||
else:
|
||||
|
@ -306,7 +307,7 @@ else:
|
|||
class LeafListener(TListener):
|
||||
def visitTerminal(self, node):
|
||||
print(node.symbol.text)
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
WalkListener(s) ::= <<
|
||||
|
@ -328,6 +329,7 @@ class MyRuleNode(ParserRuleContext):
|
|||
>>
|
||||
|
||||
TokenGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
if __name__ is not None and "." in __name__:
|
||||
from .<X>Listener import <X>Listener
|
||||
else:
|
||||
|
@ -339,10 +341,11 @@ class LeafListener(TListener):
|
|||
print(ctx.INT(0).symbol.text + ' ' + ctx.INT(1).symbol.text + ' ' + str_list(ctx.INT()))
|
||||
else:
|
||||
print(str(ctx.ID().symbol))
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
RuleGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
if __name__ is not None and "." in __name__:
|
||||
from .<X>Listener import <X>Listener
|
||||
else:
|
||||
|
@ -354,11 +357,12 @@ class LeafListener(TListener):
|
|||
print(ctx.b(0).start.text + ' ' + ctx.b(1).start.text + ' ' + ctx.b()[0].start.text)
|
||||
else:
|
||||
print(ctx.b(0).start.text)
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
|
||||
LRListener(X) ::= <<
|
||||
@parser::members {
|
||||
if __name__ is not None and "." in __name__:
|
||||
from .<X>Listener import <X>Listener
|
||||
else:
|
||||
|
@ -370,10 +374,11 @@ class LeafListener(TListener):
|
|||
print(ctx.e(0).start.text + ' ' + ctx.e(1).start.text + ' ' + ctx.e()[0].start.text)
|
||||
else:
|
||||
print(ctx.INT().symbol.text)
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
LRWithLabelsListener(X) ::= <<
|
||||
@parser::members {
|
||||
if __name__ is not None and "." in __name__:
|
||||
from .<X>Listener import <X>Listener
|
||||
else:
|
||||
|
@ -384,7 +389,7 @@ class LeafListener(TListener):
|
|||
print(ctx.e().start.text + ' ' + str(ctx.eList()))
|
||||
def exitInt(self, ctx):
|
||||
print(ctx.INT().symbol.text)
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
DeclareContextListGettersFunction() ::= <<
|
||||
|
|
|
@ -229,8 +229,11 @@ LANotEquals(i, v) ::= <%self._input.LA(<i>)!=<v>%>
|
|||
|
||||
TokenStartColumnEquals(i) ::= <%self._tokenStartColumn==<i>%>
|
||||
|
||||
ImportListener(X) ::= <<class MockListener:
|
||||
ImportListener(X) ::= <<
|
||||
@parser::header {
|
||||
class MockListener:
|
||||
pass
|
||||
}
|
||||
>>
|
||||
|
||||
GetExpectedTokenNames() ::= "self.getExpectedTokens().toString(self.literalNames, self.symbolicNames)"
|
||||
|
@ -300,10 +303,11 @@ def isIdentifierChar(c):
|
|||
>>
|
||||
|
||||
BasicListener(X) ::= <<
|
||||
@parser::members {
|
||||
class LeafListener(MockListener):
|
||||
def visitTerminal(self, node):
|
||||
print(node.symbol.text)
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
WalkListener(s) ::= <<
|
||||
|
@ -330,43 +334,47 @@ class MyRuleNode(ParserRuleContext):
|
|||
>>
|
||||
|
||||
TokenGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
class LeafListener(MockListener):
|
||||
def exitA(self, ctx):
|
||||
if ctx.getChildCount()==2:
|
||||
print(ctx.INT(0).symbol.text + ' ' + ctx.INT(1).symbol.text + ' ' + str_list(ctx.INT()))
|
||||
else:
|
||||
print(str(ctx.ID().symbol))
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
RuleGetterListener(X) ::= <<
|
||||
@parser::members {
|
||||
class LeafListener(MockListener):
|
||||
def exitA(self, ctx):
|
||||
if ctx.getChildCount()==2:
|
||||
print(ctx.b(0).start.text + ' ' + ctx.b(1).start.text + ' ' + ctx.b()[0].start.text)
|
||||
else:
|
||||
print(ctx.b(0).start.text)
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
|
||||
LRListener(X) ::= <<
|
||||
@parser::members {
|
||||
class LeafListener(MockListener):
|
||||
def exitE(self, ctx):
|
||||
if ctx.getChildCount()==3:
|
||||
print(ctx.e(0).start.text + ' ' + ctx.e(1).start.text + ' ' + ctx.e()[0].start.text)
|
||||
else:
|
||||
print(ctx.INT().symbol.text)
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
LRWithLabelsListener(X) ::= <<
|
||||
@parser::members {
|
||||
class LeafListener(MockListener):
|
||||
def exitCall(self, ctx):
|
||||
print(ctx.e().start.text + ' ' + str(ctx.eList()))
|
||||
def exitInt(self, ctx):
|
||||
print(ctx.INT().symbol.text)
|
||||
|
||||
}
|
||||
>>
|
||||
|
||||
DeclareContextListGettersFunction() ::= <<
|
||||
|
|
|
@ -22,18 +22,14 @@ Errors() ::= ""
|
|||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
@parser::header {
|
||||
<ImportListener(grammarName)>
|
||||
}
|
||||
|
||||
@parser::members {
|
||||
<ImportListener(grammarName)>
|
||||
<BasicListener(grammarName)>
|
||||
}
|
||||
|
||||
s
|
||||
@after {
|
||||
<ToStringTree("$ctx.r"):writeln()>
|
||||
<WalkListener("$ctx.r")>
|
||||
<ContextRuleFunction("$ctx", "r"):ToStringTree():writeln()>
|
||||
<ContextRuleFunction("$ctx", "r"):WalkListener()>
|
||||
}
|
||||
: r=a ;
|
||||
a : INT INT
|
||||
|
|
|
@ -25,18 +25,14 @@ Errors() ::= ""
|
|||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
@parser::header {
|
||||
<ImportListener(grammarName)>
|
||||
}
|
||||
|
||||
@parser::members {
|
||||
<ImportListener(grammarName)>
|
||||
<LRListener(grammarName)>
|
||||
}
|
||||
|
||||
s
|
||||
@after {
|
||||
<ToStringTree("$ctx.r"):writeln()>
|
||||
<WalkListener("$ctx.r")>
|
||||
<ContextRuleFunction("$ctx", "r"):ToStringTree():writeln()>
|
||||
<ContextRuleFunction("$ctx", "r"):WalkListener()>
|
||||
}
|
||||
: r=e ;
|
||||
e : e op='*' e
|
||||
|
|
|
@ -24,18 +24,14 @@ Errors() ::= ""
|
|||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
@parser::header {
|
||||
<ImportListener(grammarName)>
|
||||
}
|
||||
|
||||
@parser::members {
|
||||
<ImportListener(grammarName)>
|
||||
<LRWithLabelsListener(grammarName)>
|
||||
}
|
||||
|
||||
s
|
||||
@after {
|
||||
<ToStringTree("$ctx.r"):writeln()>
|
||||
<WalkListener("$ctx.r")>
|
||||
<ContextRuleFunction("$ctx", "r"):ToStringTree():writeln()>
|
||||
<ContextRuleFunction("$ctx", "r"):WalkListener()>
|
||||
}
|
||||
: r=e ;
|
||||
e : e '(' eList ')' # Call
|
||||
|
|
|
@ -12,18 +12,14 @@ Rule() ::= "s"
|
|||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
@parser::header {
|
||||
<ImportListener(grammarName)>
|
||||
}
|
||||
|
||||
@parser::members {
|
||||
<ImportListener(grammarName)>
|
||||
<RuleGetterListener(grammarName)>
|
||||
}
|
||||
|
||||
s
|
||||
@after {
|
||||
<ToStringTree("$ctx.r"):writeln()>
|
||||
<WalkListener("$ctx.r")>
|
||||
<ContextRuleFunction("$ctx", "r"):ToStringTree():writeln()>
|
||||
<ContextRuleFunction("$ctx", "r"):WalkListener()>
|
||||
}
|
||||
: r=a ;
|
||||
a : b b // forces list
|
||||
|
|
|
@ -12,18 +12,14 @@ Rule() ::= "s"
|
|||
|
||||
grammar(grammarName) ::= <<
|
||||
grammar <grammarName>;
|
||||
@parser::header {
|
||||
<ImportListener(grammarName)>
|
||||
}
|
||||
|
||||
@parser::members {
|
||||
<ImportListener(grammarName)>
|
||||
<TokenGetterListener(grammarName)>
|
||||
}
|
||||
|
||||
s
|
||||
@after {
|
||||
<ToStringTree("$ctx.r"):writeln()>
|
||||
<WalkListener("$ctx.r")>
|
||||
<ContextRuleFunction("$ctx", "r"):ToStringTree():writeln()>
|
||||
<ContextRuleFunction("$ctx", "r"):WalkListener()>
|
||||
}
|
||||
: r=a ;
|
||||
a : INT INT
|
||||
|
|
|
@ -13,28 +13,22 @@ public class TestListeners extends BaseCppTest {
|
|||
public void testBasic() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(533);
|
||||
StringBuilder grammarBuilder = new StringBuilder(484);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\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("@parser::definitions {\n");
|
||||
grammarBuilder.append("class LeafListener : public TBaseListener {\n");
|
||||
grammarBuilder.append("public:\n");
|
||||
grammarBuilder.append(" virtual void visitTerminal(Ref<tree::TerminalNode> node) override {\n");
|
||||
grammarBuilder.append(" std::cout << node->getSymbol()->getText() << std::endl;\n");
|
||||
grammarBuilder.append(" }\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
grammarBuilder.append("std::cout << $ctx.r.toStringTree(recog=self) << \"\\n\";\n");
|
||||
grammarBuilder.append("walker = ParseTreeWalker()\n");
|
||||
grammarBuilder.append("walker.walk(TParser.LeafListener(), $ctx.r)\n");
|
||||
grammarBuilder.append("std::cout << $ctx->r->toStringTree(this) << std::endl;\n");
|
||||
grammarBuilder.append("tree::ParseTreeWalker::DEFAULT->walk(std::make_shared<LeafListener>(), $ctx->r);\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append(" : r=a ;\n");
|
||||
grammarBuilder.append("a : INT INT\n");
|
||||
|
@ -64,31 +58,26 @@ public class TestListeners extends BaseCppTest {
|
|||
public void testLR() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(705);
|
||||
StringBuilder grammarBuilder = new StringBuilder(690);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\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("@parser::definitions {\n");
|
||||
grammarBuilder.append("class LeafListener : public TBaseListener {\n");
|
||||
grammarBuilder.append("public:\n");
|
||||
grammarBuilder.append(" virtual void exitE(TParser::EContext *ctx) override {\n");
|
||||
grammarBuilder.append(" if (ctx->getChildCount() == 3) {\n");
|
||||
grammarBuilder.append(" std::cout << ctx->e(0)->start->getText() << \" \" << ctx->e(1)->start->getText() << \" \" << ctx->e()[0]->start->getText() << std::endl;\n");
|
||||
grammarBuilder.append(" } else {\n");
|
||||
grammarBuilder.append(" std::cout << ctx->INT()->getSymbol()->getText() << std::endl;\n");
|
||||
grammarBuilder.append(" }\n");
|
||||
grammarBuilder.append(" }\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
grammarBuilder.append("std::cout << $ctx.r.toStringTree(recog=self) << \"\\n\";\n");
|
||||
grammarBuilder.append("walker = ParseTreeWalker()\n");
|
||||
grammarBuilder.append("walker.walk(TParser.LeafListener(), $ctx.r)\n");
|
||||
grammarBuilder.append("std::cout << $ctx->r->toStringTree(this) << std::endl;\n");
|
||||
grammarBuilder.append("tree::ParseTreeWalker::DEFAULT->walk(std::make_shared<LeafListener>(), $ctx->r);\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append(" : r=e ;\n");
|
||||
grammarBuilder.append("e : e op='*' e\n");
|
||||
|
@ -122,30 +111,25 @@ public class TestListeners extends BaseCppTest {
|
|||
public void testLRWithLabels() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(683);
|
||||
StringBuilder grammarBuilder = new StringBuilder(692);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\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("@parser::definitions {\n");
|
||||
grammarBuilder.append("class LeafListener : public TBaseListener {\n");
|
||||
grammarBuilder.append("public:\n");
|
||||
grammarBuilder.append(" virtual void exitCall(TParser::CallContext *ctx) override {\n");
|
||||
grammarBuilder.append(" std::cout << ctx->e()->start->getText() << \" \" << ctx->eList()->toString() << std::endl;\n");
|
||||
grammarBuilder.append(" }\n");
|
||||
grammarBuilder.append(" virtual void exitInt(TParser::IntContext *ctx) override {\n");
|
||||
grammarBuilder.append(" std::cout << ctx->INT()->getSymbol()->getText() << std::endl;\n");
|
||||
grammarBuilder.append(" }\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
grammarBuilder.append("std::cout << $ctx.r.toStringTree(recog=self) << \"\\n\";\n");
|
||||
grammarBuilder.append("walker = ParseTreeWalker()\n");
|
||||
grammarBuilder.append("walker.walk(TParser.LeafListener(), $ctx.r)\n");
|
||||
grammarBuilder.append("std::cout << $ctx->r->toStringTree(this) << std::endl;\n");
|
||||
grammarBuilder.append("tree::ParseTreeWalker::DEFAULT->walk(std::make_shared<LeafListener>(), $ctx->r);\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append(" : r=e ;\n");
|
||||
grammarBuilder.append("e : e '(' eList ')' # Call\n");
|
||||
|
@ -178,32 +162,26 @@ public class TestListeners extends BaseCppTest {
|
|||
public void testRuleGetters_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(732);
|
||||
StringBuilder grammarBuilder = new StringBuilder(710);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\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("@parser::definitions {\n");
|
||||
grammarBuilder.append("class LeafListener : public TBaseListener {\n");
|
||||
grammarBuilder.append("public:\n");
|
||||
grammarBuilder.append(" virtual void exitA(TParser::AContext *ctx) override {\n");
|
||||
grammarBuilder.append(" if (ctx->getChildCount() == 2) {\n");
|
||||
grammarBuilder.append(" std::cout << ctx->b(0)->start->getText() << \" \" << ctx->b(1)->start->getText() << \" \" << ctx->b()[0]->start->getText() << std::endl;\n");
|
||||
grammarBuilder.append(" } else {\n");
|
||||
grammarBuilder.append(" std::cout << ctx->b(0)->start->getText() << std::endl;\n");
|
||||
grammarBuilder.append(" }\n");
|
||||
grammarBuilder.append(" }\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
grammarBuilder.append("std::cout << $ctx.r.toStringTree(recog=self) << \"\\n\";\n");
|
||||
grammarBuilder.append("walker = ParseTreeWalker()\n");
|
||||
grammarBuilder.append("walker.walk(TParser.LeafListener(), $ctx.r)\n");
|
||||
grammarBuilder.append("std::cout << $ctx->r->toStringTree(this) << std::endl;\n");
|
||||
grammarBuilder.append("tree::ParseTreeWalker::DEFAULT->walk(std::make_shared<LeafListener>(), $ctx->r);\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append(" : r=a ;\n");
|
||||
grammarBuilder.append("a : b b // forces list\n");
|
||||
|
@ -233,32 +211,26 @@ public class TestListeners extends BaseCppTest {
|
|||
public void testRuleGetters_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(732);
|
||||
StringBuilder grammarBuilder = new StringBuilder(710);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\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("@parser::definitions {\n");
|
||||
grammarBuilder.append("class LeafListener : public TBaseListener {\n");
|
||||
grammarBuilder.append("public:\n");
|
||||
grammarBuilder.append(" virtual void exitA(TParser::AContext *ctx) override {\n");
|
||||
grammarBuilder.append(" if (ctx->getChildCount() == 2) {\n");
|
||||
grammarBuilder.append(" std::cout << ctx->b(0)->start->getText() << \" \" << ctx->b(1)->start->getText() << \" \" << ctx->b()[0]->start->getText() << std::endl;\n");
|
||||
grammarBuilder.append(" } else {\n");
|
||||
grammarBuilder.append(" std::cout << ctx->b(0)->start->getText() << std::endl;\n");
|
||||
grammarBuilder.append(" }\n");
|
||||
grammarBuilder.append(" }\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
grammarBuilder.append("std::cout << $ctx.r.toStringTree(recog=self) << \"\\n\";\n");
|
||||
grammarBuilder.append("walker = ParseTreeWalker()\n");
|
||||
grammarBuilder.append("walker.walk(TParser.LeafListener(), $ctx.r)\n");
|
||||
grammarBuilder.append("std::cout << $ctx->r->toStringTree(this) << std::endl;\n");
|
||||
grammarBuilder.append("tree::ParseTreeWalker::DEFAULT->walk(std::make_shared<LeafListener>(), $ctx->r);\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append(" : r=a ;\n");
|
||||
grammarBuilder.append("a : b b // forces list\n");
|
||||
|
@ -288,32 +260,26 @@ public class TestListeners extends BaseCppTest {
|
|||
public void testTokenGetters_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(702);
|
||||
StringBuilder grammarBuilder = new StringBuilder(675);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\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("@parser::definitions {\n");
|
||||
grammarBuilder.append("class LeafListener : public TBaseListener {\n");
|
||||
grammarBuilder.append("public:\n");
|
||||
grammarBuilder.append(" virtual void exitA(TParser::AContext *ctx) override {\n");
|
||||
grammarBuilder.append(" if (ctx->getChildCount() == 2)\n");
|
||||
grammarBuilder.append(" std::cout << ctx->INT(0)->getSymbol()->getText() << \" \" << ctx->INT(1)->getSymbol()->getText()\n");
|
||||
grammarBuilder.append(" << \" \" << Arrays::toString(ctx->INT()) << std::endl;\n");
|
||||
grammarBuilder.append(" else\n");
|
||||
grammarBuilder.append(" std::cout << ctx->ID()->getSymbol()->toString() << std::endl;\n");
|
||||
grammarBuilder.append(" }\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
grammarBuilder.append("std::cout << $ctx.r.toStringTree(recog=self) << \"\\n\";\n");
|
||||
grammarBuilder.append("walker = ParseTreeWalker()\n");
|
||||
grammarBuilder.append("walker.walk(TParser.LeafListener(), $ctx.r)\n");
|
||||
grammarBuilder.append("std::cout << $ctx->r->toStringTree(this) << std::endl;\n");
|
||||
grammarBuilder.append("tree::ParseTreeWalker::DEFAULT->walk(std::make_shared<LeafListener>(), $ctx->r);\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append(" : r=a ;\n");
|
||||
grammarBuilder.append("a : INT INT\n");
|
||||
|
@ -342,32 +308,26 @@ public class TestListeners extends BaseCppTest {
|
|||
public void testTokenGetters_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(702);
|
||||
StringBuilder grammarBuilder = new StringBuilder(675);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\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("@parser::definitions {\n");
|
||||
grammarBuilder.append("class LeafListener : public TBaseListener {\n");
|
||||
grammarBuilder.append("public:\n");
|
||||
grammarBuilder.append(" virtual void exitA(TParser::AContext *ctx) override {\n");
|
||||
grammarBuilder.append(" if (ctx->getChildCount() == 2)\n");
|
||||
grammarBuilder.append(" std::cout << ctx->INT(0)->getSymbol()->getText() << \" \" << ctx->INT(1)->getSymbol()->getText()\n");
|
||||
grammarBuilder.append(" << \" \" << Arrays::toString(ctx->INT()) << std::endl;\n");
|
||||
grammarBuilder.append(" else\n");
|
||||
grammarBuilder.append(" std::cout << ctx->ID()->getSymbol()->toString() << std::endl;\n");
|
||||
grammarBuilder.append(" }\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
grammarBuilder.append("@after {\n");
|
||||
grammarBuilder.append("std::cout << $ctx.r.toStringTree(recog=self) << \"\\n\";\n");
|
||||
grammarBuilder.append("walker = ParseTreeWalker()\n");
|
||||
grammarBuilder.append("walker.walk(TParser.LeafListener(), $ctx.r)\n");
|
||||
grammarBuilder.append("std::cout << $ctx->r->toStringTree(this) << std::endl;\n");
|
||||
grammarBuilder.append("tree::ParseTreeWalker::DEFAULT->walk(std::make_shared<LeafListener>(), $ctx->r);\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append(" : r=a ;\n");
|
||||
grammarBuilder.append("a : INT INT\n");
|
||||
|
|
|
@ -11,10 +11,8 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testBasic() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(458);
|
||||
StringBuilder grammarBuilder = new StringBuilder(438);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("public class LeafListener : TBaseListener {\n");
|
||||
|
@ -53,10 +51,8 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testLR() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(612);
|
||||
StringBuilder grammarBuilder = new StringBuilder(592);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("public class LeafListener : TBaseListener {\n");
|
||||
|
@ -103,10 +99,8 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testLRWithLabels() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(636);
|
||||
StringBuilder grammarBuilder = new StringBuilder(616);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("public class LeafListener : TBaseListener {\n");
|
||||
|
@ -151,10 +145,8 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testRuleGetters_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(634);
|
||||
StringBuilder grammarBuilder = new StringBuilder(614);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("public class LeafListener : TBaseListener {\n");
|
||||
|
@ -197,10 +189,8 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testRuleGetters_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(634);
|
||||
StringBuilder grammarBuilder = new StringBuilder(614);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("public class LeafListener : TBaseListener {\n");
|
||||
|
@ -243,10 +233,8 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testTokenGetters_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(801);
|
||||
StringBuilder grammarBuilder = new StringBuilder(781);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("public class LeafListener : TBaseListener {\n");
|
||||
|
@ -297,10 +285,8 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testTokenGetters_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(801);
|
||||
StringBuilder grammarBuilder = new StringBuilder(781);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("public class LeafListener : TBaseListener {\n");
|
||||
|
|
|
@ -13,10 +13,8 @@ public class TestListeners extends BaseTest {
|
|||
public void testBasic() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(473);
|
||||
StringBuilder grammarBuilder = new StringBuilder(453);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("public static class LeafListener extends TBaseListener {\n");
|
||||
|
@ -59,10 +57,8 @@ public class TestListeners extends BaseTest {
|
|||
public void testLR() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(653);
|
||||
StringBuilder grammarBuilder = new StringBuilder(633);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("public static class LeafListener extends TBaseListener {\n");
|
||||
|
@ -113,10 +109,8 @@ public class TestListeners extends BaseTest {
|
|||
public void testLRWithLabels() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(650);
|
||||
StringBuilder grammarBuilder = new StringBuilder(630);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("public static class LeafListener extends TBaseListener {\n");
|
||||
|
@ -165,10 +159,8 @@ public class TestListeners extends BaseTest {
|
|||
public void testRuleGetters_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(670);
|
||||
StringBuilder grammarBuilder = new StringBuilder(650);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("public static class LeafListener extends TBaseListener {\n");
|
||||
|
@ -215,10 +207,8 @@ public class TestListeners extends BaseTest {
|
|||
public void testRuleGetters_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(670);
|
||||
StringBuilder grammarBuilder = new StringBuilder(650);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("public static class LeafListener extends TBaseListener {\n");
|
||||
|
@ -265,10 +255,8 @@ public class TestListeners extends BaseTest {
|
|||
public void testTokenGetters_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(615);
|
||||
StringBuilder grammarBuilder = new StringBuilder(595);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("public static class LeafListener extends TBaseListener {\n");
|
||||
|
@ -314,10 +302,8 @@ public class TestListeners extends BaseTest {
|
|||
public void testTokenGetters_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(615);
|
||||
StringBuilder grammarBuilder = new StringBuilder(595);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("public static class LeafListener extends TBaseListener {\n");
|
||||
|
|
|
@ -13,12 +13,12 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testBasic() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(633);
|
||||
StringBuilder grammarBuilder = new StringBuilder(632);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("var TListener = require('./TListener').TListener;\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("this.LeafListener = function() {\n");
|
||||
grammarBuilder.append(" this.visitTerminal = function(node) {\n");
|
||||
|
@ -28,7 +28,6 @@ public class TestListeners extends BaseTest {
|
|||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("this.LeafListener.prototype = Object.create(TListener.prototype);\n");
|
||||
grammarBuilder.append("this.LeafListener.prototype.constructor = this.LeafListener;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -62,12 +61,12 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testLR() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(843);
|
||||
StringBuilder grammarBuilder = new StringBuilder(842);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("var TListener = require('./TListener').TListener;\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("this.LeafListener = function() {\n");
|
||||
grammarBuilder.append(" this.exitE = function(ctx) {\n");
|
||||
|
@ -83,7 +82,6 @@ public class TestListeners extends BaseTest {
|
|||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("this.LeafListener.prototype = Object.create(TListener.prototype);\n");
|
||||
grammarBuilder.append("this.LeafListener.prototype.constructor = this.LeafListener;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -121,12 +119,12 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testLRWithLabels() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(833);
|
||||
StringBuilder grammarBuilder = new StringBuilder(832);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("var TListener = require('./TListener').TListener;\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("this.LeafListener = function() {\n");
|
||||
grammarBuilder.append(" this.exitCall = function(ctx) {\n");
|
||||
|
@ -141,7 +139,6 @@ public class TestListeners extends BaseTest {
|
|||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("this.LeafListener.prototype = Object.create(TListener.prototype);\n");
|
||||
grammarBuilder.append("this.LeafListener.prototype.constructor = this.LeafListener;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -178,12 +175,12 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testRuleGetters_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(868);
|
||||
StringBuilder grammarBuilder = new StringBuilder(867);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("var TListener = require('./TListener').TListener;\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("this.LeafListener = function() {\n");
|
||||
grammarBuilder.append(" this.exitA = function(ctx) {\n");
|
||||
|
@ -199,7 +196,6 @@ public class TestListeners extends BaseTest {
|
|||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("this.LeafListener.prototype = Object.create(TListener.prototype);\n");
|
||||
grammarBuilder.append("this.LeafListener.prototype.constructor = this.LeafListener;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -233,12 +229,12 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testRuleGetters_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(868);
|
||||
StringBuilder grammarBuilder = new StringBuilder(867);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("var TListener = require('./TListener').TListener;\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("this.LeafListener = function() {\n");
|
||||
grammarBuilder.append(" this.exitA = function(ctx) {\n");
|
||||
|
@ -254,7 +250,6 @@ public class TestListeners extends BaseTest {
|
|||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("this.LeafListener.prototype = Object.create(TListener.prototype);\n");
|
||||
grammarBuilder.append("this.LeafListener.prototype.constructor = this.LeafListener;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -288,12 +283,12 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testTokenGetters_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(855);
|
||||
StringBuilder grammarBuilder = new StringBuilder(854);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("var TListener = require('./TListener').TListener;\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("this.LeafListener = function() {\n");
|
||||
grammarBuilder.append(" this.exitA = function(ctx) {\n");
|
||||
|
@ -309,7 +304,6 @@ public class TestListeners extends BaseTest {
|
|||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("this.LeafListener.prototype = Object.create(TListener.prototype);\n");
|
||||
grammarBuilder.append("this.LeafListener.prototype.constructor = this.LeafListener;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -342,12 +336,12 @@ public class TestListeners extends BaseTest {
|
|||
@Test
|
||||
public void testTokenGetters_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
StringBuilder grammarBuilder = new StringBuilder(855);
|
||||
StringBuilder grammarBuilder = new StringBuilder(854);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("var TListener = require('./TListener').TListener;\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("this.LeafListener = function() {\n");
|
||||
grammarBuilder.append(" this.exitA = function(ctx) {\n");
|
||||
|
@ -363,7 +357,6 @@ public class TestListeners extends BaseTest {
|
|||
grammarBuilder.append("};\n");
|
||||
grammarBuilder.append("this.LeafListener.prototype = Object.create(TListener.prototype);\n");
|
||||
grammarBuilder.append("this.LeafListener.prototype.constructor = this.LeafListener;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
|
|
@ -13,10 +13,8 @@ public class TestListeners extends BasePython2Test {
|
|||
public void testBasic() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(511);
|
||||
StringBuilder grammarBuilder = new StringBuilder(490);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("if __name__ is not None and \".\" in __name__:\n");
|
||||
|
@ -27,7 +25,6 @@ public class TestListeners extends BasePython2Test {
|
|||
grammarBuilder.append("class LeafListener(TListener):\n");
|
||||
grammarBuilder.append(" def visitTerminal(self, node):\n");
|
||||
grammarBuilder.append(" print(node.symbol.text)\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -64,10 +61,8 @@ public class TestListeners extends BasePython2Test {
|
|||
public void testLR() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(672);
|
||||
StringBuilder grammarBuilder = new StringBuilder(651);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("if __name__ is not None and \".\" in __name__:\n");
|
||||
|
@ -81,7 +76,6 @@ public class TestListeners extends BasePython2Test {
|
|||
grammarBuilder.append(" print(ctx.e(0).start.text + ' ' + ctx.e(1).start.text + ' ' + ctx.e()[0].start.text)\n");
|
||||
grammarBuilder.append(" else:\n");
|
||||
grammarBuilder.append(" print(ctx.INT().symbol.text)\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -122,10 +116,8 @@ public class TestListeners extends BasePython2Test {
|
|||
public void testLRWithLabels() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(652);
|
||||
StringBuilder grammarBuilder = new StringBuilder(631);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("if __name__ is not None and \".\" in __name__:\n");
|
||||
|
@ -138,7 +130,6 @@ public class TestListeners extends BasePython2Test {
|
|||
grammarBuilder.append(" print(ctx.e().start.text + ' ' + str(ctx.eList()))\n");
|
||||
grammarBuilder.append(" def exitInt(self, ctx):\n");
|
||||
grammarBuilder.append(" print(ctx.INT().symbol.text)\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -178,10 +169,8 @@ public class TestListeners extends BasePython2Test {
|
|||
public void testRuleGetters_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(697);
|
||||
StringBuilder grammarBuilder = new StringBuilder(676);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("if __name__ is not None and \".\" in __name__:\n");
|
||||
|
@ -195,7 +184,6 @@ public class TestListeners extends BasePython2Test {
|
|||
grammarBuilder.append(" print(ctx.b(0).start.text + ' ' + ctx.b(1).start.text + ' ' + ctx.b()[0].start.text)\n");
|
||||
grammarBuilder.append(" else:\n");
|
||||
grammarBuilder.append(" print(ctx.b(0).start.text)\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -232,10 +220,8 @@ public class TestListeners extends BasePython2Test {
|
|||
public void testRuleGetters_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(697);
|
||||
StringBuilder grammarBuilder = new StringBuilder(676);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("if __name__ is not None and \".\" in __name__:\n");
|
||||
|
@ -249,7 +235,6 @@ public class TestListeners extends BasePython2Test {
|
|||
grammarBuilder.append(" print(ctx.b(0).start.text + ' ' + ctx.b(1).start.text + ' ' + ctx.b()[0].start.text)\n");
|
||||
grammarBuilder.append(" else:\n");
|
||||
grammarBuilder.append(" print(ctx.b(0).start.text)\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -286,10 +271,8 @@ public class TestListeners extends BasePython2Test {
|
|||
public void testTokenGetters_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(660);
|
||||
StringBuilder grammarBuilder = new StringBuilder(639);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("if __name__ is not None and \".\" in __name__:\n");
|
||||
|
@ -303,7 +286,6 @@ public class TestListeners extends BasePython2Test {
|
|||
grammarBuilder.append(" print(ctx.INT(0).symbol.text + ' ' + ctx.INT(1).symbol.text + ' ' + str_list(ctx.INT()))\n");
|
||||
grammarBuilder.append(" else:\n");
|
||||
grammarBuilder.append(" print(str(ctx.ID().symbol))\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -339,10 +321,8 @@ public class TestListeners extends BasePython2Test {
|
|||
public void testTokenGetters_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(660);
|
||||
StringBuilder grammarBuilder = new StringBuilder(639);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("if __name__ is not None and \".\" in __name__:\n");
|
||||
|
@ -356,7 +336,6 @@ public class TestListeners extends BasePython2Test {
|
|||
grammarBuilder.append(" print(ctx.INT(0).symbol.text + ' ' + ctx.INT(1).symbol.text + ' ' + str_list(ctx.INT()))\n");
|
||||
grammarBuilder.append(" else:\n");
|
||||
grammarBuilder.append(" print(str(ctx.ID().symbol))\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
|
|
@ -13,18 +13,17 @@ public class TestListeners extends BasePython3Test {
|
|||
public void testBasic() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(588);
|
||||
StringBuilder grammarBuilder = new StringBuilder(587);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("class MockListener:\n");
|
||||
grammarBuilder.append(" pass\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("class LeafListener(MockListener):\n");
|
||||
grammarBuilder.append(" def visitTerminal(self, node):\n");
|
||||
grammarBuilder.append(" print(node.symbol.text)\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -66,13 +65,13 @@ public class TestListeners extends BasePython3Test {
|
|||
public void testLR() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(749);
|
||||
StringBuilder grammarBuilder = new StringBuilder(748);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("class MockListener:\n");
|
||||
grammarBuilder.append(" pass\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("class LeafListener(MockListener):\n");
|
||||
grammarBuilder.append(" def exitE(self, ctx):\n");
|
||||
|
@ -80,7 +79,6 @@ public class TestListeners extends BasePython3Test {
|
|||
grammarBuilder.append(" print(ctx.e(0).start.text + ' ' + ctx.e(1).start.text + ' ' + ctx.e()[0].start.text)\n");
|
||||
grammarBuilder.append(" else:\n");
|
||||
grammarBuilder.append(" print(ctx.INT().symbol.text)\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -126,20 +124,19 @@ public class TestListeners extends BasePython3Test {
|
|||
public void testLRWithLabels() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(729);
|
||||
StringBuilder grammarBuilder = new StringBuilder(728);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("class MockListener:\n");
|
||||
grammarBuilder.append(" pass\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("class LeafListener(MockListener):\n");
|
||||
grammarBuilder.append(" def exitCall(self, ctx):\n");
|
||||
grammarBuilder.append(" print(ctx.e().start.text + ' ' + str(ctx.eList()))\n");
|
||||
grammarBuilder.append(" def exitInt(self, ctx):\n");
|
||||
grammarBuilder.append(" print(ctx.INT().symbol.text)\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -184,13 +181,13 @@ public class TestListeners extends BasePython3Test {
|
|||
public void testRuleGetters_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(774);
|
||||
StringBuilder grammarBuilder = new StringBuilder(773);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("class MockListener:\n");
|
||||
grammarBuilder.append(" pass\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("class LeafListener(MockListener):\n");
|
||||
grammarBuilder.append(" def exitA(self, ctx):\n");
|
||||
|
@ -198,7 +195,6 @@ public class TestListeners extends BasePython3Test {
|
|||
grammarBuilder.append(" print(ctx.b(0).start.text + ' ' + ctx.b(1).start.text + ' ' + ctx.b()[0].start.text)\n");
|
||||
grammarBuilder.append(" else:\n");
|
||||
grammarBuilder.append(" print(ctx.b(0).start.text)\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -240,13 +236,13 @@ public class TestListeners extends BasePython3Test {
|
|||
public void testRuleGetters_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(774);
|
||||
StringBuilder grammarBuilder = new StringBuilder(773);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("class MockListener:\n");
|
||||
grammarBuilder.append(" pass\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("class LeafListener(MockListener):\n");
|
||||
grammarBuilder.append(" def exitA(self, ctx):\n");
|
||||
|
@ -254,7 +250,6 @@ public class TestListeners extends BasePython3Test {
|
|||
grammarBuilder.append(" print(ctx.b(0).start.text + ' ' + ctx.b(1).start.text + ' ' + ctx.b()[0].start.text)\n");
|
||||
grammarBuilder.append(" else:\n");
|
||||
grammarBuilder.append(" print(ctx.b(0).start.text)\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -296,13 +291,13 @@ public class TestListeners extends BasePython3Test {
|
|||
public void testTokenGetters_1() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(737);
|
||||
StringBuilder grammarBuilder = new StringBuilder(736);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("class MockListener:\n");
|
||||
grammarBuilder.append(" pass\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("class LeafListener(MockListener):\n");
|
||||
grammarBuilder.append(" def exitA(self, ctx):\n");
|
||||
|
@ -310,7 +305,6 @@ public class TestListeners extends BasePython3Test {
|
|||
grammarBuilder.append(" print(ctx.INT(0).symbol.text + ' ' + ctx.INT(1).symbol.text + ' ' + str_list(ctx.INT()))\n");
|
||||
grammarBuilder.append(" else:\n");
|
||||
grammarBuilder.append(" print(str(ctx.ID().symbol))\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
@ -351,13 +345,13 @@ public class TestListeners extends BasePython3Test {
|
|||
public void testTokenGetters_2() throws Exception {
|
||||
mkdir(tmpdir);
|
||||
|
||||
StringBuilder grammarBuilder = new StringBuilder(737);
|
||||
StringBuilder grammarBuilder = new StringBuilder(736);
|
||||
grammarBuilder.append("grammar T;\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::header {\n");
|
||||
grammarBuilder.append("class MockListener:\n");
|
||||
grammarBuilder.append(" pass\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("@parser::members {\n");
|
||||
grammarBuilder.append("class LeafListener(MockListener):\n");
|
||||
grammarBuilder.append(" def exitA(self, ctx):\n");
|
||||
|
@ -365,7 +359,6 @@ public class TestListeners extends BasePython3Test {
|
|||
grammarBuilder.append(" print(ctx.INT(0).symbol.text + ' ' + ctx.INT(1).symbol.text + ' ' + str_list(ctx.INT()))\n");
|
||||
grammarBuilder.append(" else:\n");
|
||||
grammarBuilder.append(" print(str(ctx.ID().symbol))\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("}\n");
|
||||
grammarBuilder.append("\n");
|
||||
grammarBuilder.append("s\n");
|
||||
|
|
|
@ -142,14 +142,14 @@ public:
|
|||
<namedActions.baselistenerdeclarations>
|
||||
|
||||
<file.listenerNames: {lname |
|
||||
void enter<lname; format="cap">(<file.parserName>::<lname; format = "cap">Context * /*ctx*/) { \}
|
||||
void exit<lname; format="cap">(<file.parserName>::<lname; format = "cap">Context * /*ctx*/) { \}
|
||||
virtual void enter<lname; format="cap">(<file.parserName>::<lname; format = "cap">Context * /*ctx*/) override { \}
|
||||
virtual void exit<lname; format="cap">(<file.parserName>::<lname; format = "cap">Context * /*ctx*/) override { \}
|
||||
}; separator="\n">
|
||||
|
||||
void enterEveryRule(Ref\<ParserRuleContext> /*ctx*/) { }
|
||||
void exitEveryRule(Ref\<ParserRuleContext> /*ctx*/) { }
|
||||
void visitTerminal(Ref\<tree::TerminalNode> /*node*/) { }
|
||||
void visitErrorNode(Ref\<tree::ErrorNode> /*node*/) { }
|
||||
virtual void enterEveryRule(Ref\<ParserRuleContext> /*ctx*/) override { }
|
||||
virtual void exitEveryRule(Ref\<ParserRuleContext> /*ctx*/) override { }
|
||||
virtual void visitTerminal(Ref\<tree::TerminalNode> /*node*/) override { }
|
||||
virtual void visitErrorNode(Ref\<tree::ErrorNode> /*node*/) override { }
|
||||
|
||||
<if (namedActions.baselistenermembers)>
|
||||
private:
|
||||
|
@ -324,7 +324,7 @@ public:
|
|||
* Visit parse trees produced by <file.parserName>.
|
||||
*/
|
||||
<file.visitorNames: {lname |
|
||||
T* visit<lname; format = "cap">(<file.parserName>::<lname; format = "cap">Context *context) = 0;
|
||||
virtual T* visit<lname; format = "cap">(<file.parserName>::<lname; format = "cap">Context *context) = 0;
|
||||
}; separator="\n">
|
||||
|
||||
<if (namedActions.visitormembers)>
|
||||
|
|
Loading…
Reference in New Issue