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

Function parse_statements

nodedb/src/control/planner/procedural/parser/mod.rs:44–70  ·  view source on GitHub ↗

Parse a sequence of statements until we hit END, ELSE, ELSIF, EXCEPTION, or end of tokens.

(
    tokens: &[Token],
    pos: &mut usize,
)

Source from the content-addressed store, hash-verified

42
43/// Parse a sequence of statements until we hit END, ELSE, ELSIF, EXCEPTION, or end of tokens.
44pub(crate) fn parse_statements(
45 tokens: &[Token],
46 pos: &mut usize,
47) -> Result<Vec<Statement>, ProceduralError> {
48 let mut stmts = Vec::new();
49
50 while *pos < tokens.len() {
51 match tokens.get(*pos) {
52 Some(
53 Token::End
54 | Token::EndIf
55 | Token::EndLoop
56 | Token::Else
57 | Token::Elsif
58 | Token::Exception,
59 ) => {
60 break;
61 }
62 None => break,
63 _ => {}
64 }
65
66 stmts.push(statements::parse_statement(tokens, pos)?);
67 }
68
69 Ok(stmts)
70}
71
72#[cfg(test)]
73mod tests {

Callers 5

parse_blockFunction · 0.85
parse_ifFunction · 0.85
parse_whileFunction · 0.85
parse_forFunction · 0.85
parse_loopFunction · 0.85

Calls 4

parse_statementFunction · 0.85
lenMethod · 0.45
getMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected