private ICommand ParseVarCommand()
{
string name = this.ParseName();
this.IsValidName(name);
IExpression expression = null;
if (this.TryParse(TokenType.Operator, "="))
{
this.lexer.NextToken();
expression = this.ParseExpression();
}
this.Parse(TokenType.Delimiter, ";");
if (this.hoistedCommands != null)
{
this.hoistedCommands.Add(new VarCommand(name));
if (expression == null)
return NoOperationCommand.Instance;
return new SetVariableCommand(name, expression);
}
if (expression == null)
return new VarCommand(name);
return new CompositeCommand(new List<ICommand>() { new VarCommand(name), new SetVariableCommand(name, expression) });
}