diff options
author | John Wiegley <johnw@newartisans.com> | 2010-02-04 23:59:17 -0500 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2010-02-05 00:00:40 -0500 |
commit | 69da18cd303b10f9badd542141ffdfd546009508 (patch) | |
tree | 2f3a39c4b71b8cb8b232502401e8dd2c8c2247ef /src/post.cc | |
parent | 40eae8bf94f65a000541449b863ea26a469627fd (diff) | |
download | fork-ledger-69da18cd303b10f9badd542141ffdfd546009508.tar.gz fork-ledger-69da18cd303b10f9badd542141ffdfd546009508.tar.bz2 fork-ledger-69da18cd303b10f9badd542141ffdfd546009508.zip |
Some minor refactoring of the textual parser
Diffstat (limited to 'src/post.cc')
-rw-r--r-- | src/post.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/post.cc b/src/post.cc index 5b9d2bb3..43cfe55f 100644 --- a/src/post.cc +++ b/src/post.cc @@ -417,6 +417,20 @@ expr_t::ptr_op_t post_t::lookup(const symbol_t::kind_t kind, return item_t::lookup(kind, name); } +amount_t post_t::resolve_expr(scope_t& scope, expr_t& expr) +{ + bind_scope_t bound_scope(scope, *this); + value_t result(expr.calc(bound_scope)); + if (result.is_long()) { + return result.to_amount(); + } else { + if (! result.is_amount()) + throw_(amount_error, + _("Amount expressions must result in a simple amount")); + return result.as_amount(); + } +} + bool post_t::valid() const { if (! xact) { |