MCPcopy Index your code
hub / github.com/endbasic/endbasic / parse_if

Method parse_if

core/src/parser.rs:1163–1176  ·  view source on GitHub ↗

Parses an `IF` statement.

(&mut self, if_pos: LineCol)

Source from the content-addressed store, hash-verified

1161
1162 /// Parses an `IF` statement.
1163 fn parse_if(&mut self, if_pos: LineCol) -> Result<Statement> {
1164 let expr = self.parse_required_expr("No expression in IF statement")?;
1165 self.expect_and_consume(Token::Then, "No THEN in IF statement")?;
1166
1167 let mut branches = vec![IfBranchSpan { guard: expr, body: vec![] }];
1168
1169 let peeked = self.lexer.peek()?;
1170 match peeked.token {
1171 Token::Eol | Token::Eof => self.parse_if_multiline(if_pos, &mut branches)?,
1172 _ => self.parse_if_uniline(&mut branches)?,
1173 }
1174
1175 Ok(Statement::If(IfSpan { branches }))
1176 }
1177
1178 /// Advances until the next statement after failing to parse an `IF` statement.
1179 fn reset_if(&mut self, if_pos: LineCol) -> Result<()> {

Callers 1

parse_oneMethod · 0.80

Calls 5

parse_required_exprMethod · 0.80
expect_and_consumeMethod · 0.80
parse_if_multilineMethod · 0.80
parse_if_unilineMethod · 0.80
peekMethod · 0.45

Tested by

no test coverage detected