summaryrefslogtreecommitdiff
path: root/src/parser.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2012-02-21 01:45:36 -0600
committerJohn Wiegley <johnw@newartisans.com>2012-02-21 01:45:36 -0600
commit902673a199ccc1716c93543d77bd782cbbe25ead (patch)
treee44cd8458af9f8e81a04f3effe8e3885d17b1900 /src/parser.cc
parent4e8c9805bb0a68f7d4d20696f28db7d763e370e6 (diff)
parent1837e323916c7479623bb61e479407b85edee562 (diff)
downloadfork-ledger-902673a199ccc1716c93543d77bd782cbbe25ead.tar.gz
fork-ledger-902673a199ccc1716c93543d77bd782cbbe25ead.tar.bz2
fork-ledger-902673a199ccc1716c93543d77bd782cbbe25ead.zip
Merge branch 't/scopes' into next
Diffstat (limited to 'src/parser.cc')
-rw-r--r--src/parser.cc33
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;