From 72ee6af4d4e4d16a81e3f518f9c75f513a9a7dea Mon Sep 17 00:00:00 2001 From: John Clements Date: Thu, 5 Sep 2013 14:14:31 -0700 Subject: [PATCH] compare macro tokens hygienically (commented out) --- src/libsyntax/ext/tt/macro_parser.rs | 16 +++++++++++++++- src/libsyntax/parse/parser.rs | 5 ++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 7a9e916421c..f859a656d1f 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -234,6 +234,19 @@ pub fn parse_or_else( } } +// temporary for testing +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 + } + } +} + pub fn parse( sess: @mut ParseSess, cfg: ast::CrateConfig, @@ -343,7 +356,8 @@ pub fn parse( match_nonterminal(_,_,_) => { bb_eis.push(ei) } match_tok(ref t) => { let mut ei_t = ei.clone(); - if (*t) == tok { + if (token_name_eq(t,&tok)) { + //if (token::mtwt_token_eq(t,&tok)) { ei_t.idx += 1; next_eis.push(ei_t); } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 51c5522ae2f..62abe3850c9 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3518,7 +3518,10 @@ impl Parser { } fn is_self_ident(&self) -> bool { - *self.token == token::IDENT(special_idents::self_, false) + match *self.token { + token::IDENT(id, false) => id.name == special_idents::self_.name, + _ => false + } } fn expect_self_ident(&self) {