diff options
author | John Wiegley <johnw@newartisans.com> | 2012-02-20 17:20:16 -0600 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2012-02-20 17:20:22 -0600 |
commit | bc9ff7095fbfa1812e4f47dbf8531dec76cd0d00 (patch) | |
tree | 1e8deee7874598f2f827e62984ebb6383e049a1e /src/parser.cc | |
parent | 4e8c9805bb0a68f7d4d20696f28db7d763e370e6 (diff) | |
download | fork-ledger-bc9ff7095fbfa1812e4f47dbf8531dec76cd0d00.tar.gz fork-ledger-bc9ff7095fbfa1812e4f47dbf8531dec76cd0d00.tar.bz2 fork-ledger-bc9ff7095fbfa1812e4f47dbf8531dec76cd0d00.zip |
Introduced a new SCOPE expression terminal
Diffstat (limited to 'src/parser.cc')
-rw-r--r-- | src/parser.cc | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/parser.cc b/src/parser.cc index a18fa552..ad621106 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -434,7 +434,6 @@ expr_t::parser_t::parse_comma_expr(std::istream& in, ptr_op_t prev(node); node = new op_t(op_t::O_CONS); node->set_left(prev); - next = node; } @@ -493,7 +492,9 @@ expr_t::parser_t::parse_assign_expr(std::istream& in, ptr_op_t prev(node); node = new op_t(op_t::O_DEFINE); node->set_left(prev); - node->set_right(parse_lambda_expr(in, tflags)); + ptr_op_t scope(new op_t(op_t::SCOPE)); + scope->set_left(parse_lambda_expr(in, tflags)); + node->set_right(scope); } else { push_token(tok); } @@ -509,24 +510,24 @@ expr_t::parser_t::parse_value_expr(std::istream& in, ptr_op_t node(parse_assign_expr(in, tflags)); if (node && ! tflags.has_flags(PARSE_SINGLE)) { - ptr_op_t next; + ptr_op_t chain; while (true) { token_t& tok = next_token(in, tflags.plus_flags(PARSE_OP_CONTEXT)); - if (tok.kind == token_t::SEMI) { - if (! next) { - ptr_op_t prev(node); - node = new op_t(op_t::O_SEQ); - node->set_left(prev); - - next = node; + ptr_op_t seq(new op_t(op_t::O_SEQ)); + if (! chain) { + seq->set_left(node); + ptr_op_t scope(new op_t(op_t::SCOPE)); + scope->set_left(seq); + node = scope; + } else { + seq->set_left(chain->right()); + ptr_op_t scope(new op_t(op_t::SCOPE)); + scope->set_left(seq); + chain->set_right(scope); } - - ptr_op_t chain(new op_t(op_t::O_SEQ)); - chain->set_left(parse_assign_expr(in, tflags)); - - next->set_right(chain); - next = chain; + seq->set_right(parse_assign_expr(in, tflags)); + chain = seq; } else { push_token(tok); break; |