Handles an `input.next()` call that returned an unexpected character. This returns a `Token::Bad` with the provided `msg` and skips characters in the input stream until a field separator is found.
(
&mut self,
msg: S,
first_pos: LineCol,
)
| 276 | /// This returns a `Token::Bad` with the provided `msg` and skips characters in the input |
| 277 | /// stream until a field separator is found. |
| 278 | fn handle_bad_read<S: Into<String>>( |
| 279 | &mut self, |
| 280 | msg: S, |
| 281 | first_pos: LineCol, |
| 282 | ) -> io::Result<TokenSpan> { |
| 283 | let mut len = 1; |
| 284 | loop { |
| 285 | match self.input.peek() { |
| 286 | Some(Ok(ch_span)) if ch_span.ch.is_separator() => break, |
| 287 | Some(Ok(_)) => { |
| 288 | self.input.next().unwrap()?; |
| 289 | len += 1; |
| 290 | } |
| 291 | Some(Err(_)) => return Err(self.input.next().unwrap().unwrap_err()), |
| 292 | None => break, |
| 293 | } |
| 294 | } |
| 295 | Ok(TokenSpan::new(Token::Bad(msg.into()), first_pos, len)) |
| 296 | } |
| 297 | |
| 298 | /// Consumes the number at the current position, whose first digit is `first`. |
| 299 | fn consume_number(&mut self, first: CharSpan) -> io::Result<TokenSpan> { |
no test coverage detected