diff --git a/src/comp/front/ext.rs b/src/comp/front/ext.rs index f1c065eeeb4..0d34c8389cb 100644 --- a/src/comp/front/ext.rs +++ b/src/comp/front/ext.rs @@ -2,6 +2,7 @@ import std::option; import std::map::hashmap; import driver::session::session; +import front::parser::parser; import util::common::span; import util::common::new_str_hash; @@ -24,13 +25,17 @@ fn syntax_expander_table() -> hashmap[str, syntax_extension] { } type span_msg_fn = fn (span sp, str msg) -> !; +type next_ann_fn = fn () -> ast::ann; // Provides a limited set of services necessary for syntax extensions // to do their thing type ext_ctxt = rec(span_msg_fn span_err, - span_msg_fn span_unimpl); + span_msg_fn span_unimpl, + next_ann_fn next_ann); + +fn mk_ctxt(parser parser) -> ext_ctxt { + auto sess = parser.get_session(); -fn mk_ctxt(session sess) -> ext_ctxt { fn ext_span_err_(session sess, span sp, str msg) -> ! { sess.span_err(sp, msg); } @@ -41,8 +46,12 @@ fn mk_ctxt(session sess) -> ext_ctxt { } auto ext_span_unimpl = bind ext_span_unimpl_(sess, _, _); + fn ext_next_ann_(parser parser) -> ast::ann { parser.get_ann() } + auto ext_next_ann = bind ext_next_ann_(parser); + ret rec(span_err = ext_span_err, - span_unimpl = ext_span_unimpl); + span_unimpl = ext_span_unimpl, + next_ann = ext_next_ann); } // diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs index f23a1eece2d..1663585971a 100644 --- a/src/comp/front/parser.rs +++ b/src/comp/front/parser.rs @@ -1048,7 +1048,7 @@ fn expand_syntax_ext(&parser p, common::span sp, p.err("unknown syntax expander: '" + extname + "'"); } case (some(ext::x(?ext))) { - auto ext_cx = ext::mk_ctxt(p.get_session()); + auto ext_cx = ext::mk_ctxt(p); ret ast::expr_ext(path, args, body, ext(ext_cx, p, sp, args, body), p.get_ann());