pub struct ParserLimits { /* private fields */ }Expand description
Resource budgets applied while tokenizing and parsing one formula.
Start from ParserLimits::default and adjust individual budgets with the
with_* setters. Values are stored exactly as given: nothing is clamped,
and a zero budget rejects every input that needs that resource.
use formualizer_parse::{Parser, ParserLimits};
let limits = ParserLimits::default().with_ast_nodes(64).with_tokens(128);
assert_eq!(limits.ast_nodes(), 64);
let ast = Parser::builder().limits(limits).parse("=SUM(A1:B2)").unwrap();Implementations§
Source§impl ParserLimits
impl ParserLimits
Sourcepub const fn with_source_bytes(self, source_bytes: usize) -> Self
pub const fn with_source_bytes(self, source_bytes: usize) -> Self
Maximum UTF-8 source length in bytes.
Sourcepub const fn with_tokens(self, tokens: usize) -> Self
pub const fn with_tokens(self, tokens: usize) -> Self
Maximum number of tokens, including retained whitespace tokens.
Sourcepub const fn with_ast_nodes(self, ast_nodes: usize) -> Self
pub const fn with_ast_nodes(self, ast_nodes: usize) -> Self
Maximum number of AST nodes, including omitted arguments.
Sourcepub const fn with_pratt_frames(self, pratt_frames: usize) -> Self
pub const fn with_pratt_frames(self, pratt_frames: usize) -> Self
Maximum active Pratt-parser frames (see Self::pratt_frames).
Raising this above the default needs a correspondingly larger stack on the parsing thread.
Sourcepub const fn with_ast_height(self, ast_height: usize) -> Self
pub const fn with_ast_height(self, ast_height: usize) -> Self
Maximum AST height, counting the root as one.
The default (256) is tested on a 1 MiB thread stack in release builds through parsing, workbook evaluation and XLSX cache recalculation. Raising it needs about 2.5 KiB more stack per level (up to 4.2 KiB for right-nested shapes; release, x86-64) on every thread that parses, clones, drops or evaluates the tree.
pub const fn source_bytes(self) -> usize
pub const fn tokens(self) -> usize
pub const fn ast_nodes(self) -> usize
Sourcepub const fn pratt_frames(self) -> usize
pub const fn pratt_frames(self) -> usize
Active Pratt frames, not an exact Excel function-nesting limit. The default leaves headroom for ordinary 64-level calls/parentheses and IF conditions; right-nested parenthesized infix uses two frames per level.