Class DefaultErrorStrategy

java.lang.Object
org.antlr.v4.runtime.DefaultErrorStrategy
All Implemented Interfaces:
ANTLRErrorStrategy
Direct Known Subclasses:
BailErrorStrategy, GrammarParserInterpreter.BailButConsumeErrorStrategy

public class DefaultErrorStrategy extends Object implements ANTLRErrorStrategy
This is the default implementation of ANTLRErrorStrategy used for error reporting and recovery in ANTLR parsers.
  • Field Details

    • errorRecoveryMode

      protected boolean errorRecoveryMode
      Indicates whether the error strategy is currently "recovering from an error". This is used to suppress reporting multiple error messages while attempting to recover from a detected syntax error.
      See Also:
    • lastErrorIndex

      protected int lastErrorIndex
      The index into the input stream where the last error occurred. This is used to prevent infinite loops where an error is found but no token is consumed during recovery...another error is found, ad nauseum. This is a failsafe mechanism to guarantee that at least one token/tree node is consumed for two errors.
    • lastErrorStates

      protected IntervalSet lastErrorStates
    • nextTokensContext

      protected ParserRuleContext nextTokensContext
      This field is used to propagate information about the lookahead following the previous match. Since prediction prefers completing the current rule to error recovery efforts, error reporting may occur later than the original point where it was discoverable. The original context is used to compute the true expected sets as though the reporting occurred as early as possible.
    • nextTokensState

      protected int nextTokensState
      See Also:
  • Constructor Details

    • DefaultErrorStrategy

      public DefaultErrorStrategy()
  • Method Details