pub struct NfaTable {
pub states: Vec<NfaState>,
pub start_state: StateId,
pub accept_state: StateId,
pub counter_defs: Vec<CounterDef>,
}Expand description
Complete NFA table for a content model
Represents a compiled content model as a state machine. The NFA can be used for validation by tracking active states and matching input elements.
Fields§
§states: Vec<NfaState>All states in the automaton
start_state: StateIdInitial state ID
accept_state: StateIdAccepting state ID (single accept state per Thompson’s construction)
counter_defs: Vec<CounterDef>Counter definitions for counted loops (empty if no counted repeats)
Implementations§
Source§impl NfaTable
impl NfaTable
Sourcepub fn new(
states: Vec<NfaState>,
start_state: StateId,
accept_state: StateId,
) -> Self
pub fn new( states: Vec<NfaState>, start_state: StateId, accept_state: StateId, ) -> Self
Create a new NFA table with the given states (no counters)
Sourcepub fn with_counters(
states: Vec<NfaState>,
start_state: StateId,
accept_state: StateId,
counter_defs: Vec<CounterDef>,
) -> Self
pub fn with_counters( states: Vec<NfaState>, start_state: StateId, accept_state: StateId, counter_defs: Vec<CounterDef>, ) -> Self
Create a new NFA table with counters
Sourcepub fn has_counters(&self) -> bool
pub fn has_counters(&self) -> bool
Check if this NFA has any counted loops
Sourcepub fn get_state_mut(&mut self, id: StateId) -> Option<&mut NfaState>
pub fn get_state_mut(&mut self, id: StateId) -> Option<&mut NfaState>
Get a mutable reference to a state by ID
Sourcepub fn state_count(&self) -> usize
pub fn state_count(&self) -> usize
Get the number of states
Sourcepub fn concat(self, other: NfaTable) -> NfaTable
pub fn concat(self, other: NfaTable) -> NfaTable
Concatenate two NFA tables: self followed by other. Creates an epsilon transition from self’s accept state to other’s start state. Offsets both state IDs and counter IDs in the second table.
Sourcepub fn transitions_from(&self, state_id: StateId) -> &[NfaTransition]
pub fn transitions_from(&self, state_id: StateId) -> &[NfaTransition]
Get all transitions from a given state