summaryrefslogtreecommitdiff
path: root/src/parser.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2010-09-06 00:59:45 -0400
committerJohn Wiegley <johnw@newartisans.com>2010-09-06 01:01:20 -0400
commitab24901b9de71392f7e4fa7a357fce659d83d82c (patch)
tree95c7c755f3c01567750f5976a8e5b7856fd2f23d /src/parser.cc
parent84780270f9bc427f6edcd295b68ffcf6b911baf6 (diff)
downloadfork-ledger-ab24901b9de71392f7e4fa7a357fce659d83d82c.tar.gz
fork-ledger-ab24901b9de71392f7e4fa7a357fce659d83d82c.tar.bz2
fork-ledger-ab24901b9de71392f7e4fa7a357fce659d83d82c.zip
Made -> have higher precedence than comma
Diffstat (limited to 'src/parser.cc')
-rw-r--r--src/parser.cc52
1 files changed, 26 insertions, 26 deletions
diff --git a/src/parser.cc b/src/parser.cc
index e9205d16..f0085295 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -419,32 +419,10 @@ expr_t::parser_t::parse_querycolon_expr(std::istream& in,
}
expr_t::ptr_op_t
-expr_t::parser_t::parse_lambda_expr(std::istream& in,
- const parse_flags_t& tflags) const
-{
- ptr_op_t node(parse_querycolon_expr(in, tflags));
-
- if (node && ! tflags.has_flags(PARSE_SINGLE)) {
- token_t& tok = next_token(in, tflags.plus_flags(PARSE_OP_CONTEXT));
-
- if (tok.kind == token_t::ARROW) {
- ptr_op_t prev(node);
- node = new op_t(op_t::O_LAMBDA);
- node->set_left(prev);
- node->set_right(parse_querycolon_expr(in, tflags));
- } else {
- push_token(tok);
- }
- }
-
- return node;
-}
-
-expr_t::ptr_op_t
expr_t::parser_t::parse_comma_expr(std::istream& in,
const parse_flags_t& tflags) const
{
- ptr_op_t node(parse_lambda_expr(in, tflags));
+ ptr_op_t node(parse_querycolon_expr(in, tflags));
if (node && ! tflags.has_flags(PARSE_SINGLE)) {
ptr_op_t next;
@@ -466,7 +444,7 @@ expr_t::parser_t::parse_comma_expr(std::istream& in,
break;
ptr_op_t chain(new op_t(op_t::O_CONS));
- chain->set_left(parse_lambda_expr(in, tflags));
+ chain->set_left(parse_querycolon_expr(in, tflags));
next->set_right(chain);
next = chain;
@@ -481,7 +459,7 @@ expr_t::parser_t::parse_comma_expr(std::istream& in,
}
expr_t::ptr_op_t
-expr_t::parser_t::parse_assign_expr(std::istream& in,
+expr_t::parser_t::parse_lambda_expr(std::istream& in,
const parse_flags_t& tflags) const
{
ptr_op_t node(parse_comma_expr(in, tflags));
@@ -489,11 +467,33 @@ expr_t::parser_t::parse_assign_expr(std::istream& in,
if (node && ! tflags.has_flags(PARSE_SINGLE)) {
token_t& tok = next_token(in, tflags.plus_flags(PARSE_OP_CONTEXT));
+ if (tok.kind == token_t::ARROW) {
+ ptr_op_t prev(node);
+ node = new op_t(op_t::O_LAMBDA);
+ node->set_left(prev);
+ node->set_right(parse_querycolon_expr(in, tflags));
+ } else {
+ push_token(tok);
+ }
+ }
+
+ return node;
+}
+
+expr_t::ptr_op_t
+expr_t::parser_t::parse_assign_expr(std::istream& in,
+ const parse_flags_t& tflags) const
+{
+ ptr_op_t node(parse_lambda_expr(in, tflags));
+
+ if (node && ! tflags.has_flags(PARSE_SINGLE)) {
+ token_t& tok = next_token(in, tflags.plus_flags(PARSE_OP_CONTEXT));
+
if (tok.kind == token_t::ASSIGN) {
ptr_op_t prev(node);
node = new op_t(op_t::O_DEFINE);
node->set_left(prev);
- node->set_right(parse_comma_expr(in, tflags));
+ node->set_right(parse_lambda_expr(in, tflags));
} else {
push_token(tok);
}