Parse swap.

This commit is contained in:
Michael Sullivan 2011-06-13 16:04:48 -07:00 committed by Graydon Hoare
parent e8d2d27a88
commit 066599104a
2 changed files with 15 additions and 5 deletions

View File

@ -245,11 +245,13 @@ tag expr_ {
expr_alt(@expr, vec[arm], ann);
expr_fn(_fn, ann);
expr_block(block, ann);
expr_move(@expr, /* TODO: @expr|is_lval */@expr, ann);
expr_assign(@expr, /* TODO: @expr|is_lval */@expr, ann);
expr_assign_op(binop, @expr, /* TODO: @expr|is_lval */@expr, ann);
expr_send(@expr, /* TODO: @expr|is_lval */@expr, ann);
expr_recv(@expr, /* TODO: @expr|is_lval */@expr, ann);
expr_move(@expr /* TODO: @expr|is_lval */, @expr, ann);
expr_assign(@expr /* TODO: @expr|is_lval */, @expr, ann);
expr_swap(@expr /* TODO: @expr|is_lval */,
@expr /* TODO: @expr|is_lval */, ann);
expr_assign_op(binop, @expr /* TODO: @expr|is_lval */, @expr, ann);
expr_send(@expr /* TODO: @expr|is_lval */, @expr, ann);
expr_recv(@expr /* TODO: @expr|is_lval */, @expr, ann);
expr_field(@expr, ident, ann);
expr_index(@expr, @expr, ann);
expr_path(path, ann);

View File

@ -1176,6 +1176,12 @@ fn parse_assign_expr(&parser p) -> @ast::expr {
ret @spanned(lo, rhs.span.hi,
ast::expr_recv(rhs, lhs, p.get_ann()));
}
case (token::DARROW) {
p.bump();
auto rhs = parse_expr(p);
ret @spanned(lo, rhs.span.hi,
ast::expr_swap(lhs, rhs, p.get_ann()));
}
case (_) {/* fall through */ }
}
ret lhs;
@ -1536,7 +1542,9 @@ fn stmt_ends_with_semi(&ast::stmt stmt) -> bool {
case (ast::expr_alt(_, _, _)) { ret false; }
case (ast::expr_fn(_, _)) { ret false; }
case (ast::expr_block(_, _)) { ret false; }
case (ast::expr_move(_, _, _)) { ret true; }
case (ast::expr_assign(_, _, _)) { ret true; }
case (ast::expr_swap(_, _, _)) { ret true; }
case (ast::expr_assign_op(_, _, _, _)) { ret true; }
case (ast::expr_send(_, _, _)) { ret true; }
case (ast::expr_recv(_, _, _)) { ret true; }