MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / error_at

Method error_at

compiler/src/modules/parser/mod.rs:323–344  ·  view source on GitHub ↗

Diagnostic at caller span + panic-mode sync; stops at statement boundary or bracket close. */

(&mut self, start: usize, end: usize, msg: &str)

Source from the content-addressed store, hash-verified

321
322 /* Diagnostic at caller span + panic-mode sync; stops at statement boundary or bracket close. */
323 pub(super) fn error_at(&mut self, start: usize, end: usize, msg: &str) {
324 self.errors.push(Diagnostic { start, end, msg: msg.to_string() });
325 let in_brackets = !self.bracket_stack.is_empty();
326 let mut depth: i32 = 0;
327 loop {
328 let kind = self.tokens.peek().map(|t| t.kind);
329 match kind {
330 None | Some(TokenType::Newline | TokenType::Dedent | TokenType::Endmarker) => break,
331 Some(TokenType::Comma) if in_brackets && depth == 0 => break,
332 Some(TokenType::Rpar | TokenType::Rsqb | TokenType::Rbrace) => {
333 if in_brackets && depth == 0 { break; }
334 depth -= 1;
335 self.tokens.next();
336 }
337 Some(TokenType::Lpar | TokenType::Lsqb | TokenType::Lbrace) => {
338 depth += 1;
339 self.tokens.next();
340 }
341 _ => { self.tokens.next(); }
342 }
343 }
344 }
345
346 pub(super) fn at_end(&mut self) -> bool { self.peek().is_none() }
347

Callers 11

stmtMethod · 0.80
name_stmtMethod · 0.80
fstringMethod · 0.80
errorMethod · 0.80
eatMethod · 0.80
parse_or_get_cachedMethod · 0.80
resolve_and_bind_allMethod · 0.80
resolve_and_bind_starMethod · 0.80
parse_atomMethod · 0.80

Calls 4

pushMethod · 0.80
nextMethod · 0.80
is_emptyMethod · 0.45
peekMethod · 0.45

Tested by

no test coverage detected