@@ -28,8 +28,8 @@ tag file_type {
28
28
type ty_or_bang = util:: common:: ty_or_bang[ @ast:: ty ] ;
29
29
30
30
// 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 ) ;
33
33
}
34
34
35
35
state type parser =
@@ -52,15 +52,15 @@ state type parser =
52
52
fn get_str ( token:: str_num ) -> str ;
53
53
fn get_reader ( ) -> lexer:: reader ;
54
54
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 ] ;
57
57
fn get_chpos ( ) -> uint ;
58
58
fn get_ann ( ) -> ast:: ann ;
59
59
fn next_ann_num ( ) -> uint ;
60
60
} ;
61
61
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 ;
64
64
65
65
fn new_parser ( session:: session sess,
66
66
eval:: env env,
@@ -79,8 +79,8 @@ fn new_parser(session::session sess,
79
79
lexer:: reader rdr,
80
80
vec[ op_spec] precs,
81
81
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 )
84
84
{
85
85
fn peek ( ) -> token:: token {
86
86
ret tok;
@@ -149,12 +149,12 @@ fn new_parser(session::session sess,
149
149
ret rdr. get_filemap ( ) ;
150
150
}
151
151
152
- fn get_bad_expr_words ( ) -> std :: map :: hashmap [ str, ( ) ] {
152
+ fn get_bad_expr_words ( ) -> hashmap [ str, ( ) ] {
153
153
ret bad_words;
154
154
}
155
155
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 ;
158
158
}
159
159
160
160
fn get_chpos ( ) -> uint { ret rdr. get_chpos ( ) ; }
@@ -183,13 +183,13 @@ fn new_parser(session::session sess,
183
183
ret stdio_parser ( sess, env, ftype, lexer:: next_token ( rdr) ,
184
184
npos, npos, npos, initial_def. _1 , UNRESTRICTED ,
185
185
initial_def. _0 , rdr, prec_table ( ) , next_ann,
186
- bad_expr_word_table ( ) , macro_table ( ) ) ;
186
+ bad_expr_word_table ( ) , syntax_expander_table ( ) ) ;
187
187
}
188
188
189
189
// These are the words that shouldn't be allowed as value identifiers,
190
190
// because, if used at the start of a line, they will cause the line to be
191
191
// 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, ( ) ] {
193
193
auto words = new_str_hash[ ( ) ] ( ) ;
194
194
words. insert ( "mod" , ( ) ) ;
195
195
words. insert ( "if" , ( ) ) ;
@@ -227,11 +227,11 @@ fn bad_expr_word_table() -> std::map::hashmap[str, ()] {
227
227
ret words;
228
228
}
229
229
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 ;
235
235
}
236
236
237
237
fn unexpected ( & parser p, token:: token t) -> ! {
@@ -1059,11 +1059,11 @@ fn expand_syntax_ext(&parser p, common::span sp,
1059
1059
assert ( vec:: len[ ast:: ident] ( path. node . idents ) > 0 u) ;
1060
1060
auto extname = path. node . idents . ( 0 ) ;
1061
1061
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 + "'" ) ;
1065
1065
}
1066
- case ( some[ xmacro ] ( x ( ?ext) ) ) {
1066
+ case ( some[ syntax_extension ] ( x ( ?ext) ) ) {
1067
1067
ret ast:: expr_ext ( path, args, body, ext ( p, sp, args, body) ,
1068
1068
p. get_ann ( ) ) ;
1069
1069
}
0 commit comments