Class RecoveringDescriptiveErrorStrategy
- All Implemented Interfaces:
org.antlr.v4.runtime.ANTLRErrorStrategy
DescriptiveErrorStrategy.
Uses ANTLR's default resync / single-token repair so multiple recognition
errors can be reported in one pass (IDE editing). Prefer construction via
DescriptiveErrorStrategy.create(CharStream, boolean).
Callers must parse with LL prediction and error listeners installed. Hosts
should read diagnostics from
ErrorCollector: a partial tree may still
fail during AST building after recovery.
-
Field Summary
Fields inherited from class org.antlr.v4.runtime.DefaultErrorStrategy
errorRecoveryMode, lastErrorIndex, lastErrorStates, nextTokensContext, nextTokensState -
Constructor Summary
ConstructorsConstructorDescriptionRecoveringDescriptiveErrorStrategy(org.antlr.v4.runtime.CharStream charStream) -
Method Summary
Modifier and TypeMethodDescriptionprotected StringcreateFailedPredicateErrorMessage(org.antlr.v4.runtime.Parser recognizer, org.antlr.v4.runtime.FailedPredicateException e) Format a failed-predicate diagnostic.protected StringcreateInputMismatchErrorMessage(org.antlr.v4.runtime.Parser recognizer, org.antlr.v4.runtime.InputMismatchException e) Builds the input-mismatch diagnostic:"Unexpected input: "followed by the display of the offending token.protected StringcreateNoViableAlternativeErrorMessage(org.antlr.v4.runtime.Parser recognizer, org.antlr.v4.runtime.NoViableAltException e) Builds the no-viable-alternative diagnostic.protected voidreportFailedPredicate(org.antlr.v4.runtime.Parser recognizer, org.antlr.v4.runtime.FailedPredicateException e) protected voidreportInputMismatch(org.antlr.v4.runtime.Parser recognizer, org.antlr.v4.runtime.InputMismatchException e) protected voidreportNoViableAlternative(org.antlr.v4.runtime.Parser recognizer, org.antlr.v4.runtime.NoViableAltException e) Methods inherited from class org.antlr.v4.runtime.DefaultErrorStrategy
beginErrorCondition, constructToken, consumeUntil, endErrorCondition, escapeWSAndQuote, getErrorRecoverySet, getExpectedTokens, getMissingSymbol, getSymbolText, getSymbolType, getTokenErrorDisplay, inErrorRecoveryMode, isReportMatchRequired, notifyErrorListeners, recover, recoverInline, reportError, reportMatch, reportMissingToken, reportUnwantedToken, reset, singleTokenDeletion, singleTokenInsertion, syncMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.antlr.v4.runtime.ANTLRErrorStrategy
isSyncRequired
-
Constructor Details
-
RecoveringDescriptiveErrorStrategy
public RecoveringDescriptiveErrorStrategy(org.antlr.v4.runtime.CharStream charStream) - Parameters:
charStream- source character stream used for snippet extraction
-
-
Method Details
-
createNoViableAlternativeErrorMessage
protected String createNoViableAlternativeErrorMessage(org.antlr.v4.runtime.Parser recognizer, org.antlr.v4.runtime.NoViableAltException e) Builds the no-viable-alternative diagnostic. The input text is<EOF>when the start token is end of file,<unknown input>whenrecognizerhas no token stream, and otherwise the characters from the start token through the offending token. That text is passed toescapeWSAndQuoteand prefixed with"Unexpected input: ".- Parameters:
recognizer- the parser that failede- the failure- Returns:
- the diagnostic message
-
reportNoViableAlternative
protected void reportNoViableAlternative(org.antlr.v4.runtime.Parser recognizer, org.antlr.v4.runtime.NoViableAltException e) - Overrides:
reportNoViableAlternativein classorg.antlr.v4.runtime.DefaultErrorStrategy
-
createInputMismatchErrorMessage
protected String createInputMismatchErrorMessage(org.antlr.v4.runtime.Parser recognizer, org.antlr.v4.runtime.InputMismatchException e) Builds the input-mismatch diagnostic:"Unexpected input: "followed by the display of the offending token.- Parameters:
recognizer- the parser that failede- the mismatch- Returns:
- the diagnostic message
-
reportInputMismatch
protected void reportInputMismatch(org.antlr.v4.runtime.Parser recognizer, org.antlr.v4.runtime.InputMismatchException e) - Overrides:
reportInputMismatchin classorg.antlr.v4.runtime.DefaultErrorStrategy
-
createFailedPredicateErrorMessage
protected String createFailedPredicateErrorMessage(org.antlr.v4.runtime.Parser recognizer, org.antlr.v4.runtime.FailedPredicateException e) Format a failed-predicate diagnostic.recognizeris part of the protected hook surface (parity withcreateNoViableAlternativeErrorMessage(org.antlr.v4.runtime.Parser, org.antlr.v4.runtime.NoViableAltException)/createInputMismatchErrorMessage(org.antlr.v4.runtime.Parser, org.antlr.v4.runtime.InputMismatchException)) so subclasses can include parser state when customising the message. -
reportFailedPredicate
protected void reportFailedPredicate(org.antlr.v4.runtime.Parser recognizer, org.antlr.v4.runtime.FailedPredicateException e) - Overrides:
reportFailedPredicatein classorg.antlr.v4.runtime.DefaultErrorStrategy
-