[][src]Function whenever_parser::lexer::eat

pub fn eat<'a>(
    input: &'a str
) -> Result<(Token<'a>, &'a str), (String, &'a str)>

Reads a token from the input.

Returns a token and a slice from the end of the token to the end of the input.

Note: difference between input and output slices may be more than the length of the token, as leading whitespace is ignored.

Errors

Will return Err if:

  • end of input is reached in an unfinished token (such as a string)
  • a number contains an invalid digit
  • token is not known (reminder: keywords are case sensitive)

Err's contents are a description of the issue and the slice where it happened.