public Token NextToken()
{
int c1 = ReadNextChar();
if (IsPunctuatorStartChar(c1) == true)
{
// Punctuator (puntcuation + operators).
this.lastSignificantToken = ReadPunctuator(c1);
return this.lastSignificantToken;
}
else if (IsWhiteSpace(c1) == true)
{
// White space.
return ReadWhiteSpace();
}
else if (IsIdentifierStartChar(c1) == true)
{
// Identifier or reserved word.
this.lastSignificantToken = ReadIdentifier(c1);
return this.lastSignificantToken;
}
else if (IsStringLiteralStartChar(c1) == true)
{
// String literal.
this.lastSignificantToken = ReadStringLiteral(c1);
return this.lastSignificantToken;
}
else if (IsNumericLiteralStartChar(c1) == true)
{
// Number literal.
this.lastSignificantToken = ReadNumericLiteral(c1);
return this.lastSignificantToken;
}
else if (IsLineTerminator(c1) == true)
{
// Line Terminator.
this.lastSignificantToken = ReadLineTerminator(c1);
return this.lastSignificantToken;
}
else if (c1 == '/')
{
// Comment or divide or regular expression.
this.lastSignificantToken = ReadDivideCommentOrRegularExpression();
return this.lastSignificantToken;
}
else if (c1 == -1)
{
// End of input.
this.lastSignificantToken = null;
return null;
}
else
throw new JavaScriptException(this.engine, ErrorType.SyntaxError, string.Format("Unexpected character '{0}'.", (char)c1), this.lineNumber, this.Source.Path);
}