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

Method expr_bp

compiler/src/modules/parser/expr.rs:38–55  ·  view source on GitHub ↗

Pratt parser: unary prefix then infix loop via `binding_power` table. Bounds every recursive descent (prefix `-`/`+`/`~`/`await`/`not`, right-associative `**`, infix right operands) so deep chains raise instead of overflowing the native/WASM stack. */

(&mut self, min_bp: u8)

Source from the content-addressed store, hash-verified

36
37 /* Pratt parser: unary prefix then infix loop via `binding_power` table. Bounds every recursive descent (prefix `-`/`+`/`~`/`await`/`not`, right-associative `**`, infix right operands) so deep chains raise instead of overflowing the native/WASM stack. */
38 pub(super) fn expr_bp(&mut self, min_bp: u8) {
39 self.expr_depth += 1;
40 if self.expr_depth > MAX_EXPR_DEPTH {
41 self.expr_depth -= 1;
42 self.error("expression too deeply nested");
43 return;
44 }
45 match self.peek() {
46 Some(TokenType::Not) => {
47 self.advance();
48 self.expr_bp(5);
49 self.chunk.emit(OpCode::Not, 0);
50 }
51 _ => self.parse_unary(),
52 }
53 self.infix_bp(min_bp);
54 self.expr_depth -= 1;
55 }
56
57 pub(super) fn infix_bp(&mut self, min_bp: u8) {
58 while let Some(tok) = self.peek() {

Callers 5

comprehension_loopMethod · 0.80
parse_simple_patternMethod · 0.80
exprMethod · 0.80
infix_bpMethod · 0.80
parse_unaryMethod · 0.80

Calls 6

errorMethod · 0.80
advanceMethod · 0.80
emitMethod · 0.80
parse_unaryMethod · 0.80
infix_bpMethod · 0.80
peekMethod · 0.45

Tested by

no test coverage detected