private void ReadToken()
{
while (Next())
{
if (this._scanner.Read() == '"')
{
if (this._pos.Count > 0 && this._pos.Peek() == "\"")
{
if (this._scanner.Read(-1) != '\\'
|| GetPrevCharCount('\\') % 2 == 0)
{
if (this._kind == TokenKind.StringStart)
{
AddToken(TokenKind.String);
}
AddToken(TokenKind.StringEnd);
this._pos.Pop();
}
continue;
}
if (this._kind == TokenKind.TagStart
|| this._kind == TokenKind.LeftBracket
|| this._kind == TokenKind.LeftParentheses
|| this._kind == TokenKind.Operator
|| this._kind == TokenKind.Punctuation
|| this._kind == TokenKind.Comma
|| this._kind == TokenKind.Space)
{
AddToken(TokenKind.StringStart);
this._pos.Push("\"");
continue;
}
}
if (this._kind == TokenKind.StringStart)
{
AddToken(TokenKind.String);
continue;
}
if (this._kind == TokenKind.String)
{
continue;
}
if (this._scanner.Read() == '(')
{
this._pos.Push("(");
}
else if (this._scanner.Read() == ')' && this._pos.Count > 0 && this._pos.Peek() == "(")// && this.pos.Count > 2
{
this._pos.Pop();
if (this._pos.Count == 1)
{
}
}
else if (ReadEndToken())
{
break;
}
TokenKind tk;
if (this._scanner.Read() == '+' || this._scanner.Read() == '-') //正负数符号识别
{
if (Char.IsNumber(this._scanner.Read(1)) &&
(this._kind == TokenKind.Operator || this._kind == TokenKind.LeftParentheses))
{
tk = TokenKind.Number;
}
else
{
tk = TokenKind.Operator;
}
}
else
{
tk = GetTokenKind(this._scanner.Read());
}
//if (this.kind == tk || (tk == TokenKind.Number && this.kind == TokenKind.TextData))
if ((this._kind != tk || this._kind == TokenKind.LeftParentheses || this._kind == TokenKind.RightParentheses)
&& (tk != TokenKind.Number || this._kind != TokenKind.TextData)
//&& (this.kind == TokenKind.Number && tk != TokenKind.Dot)
)
//|| (this.kind != TokenKind.Number && tk == TokenKind.Dot)
{
if (tk == TokenKind.Dot && this._kind == TokenKind.Number)
{
}
else
{
AddToken(tk);
}
}
}
}