コード例 #1
0
void DefaultErrorStrategy::reportError(Parser *recognizer, const 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)) {
    return; // don't report spurious errors
  }

  beginErrorCondition(recognizer);
  if (is<const NoViableAltException *>(&e)) {
    reportNoViableAlternative(recognizer, (const NoViableAltException &)e);
  } else if (is<const InputMismatchException *>(&e)) {
    reportInputMismatch(recognizer, (const InputMismatchException &)e);
  } else if (is<const FailedPredicateException *>(&e)) {
    reportFailedPredicate(recognizer, (const FailedPredicateException &)e);
  } else if (is<const RecognitionException *>(&e)) {
    recognizer->notifyErrorListeners(e.getOffendingToken(), e.what(), std::current_exception());
  }
}