Remove code from parser that was awaiting snapshot

Remove old parser functions as well as support for old-style capture
clauses. Remove remaining old-style capture clauses.
This commit is contained in:
Tim Chevalier 2012-06-14 19:02:30 -07:00
parent bc507c4ef5
commit 39d9c30a15
8 changed files with 9 additions and 69 deletions

View File

@ -879,7 +879,7 @@ fn test_avoid_copying_the_body_spawn() {
#[test]
fn test_avoid_copying_the_body_spawn_listener() {
avoid_copying_the_body {|f|
spawn_listener(fn~[move f](_po: comm::port<int>) {
spawn_listener(fn~(move f, _po: comm::port<int>) {
f();
});
}
@ -899,7 +899,7 @@ fn test_avoid_copying_the_body_run() {
fn test_avoid_copying_the_body_run_listener() {
avoid_copying_the_body {|f|
let buildr = builder();
run_listener(buildr, fn~[move f](_po: comm::port<int>) {
run_listener(buildr, fn~(move f, _po: comm::port<int>) {
f();
});
}

View File

@ -59,7 +59,7 @@ fn expand_include(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
let p = parse::new_parser_from_file(cx.parse_sess(), cx.cfg(),
res_rel_file(cx, sp, file),
parse::parser::SOURCE_FILE);
ret parse::parser::parse_expr(p)
ret p.parse_expr();
}
fn expand_include_str(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,

View File

@ -16,8 +16,6 @@ import dvec::{dvec, extensions};
export file_type;
export parser;
export parse_expr;
export parse_pat;
// FIXME: #ast expects to find this here but it's actually defined in `parse`
// Fixing this will be easier when we have export decls on individual items --
@ -26,12 +24,6 @@ export parse_pat;
import parse_from_source_str;
export parse_from_source_str;
// TODO: remove these once we go around a snapshot cycle.
// These are here for the old way that #ast (qquote.rs) worked
fn parse_expr(p: parser) -> @ast::expr { p.parse_expr() }
fn parse_pat(p: parser) -> @ast::pat { p.parse_pat() }
enum restriction {
UNRESTRICTED,
RESTRICT_STMT_EXPR,
@ -1231,8 +1223,6 @@ class parser {
fn parse_fn_expr(proto: proto) -> @expr {
let lo = self.last_span.lo;
let cc_old = self.parse_old_skool_capture_clause();
// if we want to allow fn expression argument types to be inferred in
// the future, just have to change parse_arg to parse_fn_block_arg.
let (decl, capture_clause) =
@ -1241,8 +1231,7 @@ class parser {
let body = self.parse_block();
ret self.mk_expr(lo, body.span.hi,
expr_fn(proto, decl, body,
@(*capture_clause + cc_old)));
expr_fn(proto, decl, body, capture_clause));
}
fn parse_fn_block_expr() -> @expr {
@ -1731,55 +1720,6 @@ class parser {
} else { [] }
}
// FIXME Remove after snapshot
fn parse_old_skool_capture_clause() -> [capture_item] {
fn expect_opt_trailing_semi(p: parser) {
if !p.eat(token::SEMI) {
if p.token != token::RBRACKET {
p.fatal("expecting ; or ]");
}
}
}
fn eat_ident_list(p: parser, is_move: bool) -> [capture_item] {
let mut res = [];
loop {
alt p.token {
token::IDENT(_, _) {
let id = p.get_id();
let sp = mk_sp(p.span.lo, p.span.hi);
let ident = p.parse_ident();
res += [@{id:id, is_move: is_move, name:ident, span:sp}];
if !p.eat(token::COMMA) {
ret res;
}
}
_ { ret res; }
}
};
}
let mut cap_items = [];
if self.eat(token::LBRACKET) {
while !self.eat(token::RBRACKET) {
if self.eat_keyword("copy") {
cap_items += eat_ident_list(self, false);
expect_opt_trailing_semi(self);
} else if self.eat_keyword("move") {
cap_items += eat_ident_list(self, true);
expect_opt_trailing_semi(self);
} else {
let s: str = "expecting send, copy, or move clause";
self.fatal(s);
}
}
}
ret cap_items;
}
fn parse_fn_decl(purity: purity,
parse_arg_fn: fn(parser) -> arg_or_capture_item)
-> (fn_decl, capture_clause) {

View File

@ -97,7 +97,7 @@ fn exec<T:send>(
) -> T {
let po = comm::port();
let ch = comm::chan(po);
let msg = handle_request(fn~[move f](ctxt: ctxt) {
let msg = handle_request(fn~(move f, ctxt: ctxt) {
comm::send(ch, f(ctxt))
});
comm::send(srv.ch, msg);

View File

@ -1,6 +1,6 @@
fn main() {
let x = 1;
let y = fn@[move x]() -> int {
let y = fn@(move x) -> int {
x
}();
}

View File

@ -15,7 +15,7 @@ fn test05() {
log(error, *three + n); // will copy x into the closure
assert(*three == 3);
};
task::spawn(fn~[move fn_to_send]() {
task::spawn(fn~(move fn_to_send) {
test05_start(fn_to_send);
});
}

View File

@ -8,7 +8,7 @@ fn main() {
let y = ~2;
let y_in_parent = ptr::addr_of(*y) as uint;
task::spawn(fn~[copy ch, y; move x]() {
task::spawn(fn~(copy ch, copy y, move x) {
let x_in_child = ptr::addr_of(*x) as uint;
comm::send(ch, x_in_child);

View File

@ -1,5 +1,5 @@
fn main() {
let x = ~1;
let lam_move = fn@[move x]() { };
let lam_move = fn@(move x) { };
lam_move();
}