public class BailErrorStrategy extends DefaultErrorStrategy
myparser.setErrorHandler(new BailErrorStrategy());
errorRecoveryMode, lastErrorIndex, lastErrorStates
Constructor and Description |
---|
BailErrorStrategy() |
Modifier and Type | Method and Description |
---|---|
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, consumeUntil, endErrorCondition, escapeWSAndQuote, getErrorRecoverySet, getExpectedTokens, getMissingSymbol, getSymbolText, getSymbolType, getTokenErrorDisplay, inErrorRecoveryMode, reportError, reportFailedPredicate, reportInputMismatch, reportMatch, reportMissingToken, reportNoViableAlternative, reportUnwantedToken, reset, singleTokenDeletion, singleTokenInsertion
public 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
in interface ANTLRErrorStrategy
recover
in class DefaultErrorStrategy
recognizer
- 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
in interface ANTLRErrorStrategy
recoverInline
in class DefaultErrorStrategy
recognizer
- the parser instanceRecognitionException
- if the error strategy was not able to
recover from the unexpected input symbolpublic void sync(Parser recognizer)
sync
in interface ANTLRErrorStrategy
sync
in class DefaultErrorStrategy
recognizer
- the parser instanceDefaultErrorStrategy.sync(org.antlr.v4.runtime.Parser)
Copyright © 1992-2013 ANTLR. All Rights Reserved.