Fixed parsing of '(1, 2, (3, 4))'

This commit is contained in:
John Wiegley 2009-03-03 16:02:34 -04:00
parent 4af1bfdde3
commit 098e3b0043
3 changed files with 12 additions and 1 deletions

View file

@ -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 << ")";

View file

@ -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:

View file

@ -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())