pub struct NfaState {
pub id: StateId,
pub term: Option<NfaTerm>,
pub transitions: Vec<NfaTransition>,
pub origin: Option<SourceRef>,
}Expand description
A single state in the NFA
Each state can optionally have a term that must be matched to consume input when transitioning through this state. States without terms (epsilon states) are used for branching logic.
Fields§
§id: StateIdUnique identifier for this state
term: Option<NfaTerm>The term that must be matched to enter this state via a consuming transition. None for epsilon states (branching/merging points).
transitions: Vec<NfaTransition>Outgoing transitions from this state
origin: Option<SourceRef>Source location in the schema for error reporting
Implementations§
Source§impl NfaState
impl NfaState
Sourcepub fn epsilon(id: StateId, origin: Option<SourceRef>) -> Self
pub fn epsilon(id: StateId, origin: Option<SourceRef>) -> Self
Create a new state with no term (epsilon state)
Sourcepub fn with_term(id: StateId, term: NfaTerm, origin: Option<SourceRef>) -> Self
pub fn with_term(id: StateId, term: NfaTerm, origin: Option<SourceRef>) -> Self
Create a new state with a term
Sourcepub fn add_transition(&mut self, target: StateId, kind: TransitionKind)
pub fn add_transition(&mut self, target: StateId, kind: TransitionKind)
Add a transition to this state
Sourcepub fn add_epsilon(&mut self, target: StateId)
pub fn add_epsilon(&mut self, target: StateId)
Add an epsilon transition
Sourcepub fn add_consume(&mut self, target: StateId)
pub fn add_consume(&mut self, target: StateId)
Add a consuming transition
Sourcepub fn is_epsilon(&self) -> bool
pub fn is_epsilon(&self) -> bool
Check if this is an epsilon state (no term)
Sourcepub fn epsilon_transitions(&self) -> impl Iterator<Item = StateId> + '_
pub fn epsilon_transitions(&self) -> impl Iterator<Item = StateId> + '_
Get epsilon transitions from this state
Sourcepub fn consuming_transitions(&self) -> impl Iterator<Item = StateId> + '_
pub fn consuming_transitions(&self) -> impl Iterator<Item = StateId> + '_
Get consuming transitions from this state
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NfaState
impl RefUnwindSafe for NfaState
impl Send for NfaState
impl Sync for NfaState
impl Unpin for NfaState
impl UnsafeUnpin for NfaState
impl UnwindSafe for NfaState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more