parent
050170d2af
commit
0ce40f60e7
20 changed files with 66 additions and 494 deletions
|
|
@ -109,7 +109,6 @@ tag proto_sugar {
|
|||
}
|
||||
|
||||
tag proto {
|
||||
proto_iter;
|
||||
proto_bare;
|
||||
proto_shared(proto_sugar);
|
||||
proto_block;
|
||||
|
|
@ -197,7 +196,6 @@ tag expr_ {
|
|||
expr_ternary(@expr, @expr, @expr);
|
||||
expr_while(@expr, blk);
|
||||
expr_for(@local, @expr, blk);
|
||||
expr_for_each(@local, @expr, blk);
|
||||
expr_do_while(blk, @expr);
|
||||
expr_alt(@expr, [arm]);
|
||||
expr_fn(_fn);
|
||||
|
|
@ -219,7 +217,6 @@ tag expr_ {
|
|||
expr_break;
|
||||
expr_cont;
|
||||
expr_ret(option::t<@expr>);
|
||||
expr_put(option::t<@expr>);
|
||||
expr_be(@expr);
|
||||
expr_log(int, @expr);
|
||||
|
||||
|
|
|
|||
|
|
@ -377,10 +377,6 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
|
|||
expr_for(fld.fold_local(decl), fld.fold_expr(expr),
|
||||
fld.fold_block(blk))
|
||||
}
|
||||
expr_for_each(decl, expr, blk) {
|
||||
expr_for_each(fld.fold_local(decl), fld.fold_expr(expr),
|
||||
fld.fold_block(blk))
|
||||
}
|
||||
expr_do_while(blk, expr) {
|
||||
expr_do_while(fld.fold_block(blk), fld.fold_expr(expr))
|
||||
}
|
||||
|
|
@ -413,7 +409,6 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
|
|||
expr_break. { e }
|
||||
expr_cont. { e }
|
||||
expr_ret(e) { expr_ret(option::map(fld.fold_expr, e)) }
|
||||
expr_put(e) { expr_put(option::map(fld.fold_expr, e)) }
|
||||
expr_be(e) { expr_be(fld.fold_expr(e)) }
|
||||
expr_log(lv, e) { expr_log(lv, fld.fold_expr(e)) }
|
||||
expr_assert(e) { expr_assert(fld.fold_expr(e)) }
|
||||
|
|
|
|||
|
|
@ -148,10 +148,8 @@ fn bad_expr_word_table() -> hashmap<str, ()> {
|
|||
words.insert("do", ());
|
||||
words.insert("alt", ());
|
||||
words.insert("for", ());
|
||||
words.insert("each", ());
|
||||
words.insert("break", ());
|
||||
words.insert("cont", ());
|
||||
words.insert("put", ());
|
||||
words.insert("ret", ());
|
||||
words.insert("be", ());
|
||||
words.insert("fail", ());
|
||||
|
|
@ -160,13 +158,11 @@ fn bad_expr_word_table() -> hashmap<str, ()> {
|
|||
words.insert("check", ());
|
||||
words.insert("assert", ());
|
||||
words.insert("claim", ());
|
||||
words.insert("prove", ());
|
||||
words.insert("native", ());
|
||||
words.insert("fn", ());
|
||||
words.insert("lambda", ());
|
||||
words.insert("pure", ());
|
||||
words.insert("unsafe", ());
|
||||
words.insert("iter", ());
|
||||
words.insert("block", ());
|
||||
words.insert("import", ());
|
||||
words.insert("export", ());
|
||||
|
|
@ -566,9 +562,6 @@ fn parse_ty(p: parser, colons_before_params: bool) -> @ast::ty {
|
|||
} else if eat_word(p, "block") {
|
||||
t = parse_ty_fn(ast::proto_block, p);
|
||||
alt t { ast::ty_fn(_, _, out, _, _) { hi = out.span.hi; } }
|
||||
} else if eat_word(p, "iter") {
|
||||
t = parse_ty_fn(ast::proto_iter, p);
|
||||
alt t { ast::ty_fn(_, _, out, _, _) { hi = out.span.hi; } }
|
||||
} else if eat_word(p, "obj") {
|
||||
t = parse_ty_obj(p, hi);
|
||||
} else if p.peek() == token::MOD_SEP || is_ident(p.peek()) {
|
||||
|
|
@ -964,15 +957,6 @@ fn parse_bottom_expr(p: parser) -> @ast::expr {
|
|||
} else if eat_word(p, "cont") {
|
||||
ex = ast::expr_cont;
|
||||
hi = p.get_hi_pos();
|
||||
} else if eat_word(p, "put") {
|
||||
alt p.peek() {
|
||||
token::SEMI. { ex = ast::expr_put(none); }
|
||||
_ {
|
||||
let e = parse_expr(p);
|
||||
hi = e.span.hi;
|
||||
ex = ast::expr_put(some(e));
|
||||
}
|
||||
}
|
||||
} else if eat_word(p, "be") {
|
||||
let e = parse_expr(p);
|
||||
|
||||
|
|
@ -1341,15 +1325,12 @@ fn parse_else_expr(p: parser) -> @ast::expr {
|
|||
|
||||
fn parse_for_expr(p: parser) -> @ast::expr {
|
||||
let lo = p.get_last_lo_pos();
|
||||
let is_each = eat_word(p, "each");
|
||||
let decl = parse_local(p, false);
|
||||
expect_word(p, "in");
|
||||
let seq = parse_expr(p);
|
||||
let body = parse_block_no_value(p);
|
||||
let hi = body.span.hi;
|
||||
if is_each {
|
||||
ret mk_expr(p, lo, hi, ast::expr_for_each(decl, seq, body));
|
||||
} else { ret mk_expr(p, lo, hi, ast::expr_for(decl, seq, body)); }
|
||||
ret mk_expr(p, lo, hi, ast::expr_for(decl, seq, body));
|
||||
}
|
||||
|
||||
fn parse_while_expr(p: parser) -> @ast::expr {
|
||||
|
|
@ -1640,8 +1621,7 @@ fn expr_has_value(e: @ast::expr) -> bool {
|
|||
found_expr
|
||||
}
|
||||
ast::expr_block(blk) | ast::expr_while(_, blk) |
|
||||
ast::expr_for(_, _, blk) | ast::expr_for_each(_, _, blk) |
|
||||
ast::expr_do_while(blk, _) {
|
||||
ast::expr_for(_, _, blk) | ast::expr_do_while(blk, _) {
|
||||
!option::is_none(blk.node.expr)
|
||||
}
|
||||
_ { true }
|
||||
|
|
@ -1837,7 +1817,7 @@ fn mk_item(p: parser, lo: uint, hi: uint, ident: ast::ident, node: ast::item_,
|
|||
span: ast_util::mk_sp(lo, hi)};
|
||||
}
|
||||
|
||||
fn parse_item_fn_or_iter(p: parser, purity: ast::purity, proto: ast::proto,
|
||||
fn parse_item_fn(p: parser, purity: ast::purity, proto: ast::proto,
|
||||
attrs: [ast::attribute], il: ast::inlineness) ->
|
||||
@ast::item {
|
||||
let lo = p.get_last_lo_pos();
|
||||
|
|
@ -2167,9 +2147,7 @@ fn parse_fn_anon_proto(p: parser) -> ast::proto {
|
|||
}
|
||||
|
||||
fn parse_method_proto(p: parser) -> ast::proto {
|
||||
if eat_word(p, "iter") {
|
||||
ret ast::proto_iter;
|
||||
} else if eat_word(p, "fn") {
|
||||
if eat_word(p, "fn") {
|
||||
ret ast::proto_bare;
|
||||
} else { unexpected(p, p.peek()); }
|
||||
}
|
||||
|
|
@ -2180,27 +2158,24 @@ fn parse_item(p: parser, attrs: [ast::attribute]) -> option::t<@ast::item> {
|
|||
} else if eat_word(p, "inline") {
|
||||
expect_word(p, "fn");
|
||||
let proto = parse_fn_item_proto(p);
|
||||
ret some(parse_item_fn_or_iter(p, ast::impure_fn, proto,
|
||||
ret some(parse_item_fn(p, ast::impure_fn, proto,
|
||||
attrs, ast::il_inline));
|
||||
} else if is_word(p, "fn") && p.look_ahead(1u) != token::LPAREN {
|
||||
p.bump();
|
||||
let proto = parse_fn_item_proto(p);
|
||||
ret some(parse_item_fn_or_iter(p, ast::impure_fn, proto,
|
||||
attrs, ast::il_normal));
|
||||
ret some(parse_item_fn(p, ast::impure_fn, proto,
|
||||
attrs, ast::il_normal));
|
||||
} else if eat_word(p, "pure") {
|
||||
expect_word(p, "fn");
|
||||
let proto = parse_fn_item_proto(p);
|
||||
ret some(parse_item_fn_or_iter(p, ast::pure_fn, proto, attrs,
|
||||
ast::il_normal));
|
||||
ret some(parse_item_fn(p, ast::pure_fn, proto, attrs,
|
||||
ast::il_normal));
|
||||
} else if is_word(p, "unsafe") && p.look_ahead(1u) != token::LBRACE {
|
||||
p.bump();
|
||||
expect_word(p, "fn");
|
||||
let proto = parse_fn_item_proto(p);
|
||||
ret some(parse_item_fn_or_iter(p, ast::unsafe_fn, proto,
|
||||
attrs, ast::il_normal));
|
||||
} else if eat_word(p, "iter") {
|
||||
ret some(parse_item_fn_or_iter(p, ast::impure_fn, ast::proto_iter,
|
||||
attrs, ast::il_normal));
|
||||
ret some(parse_item_fn(p, ast::unsafe_fn, proto,
|
||||
attrs, ast::il_normal));
|
||||
} else if eat_word(p, "mod") {
|
||||
ret some(parse_item_mod(p, attrs));
|
||||
} else if eat_word(p, "native") {
|
||||
|
|
|
|||
|
|
@ -606,8 +606,7 @@ fn print_possibly_embedded_block(s: ps, blk: ast::blk, embedded: embed_type,
|
|||
// alt, do, & while unambiguously without being parenthesized
|
||||
fn print_maybe_parens_discrim(s: ps, e: @ast::expr) {
|
||||
let disambig = alt e.node {
|
||||
ast::expr_ret(none.) | ast::expr_put(none.) |
|
||||
ast::expr_fail(none.) { true }
|
||||
ast::expr_ret(none.) | ast::expr_fail(none.) { true }
|
||||
_ { false }
|
||||
};
|
||||
if disambig { popen(s); }
|
||||
|
|
@ -796,12 +795,6 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
|
|||
space(s.s);
|
||||
print_block(s, blk);
|
||||
}
|
||||
ast::expr_for_each(decl, expr, blk) {
|
||||
head(s, "for each");
|
||||
print_for_decl(s, decl, expr);
|
||||
space(s.s);
|
||||
print_block(s, blk);
|
||||
}
|
||||
ast::expr_do_while(blk, expr) {
|
||||
head(s, "do");
|
||||
space(s.s);
|
||||
|
|
@ -924,13 +917,6 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
|
|||
_ { }
|
||||
}
|
||||
}
|
||||
ast::expr_put(result) {
|
||||
word(s.s, "put");
|
||||
alt result {
|
||||
some(expr) { word(s.s, " "); print_expr(s, expr); }
|
||||
_ { }
|
||||
}
|
||||
}
|
||||
ast::expr_be(result) { word_nbsp(s, "be"); print_expr(s, result); }
|
||||
ast::expr_log(lvl, expr) {
|
||||
alt lvl { 1 { word_nbsp(s, "log"); } 0 { word_nbsp(s, "log_err"); } }
|
||||
|
|
@ -1005,7 +991,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
|
|||
|
||||
fn print_expr_parens_if_not_bot(s: ps, ex: @ast::expr) {
|
||||
let parens = alt ex.node {
|
||||
ast::expr_fail(_) | ast::expr_ret(_) | ast::expr_put(_) |
|
||||
ast::expr_fail(_) | ast::expr_ret(_) |
|
||||
ast::expr_binary(_, _, _) | ast::expr_unary(_, _) |
|
||||
ast::expr_ternary(_, _, _) | ast::expr_move(_, _) |
|
||||
ast::expr_copy(_) | ast::expr_assign(_, _) | ast::expr_be(_) |
|
||||
|
|
@ -1319,7 +1305,6 @@ fn need_parens(expr: @ast::expr, outer_prec: int) -> bool {
|
|||
ast::expr_swap(_, _) { true }
|
||||
ast::expr_assign_op(_, _, _) { true }
|
||||
ast::expr_ret(_) { true }
|
||||
ast::expr_put(_) { true }
|
||||
ast::expr_be(_) { true }
|
||||
ast::expr_assert(_) { true }
|
||||
ast::expr_check(_, _) { true }
|
||||
|
|
@ -1643,7 +1628,6 @@ fn ast_fn_constrs_str(decl: ast::fn_decl, constrs: [@ast::constr]) -> str {
|
|||
|
||||
fn proto_to_str(p: ast::proto) -> str {
|
||||
ret alt p {
|
||||
ast::proto_iter. { "iter" }
|
||||
ast::proto_bare. { "fn" }
|
||||
ast::proto_block. { "block" }
|
||||
ast::proto_shared(ast::sugar_normal.) { "fn@" }
|
||||
|
|
@ -1679,7 +1663,7 @@ fn ends_in_lit_int(ex: @ast::expr) -> bool {
|
|||
ast::expr_assign_op(_, _, sub) | ast::expr_swap(_, sub) |
|
||||
ast::expr_log(_, sub) | ast::expr_assert(sub) |
|
||||
ast::expr_check(_, sub) { ends_in_lit_int(sub) }
|
||||
ast::expr_fail(osub) | ast::expr_ret(osub) | ast::expr_put(osub) {
|
||||
ast::expr_fail(osub) | ast::expr_ret(osub) {
|
||||
alt osub {
|
||||
some(ex) { ends_in_lit_int(ex) }
|
||||
_ { false }
|
||||
|
|
|
|||
|
|
@ -274,7 +274,7 @@ fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
|
|||
v.visit_expr(el, e, v);
|
||||
}
|
||||
expr_while(x, b) { v.visit_expr(x, e, v); v.visit_block(b, e, v); }
|
||||
expr_for(dcl, x, b) | expr_for_each(dcl, x, b) {
|
||||
expr_for(dcl, x, b) {
|
||||
v.visit_local(dcl, e, v);
|
||||
v.visit_expr(x, e, v);
|
||||
v.visit_block(b, e, v);
|
||||
|
|
@ -301,7 +301,6 @@ fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
|
|||
expr_break. { }
|
||||
expr_cont. { }
|
||||
expr_ret(eo) { visit_expr_opt(eo, e, v); }
|
||||
expr_put(eo) { visit_expr_opt(eo, e, v); }
|
||||
expr_be(x) { v.visit_expr(x, e, v); }
|
||||
expr_log(_, x) { v.visit_expr(x, e, v); }
|
||||
expr_check(_, x) { v.visit_expr(x, e, v); }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue