From 4b566fe7f9d9571c5933fd0dad18bf83d57dea5e Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sat, 4 Jun 2011 17:47:36 -0400 Subject: [PATCH] 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. --- src/comp/front/ext.rs | 2 +- src/comp/front/extenv.rs | 2 -- src/comp/front/extfmt.rs | 8 +++----- src/comp/front/parser.rs | 2 +- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/comp/front/ext.rs b/src/comp/front/ext.rs index 0d34c8389cb..d08fc3ef7d5 100644 --- a/src/comp/front/ext.rs +++ b/src/comp/front/ext.rs @@ -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; diff --git a/src/comp/front/extenv.rs b/src/comp/front/extenv.rs index a99ef94e07f..62e39c8488b 100644 --- a/src/comp/front/extenv.rs +++ b/src/comp/front/extenv.rs @@ -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 { diff --git a/src/comp/front/extfmt.rs b/src/comp/front/extfmt.rs index c2f7cd79308..0b5e399f332 100644 --- a/src/comp/front/extfmt.rs +++ b/src/comp/front/extfmt.rs @@ -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, diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs index 1663585971a..62ba7325f99 100644 --- a/src/comp/front/parser.rs +++ b/src/comp/front/parser.rs @@ -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()); } }