(
tokens: &'a [Token],
position: &'a mut usize,
expected_kind: TokenKind,
message: &'a str,
)
| 3967 | |
| 3968 | #[inline(always)] |
| 3969 | pub(crate) fn consume_token_or_error<'a>( |
| 3970 | tokens: &'a [Token], |
| 3971 | position: &'a mut usize, |
| 3972 | expected_kind: TokenKind, |
| 3973 | message: &'a str, |
| 3974 | ) -> Result<&'a Token, Box<Diagnostic>> { |
| 3975 | if *position < tokens.len() && tokens[*position].kind == expected_kind { |
| 3976 | *position += 1; |
| 3977 | let index = *position - 1; |
| 3978 | return Ok(&tokens[index]); |
| 3979 | } |
| 3980 | |
| 3981 | Err(Diagnostic::error(message) |
| 3982 | .with_location(calculate_safe_location(tokens, *position)) |
| 3983 | .as_boxed()) |
| 3984 | } |
| 3985 | |
| 3986 | #[inline(always)] |
| 3987 | pub(crate) fn consume_conditional_token_or_errors<'a>( |
no test coverage detected
searching dependent graphs…