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

ReportMissingToken() protected method

This method is called to report a syntax error which requires the insertion of a missing token into the input stream.
This method is called to report a syntax error which requires the insertion of a missing token into the input stream. At the time this method is called, the missing token has not yet been inserted. When this method returns, recognizer is in error recovery mode.

This method is called when SingleTokenInsertion(Parser) identifies single-token insertion as a viable recovery strategy for a mismatched input error.

The default implementation simply returns if the handler is already in error recovery mode. Otherwise, it calls BeginErrorCondition(Parser) to enter error recovery mode, followed by calling Parser.NotifyErrorListeners(string) .

protected ReportMissingToken ( Parser recognizer ) : void
recognizer Parser the parser instance
return void
        protected internal virtual void ReportMissingToken(Parser recognizer)
        {
            if (InErrorRecoveryMode(recognizer))
            {
                return;
            }
            BeginErrorCondition(recognizer);
            IToken t = recognizer.CurrentToken;
            IntervalSet expecting = GetExpectedTokens(recognizer);
            string msg = "missing " + expecting.ToString(recognizer.Vocabulary) + " at " + GetTokenErrorDisplay(t);
            recognizer.NotifyErrorListeners(t, msg, null);
        }