diff options
| author | Kevin Atkinson <kevina@cs.utah.edu> | 2012-01-31 20:30:26 -0700 |
|---|---|---|
| committer | Kevin Atkinson <kevina@cs.utah.edu> | 2012-02-03 20:41:48 -0700 |
| commit | e76fdeb3a6411f151aafb6a48df26bc6c8f977a5 (patch) | |
| tree | cf0615c34a821eef5c4d83248da911d9c81745d3 | |
| parent | 099290bc7385477ab6c9908abb3b540e8cb6956a (diff) | |
| download | rust-e76fdeb3a6411f151aafb6a48df26bc6c8f977a5.tar.gz rust-e76fdeb3a6411f151aafb6a48df26bc6c8f977a5.zip | |
Change the type for the macro body to also store the span.
Note: the body is the part of the macro syntax between the {}.
| -rw-r--r-- | src/comp/syntax/ast.rs | 5 | ||||
| -rw-r--r-- | src/comp/syntax/ext/base.rs | 4 | ||||
| -rw-r--r-- | src/comp/syntax/ext/concat_idents.rs | 2 | ||||
| -rw-r--r-- | src/comp/syntax/ext/env.rs | 2 | ||||
| -rw-r--r-- | src/comp/syntax/ext/fmt.rs | 2 | ||||
| -rw-r--r-- | src/comp/syntax/ext/ident_to_str.rs | 2 | ||||
| -rw-r--r-- | src/comp/syntax/ext/log_syntax.rs | 2 | ||||
| -rw-r--r-- | src/comp/syntax/ext/simplext.rs | 4 |
8 files changed, 13 insertions, 10 deletions
diff --git a/src/comp/syntax/ast.rs b/src/comp/syntax/ast.rs index ea8dcbf7f4b..8ed392d011b 100644 --- a/src/comp/syntax/ast.rs +++ b/src/comp/syntax/ast.rs @@ -272,8 +272,11 @@ enum blk_sort { type mac = spanned<mac_>; +type mac_body_ = {str: str, span: span}; +type mac_body = option::t<mac_body_>; + enum mac_ { - mac_invoc(@path, @expr, option<str>), + mac_invoc(@path, @expr, mac_body), mac_embed_type(@ty), mac_embed_block(blk), mac_ellipsis, diff --git a/src/comp/syntax/ext/base.rs b/src/comp/syntax/ext/base.rs index bfe3e36c0bc..d15d74c8951 100644 --- a/src/comp/syntax/ext/base.rs +++ b/src/comp/syntax/ext/base.rs @@ -6,10 +6,10 @@ import std::map::new_str_hash; import codemap; type syntax_expander = - fn@(ext_ctxt, span, @ast::expr, option<str>) -> @ast::expr; + fn@(ext_ctxt, span, @ast::expr, ast::mac_body) -> @ast::expr; type macro_def = {ident: str, ext: syntax_extension}; type macro_definer = - fn@(ext_ctxt, span, @ast::expr, option<str>) -> macro_def; + fn@(ext_ctxt, span, @ast::expr, ast::mac_body) -> macro_def; enum syntax_extension { normal(syntax_expander), diff --git a/src/comp/syntax/ext/concat_idents.rs b/src/comp/syntax/ext/concat_idents.rs index 0a9d5b4cf3e..3a4c59e4960 100644 --- a/src/comp/syntax/ext/concat_idents.rs +++ b/src/comp/syntax/ext/concat_idents.rs @@ -3,7 +3,7 @@ import base::*; import syntax::ast; fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: @ast::expr, - _body: option<str>) -> @ast::expr { + _body: ast::mac_body) -> @ast::expr { let args: [@ast::expr] = alt arg.node { ast::expr_vec(elts, _) { elts } diff --git a/src/comp/syntax/ext/env.rs b/src/comp/syntax/ext/env.rs index fe464473e03..509f721127c 100644 --- a/src/comp/syntax/ext/env.rs +++ b/src/comp/syntax/ext/env.rs @@ -10,7 +10,7 @@ import base::*; export expand_syntax_ext; fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: @ast::expr, - _body: option<str>) -> @ast::expr { + _body: ast::mac_body) -> @ast::expr { let args: [@ast::expr] = alt arg.node { ast::expr_vec(elts, _) { elts } diff --git a/src/comp/syntax/ext/fmt.rs b/src/comp/syntax/ext/fmt.rs index 84994c0e5dc..b0a346131d6 100644 --- a/src/comp/syntax/ext/fmt.rs +++ b/src/comp/syntax/ext/fmt.rs @@ -14,7 +14,7 @@ import syntax::ext::build::*; export expand_syntax_ext; fn expand_syntax_ext(cx: ext_ctxt, sp: span, arg: @ast::expr, - _body: option<str>) -> @ast::expr { + _body: ast::mac_body) -> @ast::expr { let args: [@ast::expr] = alt arg.node { ast::expr_vec(elts, _) { elts } diff --git a/src/comp/syntax/ext/ident_to_str.rs b/src/comp/syntax/ext/ident_to_str.rs index 5fbc05062ee..f5e61bbae3e 100644 --- a/src/comp/syntax/ext/ident_to_str.rs +++ b/src/comp/syntax/ext/ident_to_str.rs @@ -3,7 +3,7 @@ import base::*; import syntax::ast; fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: @ast::expr, - _body: option<str>) -> @ast::expr { + _body: ast::mac_body) -> @ast::expr { let args: [@ast::expr] = alt arg.node { ast::expr_vec(elts, _) { elts } diff --git a/src/comp/syntax/ext/log_syntax.rs b/src/comp/syntax/ext/log_syntax.rs index b7be75e349f..bfdd336e1ef 100644 --- a/src/comp/syntax/ext/log_syntax.rs +++ b/src/comp/syntax/ext/log_syntax.rs @@ -3,7 +3,7 @@ import syntax::ast; import std::io::writer_util; fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: @ast::expr, - _body: option<str>) -> @ast::expr { + _body: ast::mac_body) -> @ast::expr { cx.print_backtrace(); std::io::stdout().write_line(print::pprust::expr_to_str(arg)); diff --git a/src/comp/syntax/ext/simplext.rs b/src/comp/syntax/ext/simplext.rs index 3ee7a422d2e..d35c76838fc 100644 --- a/src/comp/syntax/ext/simplext.rs +++ b/src/comp/syntax/ext/simplext.rs @@ -670,7 +670,7 @@ fn p_t_s_r_actual_vector(cx: ext_ctxt, elts: [@expr], _repeat_after: bool, } fn add_new_extension(cx: ext_ctxt, sp: span, arg: @expr, - _body: option<str>) -> base::macro_def { + _body: ast::mac_body) -> base::macro_def { let args: [@ast::expr] = alt arg.node { ast::expr_vec(elts, _) { elts } @@ -754,7 +754,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: @expr, ext: normal(ext)}; fn generic_extension(cx: ext_ctxt, sp: span, arg: @expr, - _body: option<str>, clauses: [@clause]) -> @expr { + _body: ast::mac_body, clauses: [@clause]) -> @expr { for c: @clause in clauses { alt use_selectors_to_bind(c.params, arg) { some(bindings) { ret transcribe(cx, bindings, c.body); } |
