Change the type for the macro body to also store the span.

Note: the body is the part of the macro syntax between the {}.
This commit is contained in:
Kevin Atkinson 2012-01-31 20:30:26 -07:00
parent 099290bc73
commit e76fdeb3a6
8 changed files with 13 additions and 10 deletions

View file

@ -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,

View file

@ -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),

View file

@ -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 }

View file

@ -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 }

View file

@ -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 }

View file

@ -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 }

View file

@ -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));

View file

@ -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); }