From 4518ea95408e2d5fe90a87159b88bb41734ec1dc Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 29 Jul 2008 05:10:16 -0400 Subject: Value expression architecture is now rewritten, but the functionality of the old system (for example, the meaning of 'a') has yet to be restored. In the new scheme, this will be done by definition a function outside of the value expression logic, rather than the tight coupling between journal innards and value expressions that occurred in 2.x. --- main.cc | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'main.cc') diff --git a/main.cc b/main.cc index 5646b032..c79f54dd 100644 --- a/main.cc +++ b/main.cc @@ -46,10 +46,10 @@ #endif namespace ledger { - value_t register_command(expr::call_scope_t& args) + value_t register_command(call_scope_t& args) { - expr::var_t report(args, 0); - expr::var_t ostream(args, 1); + var_t report(args, 0); + var_t ostream(args, 1); report->transactions_report (xact_handler_ptr(new format_transactions @@ -168,9 +168,8 @@ static int read_and_report(ledger::report_t& report, int argc, char * argv[], string verb = *arg++; if (verb == "parse") { - value_expr expr(*arg); + expr_t expr(*arg); -#if 0 IF_INFO() { std::cout << "Value expression tree:" << std::endl; expr.dump(std::cout); @@ -194,7 +193,6 @@ static int read_and_report(ledger::report_t& report, int argc, char * argv[], } std::cout << expr.calc(report).strip_annotations() << std::endl; -#endif return 0; } @@ -227,28 +225,26 @@ static int read_and_report(ledger::report_t& report, int argc, char * argv[], // Are we handling the expr commands? Do so now. if (verb == "expr") { - value_expr expr(*arg); + expr_t expr(*arg); -#if 0 IF_INFO() { *out << "Value expression tree:" << std::endl; expr.dump(*out); *out << std::endl; *out << "Value expression parsed was:" << std::endl; - expr.print(*out, doc_scope); + expr.print(*out, report); *out << std::endl << std::endl; *out << "Result of calculation: "; } - *out << expr.calc(doc_scope).strip_annotations() << std::endl; -#endif + *out << expr.calc(report).strip_annotations() << std::endl; return 0; } // Read the command word and create a command object based on it - expr::function_t command; + function_t command; if (verb == "register" || verb == "reg" || verb == "r") command = register_command; @@ -285,7 +281,7 @@ static int read_and_report(ledger::report_t& report, int argc, char * argv[], std::strcpy(buf, "command_"); std::strcat(buf, verb.c_str()); - if (expr::ptr_op_t def = report.lookup(buf)) + if (expr_t::ptr_op_t def = report.lookup(buf)) command = def->as_function(); if (! command) @@ -295,7 +291,7 @@ static int read_and_report(ledger::report_t& report, int argc, char * argv[], // Create an argument scope containing the report command's // arguments, and then invoke the command. - expr::call_scope_t command_args(report); + call_scope_t command_args(report); command_args.push_back(value_t(&report)); command_args.push_back(value_t(out)); @@ -320,7 +316,7 @@ static int read_and_report(ledger::report_t& report, int argc, char * argv[], TRACE_START(binary_cache, 1, "Wrote binary journal file"); ofstream stream(*session.cache_file); - binary::write_journal(stream, journal); + journal.write(stream); TRACE_FINISH(binary_cache, 1); } @@ -400,7 +396,7 @@ int main(int argc, char * argv[], char * envp[]) ledger::set_session_context(session.get()); - session->register_parser(new ledger::binary_parser_t); + session->register_parser(new ledger::journal_t::binary_parser_t); #if defined(HAVE_EXPAT) || defined(HAVE_XMLPARSE) session->register_parser(new ledger::xml_parser_t); session->register_parser(new ledger::gnucash_parser_t); -- cgit v1.2.3