diff options
author | John Wiegley <johnw@newartisans.com> | 2009-03-03 16:05:04 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-03-03 16:05:04 -0400 |
commit | e2c30cf6e4e8c0d38f129e3e209954bf1bfbe602 (patch) | |
tree | 118ab3ef92756dd208ece3c35d4b8ba4d6d47271 /src/op.cc | |
parent | 098e3b0043c275cfe195be1c592baf5716ab73e5 (diff) | |
download | fork-ledger-e2c30cf6e4e8c0d38f129e3e209954bf1bfbe602.tar.gz fork-ledger-e2c30cf6e4e8c0d38f129e3e209954bf1bfbe602.tar.bz2 fork-ledger-e2c30cf6e4e8c0d38f129e3e209954bf1bfbe602.zip |
Added ; as a sequencing operator in valexprs
Diffstat (limited to 'src/op.cc')
-rw-r--r-- | src/op.cc | 46 |
1 files changed, 46 insertions, 0 deletions
@@ -294,6 +294,25 @@ value_t expr_t::op_t::calc(scope_t& scope, ptr_op_t * locus) } break; + case O_SEQ: { + left()->calc(scope, locus); + assert(has_right()); + + ptr_op_t next = right(); + while (next) { + ptr_op_t value_op; + if (next->kind == O_SEQ) { + value_op = next->left(); + next = next->right(); + } else { + value_op = next; + next = NULL; + } + result = value_op->calc(scope, locus); + } + break; + } + case LAST: default: assert(false); @@ -331,6 +350,26 @@ namespace { } return found; } + + bool print_seq(std::ostream& out, const expr_t::const_ptr_op_t op, + const expr_t::op_t::context_t& context) + { + bool found = false; + + assert(op->left()); + if (op->left()->print(out, context)) + found = true; + + assert(op->has_right()); + out << "; "; + + if (op->right()->kind == expr_t::op_t::O_CONS) + found = print_cons(out, op->right(), context); + else if (op->right()->print(out, context)) + found = true; + + return found; + } } bool expr_t::op_t::print(std::ostream& out, const context_t& context) const @@ -495,6 +534,12 @@ bool expr_t::op_t::print(std::ostream& out, const context_t& context) const out << ")"; break; + case O_SEQ: + out << "("; + found = print_seq(out, this, context); + out << ")"; + break; + case O_DEFINE: if (left() && left()->print(out, context)) found = true; @@ -606,6 +651,7 @@ void expr_t::op_t::dump(std::ostream& out, const int depth) const case O_COLON: out << "O_COLON"; break; case O_CONS: out << "O_CONS"; break; + case O_SEQ: out << "O_SEQ"; break; case LAST: default: |