Merge pull request #1956 from renatahodovan/syntax-errors

Python: add public getter to parsers to access syntax error count.
This commit is contained in:
Terence Parr 2017-09-17 11:20:56 -07:00 committed by GitHub
commit e6d60007e7
2 changed files with 15 additions and 0 deletions

View File

@ -218,6 +218,13 @@ class Parser (Recognizer):
self._ctx.exitRule(listener)
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):
return self._input.tokenSource._factory

View File

@ -227,6 +227,14 @@ class Parser (Recognizer):
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):
return self._input.tokenSource._factory