Skip to main content

MAX_QUANTIFIER_BOUND

Constant MAX_QUANTIFIER_BOUND 

Source
const MAX_QUANTIFIER_BOUND: u32 = 1000;
Expand description

Largest bound accepted in a {n} / {n,} / {n,m} / {,m} range quantifier.

Nfa::compile expands a range quantifier eagerly: min mandatory copies of the inner pattern plus max - min optional copies, at 2 NFA states per pattern variable and 2 more per optional wrapper. Repeating a single variable therefore costs up to 4 states per repetition, so this cap bounds such a quantifier at 4 * 1000 = 4000 states, while leaving two orders of magnitude of headroom over the bounds real patterns use (single or low double digits). A larger inner pattern costs proportionally more per repetition and is bounded by MAX_PATTERN_NFA_STATES instead.