summaryrefslogtreecommitdiff
path: root/src/parser.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-08 03:01:51 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-08 03:01:51 -0400
commit75946395818ca22c9a14f2d62ec9ed02acfe766d (patch)
tree585da94e6be0f200827302caa47c7a441eee1c2c /src/parser.cc
parentaebfc92a4dc9b25183ba0aa637582e8ab8d24c93 (diff)
downloadfork-ledger-75946395818ca22c9a14f2d62ec9ed02acfe766d.tar.gz
fork-ledger-75946395818ca22c9a14f2d62ec9ed02acfe766d.tar.bz2
fork-ledger-75946395818ca22c9a14f2d62ec9ed02acfe766d.zip
Better semantics for the ?: ternary operator.
Diffstat (limited to 'src/parser.cc')
-rw-r--r--src/parser.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/parser.cc b/src/parser.cc
index 0819e3d8..eeff59f0 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -340,7 +340,7 @@ expr_t::parser_t::parse_querycolon_expr(std::istream& in,
if (tok.kind == token_t::QUERY) {
ptr_op_t prev(node);
- node = new op_t(op_t::O_AND);
+ node = new op_t(op_t::O_QUERY);
node->set_left(prev);
node->set_right(parse_or_expr(in, tflags));
if (! node->right())
@@ -351,13 +351,15 @@ expr_t::parser_t::parse_querycolon_expr(std::istream& in,
if (next_tok.kind != token_t::COLON)
next_tok.expected(':');
- prev = node;
- node = new op_t(op_t::O_OR);
- node->set_left(prev);
- node->set_right(parse_or_expr(in, tflags));
- if (! node->right())
+ prev = node->right();
+ ptr_op_t subnode = new op_t(op_t::O_COLON);
+ subnode->set_left(prev);
+ subnode->set_right(parse_or_expr(in, tflags));
+ if (! subnode->right())
throw_(parse_error,
tok.symbol << " operator not followed by argument");
+
+ node->set_right(subnode);
} else {
push_token(tok);
}