提交 8818f42b 编写于 作者: N Niko Matsakis

make parser disambiguate fn~ at top level correctly

上级 263f4c58
......@@ -2166,13 +2166,24 @@ fn parse_fn_ty_proto(p: parser) -> ast::proto {
}
}
fn fn_expr_lookahead(tok: token::token) -> bool {
alt tok {
token::LPAREN. | token::AT. | token::TILDE. | token::BINOP(_) {
true
}
_ {
false
}
}
}
fn parse_item(p: parser, attrs: [ast::attribute]) -> option::t<@ast::item> {
if eat_word(p, "const") {
ret some(parse_item_const(p, attrs));
} else if eat_word(p, "inline") {
expect_word(p, "fn");
ret some(parse_item_fn(p, ast::impure_fn, attrs));
} else if is_word(p, "fn") && p.look_ahead(1u) != token::LPAREN {
} else if is_word(p, "fn") && !fn_expr_lookahead(p.look_ahead(1u)) {
p.bump();
ret some(parse_item_fn(p, ast::impure_fn, attrs));
} else if eat_word(p, "pure") {
......
......@@ -5,11 +5,11 @@
type pointy = {
mutable a : maybe_pointy,
d : sendfn() -> uint,
d : fn~() -> uint,
};
fn make_uniq_closure<A:send>(a: A) -> sendfn() -> uint {
sendfn() -> uint { ptr::addr_of(a) as uint }
fn make_uniq_closure<A:send>(a: A) -> fn~() -> uint {
fn~() -> uint { ptr::addr_of(a) as uint }
}
fn empty_pointy() -> @pointy {
......
......@@ -6,14 +6,14 @@
type pointy = {
mutable a : maybe_pointy,
c : ~int,
d : sendfn()->(),
d : fn~()->(),
};
fn empty_pointy() -> @pointy {
ret @{
mutable a : none,
c : ~22,
d : sendfn()->(){},
d : fn~()->(){},
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册