about summary refs log tree commit diff
path: root/src/libsyntax/parse/lexer
diff options
context:
space:
mode:
authorNick Cameron <ncameron@mozilla.com>2014-11-03 17:52:00 +1300
committerNick Cameron <ncameron@mozilla.com>2014-11-03 17:52:00 +1300
commit3ceb0112ef307d4d280dda8aca4aa7d4a34eb3f6 (patch)
treed891f1afdb8c2e0ccc35dba7425486fbaa625980 /src/libsyntax/parse/lexer
parentdcc5c3b31b294a19c369e7b1926528610230686d (diff)
downloadrust-3ceb0112ef307d4d280dda8aca4aa7d4a34eb3f6.tar.gz
rust-3ceb0112ef307d4d280dda8aca4aa7d4a34eb3f6.zip
Ignore whitespace tokens when re-computing spans in save_analysis
Diffstat (limited to 'src/libsyntax/parse/lexer')
-rw-r--r--src/libsyntax/parse/lexer/mod.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs
index 293b91111b5..1bc1d42d888 100644
--- a/src/libsyntax/parse/lexer/mod.rs
+++ b/src/libsyntax/parse/lexer/mod.rs
@@ -35,6 +35,19 @@ pub trait Reader {
     /// Report a non-fatal error with the current span.
     fn err(&self, &str);
     fn peek(&self) -> TokenAndSpan;
+    /// Get a token the parser cares about.
+    fn real_token(&mut self) -> TokenAndSpan {
+        let mut t = self.next_token();
+        loop {
+            match t.tok {
+                token::Whitespace | token::Comment | token::Shebang(_) => {
+                    t = self.next_token();
+                },
+                _ => break
+            }
+        }
+        t
+    }
 }
 
 #[deriving(Clone, PartialEq, Eq, Show)]