Class: BailErrorStrategy

Inherits:
DefaultErrorStrategy show all
Defined in:
lib/antlr4/error/ErrorStrategy.rb

Overview

See Also:

  • Parser#setErrorHandler(ANTLRErrorStrategy)

Instance Attribute Summary

Attributes inherited from DefaultErrorStrategy

#errorRecoveryMode, #lastErrorIndex, #lastErrorStates

Instance Method Summary collapse

Methods inherited from DefaultErrorStrategy

#beginErrorCondition, #consumeUntil, #endErrorCondition, #escapeWSAndQuote, #getErrorRecoverySet, #getExpectedTokens, #getMissingSymbol, #getTokenErrorDisplay, #inErrorRecoveryMode, #initialize, #reportError, #reportFailedPredicate, #reportInputMismatch, #reportMatch, #reportMissingToken, #reportNoViableAlternative, #reportUnwantedToken, #reset, #singleTokenDeletion, #singleTokenInsertion

Methods inherited from ErrorStrategy

#inErrorRecoveryMode, #reportError, #reset

Constructor Details

This class inherits a constructor from DefaultErrorStrategy

Instance Method Details

#recover(recognizer, e) ⇒ Object

Instead of recovering from exception e, re-throw it wrapped

in a {@link ParseCancellationException} so it is not caught by the
rule function catches.  Use {@link Exception#getCause()} to get the
original {@link RecognitionException}.


725
726
727
728
729
730
731
732
# File 'lib/antlr4/error/ErrorStrategy.rb', line 725

def recover(recognizer, e)
    context = recognizer.ctx
    while not context.nil?  do
        context.exception = e
        context = context.parentCtx
    end
    raise ParseCancellationException.new(e)
end

#recoverInline(recognizer) ⇒ Object

Make sure we don’t attempt to recover inline; if the parser

successfully recovers, it won't throw an exception.


736
737
738
# File 'lib/antlr4/error/ErrorStrategy.rb', line 736

def recoverInline(recognizer)
    self.recover(recognizer, InputMismatchException.new(recognizer))
end

#sync(recognizer) ⇒ Object

Make sure we don’t attempt to recover from problems in subrules.#



740
741
# File 'lib/antlr4/error/ErrorStrategy.rb', line 740

def sync(recognizer)
end