private ICommand ParseForCommand()
{
this.Parse(TokenType.Delimiter, "(");
Token token = this.lexer.NextToken();
if (token.TokenType == TokenType.Name && token.Value == "var")
{
string name = this.ParseName();
if (this.TryParse(TokenType.Name, "in"))
{
this.lexer.PushToken(new Token() { TokenType = TokenType.Name, Value = name });
this.lexer.PushToken(token);
return this.ParseForInCommand();
}
this.lexer.PushToken(new Token() { TokenType = TokenType.Name, Value = name });
this.lexer.PushToken(token);
}
ICommand initial = this.ParseSimpleCommand();
// this.Parse(TokenType.Separator, ";");
IExpression condition = this.ParseExpression();
this.Parse(TokenType.Delimiter, ";");
ICommand endcmd = this.ParseSimpleCommand();
this.Parse(TokenType.Delimiter, ")");
ICommand command = this.ParseCommand();
return new ForCommand(initial, condition, endcmd, command);
}