diff options
author | John Wiegley <johnw@newartisans.com> | 2012-03-05 22:01:41 -0600 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2012-03-05 22:01:41 -0600 |
commit | acb5e1beea4176ab51ca2c9d32b006e7c0a7bef0 (patch) | |
tree | e4f890c10c081a88b7e63401b47e4d9781ba90e6 /src/op.cc | |
parent | 59a16e59ee2e684f1d5292fe78ef94464a935d73 (diff) | |
download | fork-ledger-acb5e1beea4176ab51ca2c9d32b006e7c0a7bef0.tar.gz fork-ledger-acb5e1beea4176ab51ca2c9d32b006e7c0a7bef0.tar.bz2 fork-ledger-acb5e1beea4176ab51ca2c9d32b006e7c0a7bef0.zip |
Generalized function call parsing
Directly calling a lambda now works:
(x -> x + 10)(10) => 20
Diffstat (limited to 'src/op.cc')
-rw-r--r-- | src/op.cc | 19 |
1 files changed, 12 insertions, 7 deletions
@@ -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 = "<lambda>"; + } call_scope_t call_args(scope, locus, depth + 1); if (has_right()) |