ErrorStrategy class abstract

The interface for defining strategies to deal with syntax errors encountered during a parse by ANTLR-generated parsers. We distinguish between three different kinds of errors:

  • The parser could not figure out which path to take in the ATN (none of the available alternatives could possibly match)
  • The current input does not match what we were looking for
  • A predicate evaluated to false

Implementations of this interface report syntax errors by calling {@link Parser#notifyErrorListeners}.

TODO: what to do about lexers

Implementers

Constructors

ErrorStrategy()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

inErrorRecoveryMode(Parser recognizer) bool
Tests whether or not recognizer is in the process of recovering from an error. In error recovery mode, {@link Parser#consume} adds symbols to the parse tree by calling {@link Parser#createErrorNode(ParserRuleContext, Token)} then {@link ParserRuleContext#addErrorNode(ErrorNode)} instead of {@link Parser#createTerminalNode(ParserRuleContext, Token)}.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
recover(Parser recognizer, RecognitionException<IntStream> e) → void
This method is called to recover from exception e. This method is called after {@link #reportError} by the default exception handler generated for a rule method.
recoverInline(Parser recognizer) Token
This method is called when an unexpected symbol is encountered during an inline match operation, such as {@link Parser#match}. If the error strategy successfully recovers from the match failure, this method returns the Token instance which should be treated as the successful result of the match.
reportError(Parser recognizer, RecognitionException<IntStream> e) → void
Report any kind of RecognitionException. This method is called by the default exception handler generated for a rule method.
reportMatch(Parser recognizer) → void
This method is called by when the parser successfully matches an input symbol.
reset(Parser recognizer) → void
Reset the error handler state for the specified recognizer. @param recognizer the parser instance
sync(Parser recognizer) → void
This method provides the error handler with an opportunity to handle syntactic or semantic errors in the input stream before they result in a RecognitionException.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited