summaryrefslogtreecommitdiff
path: root/src/op.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2012-03-05 22:01:41 -0600
committerJohn Wiegley <johnw@newartisans.com>2012-03-05 22:01:41 -0600
commitacb5e1beea4176ab51ca2c9d32b006e7c0a7bef0 (patch)
treee4f890c10c081a88b7e63401b47e4d9781ba90e6 /src/op.cc
parent59a16e59ee2e684f1d5292fe78ef94464a935d73 (diff)
downloadfork-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.cc19
1 files changed, 12 insertions, 7 deletions
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 = "<lambda>";
+ }
call_scope_t call_args(scope, locus, depth + 1);
if (has_right())