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)
| 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() { |
no test coverage detected