Skip to content

Commit 43c169d

Browse files
committed
---
yaml --- r: 79718 b: refs/heads/try c: 98a6cbd h: refs/heads/master v: v3
1 parent 8eee6d5 commit 43c169d

File tree

5 files changed

+12
-1
lines changed

5 files changed

+12
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: ba9fa89bfb4aae53db93e9ecac31807af96356fc
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 54ae2800ffb30513f89ce13d27ac3c8d095d98ac
5-
refs/heads/try: 91d3c364303c3a057feadd40adef0880531e08cc
5+
refs/heads/try: 98a6cbdba320b106690c01a354f91019020a82d0
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/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

branches/try/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
}

branches/try/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!

branches/try/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)