From 72ee6af4d4e4d16a81e3f518f9c75f513a9a7dea Mon Sep 17 00:00:00 2001 From: John Clements Date: Thu, 5 Sep 2013 14:14:31 -0700 Subject: compare macro tokens hygienically (commented out) --- src/libsyntax/ext/tt/macro_parser.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/libsyntax/ext') 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); } -- cgit 1.4.1-3-g733a5