Get the current lookahead token, after making sure there is one.
(&mut self)
| 480 | |
| 481 | // Get the current lookahead token, after making sure there is one. |
| 482 | fn token(&mut self) -> Option<Token<'a>> { |
| 483 | while self.lookahead.is_none() { |
| 484 | match self.lex.next() { |
| 485 | Some(Ok(LocatedToken { token, location })) => { |
| 486 | match token { |
| 487 | Token::Comment(text) => { |
| 488 | if self.gathering_comments { |
| 489 | self.gathered_comments.push(text); |
| 490 | } |
| 491 | } |
| 492 | _ => self.lookahead = Some(token), |
| 493 | } |
| 494 | self.loc = location; |
| 495 | } |
| 496 | Some(Err(LocatedError { error, location })) => { |
| 497 | self.lex_error = Some(error); |
| 498 | self.loc = location; |
| 499 | break; |
| 500 | } |
| 501 | None => break, |
| 502 | } |
| 503 | } |
| 504 | self.lookahead |
| 505 | } |
| 506 | |
| 507 | // Enable gathering of all comments encountered. |
| 508 | fn start_gathering_comments(&mut self) { |
no test coverage detected