rustc: Hide the parser from syntax extensions
Eventually extensions will probably need access to the parser again, but it'll be in a different form.
This commit is contained in:
parent
c88fa92de4
commit
4b566fe7f9
@ -6,7 +6,7 @@ import front::parser::parser;
|
||||
import util::common::span;
|
||||
import util::common::new_str_hash;
|
||||
|
||||
type syntax_expander = fn(&ext_ctxt, &parser::parser, span,
|
||||
type syntax_expander = fn(&ext_ctxt, span,
|
||||
&vec[@ast::expr],
|
||||
option::t[str]) -> @ast::expr;
|
||||
|
||||
|
@ -15,9 +15,7 @@ import ext::*;
|
||||
|
||||
export expand_syntax_ext;
|
||||
|
||||
|
||||
fn expand_syntax_ext(&ext_ctxt cx,
|
||||
&parser::parser p,
|
||||
common::span sp,
|
||||
&vec[@ast::expr] args,
|
||||
option::t[str] body) -> @ast::expr {
|
||||
|
@ -4,7 +4,6 @@
|
||||
* compiler syntax extension plugin interface.
|
||||
*/
|
||||
|
||||
import front::parser::parser;
|
||||
import util::common;
|
||||
|
||||
import std::str;
|
||||
@ -20,7 +19,7 @@ import ext::*;
|
||||
export expand_syntax_ext;
|
||||
|
||||
fn expand_syntax_ext(&ext_ctxt cx,
|
||||
&parser p, common::span sp,
|
||||
common::span sp,
|
||||
&vec[@ast::expr] args,
|
||||
option::t[str] body) -> @ast::expr {
|
||||
|
||||
@ -36,7 +35,7 @@ fn expand_syntax_ext(&ext_ctxt cx,
|
||||
auto pieces = parse_fmt_string(fmt);
|
||||
auto args_len = vec::len[@ast::expr](args);
|
||||
auto fmt_args = vec::slice[@ast::expr](args, 1u, args_len - 1u);
|
||||
ret pieces_to_expr(cx, p, sp, pieces, args);
|
||||
ret pieces_to_expr(cx, sp, pieces, args);
|
||||
}
|
||||
|
||||
fn expr_to_str(&ext_ctxt cx, @ast::expr expr) -> str {
|
||||
@ -60,9 +59,8 @@ fn expr_to_str(&ext_ctxt cx, @ast::expr expr) -> str {
|
||||
|
||||
// FIXME: A lot of these functions for producing expressions can probably
|
||||
// be factored out in common with other code that builds expressions.
|
||||
// FIXME: Probably should be using the parser's span functions
|
||||
// FIXME: Cleanup the naming of these functions
|
||||
fn pieces_to_expr(&ext_ctxt cx, parser p, common::span sp,
|
||||
fn pieces_to_expr(&ext_ctxt cx, common::span sp,
|
||||
vec[piece] pieces, vec[@ast::expr] args) -> @ast::expr {
|
||||
|
||||
fn make_new_lit(&ext_ctxt cx,
|
||||
|
@ -1050,7 +1050,7 @@ fn expand_syntax_ext(&parser p, common::span sp,
|
||||
case (some(ext::x(?ext))) {
|
||||
auto ext_cx = ext::mk_ctxt(p);
|
||||
ret ast::expr_ext(path, args, body,
|
||||
ext(ext_cx, p, sp, args, body),
|
||||
ext(ext_cx, sp, args, body),
|
||||
p.get_ann());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user