diff options
Diffstat (limited to 'src/libsyntax/ext/tt/macro_parser.rs')
| -rw-r--r-- | src/libsyntax/ext/tt/macro_parser.rs | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index f859a656d1f..ee7750bfd57 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -234,16 +234,12 @@ pub fn parse_or_else( } } -// temporary for testing +// perform a token equality check, ignoring syntax context (that is, an unhygienic comparison) pub fn token_name_eq(t1 : &Token, t2 : &Token) -> bool { - if (*t1 == *t2) { - true - } else { - match (t1,t2) { - (&token::IDENT(id1,_),&token::IDENT(id2,_)) => - id1.name == id2.name, - _ => false - } + match (t1,t2) { + (&token::IDENT(id1,_),&token::IDENT(id2,_)) => + id1.name == id2.name, + _ => *t1 == *t2 } } @@ -310,7 +306,10 @@ pub fn parse( // the *_t vars are workarounds for the lack of unary move match ei.sep { Some(ref t) if idx == len => { // we need a separator - if tok == (*t) { //pass the separator + // i'm conflicted about whether this should be hygienic.... + // though in this case, if the separators are never legal + // idents, it shouldn't matter. + if token_name_eq(&tok, t) { //pass the separator let mut ei_t = ei.clone(); ei_t.idx += 1; next_eis.push(ei_t); @@ -367,7 +366,7 @@ pub fn parse( } /* error messages here could be improved with links to orig. rules */ - if tok == EOF { + if token_name_eq(&tok, &EOF) { if eof_eis.len() == 1u { let mut v = ~[]; for dv in eof_eis[0u].matches.mut_iter() { |
