about summary refs log tree commit diff
path: root/src/libsyntax/ext/tt
diff options
context:
space:
mode:
authorSteven Fackler <sfackler@gmail.com>2014-01-25 13:34:26 -0800
committerSteven Fackler <sfackler@gmail.com>2014-01-25 13:55:39 -0800
commitab5bbd3c17e435b00d3ffaf820972b13779a9a46 (patch)
tree483e620169a390f5f2dbb404cf19a325dbdee008 /src/libsyntax/ext/tt
parentde57a22b9a8c8416cace31c9bd3ec4c9a6888017 (diff)
downloadrust-ab5bbd3c17e435b00d3ffaf820972b13779a9a46.tar.gz
rust-ab5bbd3c17e435b00d3ffaf820972b13779a9a46.zip
Simplify and rename macro API
Now that procedural macros can be implemented outside of the compiler,
it's more important to have a reasonable API to work with. Here are the
basic changes:

* Rename SyntaxExpanderTTTrait to MacroExpander, SyntaxExpanderTT to
    BasicMacroExpander, etc. I think "procedural macro" is the right
    term for these now, right? The other option would be SynExtExpander
    or something like that.

* Stop passing the SyntaxContext to extensions. This was only ever used
    by macro_rules, which doesn't even use it anymore. I can't think of
    a context in which an external extension would need it, and removal
    allows the API to be significantly simpler - no more
    SyntaxExpanderTTItemExpanderWithoutContext wrappers to worry about.
Diffstat (limited to 'src/libsyntax/ext/tt')
-rw-r--r--src/libsyntax/ext/tt/macro_rules.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs
index facbee135ed..aabd9c694f7 100644
--- a/src/libsyntax/ext/tt/macro_rules.rs
+++ b/src/libsyntax/ext/tt/macro_rules.rs
@@ -13,7 +13,7 @@ use ast::{TTDelim};
 use ast;
 use codemap::{Span, Spanned, DUMMY_SP};
 use ext::base::{AnyMacro, ExtCtxt, MacResult, MRAny, MRDef, MacroDef};
-use ext::base::{NormalTT, SyntaxExpanderTTTrait};
+use ext::base::{NormalTT, MacroExpander};
 use ext::base;
 use ext::tt::macro_parser::{Success, Error, Failure};
 use ext::tt::macro_parser::{NamedMatch, MatchedSeq, MatchedNonterminal};
@@ -87,18 +87,17 @@ impl AnyMacro for ParserAnyMacro {
     }
 }
 
-struct MacroRulesSyntaxExpanderTTFun {
+struct MacroRulesMacroExpander {
     name: Ident,
     lhses: @~[@NamedMatch],
     rhses: @~[@NamedMatch],
 }
 
-impl SyntaxExpanderTTTrait for MacroRulesSyntaxExpanderTTFun {
+impl MacroExpander for MacroRulesMacroExpander {
     fn expand(&self,
               cx: &mut ExtCtxt,
               sp: Span,
-              arg: &[ast::TokenTree],
-              _: ast::SyntaxContext)
+              arg: &[ast::TokenTree])
               -> MacResult {
         generic_extension(cx, sp, self.name, arg, *self.lhses, *self.rhses)
     }
@@ -175,8 +174,7 @@ fn generic_extension(cx: &ExtCtxt,
 pub fn add_new_extension(cx: &mut ExtCtxt,
                          sp: Span,
                          name: Ident,
-                         arg: ~[ast::TokenTree],
-                         _: ast::SyntaxContext)
+                         arg: ~[ast::TokenTree])
                          -> base::MacResult {
     // these spans won't matter, anyways
     fn ms(m: Matcher_) -> Matcher {
@@ -224,7 +222,7 @@ pub fn add_new_extension(cx: &mut ExtCtxt,
         _ => cx.span_bug(sp, "wrong-structured rhs")
     };
 
-    let exp = ~MacroRulesSyntaxExpanderTTFun {
+    let exp = ~MacroRulesMacroExpander {
         name: name,
         lhses: lhses,
         rhses: rhses,