private FunctionExpression ParseFunctionExpression()
{
string name = null;
if (this.TryPeekName())
{
Token token = this.lexer.NextToken();
name = token.Value;
}
IList<ICommand> currentHoistedCommands = this.hoistedCommands;
this.hoistedCommands = new List<ICommand>();
try
{
IList<string> arguments = this.ParseArgumentNames();
this.Parse(TokenType.Delimiter, "{");
CompositeCommand command = this.ParseCompositeCommand();
// TODO Review, should be 0
if (command.HoistedCommandCount > 0)
throw new ParserException("Invalid command");
command = new CompositeCommand(this.hoistedCommands, command.Commands);
return new FunctionExpression(name, arguments.ToArray(), command);
}
finally
{
this.hoistedCommands = currentHoistedCommands;
}
}