pub enum ActiveStates {
Simple(HashSet<StateId>),
Counted {
configs: HashSet<ActiveConfig>,
num_counters: usize,
},
RangedSingle {
state_ranges: HashMap<StateId, CounterRange>,
counter_def: CounterDef,
},
Hybrid {
configs: HashMap<HybridKey, CounterRange>,
ranged_counter_idx: usize,
num_counters: usize,
},
}Expand description
Quad-path active state set for NFA simulation.
Invariant: values are always closure-closed (epsilon closure has been applied). All constructors and advance methods enforce this.
Simple: counter-free NFA — delegates to existingHashSet<StateId>functions.Counted: NFA with multiple counters — tracksHashSet<ActiveConfig>(scalar).RangedSingle: single counter with nullable body — stores oneCounterRangeper reachable state, converging epsilon closure in O(states) instead of O(N).Hybrid: multiple counters, one ranged (fast-forward) + others scalar. Collapses the ranged counter’s dimension; cost proportional to remaining scalar dims.
Variants§
Simple(HashSet<StateId>)
Fast path: no counters in this NFA (bit-identical to old code)
Counted
Scalar counted path: configurations carry individual counter values
RangedSingle
Optimized path for single-counter NFAs with nullable loop body.
Each reachable state maps to one CounterRange (contiguity invariant).
Hybrid
Hybrid path: one counter ranged (fast-forward), others scalar.
The ranged counter’s slot in every HybridKey is always 0 (sentinel);
the actual ranged value lives in the CounterRange map value.
Implementations§
Source§impl ActiveStates
impl ActiveStates
Sourcepub fn from_nfa(nfa: &NfaTable) -> Self
pub fn from_nfa(nfa: &NfaTable) -> Self
Create initial active states from an NFA, picking the right variant.
Sourcepub fn contains_accept(&self, nfa: &NfaTable) -> bool
pub fn contains_accept(&self, nfa: &NfaTable) -> bool
Check if any active state is the NFA accept state.
Sourcepub fn epsilon_closure(self, nfa: &NfaTable) -> Self
pub fn epsilon_closure(self, nfa: &NfaTable) -> Self
Compute epsilon closure (including counter transitions for Counted path).
Sourcepub fn advance(
self,
nfa: &NfaTable,
element_name: NameId,
element_namespace: Option<NameId>,
target_namespace: Option<NameId>,
substitution_groups: Option<&SubstitutionGroupMap>,
xsd_version: XsdVersion,
) -> Self
pub fn advance( self, nfa: &NfaTable, element_name: NameId, element_namespace: Option<NameId>, target_namespace: Option<NameId>, substitution_groups: Option<&SubstitutionGroupMap>, xsd_version: XsdVersion, ) -> Self
Advance NFA states by matching an element (XSD 1.0 — no priority).
Sourcepub fn advance_with_priority(
self,
nfa: &NfaTable,
element_name: NameId,
element_namespace: Option<NameId>,
target_namespace: Option<NameId>,
substitution_groups: Option<&SubstitutionGroupMap>,
xsd_version: XsdVersion,
) -> Self
pub fn advance_with_priority( self, nfa: &NfaTable, element_name: NameId, element_namespace: Option<NameId>, target_namespace: Option<NameId>, substitution_groups: Option<&SubstitutionGroupMap>, xsd_version: XsdVersion, ) -> Self
Advance NFA states with element-over-wildcard priority (XSD 1.1).
Sourcepub fn find_match_info(
&self,
nfa: &NfaTable,
name: NameId,
namespace: Option<NameId>,
target_ns: Option<NameId>,
subst_groups: Option<&SubstitutionGroupMap>,
xsd_version: XsdVersion,
) -> MatchInfo
pub fn find_match_info( &self, nfa: &NfaTable, name: NameId, namespace: Option<NameId>, target_ns: Option<NameId>, subst_groups: Option<&SubstitutionGroupMap>, xsd_version: XsdVersion, ) -> MatchInfo
Find the matching term info from active states (for content validation).
Returns the element key and resolved type of the first matching term. Since ActiveStates is closure-closed, all reachable term states are already present — no additional epsilon closure needed for Counted path.
Sourcepub fn expected_element_terms(
&self,
nfa: &NfaTable,
) -> Vec<(NameId, Option<NameId>, Option<ElementKey>)>
pub fn expected_element_terms( &self, nfa: &NfaTable, ) -> Vec<(NameId, Option<NameId>, Option<ElementKey>)>
Collect expected element terms from reachable states (for error messages).
Returns (local_name, namespace, element_key) for each reachable Element term.
Trait Implementations§
Source§impl Clone for ActiveStates
impl Clone for ActiveStates
Source§fn clone(&self) -> ActiveStates
fn clone(&self) -> ActiveStates
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more