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
}
}
}