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:
parent
099290bc73
commit
e76fdeb3a6
8 changed files with 13 additions and 10 deletions
|
@ -272,8 +272,11 @@ enum blk_sort {
|
||||||
|
|
||||||
type mac = spanned<mac_>;
|
type mac = spanned<mac_>;
|
||||||
|
|
||||||
|
type mac_body_ = {str: str, span: span};
|
||||||
|
type mac_body = option::t<mac_body_>;
|
||||||
|
|
||||||
enum mac_ {
|
enum mac_ {
|
||||||
mac_invoc(@path, @expr, option<str>),
|
mac_invoc(@path, @expr, mac_body),
|
||||||
mac_embed_type(@ty),
|
mac_embed_type(@ty),
|
||||||
mac_embed_block(blk),
|
mac_embed_block(blk),
|
||||||
mac_ellipsis,
|
mac_ellipsis,
|
||||||
|
|
|
@ -6,10 +6,10 @@ import std::map::new_str_hash;
|
||||||
import codemap;
|
import codemap;
|
||||||
|
|
||||||
type syntax_expander =
|
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_def = {ident: str, ext: syntax_extension};
|
||||||
type macro_definer =
|
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 {
|
enum syntax_extension {
|
||||||
normal(syntax_expander),
|
normal(syntax_expander),
|
||||||
|
|
|
@ -3,7 +3,7 @@ import base::*;
|
||||||
import syntax::ast;
|
import syntax::ast;
|
||||||
|
|
||||||
fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: @ast::expr,
|
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] =
|
let args: [@ast::expr] =
|
||||||
alt arg.node {
|
alt arg.node {
|
||||||
ast::expr_vec(elts, _) { elts }
|
ast::expr_vec(elts, _) { elts }
|
||||||
|
|
|
@ -10,7 +10,7 @@ import base::*;
|
||||||
export expand_syntax_ext;
|
export expand_syntax_ext;
|
||||||
|
|
||||||
fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: @ast::expr,
|
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] =
|
let args: [@ast::expr] =
|
||||||
alt arg.node {
|
alt arg.node {
|
||||||
ast::expr_vec(elts, _) { elts }
|
ast::expr_vec(elts, _) { elts }
|
||||||
|
|
|
@ -14,7 +14,7 @@ import syntax::ext::build::*;
|
||||||
export expand_syntax_ext;
|
export expand_syntax_ext;
|
||||||
|
|
||||||
fn expand_syntax_ext(cx: ext_ctxt, sp: span, arg: @ast::expr,
|
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] =
|
let args: [@ast::expr] =
|
||||||
alt arg.node {
|
alt arg.node {
|
||||||
ast::expr_vec(elts, _) { elts }
|
ast::expr_vec(elts, _) { elts }
|
||||||
|
|
|
@ -3,7 +3,7 @@ import base::*;
|
||||||
import syntax::ast;
|
import syntax::ast;
|
||||||
|
|
||||||
fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: @ast::expr,
|
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] =
|
let args: [@ast::expr] =
|
||||||
alt arg.node {
|
alt arg.node {
|
||||||
ast::expr_vec(elts, _) { elts }
|
ast::expr_vec(elts, _) { elts }
|
||||||
|
|
|
@ -3,7 +3,7 @@ import syntax::ast;
|
||||||
import std::io::writer_util;
|
import std::io::writer_util;
|
||||||
|
|
||||||
fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: @ast::expr,
|
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();
|
cx.print_backtrace();
|
||||||
std::io::stdout().write_line(print::pprust::expr_to_str(arg));
|
std::io::stdout().write_line(print::pprust::expr_to_str(arg));
|
||||||
|
|
|
@ -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,
|
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] =
|
let args: [@ast::expr] =
|
||||||
alt arg.node {
|
alt arg.node {
|
||||||
ast::expr_vec(elts, _) { elts }
|
ast::expr_vec(elts, _) { elts }
|
||||||
|
@ -754,7 +754,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: @expr,
|
||||||
ext: normal(ext)};
|
ext: normal(ext)};
|
||||||
|
|
||||||
fn generic_extension(cx: ext_ctxt, sp: span, arg: @expr,
|
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 {
|
for c: @clause in clauses {
|
||||||
alt use_selectors_to_bind(c.params, arg) {
|
alt use_selectors_to_bind(c.params, arg) {
|
||||||
some(bindings) { ret transcribe(cx, bindings, c.body); }
|
some(bindings) { ret transcribe(cx, bindings, c.body); }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue