summary refs log tree commit diff
path: root/src/libsyntax/ext
diff options
context:
space:
mode:
authorJohn Clements <clements@racket-lang.org>2013-05-29 16:21:04 -0700
committerJohn Clements <clements@racket-lang.org>2013-09-06 13:35:08 -0700
commit98a6cbdba320b106690c01a354f91019020a82d0 (patch)
treeab0ef06f87669c514a0102d2711d0d8ea0d513fd /src/libsyntax/ext
parent91d3c364303c3a057feadd40adef0880531e08cc (diff)
downloadrust-98a6cbdba320b106690c01a354f91019020a82d0.tar.gz
rust-98a6cbdba320b106690c01a354f91019020a82d0.zip
comments only
Diffstat (limited to 'src/libsyntax/ext')
-rw-r--r--src/libsyntax/ext/expand.rs2
-rw-r--r--src/libsyntax/ext/tt/macro_rules.rs6
2 files changed, 8 insertions, 0 deletions
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index 25edcf63faa..039ca36b556 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -1480,6 +1480,8 @@ mod test {
                 // other, so the result of the whole thing should be "let z_123 = 3; z_123"
                 @"macro_rules! g (($x:ident) => ({macro_rules! f(($y:ident)=>({let $y=3;$x}));f!($x)}))
                    fn a(){g!(z)}"
+                // create a really evil test case where a $x appears inside a binding of $x but *shouldnt*
+                // bind because it was inserted by a different macro....
             ];
         for s in teststrs.iter() {
             // we need regexps to test these!
diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs
index 50eb03fc96e..2145e4297e7 100644
--- a/src/libsyntax/ext/tt/macro_rules.rs
+++ b/src/libsyntax/ext/tt/macro_rules.rs
@@ -23,11 +23,15 @@ use parse::token::{get_ident_interner, special_idents, gensym_ident, ident_to_st
 use parse::token::{FAT_ARROW, SEMI, nt_matchers, nt_tt};
 use print;
 
+// this procedure performs the expansion of the
+// macro_rules! macro. It parses the RHS and adds
+// an extension to the current context.
 pub fn add_new_extension(cx: @ExtCtxt,
                          sp: Span,
                          name: Ident,
                          arg: ~[ast::token_tree])
                       -> base::MacResult {
+    // Wrap a matcher_ in a spanned to produce a matcher.
     // these spans won't matter, anyways
     fn ms(m: matcher_) -> matcher {
         Spanned {
@@ -39,11 +43,13 @@ pub fn add_new_extension(cx: @ExtCtxt,
     let lhs_nm =  gensym_ident("lhs");
     let rhs_nm =  gensym_ident("rhs");
 
+    // The pattern that macro_rules matches.
     // The grammar for macro_rules! is:
     // $( $lhs:mtcs => $rhs:tt );+
     // ...quasiquoting this would be nice.
     let argument_gram = ~[
         ms(match_seq(~[
+            // NOTE : probably just use an enum for the NT_name ?
             ms(match_nonterminal(lhs_nm, special_idents::matchers, 0u)),
             ms(match_tok(FAT_ARROW)),
             ms(match_nonterminal(rhs_nm, special_idents::tt, 1u)),