about summary refs log tree commit diff
path: root/src/libsyntax/ext
diff options
context:
space:
mode:
authorJohn Clements <clements@racket-lang.org>2013-07-10 11:52:39 -0700
committerJohn Clements <clements@racket-lang.org>2013-09-06 13:35:11 -0700
commitbc2a44daf1cf348da98de9553fccc23806e84f71 (patch)
tree9fbfee9de27cffc4bb02c95f03c6a28062a4aa71 /src/libsyntax/ext
parente29d25338d7b0374f3dd5976b57463e6aafab0ac (diff)
downloadrust-bc2a44daf1cf348da98de9553fccc23806e84f71.tar.gz
rust-bc2a44daf1cf348da98de9553fccc23806e84f71.zip
fix one remaining token comparison, refactor token comparison to avoid == check
Diffstat (limited to 'src/libsyntax/ext')
-rw-r--r--src/libsyntax/ext/tt/macro_parser.rs21
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() {