MCPcopy Create free account
hub / github.com/AmrDeveloper/GQL / consume_token_or_error

Function consume_token_or_error

crates/gitql-parser/src/parser.rs:3969–3984  ·  view source on GitHub ↗
(
    tokens: &'a [Token],
    position: &'a mut usize,
    expected_kind: TokenKind,
    message: &'a str,
)

Source from the content-addressed store, hash-verified

3967
3968#[inline(always)]
3969pub(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)]
3987pub(crate) fn consume_conditional_token_or_errors<'a>(

Calls 4

calculate_safe_locationFunction · 0.85
as_boxedMethod · 0.80
with_locationMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…