diff options
author | John Wiegley <johnw@newartisans.com> | 2008-07-19 23:10:37 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-07-19 23:10:37 -0400 |
commit | 88634973a29693402edd4eb8e943531354c51893 (patch) | |
tree | 550f6fca09e80d1a0877e06c3433b37c5bb2e6d5 /textual.cc | |
parent | d568319495a0695582797de0be4b85e1e06e73b2 (diff) | |
download | ledger-88634973a29693402edd4eb8e943531354c51893.tar.gz ledger-88634973a29693402edd4eb8e943531354c51893.tar.bz2 ledger-88634973a29693402edd4eb8e943531354c51893.zip |
Some basic fixes to get things almost running, although we still can't parse
my personal ledger file yet.
Diffstat (limited to 'textual.cc')
-rw-r--r-- | textual.cc | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -158,6 +158,8 @@ transaction_t * parse_transaction(char * line, account_t * account, // Parse the optional amount + bool saw_amount = false; + if (in.good() && ! in.eof()) { p = peek_next_nonws(in); if (in.eof()) @@ -171,6 +173,11 @@ transaction_t * parse_transaction(char * line, account_t * account, xact->amount_expr = parse_amount_expr(in, xact->amount, xact.get(), PARSE_VALEXPR_NO_REDUCE); + saw_amount = true; + + xact->amount.reduce(); + DEBUG("ledger.textual.parse", "line " << linenum << ": " << + "Reduced amount is " << xact->amount); unsigned long end = (long)in.tellg(); xact->amount_expr.expr = string(line, beg, end - beg); @@ -186,6 +193,10 @@ transaction_t * parse_transaction(char * line, account_t * account, if (in.good() && ! in.eof()) { p = peek_next_nonws(in); if (p == '@') { + if (! saw_amount) + throw new parse_error + ("Transaction cannot have a cost expression with an amount"); + DEBUG("ledger.textual.parse", "line " << linenum << ": " << "Found a price indicator"); bool per_unit = true; @@ -249,10 +260,6 @@ transaction_t * parse_transaction(char * line, account_t * account, } } - xact->amount.reduce(); - DEBUG("ledger.textual.parse", "line " << linenum << ": " << - "Reduced amount is " << xact->amount); - // Parse the optional note parse_note: |