summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-03 18:31:52 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-03 18:31:52 -0400
commit8948e161cd64bbd9ed3e3dfccae5fdb03e8e8251 (patch)
treef0a7f477379245dd05128b6d8844a51d53972826 /src
parentf49dfce30209c1d2f1fbc1f348364ac53dbb2e4e (diff)
downloadfork-ledger-8948e161cd64bbd9ed3e3dfccae5fdb03e8e8251.tar.gz
fork-ledger-8948e161cd64bbd9ed3e3dfccae5fdb03e8e8251.tar.bz2
fork-ledger-8948e161cd64bbd9ed3e3dfccae5fdb03e8e8251.zip
A little code rearranging.
Diffstat (limited to 'src')
-rw-r--r--src/textual.cc28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/textual.cc b/src/textual.cc
index 99635696..018806f7 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -117,9 +117,9 @@ namespace {
if (expr) {
value_t result(expr.calc(*xact));
- // jww (2009-02-01): What about storing time-dependent expressions?
if (! result.is_amount())
throw_(parse_error, "Transactions may only specify simple amounts");
+
amount = result.as_amount();
DEBUG("textual.parse", "The transaction amount is " << amount);
return expr;
@@ -766,12 +766,6 @@ xact_t * textual_parser_t::instance_t::parse_xact(char * line,
static_cast<uint_least8_t>(expr_t::PARSE_NO_REDUCE) |
static_cast<uint_least8_t>(expr_t::PARSE_NO_ASSIGN));
- if (! xact->amount.is_null()) {
- xact->amount.reduce();
- DEBUG("textual.parse", "line " << linenum << ": " <<
- "Reduced amount is " << xact->amount);
- }
-
// We don't need to store the actual expression that resulted in the
// amount if it's constant
if (xact->amount_expr) {
@@ -782,6 +776,12 @@ xact_t * textual_parser_t::instance_t::parse_xact(char * line,
xact->amount_expr->set_text(string(line, long(beg), long(end - beg)));
}
}
+
+ if (! xact->amount.is_null()) {
+ xact->amount.reduce();
+ DEBUG("textual.parse", "line " << linenum << ": " <<
+ "Reduced amount is " << xact->amount);
+ }
}
// Parse the optional cost (@ PER-UNIT-COST, @@ TOTAL-COST)
@@ -871,13 +871,6 @@ xact_t * textual_parser_t::instance_t::parse_xact(char * line,
parse_amount_expr(in, *xact->assigned_amount, xact.get(),
static_cast<uint_least8_t>(expr_t::PARSE_NO_MIGRATE));
- if (xact->assigned_amount->is_null())
- throw parse_error
- ("An assigned balance must evaluate to a constant value");
-
- DEBUG("textual.parse", "line " << linenum << ": " <<
- "XACT assign: parsed amt = " << *xact->assigned_amount);
-
if (xact->assigned_amount_expr) {
end = in.tellg();
xact->assigned_amount_expr->set_text
@@ -885,6 +878,13 @@ xact_t * textual_parser_t::instance_t::parse_xact(char * line,
}
}
+ if (xact->assigned_amount->is_null())
+ throw parse_error
+ ("An assigned balance must evaluate to a constant value");
+
+ DEBUG("textual.parse", "line " << linenum << ": " <<
+ "XACT assign: parsed amt = " << *xact->assigned_amount);
+
account_t::xdata_t& xdata(xact->account->xdata());
amount_t& amt(*xact->assigned_amount);