Antlr.Runtime.Lexer.NextToken C# (CSharp) Method

NextToken() public method

Return a token from this source; i.e., match a token on the char stream.
public NextToken ( ) : IToken
return IToken
        public virtual IToken NextToken()
        {
            for ( ; ; )
            {
                state.token = null;
                state.channel = TokenChannels.Default;
                state.tokenStartCharIndex = input.Index;
                state.tokenStartCharPositionInLine = input.CharPositionInLine;
                state.tokenStartLine = input.Line;
                state.text = null;
                if ( input.LA( 1 ) == CharStreamConstants.EndOfFile )
                {
                    return GetEndOfFileToken();
                }
                try
                {
                    ParseNextToken();
                    if ( state.token == null )
                    {
                        Emit();
                    }
                    else if ( state.token == Tokens.Skip )
                    {
                        continue;
                    }
                    return state.token;
                }
                catch (MismatchedRangeException mre)
                {
                    ReportError(mre);
                    // MatchRange() routine has already called recover()
                }
                catch (MismatchedTokenException mte)
                {
                    ReportError(mte);
                    // Match() routine has already called recover()
                }
                catch ( RecognitionException re )
                {
                    ReportError( re );
                    Recover( re ); // throw out current char and try again
                }
            }
        }