Merge pull request #1471 from renatahodovan/visit-error-node

Call visitErrorNodes properly in Python targets.
This commit is contained in:
Terence Parr 2016-12-11 14:48:21 -08:00 committed by GitHub
commit c7e27664c2
2 changed files with 8 additions and 2 deletions

View File

@ -328,7 +328,10 @@ class Parser (Recognizer):
node = self._ctx.addTokenNode(o)
if hasListener:
for listener in self._parseListeners:
listener.visitTerminal(node)
if isinstance(node, ErrorNode):
listener.visitErrorNode(node)
elif isinstance(node, TerminalNode):
listener.visitTerminal(node)
return o
def addContextToParseTree(self):

View File

@ -335,7 +335,10 @@ class Parser (Recognizer):
node = self._ctx.addTokenNode(o)
if hasListener:
for listener in self._parseListeners:
listener.visitTerminal(node)
if isinstance(node, ErrorNode):
listener.visitErrorNode(node)
elif isinstance(node, TerminalNode):
listener.visitTerminal(node)
return o
def addContextToParseTree(self):