A little code rearranging.
This commit is contained in:
parent
f49dfce302
commit
8948e161cd
1 changed files with 14 additions and 14 deletions
|
|
@ -117,9 +117,9 @@ namespace {
|
||||||
|
|
||||||
if (expr) {
|
if (expr) {
|
||||||
value_t result(expr.calc(*xact));
|
value_t result(expr.calc(*xact));
|
||||||
// jww (2009-02-01): What about storing time-dependent expressions?
|
|
||||||
if (! result.is_amount())
|
if (! result.is_amount())
|
||||||
throw_(parse_error, "Transactions may only specify simple amounts");
|
throw_(parse_error, "Transactions may only specify simple amounts");
|
||||||
|
|
||||||
amount = result.as_amount();
|
amount = result.as_amount();
|
||||||
DEBUG("textual.parse", "The transaction amount is " << amount);
|
DEBUG("textual.parse", "The transaction amount is " << amount);
|
||||||
return expr;
|
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_REDUCE) |
|
||||||
static_cast<uint_least8_t>(expr_t::PARSE_NO_ASSIGN));
|
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
|
// We don't need to store the actual expression that resulted in the
|
||||||
// amount if it's constant
|
// amount if it's constant
|
||||||
if (xact->amount_expr) {
|
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)));
|
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)
|
// 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(),
|
parse_amount_expr(in, *xact->assigned_amount, xact.get(),
|
||||||
static_cast<uint_least8_t>(expr_t::PARSE_NO_MIGRATE));
|
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) {
|
if (xact->assigned_amount_expr) {
|
||||||
end = in.tellg();
|
end = in.tellg();
|
||||||
xact->assigned_amount_expr->set_text
|
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());
|
account_t::xdata_t& xdata(xact->account->xdata());
|
||||||
amount_t& amt(*xact->assigned_amount);
|
amount_t& amt(*xact->assigned_amount);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue