pub struct ParseBudget {
pub max_errors: usize,
pub max_depth: usize,
pub max_tokens_skipped: usize,
pub max_recoveries: usize,
}Expand description
Parse error, budget, and output types. Error types and result aliases used by the parser engine. Budget limits for parser operations to prevent runaway parsing.
These limits ensure the parser terminates in bounded time even when processing malformed or adversarial input. Each budget parameter has a sensible default that works for most real-world Perl code.
§Usage
use perl_error::ParseBudget;
// Use defaults for normal parsing
let budget = ParseBudget::default();
// Stricter limits for untrusted input
let strict = ParseBudget {
max_errors: 10,
max_depth: 64,
max_tokens_skipped: 100,
max_recoveries: 50,
};Fields§
§max_errors: usizeMaximum number of errors to collect before giving up. After this limit, parsing stops to avoid flooding diagnostics. Default: 100
max_depth: usizeMaximum nesting depth for recursive constructs (blocks, expressions). Prevents stack overflow on deeply nested input. Default: 256
max_tokens_skipped: usizeMaximum tokens to skip during a single recovery attempt. Prevents infinite loops when recovery can’t find a sync point. Default: 1000
max_recoveries: usizeMaximum number of recovery attempts per parse. Bounds total recovery work to prevent pathological cases. Default: 500
Implementations§
Source§impl ParseBudget
impl ParseBudget
Sourcepub fn for_ide() -> ParseBudget
pub fn for_ide() -> ParseBudget
Create a budget suitable for IDE/LSP usage with generous limits.
Sourcepub fn strict() -> ParseBudget
pub fn strict() -> ParseBudget
Create a strict budget for parsing untrusted input.
Sourcepub fn unlimited() -> ParseBudget
pub fn unlimited() -> ParseBudget
Create an unlimited budget (use with caution).
Trait Implementations§
Source§impl Clone for ParseBudget
impl Clone for ParseBudget
Source§fn clone(&self) -> ParseBudget
fn clone(&self) -> ParseBudget
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more