Implement the fix in #1471 for JavaScript target.

This commit is contained in:
Renata Hodovan 2016-12-11 00:59:24 +01:00
parent 661c87b47c
commit 3a4c8d8bc6
1 changed files with 7 additions and 1 deletions

View File

@ -9,6 +9,8 @@ var Recognizer = require('./Recognizer').Recognizer;
var DefaultErrorStrategy = require('./error/ErrorStrategy').DefaultErrorStrategy;
var ATNDeserializer = require('./atn/ATNDeserializer').ATNDeserializer;
var ATNDeserializationOptions = require('./atn/ATNDeserializationOptions').ATNDeserializationOptions;
var TerminalNode = require('./tree/Tree').TerminalNode;
var ErrorNode = require('./tree/Tree').ErrorNode;
function TraceListener(parser) {
ParseTreeListener.call(this);
@ -387,7 +389,11 @@ Parser.prototype.consume = function() {
node.invokingState = this.state;
if (hasListener) {
this._parseListeners.map(function(listener) {
listener.visitTerminal(node);
if (node instanceof ErrorNode || (node.isErrorNode !== undefined && node.isErrorNode())) {
listener.visitErrorNode(node);
} else if (node instanceof TerminalNode) {
listener.visitTerminal(node);
}
});
}
}