]> git.lizzy.rs Git - rust.git/commitdiff
Change "pred" to "pure fn" (but still accept "pred")
authorTim Chevalier <chevalier@alum.wellesley.edu>
Wed, 24 Aug 2011 20:39:15 +0000 (13:39 -0700)
committerTim Chevalier <chevalier@alum.wellesley.edu>
Wed, 24 Aug 2011 21:21:37 +0000 (14:21 -0700)
This is part 1 of changing the "pred" keyword to "pure fn".
Right now, the compiler accepts both "pred" and "pure fn".

src/comp/metadata/decoder.rs
src/comp/syntax/ast.rs
src/comp/syntax/parse/parser.rs
src/comp/syntax/print/pprust.rs

index fc2f3a00a9bd6e3bb2e331bceef3b78406cd3cdf..0476fd886054fbb0cab75cc6cc1e15b5f75dfa1b 100644 (file)
@@ -284,7 +284,7 @@ fn item_family_to_str(fam: u8) -> str {
     alt fam as char {
       'c' { ret "const"; }
       'f' { ret "fn"; }
-      'p' { ret "pred"; }
+      'p' { ret "pure fn"; }
       'F' { ret "native fn"; }
       'y' { ret "type"; }
       'T' { ret "native type"; }
index ec38c349ce3e2bd8a26cf027b1760ab4238c65f2..d452ffe4a6d61f61161d2ff7f53274dec6a56f72 100644 (file)
      constraints: [@constr]};
 
 tag purity {
-    pure_fn; // declared with "pred"
+    pure_fn; // declared with "pure fn"
     impure_fn; // declared with "fn"
 }
 
index aa553e32e3944960764826669c6dc30932599010..b4ad7339e25b83cab2220af08916a56070067ce6 100644 (file)
@@ -173,7 +173,7 @@ fn bad_expr_word_table() -> hashmap<str, ()> {
     words.insert("fn", ());
     words.insert("block", ());
     words.insert("lambda", ());
-    words.insert("pred", ());
+    words.insert("pure", ());
     words.insert("iter", ());
     words.insert("block", ());
     words.insert("import", ());
@@ -326,8 +326,6 @@ fn parse_proto(p: &parser) -> ast::proto {
         ret ast::proto_fn;
     } else if eat_word(p, "block") {
         ret ast::proto_block;
-    } else if eat_word(p, "pred") {
-        ret ast::proto_fn;
     } else { unexpected(p, p.peek()); }
 }
 
@@ -2123,7 +2121,13 @@ fn parse_item(p: &parser, attrs: &[ast::attribute]) -> option::t<@ast::item> {
         p.bump();
         ret some(parse_item_fn_or_iter(p, ast::impure_fn, ast::proto_fn,
                                        attrs, ast::il_normal));
-    } else if eat_word(p, "pred") {
+    } else if eat_word(p, "pure") {
+        expect_word(p, "fn");
+        ret some(parse_item_fn_or_iter(p, ast::pure_fn, ast::proto_fn, attrs,
+                                       ast::il_normal));
+    }
+    // FIXME: remove
+    else if eat_word(p, "pred") {
         ret some(parse_item_fn_or_iter(p, ast::pure_fn, ast::proto_fn, attrs,
                                        ast::il_normal));
     } else if eat_word(p, "iter") {
index 2165be225b890c19fa7aa261c8a0faf7175393d2..051c114002b5486939381e35a63463b5160ed292 100644 (file)
@@ -1197,7 +1197,7 @@ fn print_fn(s: &ps, decl: ast::fn_decl, proto: ast::proto, name: str,
             typarams: &[ast::ty_param], constrs: [@ast::constr]) {
     alt decl.purity {
       ast::impure_fn. { head(s, proto_to_str(proto)); }
-      _ { head(s, "pred"); }
+      _ { head(s, "pure fn"); }
     }
     word(s.s, name);
     print_type_params(s, typarams);