Everything but main.cc is compiling again (but with much #if 0'd code).
This commit is contained in:
parent
20e35aa6f5
commit
b85e9ba95f
6 changed files with 140 additions and 177 deletions
|
|
@ -179,7 +179,7 @@ static void endElement(void *userData, const char *name)
|
||||||
xact->state = curr_state;
|
xact->state = curr_state;
|
||||||
xact->amount = value;
|
xact->amount = value;
|
||||||
if (value != curr_value)
|
if (value != curr_value)
|
||||||
xact->cost = new amount_t(curr_value);
|
xact->cost = curr_value;
|
||||||
|
|
||||||
xact->beg_pos = beg_pos;
|
xact->beg_pos = beg_pos;
|
||||||
xact->beg_line = beg_line;
|
xact->beg_line = beg_line;
|
||||||
|
|
|
||||||
57
main.cc
57
main.cc
|
|
@ -135,16 +135,20 @@ static int read_and_report(ledger::report_t& report, int argc, char * argv[],
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if (verb == "xml")
|
if (verb == "xml")
|
||||||
|
#if 0
|
||||||
command = bind(xml_command, _1);
|
command = bind(xml_command, _1);
|
||||||
|
#else
|
||||||
|
;
|
||||||
|
#endif
|
||||||
else if (verb == "expr")
|
else if (verb == "expr")
|
||||||
;
|
;
|
||||||
else if (verb == "xpath")
|
else if (verb == "xpath")
|
||||||
;
|
;
|
||||||
else if (verb == "parse") {
|
else if (verb == "parse") {
|
||||||
xml::xpath_t expr(*arg);
|
value_expr expr(*arg);
|
||||||
xml::document_t temp(xml::LEDGER_NODE);
|
|
||||||
|
|
||||||
xml::xpath_t::context_scope_t doc_scope(report, &temp);
|
#if 0
|
||||||
|
expr::context_scope_t doc_scope(report, &temp);
|
||||||
|
|
||||||
IF_INFO() {
|
IF_INFO() {
|
||||||
std::cout << "Value expression tree:" << std::endl;
|
std::cout << "Value expression tree:" << std::endl;
|
||||||
|
|
@ -169,6 +173,7 @@ static int read_and_report(ledger::report_t& report, int argc, char * argv[],
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << expr.calc(doc_scope).strip_annotations() << std::endl;
|
std::cout << expr.calc(doc_scope).strip_annotations() << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -177,7 +182,7 @@ static int read_and_report(ledger::report_t& report, int argc, char * argv[],
|
||||||
std::strcpy(buf, "command_");
|
std::strcpy(buf, "command_");
|
||||||
std::strcat(buf, verb.c_str());
|
std::strcat(buf, verb.c_str());
|
||||||
|
|
||||||
if (xml::xpath_t::ptr_op_t def = report.lookup(buf))
|
if (expr::ptr_op_t def = report.lookup(buf))
|
||||||
command = def->as_function();
|
command = def->as_function();
|
||||||
|
|
||||||
if (! command)
|
if (! command)
|
||||||
|
|
@ -187,17 +192,19 @@ static int read_and_report(ledger::report_t& report, int argc, char * argv[],
|
||||||
// Parse the initialization file, which can only be textual; then
|
// Parse the initialization file, which can only be textual; then
|
||||||
// parse the journal data.
|
// parse the journal data.
|
||||||
|
|
||||||
|
#if 0
|
||||||
session.read_init();
|
session.read_init();
|
||||||
|
#endif
|
||||||
|
|
||||||
INFO_START(journal, "Read journal file");
|
INFO_START(journal, "Read journal file");
|
||||||
|
|
||||||
xml::document_t xml_document(xml::LEDGER_NODE);
|
journal_t * journal = session.create_journal();
|
||||||
journal_t * journal = session.create_journal();
|
|
||||||
xml::journal_builder_t builder(xml_document, journal);
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (! session.read_data(builder, journal, report.account))
|
if (! session.read_data(builder, journal, report.account))
|
||||||
throw_(parse_error, "Failed to locate any journal entries; "
|
throw_(parse_error, "Failed to locate any journal entries; "
|
||||||
"did you specify a valid file with -f?");
|
"did you specify a valid file with -f?");
|
||||||
|
#endif
|
||||||
|
|
||||||
INFO_FINISH(journal);
|
INFO_FINISH(journal);
|
||||||
|
|
||||||
|
|
@ -259,10 +266,10 @@ static int read_and_report(ledger::report_t& report, int argc, char * argv[],
|
||||||
|
|
||||||
// Are we handling the expr commands? Do so now.
|
// Are we handling the expr commands? Do so now.
|
||||||
|
|
||||||
xml::xpath_t::context_scope_t doc_scope(report, &xml_document);
|
expr::context_scope_t doc_scope(report, &xml_document);
|
||||||
|
|
||||||
if (verb == "expr") {
|
if (verb == "expr") {
|
||||||
xml::xpath_t expr(*arg);
|
value_expr expr(*arg);
|
||||||
|
|
||||||
IF_INFO() {
|
IF_INFO() {
|
||||||
*out << "Value expression tree:" << std::endl;
|
*out << "Value expression tree:" << std::endl;
|
||||||
|
|
@ -278,38 +285,6 @@ static int read_and_report(ledger::report_t& report, int argc, char * argv[],
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (verb == "xpath") {
|
|
||||||
std::cout << "XPath parsed: ";
|
|
||||||
|
|
||||||
xml::xpath_t xpath(*arg);
|
|
||||||
xpath.print(*out, doc_scope);
|
|
||||||
*out << std::endl;
|
|
||||||
|
|
||||||
IF_INFO() {
|
|
||||||
*out << "Raw results:" << std::endl;
|
|
||||||
|
|
||||||
foreach (const value_t& value, xpath.find_all(doc_scope)) {
|
|
||||||
if (value.is_xml_node())
|
|
||||||
value.as_xml_node()->print(std::cout);
|
|
||||||
else
|
|
||||||
std::cout << value;
|
|
||||||
std::cout << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
*out << "Compiled results:" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
xml::compile_node(xml_document, report);
|
|
||||||
|
|
||||||
foreach (const value_t& value, xpath.find_all(doc_scope)) {
|
|
||||||
if (value.is_xml_node())
|
|
||||||
value.as_xml_node()->print(std::cout);
|
|
||||||
else
|
|
||||||
std::cout << value;
|
|
||||||
std::cout << std::endl;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply transforms to the hierarchical document structure
|
// Apply transforms to the hierarchical document structure
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -209,7 +209,7 @@ transaction_t * parse_transaction(char * line, account_t * account,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in.good() && ! in.eof()) {
|
if (in.good() && ! in.eof()) {
|
||||||
xact->cost = new amount_t;
|
xact->cost = amount_t();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
unsigned long beg = (long)in.tellg();
|
unsigned long beg = (long)in.tellg();
|
||||||
|
|
@ -734,7 +734,9 @@ unsigned int textual_parser_t::parse(std::istream& in,
|
||||||
if (p)
|
if (p)
|
||||||
*p++ = '\0';
|
*p++ = '\0';
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
process_option(config_options, line + 2, p);
|
process_option(config_options, line + 2, p);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -835,13 +837,15 @@ unsigned int textual_parser_t::parse(std::istream& in,
|
||||||
// parser to resolve alias references.
|
// parser to resolve alias references.
|
||||||
account_t * acct = account_stack.front()->find_account(e);
|
account_t * acct = account_stack.front()->find_account(e);
|
||||||
std::pair<accounts_map::iterator, bool> result
|
std::pair<accounts_map::iterator, bool> result
|
||||||
= account_aliases.insert(accounts_map::pair_type(b, acct));
|
= account_aliases.insert(accounts_map::value_type(b, acct));
|
||||||
assert(result.second);
|
assert(result.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (word == "def") {
|
else if (word == "def") {
|
||||||
|
#if 0
|
||||||
if (! expr::global_scope.get())
|
if (! expr::global_scope.get())
|
||||||
init_value_expr();
|
init_value_expr();
|
||||||
|
#endif
|
||||||
parse_value_definition(p);
|
parse_value_definition(p);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
219
valexpr.cc
219
valexpr.cc
|
|
@ -9,7 +9,7 @@ value_expr total_expr;
|
||||||
|
|
||||||
namespace expr {
|
namespace expr {
|
||||||
|
|
||||||
std::auto_ptr<scope_t> global_scope;
|
std::auto_ptr<symbol_scope_t> global_scope;
|
||||||
datetime_t terminus;
|
datetime_t terminus;
|
||||||
|
|
||||||
details_t::details_t(const transaction_t& _xact)
|
details_t::details_t(const transaction_t& _xact)
|
||||||
|
|
@ -553,10 +553,10 @@ void op_t::compute(value_t& result, const details_t& details,
|
||||||
case O_COM:
|
case O_COM:
|
||||||
if (! left())
|
if (! left())
|
||||||
throw new compute_error("Comma operator missing left operand",
|
throw new compute_error("Comma operator missing left operand",
|
||||||
new valexpr_context(this));
|
new valexpr_context(const_cast<op_t *>(this)));
|
||||||
if (! right())
|
if (! right())
|
||||||
throw new compute_error("Comma operator missing right operand",
|
throw new compute_error("Comma operator missing right operand",
|
||||||
new valexpr_context(this));
|
new valexpr_context(const_cast<op_t *>(this)));
|
||||||
left()->compute(result, details, context);
|
left()->compute(result, details, context);
|
||||||
right()->compute(result, details, context);
|
right()->compute(result, details, context);
|
||||||
break;
|
break;
|
||||||
|
|
@ -696,7 +696,7 @@ void op_t::compute(value_t& result, const details_t& details,
|
||||||
catch (error * err) {
|
catch (error * err) {
|
||||||
if (err->context.empty() ||
|
if (err->context.empty() ||
|
||||||
! dynamic_cast<valexpr_context *>(err->context.back()))
|
! dynamic_cast<valexpr_context *>(err->context.back()))
|
||||||
err->context.push_back(new valexpr_context(this));
|
err->context.push_back(new valexpr_context(const_cast<op_t *>(this)));
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -823,7 +823,7 @@ ptr_op_t parse_value_term(std::istream& in, scope_t * scope,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (definition) {
|
if (definition) {
|
||||||
std::auto_ptr<call_scope_t> params(new call_scope_t(scope));
|
std::auto_ptr<call_scope_t> params(new call_scope_t(*scope));
|
||||||
|
|
||||||
long arg_index = 0;
|
long arg_index = 0;
|
||||||
if (have_args) {
|
if (have_args) {
|
||||||
|
|
@ -846,7 +846,7 @@ ptr_op_t parse_value_term(std::istream& in, scope_t * scope,
|
||||||
// an O_ARG value.
|
// an O_ARG value.
|
||||||
node.reset(new op_t(op_t::O_ARG));
|
node.reset(new op_t(op_t::O_ARG));
|
||||||
node->set_left(new op_t(op_t::ARG_INDEX));
|
node->set_left(new op_t(op_t::ARG_INDEX));
|
||||||
node->left->arg_index = arg_index++;
|
node->left()->set_long(arg_index++);
|
||||||
params->define(ident, node.release());
|
params->define(ident, node.release());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -864,7 +864,7 @@ ptr_op_t parse_value_term(std::istream& in, scope_t * scope,
|
||||||
|
|
||||||
node.reset(new op_t(op_t::O_DEF));
|
node.reset(new op_t(op_t::O_DEF));
|
||||||
node->set_left(new op_t(op_t::ARG_INDEX));
|
node->set_left(new op_t(op_t::ARG_INDEX));
|
||||||
node->left->arg_index = arg_index;
|
node->left()->set_long(arg_index);
|
||||||
node->set_right(def.release());
|
node->set_right(def.release());
|
||||||
|
|
||||||
scope->define(buf, node.get());
|
scope->define(buf, node.get());
|
||||||
|
|
@ -883,7 +883,7 @@ ptr_op_t parse_value_term(std::istream& in, scope_t * scope,
|
||||||
}
|
}
|
||||||
else if (def->kind == op_t::O_DEF) {
|
else if (def->kind == op_t::O_DEF) {
|
||||||
node.reset(new op_t(op_t::O_REF));
|
node.reset(new op_t(op_t::O_REF));
|
||||||
node->set_left(def->right);
|
node->set_left(def->right());
|
||||||
|
|
||||||
unsigned int count = 0;
|
unsigned int count = 0;
|
||||||
if (have_args) {
|
if (have_args) {
|
||||||
|
|
@ -904,10 +904,11 @@ ptr_op_t parse_value_term(std::istream& in, scope_t * scope,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count != def->left->arg_index) {
|
if (count != def->left()->as_long()) {
|
||||||
std::ostringstream errmsg;
|
std::ostringstream errmsg;
|
||||||
errmsg << "Wrong number of arguments to '" << buf
|
errmsg << "Wrong number of arguments to '" << buf
|
||||||
<< "': saw " << count << ", wanted " << def->left->arg_index;
|
<< "': saw " << count
|
||||||
|
<< ", wanted " << def->left()->as_long();
|
||||||
throw new value_expr_error(errmsg.str());
|
throw new value_expr_error(errmsg.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -928,6 +929,7 @@ ptr_op_t parse_value_term(std::istream& in, scope_t * scope,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
|
#if 0
|
||||||
case 'c':
|
case 'c':
|
||||||
case 'C':
|
case 'C':
|
||||||
case 'p':
|
case 'p':
|
||||||
|
|
@ -983,6 +985,7 @@ ptr_op_t parse_value_term(std::istream& in, scope_t * scope,
|
||||||
node->mask = new mask_t(buf);
|
node->mask = new mask_t(buf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
case '{': {
|
case '{': {
|
||||||
amount_t temp;
|
amount_t temp;
|
||||||
|
|
@ -991,13 +994,13 @@ ptr_op_t parse_value_term(std::istream& in, scope_t * scope,
|
||||||
if (c != '}')
|
if (c != '}')
|
||||||
unexpected(c, '}');
|
unexpected(c, '}');
|
||||||
|
|
||||||
node.reset(new op_t(op_t::CONSTANT));
|
node.reset(new op_t(op_t::VALUE));
|
||||||
node->value = new value_t(temp);
|
node->set_value(temp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case '(': {
|
case '(': {
|
||||||
std::auto_ptr<scope_t> locals(new scope_t(scope));
|
std::auto_ptr<symbol_scope_t> locals(new symbol_scope_t(*scope));
|
||||||
node.reset(parse_value_expr(in, locals.get(),
|
node.reset(parse_value_expr(in, locals.get(),
|
||||||
flags | PARSE_VALEXPR_PARTIAL));
|
flags | PARSE_VALEXPR_PARTIAL));
|
||||||
in.get(c);
|
in.get(c);
|
||||||
|
|
@ -1013,8 +1016,8 @@ ptr_op_t parse_value_term(std::istream& in, scope_t * scope,
|
||||||
in.get(c);
|
in.get(c);
|
||||||
|
|
||||||
interval_t timespan(buf);
|
interval_t timespan(buf);
|
||||||
node.reset(new op_t(op_t::CONSTANT));
|
node.reset(new op_t(op_t::VALUE));
|
||||||
node->value = new value_t(timespan.first());
|
node->set_value(timespan.first());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1079,8 +1082,8 @@ ptr_op_t parse_add_expr(std::istream& in, scope_t * scope,
|
||||||
char c;
|
char c;
|
||||||
in.get(c);
|
in.get(c);
|
||||||
value_expr expr(parse_mul_expr(in, scope, flags));
|
value_expr expr(parse_mul_expr(in, scope, flags));
|
||||||
if (expr->kind == op_t::CONSTANT) {
|
if (expr->kind == op_t::VALUE) {
|
||||||
expr->value->negate();
|
expr->as_value().in_place_negate();
|
||||||
return expr.release();
|
return expr.release();
|
||||||
}
|
}
|
||||||
node.reset(new op_t(op_t::O_NEG));
|
node.reset(new op_t(op_t::O_NEG));
|
||||||
|
|
@ -1219,12 +1222,12 @@ ptr_op_t parse_boolean_expr(std::istream& in, scope_t * scope,
|
||||||
node.reset(new op_t(op_t::O_QUES));
|
node.reset(new op_t(op_t::O_QUES));
|
||||||
node->set_left(prev.release());
|
node->set_left(prev.release());
|
||||||
node->set_right(new op_t(op_t::O_COL));
|
node->set_right(new op_t(op_t::O_COL));
|
||||||
node->right->set_left(parse_logic_expr(in, scope, flags));
|
node->right()->set_left(parse_logic_expr(in, scope, flags));
|
||||||
c = peek_next_nonws(in);
|
c = peek_next_nonws(in);
|
||||||
if (c != ':')
|
if (c != ':')
|
||||||
unexpected(c, ':');
|
unexpected(c, ':');
|
||||||
in.get(c);
|
in.get(c);
|
||||||
node->right->set_right(parse_logic_expr(in, scope, flags));
|
node->right()->set_right(parse_logic_expr(in, scope, flags));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1242,8 +1245,8 @@ ptr_op_t parse_boolean_expr(std::istream& in, scope_t * scope,
|
||||||
|
|
||||||
void init_value_expr()
|
void init_value_expr()
|
||||||
{
|
{
|
||||||
global_scope.reset(new scope_t());
|
global_scope.reset(new symbol_scope_t());
|
||||||
scope_t * globals = global_scope.get();
|
symbol_scope_t * globals = global_scope.get();
|
||||||
|
|
||||||
ptr_op_t node;
|
ptr_op_t node;
|
||||||
|
|
||||||
|
|
@ -1318,26 +1321,26 @@ void init_value_expr()
|
||||||
globals->define("total_cost", node);
|
globals->define("total_cost", node);
|
||||||
|
|
||||||
// Relating to format_t
|
// Relating to format_t
|
||||||
globals->define("t", new op_t(op_t::VALUE_EXPR));
|
globals->define("t", ptr_op_t(new op_t(op_t::VALUE_EXPR)));
|
||||||
globals->define("T", new op_t(op_t::TOTAL_EXPR));
|
globals->define("T", ptr_op_t(new op_t(op_t::TOTAL_EXPR)));
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
node = new op_t(op_t::O_DEF);
|
node = new op_t(op_t::O_DEF);
|
||||||
node->set_left(new op_t(op_t::ARG_INDEX));
|
node->set_left(new op_t(op_t::ARG_INDEX));
|
||||||
node->left->arg_index = 1;
|
node->left()->set_long(1);
|
||||||
node->set_right(new op_t(op_t::F_ABS));
|
node->set_right(new op_t(op_t::F_ABS));
|
||||||
globals->define("U", node);
|
globals->define("U", node);
|
||||||
globals->define("abs", node);
|
globals->define("abs", node);
|
||||||
|
|
||||||
node = new op_t(op_t::O_DEF);
|
node = new op_t(op_t::O_DEF);
|
||||||
node->set_left(new op_t(op_t::ARG_INDEX));
|
node->set_left(new op_t(op_t::ARG_INDEX));
|
||||||
node->left->arg_index = 1;
|
node->left()->set_long(1);
|
||||||
node->set_right(new op_t(op_t::F_ROUND));
|
node->set_right(new op_t(op_t::F_ROUND));
|
||||||
globals->define("round", node);
|
globals->define("round", node);
|
||||||
|
|
||||||
node = new op_t(op_t::O_DEF);
|
node = new op_t(op_t::O_DEF);
|
||||||
node->set_left(new op_t(op_t::ARG_INDEX));
|
node->set_left(new op_t(op_t::ARG_INDEX));
|
||||||
node->left->arg_index = 1;
|
node->left()->set_long(1);
|
||||||
node->set_right(new op_t(op_t::F_QUANTITY));
|
node->set_right(new op_t(op_t::F_QUANTITY));
|
||||||
globals->define("S", node);
|
globals->define("S", node);
|
||||||
globals->define("quant", node);
|
globals->define("quant", node);
|
||||||
|
|
@ -1345,21 +1348,21 @@ void init_value_expr()
|
||||||
|
|
||||||
node = new op_t(op_t::O_DEF);
|
node = new op_t(op_t::O_DEF);
|
||||||
node->set_left(new op_t(op_t::ARG_INDEX));
|
node->set_left(new op_t(op_t::ARG_INDEX));
|
||||||
node->left->arg_index = 1;
|
node->left()->set_long(1);
|
||||||
node->set_right(new op_t(op_t::F_COMMODITY));
|
node->set_right(new op_t(op_t::F_COMMODITY));
|
||||||
globals->define("comm", node);
|
globals->define("comm", node);
|
||||||
globals->define("commodity", node);
|
globals->define("commodity", node);
|
||||||
|
|
||||||
node = new op_t(op_t::O_DEF);
|
node = new op_t(op_t::O_DEF);
|
||||||
node->set_left(new op_t(op_t::ARG_INDEX));
|
node->set_left(new op_t(op_t::ARG_INDEX));
|
||||||
node->left->arg_index = 2;
|
node->left()->set_long(2);
|
||||||
node->set_right(new op_t(op_t::F_SET_COMMODITY));
|
node->set_right(new op_t(op_t::F_SET_COMMODITY));
|
||||||
globals->define("setcomm", node);
|
globals->define("setcomm", node);
|
||||||
globals->define("set_commodity", node);
|
globals->define("set_commodity", node);
|
||||||
|
|
||||||
node = new op_t(op_t::O_DEF);
|
node = new op_t(op_t::O_DEF);
|
||||||
node->set_left(new op_t(op_t::ARG_INDEX));
|
node->set_left(new op_t(op_t::ARG_INDEX));
|
||||||
node->left->arg_index = 1;
|
node->left()->set_long(1);
|
||||||
node->set_right(new op_t(op_t::F_ARITH_MEAN));
|
node->set_right(new op_t(op_t::F_ARITH_MEAN));
|
||||||
globals->define("A", node);
|
globals->define("A", node);
|
||||||
globals->define("avg", node);
|
globals->define("avg", node);
|
||||||
|
|
@ -1368,7 +1371,7 @@ void init_value_expr()
|
||||||
|
|
||||||
node = new op_t(op_t::O_DEF);
|
node = new op_t(op_t::O_DEF);
|
||||||
node->set_left(new op_t(op_t::ARG_INDEX));
|
node->set_left(new op_t(op_t::ARG_INDEX));
|
||||||
node->left->arg_index = 2;
|
node->left()->set_long(2);
|
||||||
node->set_right(new op_t(op_t::F_VALUE));
|
node->set_right(new op_t(op_t::F_VALUE));
|
||||||
globals->define("P", node);
|
globals->define("P", node);
|
||||||
|
|
||||||
|
|
@ -1379,37 +1382,37 @@ void init_value_expr()
|
||||||
|
|
||||||
node = new op_t(op_t::O_DEF);
|
node = new op_t(op_t::O_DEF);
|
||||||
node->set_left(new op_t(op_t::ARG_INDEX));
|
node->set_left(new op_t(op_t::ARG_INDEX));
|
||||||
node->left->arg_index = 1;
|
node->left()->set_long(1);
|
||||||
node->set_right(new op_t(op_t::F_PRICE));
|
node->set_right(new op_t(op_t::F_PRICE));
|
||||||
globals->define("priceof", node);
|
globals->define("priceof", node);
|
||||||
|
|
||||||
node = new op_t(op_t::O_DEF);
|
node = new op_t(op_t::O_DEF);
|
||||||
node->set_left(new op_t(op_t::ARG_INDEX));
|
node->set_left(new op_t(op_t::ARG_INDEX));
|
||||||
node->left->arg_index = 1;
|
node->left()->set_long(1);
|
||||||
node->set_right(new op_t(op_t::F_DATE));
|
node->set_right(new op_t(op_t::F_DATE));
|
||||||
globals->define("dateof", node);
|
globals->define("dateof", node);
|
||||||
|
|
||||||
node = new op_t(op_t::O_DEF);
|
node = new op_t(op_t::O_DEF);
|
||||||
node->set_left(new op_t(op_t::ARG_INDEX));
|
node->set_left(new op_t(op_t::ARG_INDEX));
|
||||||
node->left->arg_index = 2;
|
node->left()->set_long(2);
|
||||||
node->set_right(new op_t(op_t::F_DATECMP));
|
node->set_right(new op_t(op_t::F_DATECMP));
|
||||||
globals->define("datecmp", node);
|
globals->define("datecmp", node);
|
||||||
|
|
||||||
node = new op_t(op_t::O_DEF);
|
node = new op_t(op_t::O_DEF);
|
||||||
node->set_left(new op_t(op_t::ARG_INDEX));
|
node->set_left(new op_t(op_t::ARG_INDEX));
|
||||||
node->left->arg_index = 1;
|
node->left()->set_long(1);
|
||||||
node->set_right(new op_t(op_t::F_YEAR));
|
node->set_right(new op_t(op_t::F_YEAR));
|
||||||
globals->define("yearof", node);
|
globals->define("yearof", node);
|
||||||
|
|
||||||
node = new op_t(op_t::O_DEF);
|
node = new op_t(op_t::O_DEF);
|
||||||
node->set_left(new op_t(op_t::ARG_INDEX));
|
node->set_left(new op_t(op_t::ARG_INDEX));
|
||||||
node->left->arg_index = 1;
|
node->left()->set_long(1);
|
||||||
node->set_right(new op_t(op_t::F_MONTH));
|
node->set_right(new op_t(op_t::F_MONTH));
|
||||||
globals->define("monthof", node);
|
globals->define("monthof", node);
|
||||||
|
|
||||||
node = new op_t(op_t::O_DEF);
|
node = new op_t(op_t::O_DEF);
|
||||||
node->set_left(new op_t(op_t::ARG_INDEX));
|
node->set_left(new op_t(op_t::ARG_INDEX));
|
||||||
node->left->arg_index = 1;
|
node->left()->set_long(1);
|
||||||
node->set_right(new op_t(op_t::F_DAY));
|
node->set_right(new op_t(op_t::F_DAY));
|
||||||
globals->define("dayof", node);
|
globals->define("dayof", node);
|
||||||
|
|
||||||
|
|
@ -1444,8 +1447,8 @@ ptr_op_t parse_value_expr(std::istream& in, scope_t * scope,
|
||||||
if (! global_scope.get())
|
if (! global_scope.get())
|
||||||
init_value_expr();
|
init_value_expr();
|
||||||
|
|
||||||
std::auto_ptr<scope_t> this_scope(new scope_t(scope ? scope :
|
std::auto_ptr<symbol_scope_t>
|
||||||
global_scope.get()));
|
this_scope(new symbol_scope_t(scope ? *scope : *global_scope.get()));
|
||||||
value_expr node;
|
value_expr node;
|
||||||
node.reset(parse_boolean_expr(in, this_scope.get(), flags));
|
node.reset(parse_boolean_expr(in, this_scope.get(), flags));
|
||||||
|
|
||||||
|
|
@ -1489,19 +1492,6 @@ ptr_op_t parse_value_expr(std::istream& in, scope_t * scope,
|
||||||
return node.release();
|
return node.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
valexpr_context::valexpr_context(const ledger::ptr_op_t _expr,
|
|
||||||
const string& desc) throw()
|
|
||||||
: error_context(desc), expr(_expr), error_node(_expr)
|
|
||||||
{
|
|
||||||
error_node->acquire();
|
|
||||||
}
|
|
||||||
|
|
||||||
valexpr_context::~valexpr_context() throw()
|
|
||||||
{
|
|
||||||
if (expr) expr->release();
|
|
||||||
if (error_node) error_node->release();
|
|
||||||
}
|
|
||||||
|
|
||||||
void valexpr_context::describe(std::ostream& out) const throw()
|
void valexpr_context::describe(std::ostream& out) const throw()
|
||||||
{
|
{
|
||||||
if (! expr) {
|
if (! expr) {
|
||||||
|
|
@ -1516,8 +1506,7 @@ void valexpr_context::describe(std::ostream& out) const throw()
|
||||||
unsigned long start = (long)out.tellp() - 1;
|
unsigned long start = (long)out.tellp() - 1;
|
||||||
unsigned long begin;
|
unsigned long begin;
|
||||||
unsigned long end;
|
unsigned long end;
|
||||||
bool found = ledger::print_value_expr(out, expr, true,
|
bool found = print_value_expr(out, expr, true, error_node, &begin, &end);
|
||||||
error_node, &begin, &end);
|
|
||||||
out << std::endl;
|
out << std::endl;
|
||||||
if (found) {
|
if (found) {
|
||||||
out << " ";
|
out << " ";
|
||||||
|
|
@ -1531,12 +1520,12 @@ void valexpr_context::describe(std::ostream& out) const throw()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool print_value_expr(std::ostream& out,
|
bool print_value_expr(std::ostream& out,
|
||||||
const ptr_op_t node,
|
const ptr_op_t node,
|
||||||
const bool relaxed,
|
const bool relaxed,
|
||||||
const ptr_op_t op_to_find,
|
const ptr_op_t op_to_find,
|
||||||
unsigned long * start_pos,
|
unsigned long * start_pos,
|
||||||
unsigned long * end_pos)
|
unsigned long * end_pos)
|
||||||
{
|
{
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
|
|
@ -1549,22 +1538,22 @@ bool print_value_expr(std::ostream& out,
|
||||||
|
|
||||||
switch (node->kind) {
|
switch (node->kind) {
|
||||||
case op_t::ARG_INDEX:
|
case op_t::ARG_INDEX:
|
||||||
out << node->arg_index;
|
out << node->as_long();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case op_t::CONSTANT:
|
case op_t::VALUE:
|
||||||
switch (node->value->type()) {
|
switch (node->as_value().type()) {
|
||||||
case value_t::BOOLEAN:
|
case value_t::BOOLEAN:
|
||||||
assert(false);
|
assert(false);
|
||||||
break;
|
break;
|
||||||
case value_t::DATETIME:
|
case value_t::DATETIME:
|
||||||
out << '[' << *(node->value) << ']';
|
out << '[' << node->as_value().as_datetime() << ']';
|
||||||
break;
|
break;
|
||||||
case value_t::INTEGER:
|
case value_t::INTEGER:
|
||||||
case value_t::AMOUNT:
|
case value_t::AMOUNT:
|
||||||
if (! relaxed)
|
if (! relaxed)
|
||||||
out << '{';
|
out << '{';
|
||||||
out << *(node->value);
|
out << node->as_value();
|
||||||
if (! relaxed)
|
if (! relaxed)
|
||||||
out << '}';
|
out << '}';
|
||||||
break;
|
break;
|
||||||
|
|
@ -1647,6 +1636,7 @@ bool print_value_expr(std::ostream& out,
|
||||||
case op_t::F_DAY:
|
case op_t::F_DAY:
|
||||||
symbol = "dayof"; break;
|
symbol = "dayof"; break;
|
||||||
|
|
||||||
|
#if 0
|
||||||
case op_t::F_CODE_MASK:
|
case op_t::F_CODE_MASK:
|
||||||
out << "c/" << node->mask->expr.str() << "/";
|
out << "c/" << node->mask->expr.str() << "/";
|
||||||
break;
|
break;
|
||||||
|
|
@ -1665,180 +1655,181 @@ bool print_value_expr(std::ostream& out,
|
||||||
case op_t::F_COMMODITY_MASK:
|
case op_t::F_COMMODITY_MASK:
|
||||||
out << "C/" << node->mask->expr.str() << "/";
|
out << "C/" << node->mask->expr.str() << "/";
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
case op_t::O_NOT:
|
case op_t::O_NOT:
|
||||||
out << "!";
|
out << "!";
|
||||||
if (print_value_expr(out, node->left, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->left(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
case op_t::O_NEG:
|
case op_t::O_NEG:
|
||||||
out << "-";
|
out << "-";
|
||||||
if (print_value_expr(out, node->left, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->left(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
case op_t::O_PERC:
|
case op_t::O_PERC:
|
||||||
out << "%";
|
out << "%";
|
||||||
if (print_value_expr(out, node->left, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->left(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case op_t::O_ARG:
|
case op_t::O_ARG:
|
||||||
out << "@arg" << node->arg_index;
|
out << "@arg" << node->as_long();
|
||||||
break;
|
break;
|
||||||
case op_t::O_DEF:
|
case op_t::O_DEF:
|
||||||
out << "<def args=\"";
|
out << "<def args=\"";
|
||||||
if (print_value_expr(out, node->left, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->left(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << "\" value=\"";
|
out << "\" value=\"";
|
||||||
if (print_value_expr(out, node->right, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->right(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << "\">";
|
out << "\">";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case op_t::O_REF:
|
case op_t::O_REF:
|
||||||
if (print_value_expr(out, node->left, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->left(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
if (node->right) {
|
if (node->right()) {
|
||||||
out << "(";
|
out << "(";
|
||||||
if (print_value_expr(out, node->right, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->right(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << ")";
|
out << ")";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case op_t::O_COM:
|
case op_t::O_COM:
|
||||||
if (node->left &&
|
if (node->left() &&
|
||||||
print_value_expr(out, node->left, relaxed, op_to_find, start_pos, end_pos))
|
print_value_expr(out, node->left(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << ", ";
|
out << ", ";
|
||||||
if (node->right &&
|
if (node->right() &&
|
||||||
print_value_expr(out, node->right, relaxed, op_to_find, start_pos, end_pos))
|
print_value_expr(out, node->right(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
case op_t::O_QUES:
|
case op_t::O_QUES:
|
||||||
out << "(";
|
out << "(";
|
||||||
if (print_value_expr(out, node->left, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->left(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << " ? ";
|
out << " ? ";
|
||||||
if (print_value_expr(out, node->right, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->right(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << ")";
|
out << ")";
|
||||||
break;
|
break;
|
||||||
case op_t::O_COL:
|
case op_t::O_COL:
|
||||||
if (print_value_expr(out, node->left, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->left(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << " : ";
|
out << " : ";
|
||||||
if (print_value_expr(out, node->right, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->right(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case op_t::O_AND:
|
case op_t::O_AND:
|
||||||
out << "(";
|
out << "(";
|
||||||
if (print_value_expr(out, node->left, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->left(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << " & ";
|
out << " & ";
|
||||||
if (print_value_expr(out, node->right, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->right(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << ")";
|
out << ")";
|
||||||
break;
|
break;
|
||||||
case op_t::O_OR:
|
case op_t::O_OR:
|
||||||
out << "(";
|
out << "(";
|
||||||
if (print_value_expr(out, node->left, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->left(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << " | ";
|
out << " | ";
|
||||||
if (print_value_expr(out, node->right, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->right(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << ")";
|
out << ")";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case op_t::O_NEQ:
|
case op_t::O_NEQ:
|
||||||
out << "(";
|
out << "(";
|
||||||
if (print_value_expr(out, node->left, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->left(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << " != ";
|
out << " != ";
|
||||||
if (print_value_expr(out, node->right, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->right(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << ")";
|
out << ")";
|
||||||
break;
|
break;
|
||||||
case op_t::O_EQ:
|
case op_t::O_EQ:
|
||||||
out << "(";
|
out << "(";
|
||||||
if (print_value_expr(out, node->left, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->left(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << " == ";
|
out << " == ";
|
||||||
if (print_value_expr(out, node->right, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->right(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << ")";
|
out << ")";
|
||||||
break;
|
break;
|
||||||
case op_t::O_LT:
|
case op_t::O_LT:
|
||||||
out << "(";
|
out << "(";
|
||||||
if (print_value_expr(out, node->left, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->left(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << " < ";
|
out << " < ";
|
||||||
if (print_value_expr(out, node->right, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->right(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << ")";
|
out << ")";
|
||||||
break;
|
break;
|
||||||
case op_t::O_LTE:
|
case op_t::O_LTE:
|
||||||
out << "(";
|
out << "(";
|
||||||
if (print_value_expr(out, node->left, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->left(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << " <= ";
|
out << " <= ";
|
||||||
if (print_value_expr(out, node->right, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->right(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << ")";
|
out << ")";
|
||||||
break;
|
break;
|
||||||
case op_t::O_GT:
|
case op_t::O_GT:
|
||||||
out << "(";
|
out << "(";
|
||||||
if (print_value_expr(out, node->left, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->left(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << " > ";
|
out << " > ";
|
||||||
if (print_value_expr(out, node->right, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->right(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << ")";
|
out << ")";
|
||||||
break;
|
break;
|
||||||
case op_t::O_GTE:
|
case op_t::O_GTE:
|
||||||
out << "(";
|
out << "(";
|
||||||
if (print_value_expr(out, node->left, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->left(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << " >= ";
|
out << " >= ";
|
||||||
if (print_value_expr(out, node->right, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->right(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << ")";
|
out << ")";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case op_t::O_ADD:
|
case op_t::O_ADD:
|
||||||
out << "(";
|
out << "(";
|
||||||
if (print_value_expr(out, node->left, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->left(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << " + ";
|
out << " + ";
|
||||||
if (print_value_expr(out, node->right, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->right(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << ")";
|
out << ")";
|
||||||
break;
|
break;
|
||||||
case op_t::O_SUB:
|
case op_t::O_SUB:
|
||||||
out << "(";
|
out << "(";
|
||||||
if (print_value_expr(out, node->left, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->left(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << " - ";
|
out << " - ";
|
||||||
if (print_value_expr(out, node->right, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->right(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << ")";
|
out << ")";
|
||||||
break;
|
break;
|
||||||
case op_t::O_MUL:
|
case op_t::O_MUL:
|
||||||
out << "(";
|
out << "(";
|
||||||
if (print_value_expr(out, node->left, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->left(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << " * ";
|
out << " * ";
|
||||||
if (print_value_expr(out, node->right, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->right(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << ")";
|
out << ")";
|
||||||
break;
|
break;
|
||||||
case op_t::O_DIV:
|
case op_t::O_DIV:
|
||||||
out << "(";
|
out << "(";
|
||||||
if (print_value_expr(out, node->left, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->left(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << " / ";
|
out << " / ";
|
||||||
if (print_value_expr(out, node->right, relaxed, op_to_find, start_pos, end_pos))
|
if (print_value_expr(out, node->right(), relaxed, op_to_find, start_pos, end_pos))
|
||||||
found = true;
|
found = true;
|
||||||
out << ")";
|
out << ")";
|
||||||
break;
|
break;
|
||||||
|
|
@ -1873,10 +1864,10 @@ void dump_value_expr(std::ostream& out, const ptr_op_t node,
|
||||||
|
|
||||||
switch (node->kind) {
|
switch (node->kind) {
|
||||||
case op_t::ARG_INDEX:
|
case op_t::ARG_INDEX:
|
||||||
out << "ARG_INDEX - " << node->arg_index;
|
out << "ARG_INDEX - " << node->as_long();
|
||||||
break;
|
break;
|
||||||
case op_t::CONSTANT:
|
case op_t::VALUE:
|
||||||
out << "CONSTANT - " << *(node->value);
|
out << "VALUE - " << node->as_value();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case op_t::AMOUNT: out << "AMOUNT"; break;
|
case op_t::AMOUNT: out << "AMOUNT"; break;
|
||||||
|
|
@ -1953,15 +1944,9 @@ void dump_value_expr(std::ostream& out, const ptr_op_t node,
|
||||||
out << " (" << node->refc << ')' << std::endl;
|
out << " (" << node->refc << ')' << std::endl;
|
||||||
|
|
||||||
if (node->kind > op_t::TERMINALS) {
|
if (node->kind > op_t::TERMINALS) {
|
||||||
if (node->left) {
|
dump_value_expr(out, node->left(), depth + 1);
|
||||||
dump_value_expr(out, node->left, depth + 1);
|
if (node->right())
|
||||||
if (node->right)
|
dump_value_expr(out, node->right(), depth + 1);
|
||||||
dump_value_expr(out, node->right, depth + 1);
|
|
||||||
} else {
|
|
||||||
assert(! node->right);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
assert(! node->left);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -603,8 +603,9 @@ class valexpr_context : public error_context {
|
||||||
ptr_op_t error_node;
|
ptr_op_t error_node;
|
||||||
|
|
||||||
valexpr_context(const ptr_op_t& _expr,
|
valexpr_context(const ptr_op_t& _expr,
|
||||||
const string& desc = "") throw();
|
const string& desc = "") throw()
|
||||||
virtual ~valexpr_context() throw();
|
: error_context(desc), expr(_expr), error_node(_expr) {}
|
||||||
|
virtual ~valexpr_context() throw() {}
|
||||||
|
|
||||||
virtual void describe(std::ostream& out) const throw();
|
virtual void describe(std::ostream& out) const throw();
|
||||||
};
|
};
|
||||||
|
|
@ -624,7 +625,7 @@ class value_expr_error : public error {
|
||||||
virtual ~value_expr_error() throw() {}
|
virtual ~value_expr_error() throw() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
extern std::auto_ptr<scope_t> global_scope;
|
extern std::auto_ptr<symbol_scope_t> global_scope;
|
||||||
|
|
||||||
extern datetime_t terminus;
|
extern datetime_t terminus;
|
||||||
extern bool initialized;
|
extern bool initialized;
|
||||||
|
|
|
||||||
24
walk.cc
24
walk.cc
|
|
@ -558,7 +558,7 @@ void set_comm_as_payee::operator()(transaction_t& xact)
|
||||||
transaction_t& temp = xact_temps.back();
|
transaction_t& temp = xact_temps.back();
|
||||||
temp.entry = &entry;
|
temp.entry = &entry;
|
||||||
temp.state = xact.state;
|
temp.state = xact.state;
|
||||||
temp.flags |= TRANSACTION_BULK_ALLOC;
|
temp.add_flags(TRANSACTION_BULK_ALLOC);
|
||||||
|
|
||||||
entry.add_transaction(&temp);
|
entry.add_transaction(&temp);
|
||||||
|
|
||||||
|
|
@ -571,8 +571,8 @@ void set_code_as_payee::operator()(transaction_t& xact)
|
||||||
entry_t& entry = entry_temps.back();
|
entry_t& entry = entry_temps.back();
|
||||||
entry._date = xact.date();
|
entry._date = xact.date();
|
||||||
|
|
||||||
if (! xact.entry->code.empty())
|
if (xact.entry->code)
|
||||||
entry.payee = xact.entry->code;
|
entry.payee = *xact.entry->code;
|
||||||
else
|
else
|
||||||
entry.payee = "<none>";
|
entry.payee = "<none>";
|
||||||
|
|
||||||
|
|
@ -580,7 +580,7 @@ void set_code_as_payee::operator()(transaction_t& xact)
|
||||||
transaction_t& temp = xact_temps.back();
|
transaction_t& temp = xact_temps.back();
|
||||||
temp.entry = &entry;
|
temp.entry = &entry;
|
||||||
temp.state = xact.state;
|
temp.state = xact.state;
|
||||||
temp.flags |= TRANSACTION_BULK_ALLOC;
|
temp.add_flags(TRANSACTION_BULK_ALLOC);
|
||||||
|
|
||||||
entry.add_transaction(&temp);
|
entry.add_transaction(&temp);
|
||||||
|
|
||||||
|
|
@ -659,8 +659,8 @@ void budget_transactions::report_budget_items(const datetime_t& moment)
|
||||||
|
|
||||||
xact_temps.push_back(xact);
|
xact_temps.push_back(xact);
|
||||||
transaction_t& temp = xact_temps.back();
|
transaction_t& temp = xact_temps.back();
|
||||||
temp.entry = &entry;
|
temp.entry = &entry;
|
||||||
temp.flags |= TRANSACTION_AUTO | TRANSACTION_BULK_ALLOC;
|
temp.add_flags(TRANSACTION_AUTO | TRANSACTION_BULK_ALLOC);
|
||||||
temp.amount.negate();
|
temp.amount.negate();
|
||||||
entry.add_transaction(&temp);
|
entry.add_transaction(&temp);
|
||||||
|
|
||||||
|
|
@ -750,8 +750,7 @@ void forecast_transactions::flush()
|
||||||
xact_temps.push_back(xact);
|
xact_temps.push_back(xact);
|
||||||
transaction_t& temp = xact_temps.back();
|
transaction_t& temp = xact_temps.back();
|
||||||
temp.entry = &entry;
|
temp.entry = &entry;
|
||||||
temp.flags |= TRANSACTION_AUTO;
|
temp.add_flags(TRANSACTION_AUTO | TRANSACTION_BULK_ALLOC);
|
||||||
temp.flags |= TRANSACTION_BULK_ALLOC;
|
|
||||||
entry.add_transaction(&temp);
|
entry.add_transaction(&temp);
|
||||||
|
|
||||||
datetime_t next = (*least).first.increment(begin);
|
datetime_t next = (*least).first.increment(begin);
|
||||||
|
|
@ -873,7 +872,7 @@ void walk_accounts(account_t& account,
|
||||||
for (accounts_map::const_iterator i = account.accounts.begin();
|
for (accounts_map::const_iterator i = account.accounts.begin();
|
||||||
i != account.accounts.end();
|
i != account.accounts.end();
|
||||||
i++)
|
i++)
|
||||||
walk_accounts(*(*i).second, handler, NULL);
|
walk_accounts(*(*i).second, handler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -882,9 +881,8 @@ void walk_accounts(account_t& account,
|
||||||
const string& sort_string)
|
const string& sort_string)
|
||||||
{
|
{
|
||||||
if (! sort_string.empty()) {
|
if (! sort_string.empty()) {
|
||||||
value_expr sort_order;
|
value_expr sorter(sort_string);
|
||||||
sort_order.reset(parse_value_expr(sort_string));
|
walk_accounts(account, handler, optional<value_expr>(sorter));
|
||||||
walk_accounts(account, handler, sort_order);
|
|
||||||
} else {
|
} else {
|
||||||
walk_accounts(account, handler);
|
walk_accounts(account, handler);
|
||||||
}
|
}
|
||||||
|
|
@ -917,7 +915,7 @@ void walk_commodities(commodity_pool_t::commodities_by_ident& commodities,
|
||||||
transaction_t& temp = xact_temps.back();
|
transaction_t& temp = xact_temps.back();
|
||||||
temp.entry = &entry_temps.back();
|
temp.entry = &entry_temps.back();
|
||||||
temp.amount = (*j).second;
|
temp.amount = (*j).second;
|
||||||
temp.flags |= TRANSACTION_BULK_ALLOC;
|
temp.add_flags(TRANSACTION_BULK_ALLOC);
|
||||||
entry_temps.back().add_transaction(&temp);
|
entry_temps.back().add_transaction(&temp);
|
||||||
|
|
||||||
handler(xact_temps.back());
|
handler(xact_temps.back());
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue