Skip to main content

ActiveStates

Enum ActiveStates 

Source
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 existing HashSet<StateId> functions.
  • Counted: NFA with multiple counters — tracks HashSet<ActiveConfig> (scalar).
  • RangedSingle: single counter with nullable body — stores one CounterRange per 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

Fields

§num_counters: usize
§

RangedSingle

Optimized path for single-counter NFAs with nullable loop body. Each reachable state maps to one CounterRange (contiguity invariant).

Fields

§state_ranges: HashMap<StateId, CounterRange>
§counter_def: CounterDef
§

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.

Fields

§configs: HashMap<HybridKey, CounterRange>
§ranged_counter_idx: usize
§num_counters: usize

Implementations§

Source§

impl ActiveStates

Source

pub fn from_nfa(nfa: &NfaTable) -> Self

Create initial active states from an NFA, picking the right variant.

Source

pub fn is_empty(&self) -> bool

Check if the active set is empty (no reachable states).

Source

pub fn contains_accept(&self, nfa: &NfaTable) -> bool

Check if any active state is the NFA accept state.

Source

pub fn epsilon_closure(self, nfa: &NfaTable) -> Self

Compute epsilon closure (including counter transitions for Counted path).

Source

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).

Source

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).

Source

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.

Source

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

Source§

fn clone(&self) -> ActiveStates

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ActiveStates

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybeSendSync for T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.