diff options
| author | Kevin Atkinson <kevina@cs.utah.edu> | 2012-01-28 18:09:37 -0700 |
|---|---|---|
| committer | Kevin Atkinson <kevina@cs.utah.edu> | 2012-02-03 20:39:00 -0700 |
| commit | c0f9073557b5daed86aea411fb4c56e554583af2 (patch) | |
| tree | b38d5e2d5deabdd1b74de15c4d34d6ba5b4ecf36 /src/comp/syntax | |
| parent | 67e961c17f4f30a73d1730ce6eed3cb1d34b5125 (diff) | |
Expand result of quasi-quote.
Diffstat (limited to 'src/comp/syntax')
| -rw-r--r-- | src/comp/syntax/ext/expand.rs | 8 | ||||
| -rw-r--r-- | src/comp/syntax/ext/qquote.rs | 4 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/comp/syntax/ext/expand.rs b/src/comp/syntax/ext/expand.rs index 5c81da6f492..18dcdaf1ad1 100644 --- a/src/comp/syntax/ext/expand.rs +++ b/src/comp/syntax/ext/expand.rs @@ -46,7 +46,13 @@ fn expand_expr(exts: hashmap<str, syntax_extension>, cx: ext_ctxt, } } } - mac_qq(sp, exp) { (expand_qquote(cx, sp, exp), s) } + mac_qq(sp, exp) { + let r = expand_qquote(cx, sp, exp); + // need to keep going, resuls may contain embedded qquote or + // macro that need expanding + let r2 = fld.fold_expr(r); + (r2.node, s) + } _ { cx.span_bug(mac.span, "naked syntactic bit") } } } diff --git a/src/comp/syntax/ext/qquote.rs b/src/comp/syntax/ext/qquote.rs index b5ca673908e..fc4e0599c2f 100644 --- a/src/comp/syntax/ext/qquote.rs +++ b/src/comp/syntax/ext/qquote.rs @@ -38,7 +38,7 @@ fn visit_expr_aq(expr: @ast::expr, &&cx: aq_ctxt, v: vt<aq_ctxt>) } } -fn expand_qquote(ecx: ext_ctxt, sp: span, e: @ast::expr) -> ast::expr_ { +fn expand_qquote(ecx: ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr { let str = codemap::span_to_snippet(sp, ecx.session().parse_sess.cm); let qcx = gather_anti_quotes(sp.lo, e); let cx = qcx; @@ -89,7 +89,7 @@ fn expand_qquote(ecx: ext_ctxt, sp: span, e: @ast::expr) -> ast::expr_ { mk_vec_e(cx,sp, vec::map(qcx.gather, {|g| g.e}))]); } - ret rcall.node; + ret rcall; } fn replace(e: @ast::expr, repls: [@ast::expr]) -> @ast::expr { |
