pub struct CompiledLexerDfa { /* private fields */ }Expand description
A lexer DFA compiled ahead of time from a lexer ATN.
Build one per grammar with CompiledLexerDfa::compile (generated lexers
cache it in a OnceLock beside the deserialized ATN) and match tokens
through crate::atn::lexer::next_token_compiled or
crate::atn::lexer::next_token_compiled_with_hooks.
Implementations§
Source§impl CompiledLexerDfa
impl CompiledLexerDfa
Sourcepub fn compile(atn: &Atn) -> Self
pub fn compile(atn: &Atn) -> Self
Compiles every lexer mode of atn that has no semantic predicates and
fits the state budget; the rest stay interpreter-matched.
Sourcepub fn has_compiled_modes(&self) -> bool
pub fn has_compiled_modes(&self) -> bool
True when at least one lexer mode compiled to static tables.
Sourcepub const fn state_count(&self) -> usize
pub const fn state_count(&self) -> usize
Number of compiled DFA states across all modes (diagnostics).
Sourcepub fn compiled_mode_flags(&self) -> Vec<bool>
pub fn compiled_mode_flags(&self) -> Vec<bool>
Per-mode compilation outcome (diagnostics): true = static tables.
Sourcepub fn mode_state_counts(&self) -> Vec<usize>
pub fn mode_state_counts(&self) -> Vec<usize>
Per-mode state counts (diagnostics), derived from start offsets.
Sourcepub fn serialize(&self) -> Vec<u32>
pub fn serialize(&self) -> Vec<u32>
Flattens the compiled DFA into a u32 stream for embedding in
generated code.
The format is internal to this runtime version; Self::from_serialized
rejects streams from other versions so generated lexers can fall back
to Self::compile.
Sourcepub fn from_serialized(data: &[u32]) -> Option<Self>
pub fn from_serialized(data: &[u32]) -> Option<Self>
Rebuilds a compiled DFA from Self::serialize output; None when
the stream comes from a different runtime version or is malformed.
Trait Implementations§
Source§impl Clone for CompiledLexerDfa
impl Clone for CompiledLexerDfa
Source§fn clone(&self) -> CompiledLexerDfa
fn clone(&self) -> CompiledLexerDfa
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more