Enum ScannerEngine
#[non_exhaustive]pub enum ScannerEngine {
Meta,
Lazy,
Dense,
}Expand description
Which concrete regex-automata engine drives the fast (look-around-free)
partition. Provisional knob (see LarkOptions::scanner_engine); the merge
semantics (MatchKind::LeftmostFirst, anchored-at-pos span search) and the
resulting token stream are byte-identical across all three — only the
build-time / warm-scan / resident-memory trade differs.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Meta
regex-automata meta Regex — internally a lazy/hybrid DFA with an
optimizer-picked engine and a built-in cache pool. Cheap construction,
WASM-friendly. Opt-in fallback since the tail-risk bench flipped the
default to Lazy:
on every measured grammar including a deliberately cache-thrashing
adversarial one, Lazy was faster, and Meta degraded worse under the
stress that was supposed to be its advantage.
Lazy
regex-automata hybrid (lazy) DFA driven directly, with a per-scanner
Cache pool (8 MiB cap) for &self access. Skips the meta optimizer’s
per-search engine choice; construction stays cheap (the DFA is built
lazily during the scan) at the cost of a cache-fill transient. The
shipping default — 8-25 % faster warm than Meta with neutral-to-lower
resident memory.
Dense
regex-automata dense DFA (fully materialized at build time). Fastest
warm scan on small alphabets, but determinization over \w-class
terminals blows up construction time and resident memory on large
grammars (python).
Implementations§
§impl ScannerEngine
impl ScannerEngine
pub fn from_env() -> ScannerEngine
pub fn from_env() -> ScannerEngine
The engine selected by the HL_ENGINE environment hook (meta|lazy|
dense), or the enum default (ScannerEngine::Lazy) when
unset/unrecognised. Public so out-of-façade harnesses (the conformance
corpus A/B, benches) exercise the same engine the process default
resolves to. HL_ENGINE is sampled once per process and cached, so a
later env change is ignored; pass an explicit engine to
Scanner::new_with_engine for a deterministic choice.
Trait Implementations§
§impl Clone for ScannerEngine
impl Clone for ScannerEngine
§fn clone(&self) -> ScannerEngine
fn clone(&self) -> ScannerEngine
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more