summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-03-03 16:02:34 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-03-03 16:02:34 -0400
commit098e3b0043c275cfe195be1c592baf5716ab73e5 (patch)
tree149d0f9d8c29db059cedd010beb9df237e69f343 /src
parent4af1bfdde3118b6abc19ca87ef99d42bec58197b (diff)
downloadfork-ledger-098e3b0043c275cfe195be1c592baf5716ab73e5.tar.gz
fork-ledger-098e3b0043c275cfe195be1c592baf5716ab73e5.tar.bz2
fork-ledger-098e3b0043c275cfe195be1c592baf5716ab73e5.zip
Fixed parsing of '(1, 2, (3, 4))'
Diffstat (limited to 'src')
-rw-r--r--src/op.cc1
-rw-r--r--src/parser.cc9
-rw-r--r--src/textual.cc3
3 files changed, 12 insertions, 1 deletions
diff --git a/src/op.cc b/src/op.cc
index beffab9e..902d370a 100644
--- a/src/op.cc
+++ b/src/op.cc
@@ -490,7 +490,6 @@ bool expr_t::op_t::print(std::ostream& out, const context_t& context) const
break;
case O_CONS:
- assert(has_right());
out << "(";
found = print_cons(out, this, context);
out << ")";
diff --git a/src/parser.cc b/src/parser.cc
index c651385f..15cd4fc6 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -62,6 +62,9 @@ expr_t::parser_t::parse_value_term(std::istream& in,
push_token(tok); // let the parser see it again
node->set_right(parse_value_expr(in, tflags.plus_flags(PARSE_SINGLE)));
+
+ if (node->has_right() && node->right()->kind == op_t::O_CONS)
+ node->set_right(node->right()->left());
} else {
push_token(tok);
}
@@ -74,6 +77,12 @@ expr_t::parser_t::parse_value_term(std::istream& in,
tok = next_token(in, tflags);
if (tok.kind != token_t::RPAREN)
tok.expected(')');
+
+ if (node->kind == op_t::O_CONS) {
+ ptr_op_t prev(node);
+ node = new op_t(op_t::O_CONS);
+ node->set_left(prev);
+ }
break;
default:
diff --git a/src/textual.cc b/src/textual.cc
index e3460202..4d90fad4 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -902,6 +902,7 @@ post_t * instance_t::parse_post(char * line,
else
parse_amount_expr(session_scope, stream, post->amount, post.get(),
static_cast<uint_least8_t>(expr_t::PARSE_NO_REDUCE) |
+ static_cast<uint_least8_t>(expr_t::PARSE_SINGLE) |
static_cast<uint_least8_t>(expr_t::PARSE_NO_ASSIGN));
if (! post->amount.is_null() && honor_strict && strict &&
@@ -949,6 +950,7 @@ post_t * instance_t::parse_post(char * line,
else
parse_amount_expr(session_scope, cstream, *post->cost, post.get(),
static_cast<uint_least8_t>(expr_t::PARSE_NO_MIGRATE) |
+ static_cast<uint_least8_t>(expr_t::PARSE_SINGLE) |
static_cast<uint_least8_t>(expr_t::PARSE_NO_ASSIGN));
if (post->cost->sign() < 0)
@@ -994,6 +996,7 @@ post_t * instance_t::parse_post(char * line,
post->assigned_amount->parse(stream, amount_t::PARSE_NO_MIGRATE);
else
parse_amount_expr(session_scope, stream, *post->assigned_amount, post.get(),
+ static_cast<uint_least8_t>(expr_t::PARSE_SINGLE) |
static_cast<uint_least8_t>(expr_t::PARSE_NO_MIGRATE));
if (post->assigned_amount->is_null())