MCPcopy Index your code
hub / github.com/endbasic/endbasic / handle_bad_read

Method handle_bad_read

core/src/lexer.rs:278–296  ·  view source on GitHub ↗

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,
    )

Source from the content-addressed store, hash-verified

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> {

Callers 7

consume_numberMethod · 0.80
consume_integerMethod · 0.80
consume_symbolMethod · 0.80
consume_textMethod · 0.80
consume_labelMethod · 0.80
readMethod · 0.80

Calls 3

is_separatorMethod · 0.80
peekMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected