More fixes to restore parsing capability.

This commit is contained in:
John Wiegley 2008-07-23 19:40:01 -04:00
parent 90af218524
commit 7409b050be
2 changed files with 22 additions and 16 deletions

View file

@ -62,21 +62,23 @@ namespace {
} }
#endif #endif
if (! expr::compute_amount(expr, amount, xact)) if (expr) {
throw new parse_error("Amount expression failed to compute"); if (! expr::compute_amount(expr, amount, xact))
throw new parse_error("Amount expression failed to compute");
#if 0 #if 0
if (expr->kind == expr::node_t::VALUE) { if (expr->kind == expr::node_t::VALUE) {
expr = NULL; expr = NULL;
} else { } else {
DEBUG_IF("ledger.textual.parse") { DEBUG_IF("ledger.textual.parse") {
std::cout << "Value expression tree:" << std::endl; std::cout << "Value expression tree:" << std::endl;
ledger::dump_value_expr(std::cout, expr.get()); ledger::dump_value_expr(std::cout, expr.get());
}
} }
}
#else #else
expr = value_expr(); expr = value_expr();
#endif #endif
}
DEBUG("ledger.textual.parse", "line " << linenum << ": " << DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
"The transaction amount is " << xact->amount); "The transaction amount is " << xact->amount);
@ -178,12 +180,16 @@ transaction_t * parse_transaction(char * line, account_t * account,
EXPR_PARSE_NO_REDUCE); EXPR_PARSE_NO_REDUCE);
saw_amount = true; saw_amount = true;
xact->amount.reduce(); if (! xact->amount.is_null()) {
DEBUG("ledger.textual.parse", "line " << linenum << ": " << xact->amount.reduce();
"Reduced amount is " << xact->amount); DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
"Reduced amount is " << xact->amount);
}
unsigned long end = (long)in.tellg(); if (xact->amount_expr) {
xact->amount_expr.expr_str = string(line, beg, end - beg); unsigned long end = (long)in.tellg();
xact->amount_expr.expr_str = string(line, beg, end - beg);
}
} }
catch (error * err) { catch (error * err) {
err_desc = "While parsing transaction amount:"; err_desc = "While parsing transaction amount:";

View file

@ -794,7 +794,7 @@ public:
} }
operator bool() const throw() { operator bool() const throw() {
return ptr != NULL; return ptr.get() != NULL;
} }
operator string() const throw() { operator string() const throw() {
return expr_str; return expr_str;