MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / expect_token

Function expect_token

nodedb/src/control/planner/procedural/parser/utils.rs:21–35  ·  view source on GitHub ↗
(
    tokens: &[Token],
    pos: &mut usize,
    expected: &Token,
)

Source from the content-addressed store, hash-verified

19}
20
21pub(super) fn expect_token(
22 tokens: &[Token],
23 pos: &mut usize,
24 expected: &Token,
25) -> Result<(), ProceduralError> {
26 if *pos < tokens.len() && token_matches(&tokens[*pos], expected) {
27 *pos += 1;
28 Ok(())
29 } else {
30 Err(ProceduralError::parse(format!(
31 "expected {expected:?} at position {pos}, got {:?}",
32 tokens.get(*pos)
33 )))
34 }
35}
36
37pub(super) fn expect_ident(tokens: &[Token], pos: &mut usize) -> Result<String, ProceduralError> {
38 match tokens.get(*pos) {

Callers 7

skip_tokenFunction · 0.70
parse_blockFunction · 0.70
parse_assignFunction · 0.70
parse_ifFunction · 0.70
parse_whileFunction · 0.70
parse_forFunction · 0.70
parse_loopFunction · 0.70

Calls 3

token_matchesFunction · 0.85
parseFunction · 0.50
lenMethod · 0.45

Tested by

no test coverage detected