Ignore whitespace tokens when re-computing spans in save_analysis

This commit is contained in:
Nick Cameron
2014-11-03 17:52:00 +13:00
parent dcc5c3b31b
commit 3ceb0112ef
3 changed files with 29 additions and 29 deletions

View File

@@ -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)]