From acb5e1beea4176ab51ca2c9d32b006e7c0a7bef0 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 5 Mar 2012 22:01:41 -0600 Subject: Generalized function call parsing Directly calling a lambda now works: (x -> x + 10)(10) => 20 --- src/op.cc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/op.cc') diff --git a/src/op.cc b/src/op.cc index c8e099e7..56d3710e 100644 --- a/src/op.cc +++ b/src/op.cc @@ -262,13 +262,18 @@ value_t expr_t::op_t::calc(scope_t& scope, ptr_op_t * locus, const int depth) case O_CALL: { ptr_op_t func = left(); - const string& name(func->as_ident()); - - func = func->left(); - if (! func) - func = scope.lookup(symbol_t::FUNCTION, name); - if (! func) - throw_(calc_error, _("Calling unknown function '%1'") << name); + string name; + + if (func->is_ident()) { + name = func->as_ident(); + func = func->left(); + if (! func) + func = scope.lookup(symbol_t::FUNCTION, name); + if (! func) + throw_(calc_error, _("Calling unknown function '%1'") << name); + } else { + name = ""; + } call_scope_t call_args(scope, locus, depth + 1); if (has_right()) -- cgit v1.2.3