diff options
-rw-r--r-- | src/iterators.cc | 14 | ||||
-rw-r--r-- | src/iterators.h | 26 | ||||
-rw-r--r-- | src/parser.cc | 26 | ||||
-rw-r--r-- | src/report.cc | 4 | ||||
-rw-r--r-- | src/session.cc | 2 |
5 files changed, 37 insertions, 35 deletions
diff --git a/src/iterators.cc b/src/iterators.cc index 2d924956..6745f971 100644 --- a/src/iterators.cc +++ b/src/iterators.cc @@ -30,15 +30,15 @@ */ #include "iterators.h" -#include "session.h" +#include "journal.h" #include "compare.h" namespace ledger { -void entries_iterator::reset(session_t& session) +void entries_iterator::reset(journal_t& journal) { - entries_i = session.journal->entries.begin(); - entries_end = session.journal->entries.end(); + entries_i = journal.entries.begin(); + entries_end = journal.entries.end(); entries_uninitialized = false; } @@ -50,16 +50,16 @@ entry_t * entries_iterator::operator()() return NULL; } -void session_xacts_iterator::reset(session_t& session) +void journal_xacts_iterator::reset(journal_t& journal) { - entries.reset(session); + entries.reset(journal); entry_t * entry = entries(); if (entry != NULL) xacts.reset(*entry); } -xact_t * session_xacts_iterator::operator()() +xact_t * journal_xacts_iterator::operator()() { xact_t * xact = xacts(); if (xact == NULL) { diff --git a/src/iterators.h b/src/iterators.h index 699dd891..48abf5fa 100644 --- a/src/iterators.h +++ b/src/iterators.h @@ -119,15 +119,15 @@ public: entries_iterator() : entries_uninitialized(true) { TRACE_CTOR(entries_iterator, ""); } - entries_iterator(session_t& session) : entries_uninitialized(true) { - TRACE_CTOR(entries_iterator, "session_t&"); - reset(session); + entries_iterator(journal_t& journal) : entries_uninitialized(true) { + TRACE_CTOR(entries_iterator, "journal_t&"); + reset(journal); } virtual ~entries_iterator() throw() { TRACE_DTOR(entries_iterator); } - void reset(session_t& session); + void reset(journal_t& journal); entry_t * operator()(); }; @@ -137,24 +137,24 @@ public: * * Long. */ -class session_xacts_iterator : public xacts_iterator +class journal_xacts_iterator : public xacts_iterator { entries_iterator entries; entry_xacts_iterator xacts; public: - session_xacts_iterator() { - TRACE_CTOR(session_xacts_iterator, ""); + journal_xacts_iterator() { + TRACE_CTOR(journal_xacts_iterator, ""); } - session_xacts_iterator(session_t& session) { - TRACE_CTOR(session_xacts_iterator, "session_t&"); - reset(session); + journal_xacts_iterator(journal_t& journal) { + TRACE_CTOR(journal_xacts_iterator, "journal_t&"); + reset(journal); } - virtual ~session_xacts_iterator() throw() { - TRACE_DTOR(session_xacts_iterator); + virtual ~journal_xacts_iterator() throw() { + TRACE_DTOR(journal_xacts_iterator); } - void reset(session_t& session); + void reset(journal_t& journal); virtual xact_t * operator()(); }; diff --git a/src/parser.cc b/src/parser.cc index a5fe9097..3ee57c4c 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -90,18 +90,20 @@ expr_t::parser_t::parse_dot_expr(std::istream& in, ptr_op_t node(parse_value_term(in, tflags)); if (node && ! tflags.has_flags(PARSE_SINGLE)) { - token_t& tok = next_token(in, tflags); - - if (tok.kind == token_t::DOT) { - ptr_op_t prev(node); - node = new op_t(op_t::O_LOOKUP); - node->set_left(prev); - node->set_right(parse_dot_expr(in, tflags)); - if (! node->right()) - throw_(parse_error, - tok.symbol << " operator not followed by argument"); - } else { - push_token(tok); + while (true) { + token_t& tok = next_token(in, tflags); + if (tok.kind == token_t::DOT) { + ptr_op_t prev(node); + node = new op_t(op_t::O_LOOKUP); + node->set_left(prev); + node->set_right(parse_value_term(in, tflags)); + if (! node->right()) + throw_(parse_error, + tok.symbol << " operator not followed by argument"); + } else { + push_token(tok); + break; + } } } diff --git a/src/report.cc b/src/report.cc index 77cdf59c..9dea33db 100644 --- a/src/report.cc +++ b/src/report.cc @@ -93,7 +93,7 @@ report_t::report_t(session_t& _session) : session(_session) void report_t::xacts_report(xact_handler_ptr handler) { - session_xacts_iterator walker(session); + journal_xacts_iterator walker(*session.journal.get()); pass_down_xacts(chain_xact_handlers(*this, handler), walker); session.clean_xacts(); } @@ -110,7 +110,7 @@ void report_t::sum_all_accounts() expr_t& expr(HANDLER(amount_).expr); expr.set_context(this); - session_xacts_iterator walker(session); + journal_xacts_iterator walker(*session.journal.get()); pass_down_xacts (chain_xact_handlers(*this, xact_handler_ptr(new set_account_value(expr)), false), walker); diff --git a/src/session.cc b/src/session.cc index 5dbd5593..1dfd05cc 100644 --- a/src/session.cc +++ b/src/session.cc @@ -150,7 +150,7 @@ std::size_t session_t::read_data(const string& master_account) void session_t::clean_xacts() { - session_xacts_iterator walker(*this); + journal_xacts_iterator walker(*journal.get()); pass_down_xacts(xact_handler_ptr(new clear_xact_xdata), walker); } |