Antlr4.Runtime.DefaultErrorStrategy.ReportError C# (CSharp) Method

ReportError() public method

The default implementation returns immediately if the handler is already in error recovery mode. Otherwise, it calls BeginErrorCondition(Parser) and dispatches the reporting task based on the runtime type of e according to the following table.

  • NoViableAltException : Dispatches the call to ReportNoViableAlternative(Parser, NoViableAltException)
  • InputMismatchException : Dispatches the call to ReportInputMismatch(Parser, InputMismatchException)
  • FailedPredicateException : Dispatches the call to ReportFailedPredicate(Parser, FailedPredicateException)
  • All other types: calls Parser.NotifyErrorListeners(string) to report the exception
public ReportError ( Parser recognizer, RecognitionException e ) : void
recognizer Parser
e RecognitionException
return void
        public virtual 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, (NoViableAltException)e);
            }
            else
            {
                if (e is InputMismatchException)
                {
                    ReportInputMismatch(recognizer, (InputMismatchException)e);
                }
                else
                {
                    if (e is FailedPredicateException)
                    {
                        ReportFailedPredicate(recognizer, (FailedPredicateException)e);
                    }
                    else
                    {
            #if !PORTABLE
                        System.Console.Error.WriteLine("unknown recognition error type: " + e.GetType().FullName);
            #endif
                        NotifyErrorListeners(recognizer, e.Message, e);
                    }
                }
            }
        }