@@ -234,16 +234,12 @@ pub fn parse_or_else(
234
234
}
235
235
}
236
236
237
- // temporary for testing
237
+ // perform a token equality check, ignoring syntax context (that is, an unhygienic comparison)
238
238
pub fn token_name_eq(t1 : &Token, t2 : &Token) -> bool {
239
- if (*t1 == *t2) {
240
- true
241
- } else {
242
- match (t1,t2) {
243
- (&token::IDENT(id1,_),&token::IDENT(id2,_)) =>
244
- id1.name == id2.name,
245
- _ => false
246
- }
239
+ match (t1,t2) {
240
+ (&token::IDENT(id1,_),&token::IDENT(id2,_)) =>
241
+ id1.name == id2.name,
242
+ _ => *t1 == *t2
247
243
}
248
244
}
249
245
@@ -310,7 +306,10 @@ pub fn parse(
310
306
// the *_t vars are workarounds for the lack of unary move
311
307
match ei. sep {
312
308
Some ( ref t) if idx == len => { // we need a separator
313
- if tok == ( * t) { //pass the separator
309
+ // i'm conflicted about whether this should be hygienic....
310
+ // though in this case, if the separators are never legal
311
+ // idents, it shouldn't matter.
312
+ if token_name_eq ( & tok, t) { //pass the separator
314
313
let mut ei_t = ei. clone ( ) ;
315
314
ei_t. idx += 1 ;
316
315
next_eis. push ( ei_t) ;
@@ -367,7 +366,7 @@ pub fn parse(
367
366
}
368
367
369
368
/* error messages here could be improved with links to orig. rules */
370
- if tok == EOF {
369
+ if token_name_eq ( & tok, & EOF ) {
371
370
if eof_eis. len ( ) == 1 u {
372
371
let mut v = ~[ ] ;
373
372
for dv in eof_eis[ 0 u] . matches . mut_iter ( ) {
0 commit comments