about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRafael Ávila de Espíndola <respindola@mozilla.com>2011-06-23 18:42:55 -0400
committerRafael Ávila de Espíndola <respindola@mozilla.com>2011-06-23 18:42:55 -0400
commit3c534b2bef5514ebce7acb2c829d7eee58f9bb5e (patch)
tree9bab6bcf51d216f6f70876d4eda8d183b278ecac /src
parent14c31c26c29cba36b336898f1c760e2b61c74d4c (diff)
downloadrust-3c534b2bef5514ebce7acb2c829d7eee58f9bb5e.tar.gz
rust-3c534b2bef5514ebce7acb2c829d7eee58f9bb5e.zip
Remove parse_str_lit_or_env_ident.
We decided to use metadata for the more complex cases, and a simple
string is enough for rustc right now.
Diffstat (limited to 'src')
-rw-r--r--src/comp/front/parser.rs42
1 files changed, 13 insertions, 29 deletions
diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs
index fe5725fdb6b..9fc7070e154 100644
--- a/src/comp/front/parser.rs
+++ b/src/comp/front/parser.rs
@@ -195,29 +195,6 @@ fn parse_value_ident(&parser p) -> ast::ident {
     ret parse_ident(p);
 }
 
-
-/* FIXME: gross hack copied from rustboot to make certain configuration-based
- * decisions work at build-time.  We should probably change it to use a
- * lexical sytnax-extension or something similar. For now we just imitate
- * rustboot.
- */
-fn parse_str_lit_or_env_ident(&parser p) -> ast::ident {
-    alt (p.peek()) {
-        case (token::LIT_STR(?s)) { p.bump(); ret p.get_str(s); }
-        case (token::IDENT(?i, _)) {
-            auto v =
-                eval::lookup(p.get_session(), p.get_env(), p.get_span(),
-                             p.get_str(i));
-            if (!eval::val_is_str(v)) {
-                p.fatal("expecting string-valued variable");
-            }
-            p.bump();
-            ret eval::val_as_str(v);
-        }
-        case (_) { p.fatal("expecting string literal"); fail; }
-    }
-}
-
 fn is_word(&parser p, &str word) -> bool {
     ret alt (p.peek()) {
             case (token::IDENT(?sid, false)) { str::eq(word, p.get_str(sid)) }
@@ -1849,7 +1826,7 @@ fn parse_item_native_fn(&parser p) -> @ast::native_item {
     auto link_name = none;
     if (p.peek() == token::EQ) {
         p.bump();
-        link_name = some(parse_str_lit_or_env_ident(p));
+        link_name = some(parse_str(p));
     }
     auto hi = p.get_hi_pos();
     expect(p, token::SEMI);
@@ -1897,7 +1874,7 @@ fn parse_item_native_mod(&parser p, vec[ast::attribute] attrs) -> @ast::item {
     auto lo = p.get_last_lo_pos();
     auto abi = ast::native_abi_cdecl;
     if (!is_word(p, "mod")) {
-        auto t = parse_str_lit_or_env_ident(p);
+        auto t = parse_str(p);
         if (str::eq(t, "cdecl")) {
         } else if (str::eq(t, "rust")) {
             abi = ast::native_abi_rust;
@@ -1912,7 +1889,7 @@ fn parse_item_native_mod(&parser p, vec[ast::attribute] attrs) -> @ast::item {
     auto native_name;
     if (p.peek() == token::EQ) {
         expect(p, token::EQ);
-        native_name = parse_str_lit_or_env_ident(p);
+        native_name = parse_str(p);
     } else { native_name = default_native_name(p.get_session(), id); }
     expect(p, token::LBRACE);
     auto m = parse_native_mod_items(p, native_name, abi);
@@ -2297,6 +2274,15 @@ fn parse_crate_from_source_file(&parser p) -> @ast::crate {
                                          attrs=crate_attrs._0));
 }
 
+fn parse_str(&parser p) -> ast::ident {
+    alt (p.peek()) {
+        case (token::LIT_STR(?s)) {
+            p.bump();
+            ret p.get_str(s);
+        }
+        case (_) { fail; }
+    }
+}
 
 // Logic for parsing crate files (.rc)
 //
@@ -2318,9 +2304,7 @@ fn parse_crate_directive(&parser p) -> ast::crate_directive {
             alt (p.peek()) {
                 case (token::EQ) {
                     p.bump();
-
-                    // FIXME: turn this into parse+eval expr
-                    some(parse_str_lit_or_env_ident(p))
+                    some(parse_str(p))
                 }
                 case (_) { none }
             };