about summary refs log tree commit diff
path: root/src/comp/syntax
diff options
context:
space:
mode:
authorTim Chevalier <chevalier@alum.wellesley.edu>2011-08-24 13:39:15 -0700
committerTim Chevalier <chevalier@alum.wellesley.edu>2011-08-24 14:21:37 -0700
commitc6155d1fd112407c2d111c0c81c38a3606a0954e (patch)
tree3e28872864ee455b0a7e931bd0393c7038ea24d7 /src/comp/syntax
parent5b5689d4ddbc75c34c5c9c70fdbc27b351a7a2f4 (diff)
Change "pred" to "pure fn" (but still accept "pred")
This is part 1 of changing the "pred" keyword to "pure fn".
Right now, the compiler accepts both "pred" and "pure fn".
Diffstat (limited to 'src/comp/syntax')
-rw-r--r--src/comp/syntax/ast.rs2
-rw-r--r--src/comp/syntax/parse/parser.rs12
-rw-r--r--src/comp/syntax/print/pprust.rs2
3 files changed, 10 insertions, 6 deletions
diff --git a/src/comp/syntax/ast.rs b/src/comp/syntax/ast.rs
index ec38c349ce3..d452ffe4a6d 100644
--- a/src/comp/syntax/ast.rs
+++ b/src/comp/syntax/ast.rs
@@ -371,7 +371,7 @@ type fn_decl =
      constraints: [@constr]};
 
 tag purity {
-    pure_fn; // declared with "pred"
+    pure_fn; // declared with "pure fn"
     impure_fn; // declared with "fn"
 }
 
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs
index aa553e32e39..b4ad7339e25 100644
--- a/src/comp/syntax/parse/parser.rs
+++ b/src/comp/syntax/parse/parser.rs
@@ -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") {
diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs
index 2165be225b8..051c114002b 100644
--- a/src/comp/syntax/print/pprust.rs
+++ b/src/comp/syntax/print/pprust.rs
@@ -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);