Start killing off obsolete/unused quoters, and fix long lines.

This commit is contained in:
Graydon Hoare 2012-07-27 18:06:24 -07:00
parent 1d9f01cb42
commit eabd233dcd
6 changed files with 9 additions and 76 deletions

View File

@ -406,7 +406,8 @@ type matcher = spanned<matcher_>;
// $foo:expr => 1 + $foo // interpolate an expr
// $foo:tt => $foo // interpolate a token-tree
// $foo:tt => bar! $foo // only other valid interpolation
// // is in arg position for another macro
// // is in arg position for another
// // macro
//
// As a final, horrifying aside, note that macro-by-example's input is
// also matched by one of these matchers. Holy self-referential! It is matched
@ -441,11 +442,9 @@ type mac_body = option<mac_body_>;
#[auto_serialize]
enum mac_ {
mac_invoc(@path, mac_arg, mac_body),
mac_invoc_tt(@path,~[token_tree]), // will kill mac_invoc and steal its name
mac_embed_type(@ty), // obsolete quoter
mac_embed_block(blk), // obsolete quoter
mac_ellipsis, // obsolete pattern-match terminal
mac_invoc(@path, mac_arg, mac_body), // old macro-invocation
mac_invoc_tt(@path,~[token_tree]), // new macro-invocation
mac_ellipsis, // old pattern-match (obsolete)
// the span is used by the quoter/anti-quoter ...
mac_aq(span /* span of quote */, @expr), // anti-quote

View File

@ -539,7 +539,7 @@ fn block_to_ident(blk: blk_) -> option<ident> {
}
}
fn p_t_s_r_mac(cx: ext_ctxt, mac: ast::mac, s: selector, b: binders) {
fn p_t_s_r_mac(cx: ext_ctxt, mac: ast::mac, _s: selector, _b: binders) {
fn select_pt_1(cx: ext_ctxt, m: matchable,
fn_m: fn(ast::mac) -> match_result) -> match_result {
ret alt m {
@ -556,44 +556,6 @@ fn p_t_s_r_mac(cx: ext_ctxt, mac: ast::mac, s: selector, b: binders) {
ast::mac_ellipsis { cx.span_fatal(mac.span, ~"misused `...`"); }
ast::mac_invoc(_, _, _) { no_des(cx, mac.span, ~"macro calls"); }
ast::mac_invoc_tt(_, _) { no_des(cx, mac.span, ~"macro calls"); }
ast::mac_embed_type(ty) {
alt ty.node {
ast::ty_path(pth, _) {
alt path_to_ident(pth) {
some(id) {
/* look for an embedded type */
fn select_pt_2(m: ast::mac) -> match_result {
ret alt m.node {
ast::mac_embed_type(t) { some(leaf(match_ty(t))) }
_ { none }
}
}
let final_step = |x| select_pt_1(cx, x, select_pt_2);
b.real_binders.insert(id, compose_sels(s, final_step));
}
none { no_des(cx, pth.span, ~"under `#<>`"); }
}
}
_ { no_des(cx, ty.span, ~"under `#<>`"); }
}
}
ast::mac_embed_block(blk) {
alt block_to_ident(blk.node) {
some(id) {
fn select_pt_2(m: ast::mac) -> match_result {
ret alt m.node {
ast::mac_embed_block(blk) {
some(leaf(match_block(blk)))
}
_ { none }
}
}
let final_step = |x| select_pt_1(cx, x, select_pt_2);
b.real_binders.insert(id, compose_sels(s, final_step));
}
none { no_des(cx, blk.span, ~"under `#{}`"); }
}
}
ast::mac_aq(_,_) { no_des(cx, mac.span, ~"antiquotes"); }
ast::mac_var(_) { no_des(cx, mac.span, ~"antiquote variables"); }
}

View File

@ -118,8 +118,6 @@ fn fold_mac_(m: mac, fld: ast_fold) -> mac {
option::map(arg, |x| fld.fold_expr(x)), body)
}
mac_invoc_tt(pth, tt) { m.node }
mac_embed_type(ty) { mac_embed_type(fld.fold_ty(ty)) }
mac_embed_block(blk) { mac_embed_block(fld.fold_block(blk)) }
mac_ellipsis { mac_ellipsis }
mac_aq(_,_) { /* FIXME (#2543) */ copy m.node }
mac_var(_) { /* FIXME (#2543) */ copy m.node }

View File

@ -38,8 +38,8 @@ import ast::{_mod, add, alt_check, alt_exhaustive, arg, arm, attribute,
item_foreign_mod, item_impl, item_mac, item_mod, item_trait,
item_ty, lit, lit_, lit_bool, lit_float, lit_int,
lit_int_unsuffixed, lit_nil, lit_str, lit_uint, local, m_const,
m_imm, m_mutbl, mac_, mac_aq, mac_ellipsis, mac_embed_block,
mac_embed_type, mac_invoc, mac_invoc_tt, mac_var, matcher,
m_imm, m_mutbl, mac_, mac_aq, mac_ellipsis,
mac_invoc, mac_invoc_tt, mac_var, matcher,
method, mode, mt, mtc_bb, mtc_rep, mtc_tok, mul, mutability, neg,
noreturn, not, pat, pat_box, pat_enum, pat_ident, pat_lit,
pat_range, pat_rec, pat_tup, pat_uniq, pat_wild, path, private,
@ -831,21 +831,6 @@ class parser {
|p| p.parse_expr());
hi = self.span.hi;
ex = expr_vec(es, mutbl);
} else if self.token == token::POUND
&& self.look_ahead(1u) == token::LT {
self.bump(); self.bump();
let ty = self.parse_ty(false);
self.expect(token::GT);
/* hack: early return to take advantage of specialized function */
ret pexpr(self.mk_mac_expr(lo, self.span.hi,
mac_embed_type(ty)));
} else if self.token == token::POUND
&& self.look_ahead(1u) == token::LBRACE {
self.bump(); self.bump();
let blk = mac_embed_block(
self.parse_block_tail(lo, default_blk));
ret pexpr(self.mk_mac_expr(lo, self.span.hi, blk));
} else if self.token == token::ELLIPSIS {
self.bump();
ret pexpr(self.mk_mac_expr(lo, self.span.hi, mac_ellipsis));

View File

@ -728,7 +728,7 @@ fn print_block_with_attrs(s: ps, blk: ast::blk, attrs: ~[ast::attribute]) {
print_possibly_embedded_block_(s, blk, block_normal, indent_unit, attrs);
}
enum embed_type { block_macro, block_block_fn, block_normal, }
enum embed_type { block_block_fn, block_normal, }
fn print_possibly_embedded_block(s: ps, blk: ast::blk, embedded: embed_type,
indented: uint) {
@ -747,7 +747,6 @@ fn print_possibly_embedded_block_(s: ps, blk: ast::blk, embedded: embed_type,
let ann_node = node_block(s, blk);
s.ann.pre(ann_node);
alt embedded {
block_macro { word(s.s, ~"#{"); end(s); }
block_block_fn { end(s); }
block_normal { bopen(s); }
}
@ -841,14 +840,6 @@ fn print_mac(s: ps, m: ast::mac) {
for tts.each() |tt| { print_tt(s, tt); }
bclose(s, m.span);
}
ast::mac_embed_type(ty) {
word(s.s, ~"#<");
print_type(s, ty);
word(s.s, ~">");
}
ast::mac_embed_block(blk) {
print_possibly_embedded_block(s, blk, block_normal, indent_unit);
}
ast::mac_ellipsis { word(s.s, ~"..."); }
ast::mac_var(v) { word(s.s, #fmt("$%u", v)); }
_ { /* fixme */ }

View File

@ -351,8 +351,6 @@ fn visit_mac<E>(m: mac, e: E, v: vt<E>) {
ast::mac_invoc(pth, arg, body) {
option::map(arg, |arg| v.visit_expr(arg, e, v)); }
ast::mac_invoc_tt(pth, tt) { /* no user-serviceable parts inside */ }
ast::mac_embed_type(ty) { v.visit_ty(ty, e, v); }
ast::mac_embed_block(blk) { v.visit_block(blk, e, v); }
ast::mac_ellipsis { }
ast::mac_aq(_, e) { /* FIXME: maybe visit (Issue #2340) */ }
ast::mac_var(_) { }