clarify javascript visitor code

This commit is contained in:
Eric Vergnaud 2016-11-20 14:10:05 +08:00
parent d9490e16da
commit c50b10f865
1 changed files with 5 additions and 8 deletions

View File

@ -88,10 +88,11 @@ function ParseTreeVisitor() {
ParseTreeVisitor.prototype.visit = function(ctx) {
if (Utils.isArray(ctx)) {
var self = this;
return ctx.map(function(child) { return visitAtom(self, child)});
return ctx.map(function(child) {
return ctx.accept(this);
}, this);
} else {
return visitAtom(this, ctx);
return ctx.accept(this);
}
};
@ -106,10 +107,6 @@ ParseTreeVisitor.prototype.visitErrorNode = function(node) {
};
var visitAtom = function(visitor, ctx) {
return ctx.accept(visitor);
};
function ParseTreeListener() {
return this;
}