Reputation: 1
I'm trying to bail out of the parser upon first syntax error.
It seems that the setErrorHandler
is not implemented? This is the error.
parser.setErrorHandler(BailErrorStrategy())
AttributeError: 'XParser' object has no attribute 'setErrorHandler'
Upvotes: 0
Views: 151
Reputation: 170178
It looks like Python's Parser class does not have a set-ter for this. Don't know why not.
Anyway, this is how you could set it:
from antlr4.error.ErrorStrategy import BailErrorStrategy
...
parser = ...
parser._errHandler = BailErrorStrategy()
Upvotes: 1