Skip to content

Commit 98a6cbd

Browse files
committed
comments only
1 parent 91d3c36 commit 98a6cbd

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

src/libsyntax/ast.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,7 @@ pub enum matcher_ {
642642
// lo, hi position-in-match-array used:
643643
match_seq(~[matcher], Option<::parse::token::Token>, bool, uint, uint),
644644
// parse a Rust NT: name to bind, name of NT, position in match array:
645+
// NOTE: 'name of NT' shouldnt really be represented as an ident, should it?
645646
match_nonterminal(Ident, Ident, uint)
646647
}
647648

src/libsyntax/ast_util.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ pub fn path_name_i(idents: &[Ident]) -> ~str {
2828
idents.map(|i| token::interner_get(i.name)).connect("::")
2929
}
3030

31+
// totally scary function: ignores all but the last element, should have
32+
// a different name
3133
pub fn path_to_ident(path: &Path) -> Ident {
3234
path.segments.last().identifier
3335
}

src/libsyntax/ext/expand.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,6 +1480,8 @@ mod test {
14801480
// other, so the result of the whole thing should be "let z_123 = 3; z_123"
14811481
@"macro_rules! g (($x:ident) => ({macro_rules! f(($y:ident)=>({let $y=3;$x}));f!($x)}))
14821482
fn a(){g!(z)}"
1483+
// create a really evil test case where a $x appears inside a binding of $x but *shouldnt*
1484+
// bind because it was inserted by a different macro....
14831485
];
14841486
for s in teststrs.iter() {
14851487
// we need regexps to test these!

src/libsyntax/ext/tt/macro_rules.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,15 @@ use parse::token::{get_ident_interner, special_idents, gensym_ident, ident_to_st
2323
use parse::token::{FAT_ARROW, SEMI, nt_matchers, nt_tt};
2424
use print;
2525

26+
// this procedure performs the expansion of the
27+
// macro_rules! macro. It parses the RHS and adds
28+
// an extension to the current context.
2629
pub fn add_new_extension(cx: @ExtCtxt,
2730
sp: Span,
2831
name: Ident,
2932
arg: ~[ast::token_tree])
3033
-> base::MacResult {
34+
// Wrap a matcher_ in a spanned to produce a matcher.
3135
// these spans won't matter, anyways
3236
fn ms(m: matcher_) -> matcher {
3337
Spanned {
@@ -39,11 +43,13 @@ pub fn add_new_extension(cx: @ExtCtxt,
3943
let lhs_nm = gensym_ident("lhs");
4044
let rhs_nm = gensym_ident("rhs");
4145

46+
// The pattern that macro_rules matches.
4247
// The grammar for macro_rules! is:
4348
// $( $lhs:mtcs => $rhs:tt );+
4449
// ...quasiquoting this would be nice.
4550
let argument_gram = ~[
4651
ms(match_seq(~[
52+
// NOTE : probably just use an enum for the NT_name ?
4753
ms(match_nonterminal(lhs_nm, special_idents::matchers, 0u)),
4854
ms(match_tok(FAT_ARROW)),
4955
ms(match_nonterminal(rhs_nm, special_idents::tt, 1u)),

0 commit comments

Comments
 (0)