]> git.lizzy.rs Git - rust.git/commitdiff
comments only
authorJohn Clements <clements@racket-lang.org>
Wed, 29 May 2013 23:21:04 +0000 (16:21 -0700)
committerJohn Clements <clements@racket-lang.org>
Fri, 6 Sep 2013 20:35:08 +0000 (13:35 -0700)
src/libsyntax/ast.rs
src/libsyntax/ast_util.rs
src/libsyntax/ext/expand.rs
src/libsyntax/ext/tt/macro_rules.rs

index 8e974cae86e9f4c20c1e4e1763201f3772f3bf71..cf8fe905d1a367d9b1c739feb65a4c98e0edc331 100644 (file)
@@ -642,6 +642,7 @@ pub enum matcher_ {
     // lo, hi position-in-match-array used:
     match_seq(~[matcher], Option<::parse::token::Token>, bool, uint, uint),
     // parse a Rust NT: name to bind, name of NT, position in match array:
+    // NOTE: 'name of NT' shouldnt really be represented as an ident, should it?
     match_nonterminal(Ident, Ident, uint)
 }
 
index aeca145ea180bbd33f6e59ad8a33ec1a6d9e6fbe..4c0ad816afbe337d73d0e5a1b4b3d4eabb6ea24c 100644 (file)
@@ -28,6 +28,8 @@ pub fn path_name_i(idents: &[Ident]) -> ~str {
     idents.map(|i| token::interner_get(i.name)).connect("::")
 }
 
+// totally scary function: ignores all but the last element, should have
+// a different name
 pub fn path_to_ident(path: &Path) -> Ident {
     path.segments.last().identifier
 }
index 25edcf63faacff6644cfd55ac4667a67efb7b0be..039ca36b55617cf45c5ddcc78c55c229fd24dc16 100644 (file)
@@ -1480,6 +1480,8 @@ fn automatic_renaming () {
                 // 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!
index 50eb03fc96e691b3d31fa0a1e00a643039a2d0d9..2145e4297e7967399f65abc6ea82f771c1b6b0f2 100644 (file)
 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 @@ fn ms(m: matcher_) -> matcher {
     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)),