ANTLRErrorStrategy responds to syntax errors
by immediately canceling the parse operation with a
ParseCancellationException. The implementation ensures that the
ParserRuleContext#exception field is set for all parse tree nodes
that were not completed prior to encountering the error.
This error strategy is useful in the following scenarios.
BailErrorStrategy#sync improves the performance of
the first stage.BailErrorStrategy avoids wasting work on recovering from errors
when the result will be ignored either way.
myparser.setErrorHandler(new BailErrorStrategy());
Parser#setErrorHandler(ANTLRErrorStrategy)
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | recover(Parser
the parser instance recognizer, RecognitionException the recognition exception to recover from e)Overrides org. Implements org. e, re-throw it wrapped
in a ParseCancellationException so it is not caught by the
rule function catches.
|
| public Token | recoverInline(Parser
the parser instance recognizer)Overrides org. Implements org. |
| public void | sync(Parser
the parser instance recognizer)Overrides org. Implements org. |
| BailErrorStrategy | back to summary |
|---|---|
| public BailErrorStrategy() | |
| recover | back to summary |
|---|---|
| public void recover(Parser recognizer, RecognitionException e) Overrides org. Implements org. Instead of recovering from exception
| |
| recoverInline | back to summary |
|---|---|
| public Token recoverInline(Parser recognizer) throws RecognitionException Overrides org. Implements org. Make sure we don't attempt to recover inline; if the parser successfully recovers, it won't throw an exception.
| |
| sync | back to summary |
|---|---|
| public void sync(Parser recognizer) Overrides org. Implements org. Make sure we don't attempt to recover from problems in subrules.
| |