From 69da18cd303b10f9badd542141ffdfd546009508 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 4 Feb 2010 23:59:17 -0500 Subject: Some minor refactoring of the textual parser --- src/post.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/post.cc') 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) { -- cgit v1.2.3