about summary refs log tree commit diff
path: root/src/comp/syntax/parse
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2011-12-16 10:42:28 +0100
committerMarijn Haverbeke <marijnh@gmail.com>2011-12-16 11:46:57 +0100
commitcff6bdd03616b6f20028ec8568d03363ccc3f9f2 (patch)
treee24a03d847e02bea41bded20923757d64df93da0 /src/comp/syntax/parse
parent4f826d81f611aa9486b25e1e123b24131659bd51 (diff)
downloadrust-cff6bdd03616b6f20028ec8568d03363ccc3f9f2.tar.gz
rust-cff6bdd03616b6f20028ec8568d03363ccc3f9f2.zip
Change syntax for impl
Move the name of the bundle to the front, allow type parameters (not
handled yet), and add a 'for' keyword:

    impl utils for int {
        fn str() -> str { int::str(self) }
        fn times(f: block()) { ... }
    }
Diffstat (limited to 'src/comp/syntax/parse')
-rw-r--r--src/comp/syntax/parse/parser.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs
index 94a7c3e01b2..3d00c333ad4 100644
--- a/src/comp/syntax/parse/parser.rs
+++ b/src/comp/syntax/parse/parser.rs
@@ -1859,14 +1859,14 @@ fn parse_item_obj(p: parser, attrs: [ast::attribute]) -> @ast::item {
 }
 
 fn parse_item_impl(p: parser, attrs: [ast::attribute]) -> @ast::item {
-    let lo = p.get_last_lo_pos(), ty = parse_ty(p, false);
-    expect(p, token::COLON);
-    let path = parse_path(p), meths = [];
+    let lo = p.get_last_lo_pos(), ident = parse_ident(p),
+        tps = parse_ty_params(p);
+    expect_word(p, "for");
+    let ty = parse_ty(p, false), meths = [];
     expect(p, token::LBRACE);
     while !eat(p, token::RBRACE) { meths += [parse_method(p)]; }
-    ret mk_item(p, lo, p.get_last_hi_pos(),
-                path.node.idents[vec::len(path.node.idents) - 1u],
-                ast::item_impl(path, ty, meths), attrs);
+    ret mk_item(p, lo, p.get_last_hi_pos(), ident,
+                ast::item_impl(tps, ty, meths), attrs);
 }
 
 fn parse_item_res(p: parser, attrs: [ast::attribute]) -> @ast::item {