Skip to content

Commit dbd066a

Browse files
paulstansifergraydon
authored andcommitted
"macro" -> "syntax extension" for now
1 parent 79fcd51 commit dbd066a

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

src/comp/front/parser.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ tag file_type {
2828
type ty_or_bang = util::common::ty_or_bang[@ast::ty];
2929

3030
// Temporary: to introduce a tag in order to make a recursive type work
31-
tag xmacro {
32-
x(macro);
31+
tag syntax_extension {
32+
x(syntax_expander);
3333
}
3434

3535
state type parser =
@@ -52,15 +52,15 @@ state type parser =
5252
fn get_str(token::str_num) -> str;
5353
fn get_reader() -> lexer::reader;
5454
fn get_filemap() -> codemap::filemap;
55-
fn get_bad_expr_words() -> std::map::hashmap[str, ()];
56-
fn get_macros() -> std::map::hashmap[str, xmacro];
55+
fn get_bad_expr_words() -> hashmap[str, ()];
56+
fn get_syntax_expanders() -> hashmap[str, syntax_extension];
5757
fn get_chpos() -> uint;
5858
fn get_ann() -> ast::ann;
5959
fn next_ann_num() -> uint;
6060
};
6161

62-
type macro = fn(&parser, common::span, &vec[@ast::expr], option::t[str])
63-
-> @ast::expr;
62+
type syntax_expander = fn(&parser, common::span, &vec[@ast::expr],
63+
option::t[str]) -> @ast::expr;
6464

6565
fn new_parser(session::session sess,
6666
eval::env env,
@@ -79,8 +79,8 @@ fn new_parser(session::session sess,
7979
lexer::reader rdr,
8080
vec[op_spec] precs,
8181
mutable uint next_ann_var,
82-
std::map::hashmap[str, ()] bad_words,
83-
std::map::hashmap[str, xmacro] macros)
82+
hashmap[str, ()] bad_words,
83+
hashmap[str, syntax_extension] syntax_expanders)
8484
{
8585
fn peek() -> token::token {
8686
ret tok;
@@ -149,12 +149,12 @@ fn new_parser(session::session sess,
149149
ret rdr.get_filemap();
150150
}
151151

152-
fn get_bad_expr_words() -> std::map::hashmap[str, ()] {
152+
fn get_bad_expr_words() -> hashmap[str, ()] {
153153
ret bad_words;
154154
}
155155

156-
fn get_macros() -> std::map::hashmap[str, xmacro] {
157-
ret macros;
156+
fn get_syntax_expanders() -> hashmap[str, syntax_extension] {
157+
ret syntax_expanders;
158158
}
159159

160160
fn get_chpos() -> uint {ret rdr.get_chpos();}
@@ -183,13 +183,13 @@ fn new_parser(session::session sess,
183183
ret stdio_parser(sess, env, ftype, lexer::next_token(rdr),
184184
npos, npos, npos, initial_def._1, UNRESTRICTED,
185185
initial_def._0, rdr, prec_table(), next_ann,
186-
bad_expr_word_table(), macro_table());
186+
bad_expr_word_table(), syntax_expander_table());
187187
}
188188

189189
// These are the words that shouldn't be allowed as value identifiers,
190190
// because, if used at the start of a line, they will cause the line to be
191191
// interpreted as a specific kind of statement, which would be confusing.
192-
fn bad_expr_word_table() -> std::map::hashmap[str, ()] {
192+
fn bad_expr_word_table() -> hashmap[str, ()] {
193193
auto words = new_str_hash[()]();
194194
words.insert("mod", ());
195195
words.insert("if", ());
@@ -227,11 +227,11 @@ fn bad_expr_word_table() -> std::map::hashmap[str, ()] {
227227
ret words;
228228
}
229229

230-
fn macro_table() -> std::map::hashmap[str, xmacro] {
231-
auto macros = new_str_hash[xmacro]();
232-
macros.insert("fmt", x(extfmt::expand_syntax_ext));
233-
macros.insert("env", x(extenv::expand_syntax_ext));
234-
ret macros;
230+
fn syntax_expander_table() -> hashmap[str, syntax_extension] {
231+
auto syntax_expanders = new_str_hash[syntax_extension]();
232+
syntax_expanders.insert("fmt", x(extfmt::expand_syntax_ext));
233+
syntax_expanders.insert("env", x(extenv::expand_syntax_ext));
234+
ret syntax_expanders;
235235
}
236236

237237
fn unexpected(&parser p, token::token t) -> ! {
@@ -1059,11 +1059,11 @@ fn expand_syntax_ext(&parser p, common::span sp,
10591059
assert (vec::len[ast::ident](path.node.idents) > 0u);
10601060
auto extname = path.node.idents.(0);
10611061

1062-
alt (p.get_macros().find(extname)) {
1063-
case (none[xmacro]) {
1064-
p.err("unknown macro: '" + extname + "'");
1062+
alt (p.get_syntax_expanders().find(extname)) {
1063+
case (none[syntax_extension]) {
1064+
p.err("unknown syntax expander: '" + extname + "'");
10651065
}
1066-
case (some[xmacro](x(?ext))) {
1066+
case (some[syntax_extension](x(?ext))) {
10671067
ret ast::expr_ext(path, args, body, ext(p, sp, args, body),
10681068
p.get_ann());
10691069
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
// error-pattern:unknown macro
2+
// error-pattern:unknown syntax expander
33
fn main() {
44
#iamnotanextensionthatexists("");
55
}

0 commit comments

Comments
 (0)