public class BailErrorStrategy extends DefaultErrorStrategy
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.
sync(org.antlr.v4.runtime.Parser) 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());
errorRecoveryMode, lastErrorIndex, lastErrorStates, nextTokensContext, nextTokensState| 构造器和说明 |
|---|
BailErrorStrategy() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
recover(Parser recognizer,
RecognitionException e)
Instead of recovering from exception
e, re-throw it wrapped
in a ParseCancellationException so it is not caught by the
rule function catches. |
Token |
recoverInline(Parser recognizer)
Make sure we don't attempt to recover inline; if the parser
successfully recovers, it won't throw an exception.
|
void |
sync(Parser recognizer)
Make sure we don't attempt to recover from problems in subrules.
|
beginErrorCondition, constructToken, consumeUntil, endErrorCondition, escapeWSAndQuote, getErrorRecoverySet, getExpectedTokens, getMissingSymbol, getSymbolText, getSymbolType, getTokenErrorDisplay, inErrorRecoveryMode, notifyErrorListeners, reportError, reportFailedPredicate, reportInputMismatch, reportMatch, reportMissingToken, reportNoViableAlternative, reportUnwantedToken, reset, singleTokenDeletion, singleTokenInsertionpublic void recover(Parser recognizer, RecognitionException e)
e, re-throw it wrapped
in a ParseCancellationException so it is not caught by the
rule function catches. Use Throwable.getCause() to get the
original RecognitionException.recover 在接口中 ANTLRErrorStrategyrecover 在类中 DefaultErrorStrategyrecognizer - the parser instancee - the recognition exception to recover fromANTLRErrorStrategy.reportError(org.antlr.v4.runtime.Parser, org.antlr.v4.runtime.RecognitionException)public Token recoverInline(Parser recognizer) throws RecognitionException
recoverInline 在接口中 ANTLRErrorStrategyrecoverInline 在类中 DefaultErrorStrategyrecognizer - the parser instanceRecognitionException - if the error strategy was not able to
recover from the unexpected input symbolpublic void sync(Parser recognizer)
sync 在接口中 ANTLRErrorStrategysync 在类中 DefaultErrorStrategyrecognizer - the parser instanceDefaultErrorStrategy.sync(org.antlr.v4.runtime.Parser)Copyright © 1992–2022 Daniel Sun. All rights reserved.