Python: add public getter to parsers to access syntax error count.

ANTLR parsers in Java are allowed to access the number of encountered
syntax errors via the getNumberOfSyntaxErrors method. However, the
Python variants must use the protected _syntaxErrors member to get this
value. The patch defines the same getter for Python targets too.
This commit is contained in:
Renata Hodovan 2017-07-18 18:29:36 +02:00
parent c41426c87e
commit 6e02088e6a
2 changed files with 15 additions and 0 deletions

View File

@ -218,6 +218,13 @@ class Parser (Recognizer):
self._ctx.exitRule(listener) self._ctx.exitRule(listener)
listener.exitEveryRule(self._ctx) listener.exitEveryRule(self._ctx)
# Gets the number of syntax errors reported during parsing. This value is
# incremented each time {@link #notifyErrorListeners} is called.
#
# @see #notifyErrorListeners
#
def getNumberOfSyntaxErrors(self):
return self._syntaxErrors
def getTokenFactory(self): def getTokenFactory(self):
return self._input.tokenSource._factory return self._input.tokenSource._factory

View File

@ -227,6 +227,14 @@ class Parser (Recognizer):
listener.exitEveryRule(self._ctx) listener.exitEveryRule(self._ctx)
# Gets the number of syntax errors reported during parsing. This value is
# incremented each time {@link #notifyErrorListeners} is called.
#
# @see #notifyErrorListeners
#
def getNumberOfSyntaxErrors(self):
return self._syntaxErrors
def getTokenFactory(self): def getTokenFactory(self):
return self._input.tokenSource._factory return self._input.tokenSource._factory