reportError method
{@inheritDoc}
The default implementation returns immediately if the handler is already in error recovery mode. Otherwise, it calls {@link #beginErrorCondition} and dispatches the reporting task based on the runtime type of [e] according to the following table.
- [NoViableAltException]: Dispatches the call to {@link #reportNoViableAlternative}
- [InputMismatchException]: Dispatches the call to {@link #reportInputMismatch}
- [FailedPredicateException]: Dispatches the call to {@link #reportFailedPredicate}
- All other types: calls {@link Parser#notifyErrorListeners} to report the exception
Implementation
@override
void reportError(Parser recognizer, RecognitionException e) {
// if we've already reported an error and have not matched a token
// yet successfully, don't report any errors.
if (inErrorRecoveryMode(recognizer)) {
// System.err.print("[SPURIOUS] ");
return; // don't report spurious errors
}
beginErrorCondition(recognizer);
if (e is NoViableAltException) {
reportNoViableAlternative(recognizer, e);
} else if (e is InputMismatchException) {
reportInputMismatch(recognizer, e);
} else if (e is FailedPredicateException) {
reportFailedPredicate(recognizer, e);
} else {
log('unknown recognition error type: ${e.runtimeType}',
level: Level.SEVERE.value);
recognizer.notifyErrorListeners(e.message, e.offendingToken, e);
}
}