Scans the next non-comment token. Returns a pending token if one was put back via `put_back`.
(&mut self)
| 60 | /// Scans the next non-comment token. Returns a pending token if one |
| 61 | /// was put back via `put_back`. |
| 62 | pub fn scan(&mut self) -> Result<Option<Token<'a>>, ParseError> { |
| 63 | if let Some(token) = self.pending_token.take() { |
| 64 | return Ok(Some(token)); |
| 65 | } |
| 66 | loop { |
| 67 | match self.scanner.scan()? { |
| 68 | Some(Token::CommentLine(_) | Token::CommentBlock(_)) => { |
| 69 | if !self.allow_comments { |
| 70 | return Err( |
| 71 | self |
| 72 | .scanner |
| 73 | .create_error_for_current_token(ParseErrorKind::CommentsNotAllowed), |
| 74 | ); |
| 75 | } |
| 76 | continue; |
| 77 | } |
| 78 | token => return Ok(token), |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | /// Puts a token back so the next `scan()` returns it. |
| 84 | #[cfg(feature = "serde")] |
no test coverage detected