Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CustomListener used to walk on tree and record statement indices
var QuerySeparationGrammarListener = require('./QuerySeparationGrammarListener').QuerySeparationGrammarListener;
var CustomListener = function(result) {
this.result = result;
QuerySeparationGrammarListener.call(this); // inherit default listener
return this;
};
// continue inheriting default listener
CustomListener.prototype = Object.create(QuerySeparationGrammarListener.prototype);
CustomListener.prototype.constructor = CustomListener;
// override default listener behavior
CustomListener.prototype.exitStatement = function(ctx) {
this.result.push([ctx.start.start, ctx.stop.stop]); // storing the start and stop indices of every statement
};
exports.CustomListener = CustomListener;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.