Tom Celusnak
Tom Celusnak

Reputation: 1

python3 Parser.setErrorHandler method missing

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

Answers (1)

Bart Kiers
Bart Kiers

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

Related Questions