Altering ANTLRâs Error Handling Strategy
The default error handling mechanism works very well, but there are a few atypical situations in which we might want to alter it. First, we might want to disable some of the in-line error handling because of its runtime overhead. Second, we might want to bail out of the parser upon the first syntax error. For example, when parsing a command line for a shell like bash, thereâs no point in trying to recover from errors. We canât risk executing that command anyway, so the parser can bail out at the first sign of trouble.
To explore the error handling strategy, take a look at interface ANTLRErrorStrategy and its concrete implementation class DefaultErrorStrategy. That class holds everything associated ...
Get The Definitive ANTLR 4 Reference, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.