Skip to content

Commit

Permalink
Python LexerNoViableAltException is created with messages (#4095) (#4097
Browse files Browse the repository at this point in the history
)

- Added a message to LexerNoViableAltException (python2 & 3)
- Corrected the ErrorStrategy (Python2) :
notifyErrorListeners first argument should be the message, and second the Offending Token
Exception does not have getMessage method

Signed-off-by: SU Sofyan <sofyan.su@airbus.com>
  • Loading branch information
Sofyan-SU authored Feb 3, 2023
1 parent cc54283 commit af75ac4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion runtime/Python2/src/antlr4/error/ErrorStrategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def reportError(self, recognizer, e):
self.reportFailedPredicate(recognizer, e)
else:
print("unknown recognition error type: " + type(e).__name__)
recognizer.notifyErrorListeners(e.getOffendingToken(), e.getMessage(), e)
recognizer.notifyErrorListeners(e.message, e.getOffendingToken(), e)

#
# {@inheritDoc}
Expand Down
1 change: 1 addition & 0 deletions runtime/Python2/src/antlr4/error/Errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def __init__(self, lexer, input, startIndex, deadEndConfigs):
super(LexerNoViableAltException, self).__init__(message=None, recognizer=lexer, input=input, ctx=None)
self.startIndex = startIndex
self.deadEndConfigs = deadEndConfigs
self.message = ""

def __unicode__(self):
symbol = ""
Expand Down
1 change: 1 addition & 0 deletions runtime/Python3/src/antlr4/error/Errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def __init__(self, lexer:Lexer, input:InputStream, startIndex:int, deadEndConfig
super().__init__(message=None, recognizer=lexer, input=input, ctx=None)
self.startIndex = startIndex
self.deadEndConfigs = deadEndConfigs
self.message = ""

def __str__(self):
symbol = ""
Expand Down

0 comments on commit af75ac4

Please sign in to comment.