Skip to content

Commit 1192503

Browse files
committed
---
yaml --- r: 1463 b: refs/heads/master c: 7cae0c8 h: refs/heads/master i: 1461: 2325366 1459: a913290 1455: 6021dd2 v: v3
1 parent 60fee87 commit 1192503

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 9d59d33515d889f6e65f50226ba83d91a36bba0e
2+
refs/heads/master: 7cae0c8c4d15546cbccacb6a937759903df608d7

trunk/src/comp/front/parser.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,23 @@ impure fn parse_ident(parser p) -> ast.ident {
147147
}
148148

149149

150-
impure fn parse_str_lit(parser p) -> ast.ident {
150+
/* FIXME: gross hack copied from rustboot to make certain configuration-based
151+
* decisions work at build-time. We should probably change it to use a
152+
* lexical sytnax-extension or something similar. For now we just imitate
153+
* rustboot.
154+
*/
155+
impure fn parse_str_lit_or_env_ident(parser p) -> ast.ident {
151156
alt (p.peek()) {
152157
case (token.LIT_STR(?s)) { p.bump(); ret s; }
158+
case (token.IDENT(?i)) {
159+
auto v = eval.lookup(p.get_session(), p.get_env(),
160+
p.get_span(), i);
161+
if (!eval.val_is_str(v)) {
162+
p.err("expecting string-valued variable");
163+
}
164+
p.bump();
165+
ret eval.val_as_str(v);
166+
}
153167
case (_) {
154168
p.err("expecting string literal");
155169
fail;
@@ -1824,7 +1838,7 @@ impure fn parse_item_native_mod(parser p) -> @ast.item {
18241838
expect(p, token.NATIVE);
18251839
auto abi = ast.native_abi_cdecl;
18261840
if (p.peek() != token.MOD) {
1827-
auto t = parse_str_lit(p);
1841+
auto t = parse_str_lit_or_env_ident(p);
18281842
if (_str.eq(t, "cdecl")) {
18291843
} else if (_str.eq(t, "rust")) {
18301844
abi = ast.native_abi_rust;
@@ -1838,7 +1852,7 @@ impure fn parse_item_native_mod(parser p) -> @ast.item {
18381852
auto native_name;
18391853
if (p.peek() == token.EQ) {
18401854
expect(p, token.EQ);
1841-
native_name = parse_str_lit(p);
1855+
native_name = parse_str_lit_or_env_ident(p);
18421856
} else {
18431857
native_name = default_native_name(p.get_session(), id);
18441858
}
@@ -2202,7 +2216,7 @@ impure fn parse_crate_directive(parser p) -> ast.crate_directive
22022216
case (token.EQ) {
22032217
p.bump();
22042218
// FIXME: turn this into parse+eval expr
2205-
file_opt = some[filename](parse_str_lit(p));
2219+
file_opt = some[filename](parse_str_lit_or_env_ident(p));
22062220
}
22072221
case (_) {}
22082222
}

0 commit comments

Comments
 (0)