Skip to content

Commit 3c534b2

Browse files
committed
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.
1 parent 14c31c2 commit 3c534b2

File tree

1 file changed

+13
-29
lines changed

1 file changed

+13
-29
lines changed

src/comp/front/parser.rs

+13-29
Original file line numberDiff line numberDiff line change
@@ -195,29 +195,6 @@ fn parse_value_ident(&parser p) -> ast::ident {
195195
ret parse_ident(p);
196196
}
197197

198-
199-
/* FIXME: gross hack copied from rustboot to make certain configuration-based
200-
* decisions work at build-time. We should probably change it to use a
201-
* lexical sytnax-extension or something similar. For now we just imitate
202-
* rustboot.
203-
*/
204-
fn parse_str_lit_or_env_ident(&parser p) -> ast::ident {
205-
alt (p.peek()) {
206-
case (token::LIT_STR(?s)) { p.bump(); ret p.get_str(s); }
207-
case (token::IDENT(?i, _)) {
208-
auto v =
209-
eval::lookup(p.get_session(), p.get_env(), p.get_span(),
210-
p.get_str(i));
211-
if (!eval::val_is_str(v)) {
212-
p.fatal("expecting string-valued variable");
213-
}
214-
p.bump();
215-
ret eval::val_as_str(v);
216-
}
217-
case (_) { p.fatal("expecting string literal"); fail; }
218-
}
219-
}
220-
221198
fn is_word(&parser p, &str word) -> bool {
222199
ret alt (p.peek()) {
223200
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 {
18491826
auto link_name = none;
18501827
if (p.peek() == token::EQ) {
18511828
p.bump();
1852-
link_name = some(parse_str_lit_or_env_ident(p));
1829+
link_name = some(parse_str(p));
18531830
}
18541831
auto hi = p.get_hi_pos();
18551832
expect(p, token::SEMI);
@@ -1897,7 +1874,7 @@ fn parse_item_native_mod(&parser p, vec[ast::attribute] attrs) -> @ast::item {
18971874
auto lo = p.get_last_lo_pos();
18981875
auto abi = ast::native_abi_cdecl;
18991876
if (!is_word(p, "mod")) {
1900-
auto t = parse_str_lit_or_env_ident(p);
1877+
auto t = parse_str(p);
19011878
if (str::eq(t, "cdecl")) {
19021879
} else if (str::eq(t, "rust")) {
19031880
abi = ast::native_abi_rust;
@@ -1912,7 +1889,7 @@ fn parse_item_native_mod(&parser p, vec[ast::attribute] attrs) -> @ast::item {
19121889
auto native_name;
19131890
if (p.peek() == token::EQ) {
19141891
expect(p, token::EQ);
1915-
native_name = parse_str_lit_or_env_ident(p);
1892+
native_name = parse_str(p);
19161893
} else { native_name = default_native_name(p.get_session(), id); }
19171894
expect(p, token::LBRACE);
19181895
auto m = parse_native_mod_items(p, native_name, abi);
@@ -2297,6 +2274,15 @@ fn parse_crate_from_source_file(&parser p) -> @ast::crate {
22972274
attrs=crate_attrs._0));
22982275
}
22992276

2277+
fn parse_str(&parser p) -> ast::ident {
2278+
alt (p.peek()) {
2279+
case (token::LIT_STR(?s)) {
2280+
p.bump();
2281+
ret p.get_str(s);
2282+
}
2283+
case (_) { fail; }
2284+
}
2285+
}
23002286

23012287
// Logic for parsing crate files (.rc)
23022288
//
@@ -2318,9 +2304,7 @@ fn parse_crate_directive(&parser p) -> ast::crate_directive {
23182304
alt (p.peek()) {
23192305
case (token::EQ) {
23202306
p.bump();
2321-
2322-
// FIXME: turn this into parse+eval expr
2323-
some(parse_str_lit_or_env_ident(p))
2307+
some(parse_str(p))
23242308
}
23252309
case (_) { none }
23262310
};

0 commit comments

Comments
 (0)