MCPcopy Index your code
hub / github.com/GraphLite-AI/GraphLite / expect_token

Function expect_token

graphlite/src/ast/parser.rs:3450–3468  ·  view source on GitHub ↗

Expect a specific token

(expected: Token)

Source from the content-addressed store, hash-verified

3448
3449/// Expect a specific token
3450fn expect_token(expected: Token) -> impl Fn(&[Token]) -> IResult<&[Token], Token> {
3451 move |tokens: &[Token]| {
3452 if let Some(token) = tokens.first() {
3453 if std::mem::discriminant(token) == std::mem::discriminant(&expected) {
3454 Ok((&tokens[1..], token.clone()))
3455 } else {
3456 Err(nom::Err::Error(nom::error::Error::new(
3457 tokens,
3458 nom::error::ErrorKind::Tag,
3459 )))
3460 }
3461 } else {
3462 Err(nom::Err::Error(nom::error::Error::new(
3463 tokens,
3464 nom::error::ErrorKind::Tag,
3465 )))
3466 }
3467 }
3468}
3469
3470// Helper function for tag_token (alias for expect_token for compatibility)
3471fn tag_token(expected: Token) -> impl Fn(&[Token]) -> IResult<&[Token], Token> {

Callers 15

final_mutationFunction · 0.85
parse_union_except_opFunction · 0.85
parse_intersect_opFunction · 0.85
select_statementFunction · 0.85
select_listFunction · 0.85
from_clauseFunction · 0.85
distinct_qualifierFunction · 0.85
call_statementFunction · 0.85
procedure_callFunction · 0.85
yield_clauseFunction · 0.85
yield_itemFunction · 0.85

Calls 3

ErrorEnum · 0.85
cloneMethod · 0.80
firstMethod · 0.45

Tested by

no test coverage detected