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

SingleTokenDeletion() private method

private SingleTokenDeletion ( Parser recognizer ) : IToken
recognizer Parser
return IToken
        protected internal virtual IToken SingleTokenDeletion(Parser recognizer)
        {
            int nextTokenType = ((ITokenStream)recognizer.InputStream).LA(2);
            IntervalSet expecting = GetExpectedTokens(recognizer);
            if (expecting.Contains(nextTokenType))
            {
                ReportUnwantedToken(recognizer);
                recognizer.Consume();
                // simply delete extra token
                // we want to return the token we're actually matching
                IToken matchedSymbol = recognizer.CurrentToken;
                ReportMatch(recognizer);
                // we know current token is correct
                return matchedSymbol;
            }
            return null;
        }