private ICommand ParseSimpleCommand()
{
if (this.TryParse(TokenType.Name, "var"))
{
this.lexer.NextToken();
return this.ParseVarCommand();
}
IExpression expression = this.ParseExpression();
if (expression == null)
return null;
if (this.TryParse(TokenType.Operator, "="))
{
this.lexer.NextToken();
ICommand command = null;
if (expression is IndexedExpression)
{
IndexedExpression aexpr = (IndexedExpression)expression;
command = new SetArrayCommand(aexpr.Expression, aexpr.Arguments, this.ParseExpression());
}
else
{
if (expression is VariableExpression)
this.IsValidName(((VariableExpression)expression).Name);
command = new SetCommand(expression, this.ParseExpression());
}
return command;
}
// TODO Review trick to suppor function name(pars) {} without ending ;
if (expression is FunctionExpression && ((FunctionExpression)expression).Name != null)
this.lexer.PushToken(tokenSemiColon);
return new ExpressionCommand(expression);
}