Skip to main content

State

Enum State 

Source
pub enum State {
Show 17 variants Accept, Epsilon { targets: Vec<StateId>, }, Char { class: HirClass, next: StateId, }, FuzzyChar { class: HirClass, limits: Option<FuzzyLimits>, min_edits: Option<u8>, cost_constraint: Option<CostConstraint>, next: StateId, }, FuzzyLiteral { pattern_index: PatternIndex, limits: Option<FuzzyLimits>, min_edits: Option<u8>, cost_constraint: Option<CostConstraint>, next: StateId, }, CaptureStart { index: usize, next: StateId, }, CaptureEnd { index: usize, next: StateId, }, Anchor { kind: Anchor, next: StateId, }, Lookahead { positive: bool, nfa: Box<Nfa>, literals: Vec<LiteralPattern>, next: StateId, }, Lookbehind { positive: bool, nfa: Box<Nfa>, literals: Vec<LiteralPattern>, bridge: Option<Arc<FuzzyBridge>>, next: StateId, }, Backreference { group: usize, limits: Option<FuzzyLimits>, next: StateId, }, Split { branches: Vec<StateId>, greedy: bool, }, ResetMatchStart { next: StateId, }, AtomicGroup { nfa: Box<Nfa>, next: StateId, }, RecursivePattern { next: StateId, }, RecursiveGroup { group: usize, next: StateId, }, RecursiveNamedGroup { name: String, next: StateId, },
}
Expand description

A state in the NFA.

Variants§

§

Accept

Accept state - match succeeded.

§

Epsilon

Epsilon transition - no input consumed.

Fields

§targets: Vec<StateId>

Target states (multiple for splits).

§

Char

Match a single character from a class.

Fields

§class: HirClass

The character class to match.

§next: StateId

Next state after matching.

§

FuzzyChar

Match a single character from a class with fuzzy matching support. Used for character classes inside fuzzy groups like (?:[a-z])~1.

Fields

§class: HirClass

The character class to match.

§limits: Option<FuzzyLimits>

Fuzzy matching limits (insertions, deletions, substitutions).

§min_edits: Option<u8>

Minimum edits required (for exclusive lower bounds).

§cost_constraint: Option<CostConstraint>

Cost constraint (optional).

§next: StateId

Next state after matching.

§

FuzzyLiteral

Match a literal string with fuzzy matching. Uses Levenshtein automata for the match.

Fields

§pattern_index: PatternIndex

Index into the pre-built pattern list.

§limits: Option<FuzzyLimits>

Per-pattern fuzzy limits.

§min_edits: Option<u8>

Minimum edits required (for exclusive lower bounds like {0<e<5}).

§cost_constraint: Option<CostConstraint>

Cost constraint (optional).

§next: StateId

Next state after matching.

§

CaptureStart

Start of a capture group.

Fields

§index: usize

Capture group index (1-based).

§next: StateId

Next state.

§

CaptureEnd

End of a capture group.

Fields

§index: usize

Capture group index (1-based).

§next: StateId

Next state.

§

Anchor

Anchor assertion.

Fields

§kind: Anchor

The type of anchor.

§next: StateId

Next state if anchor matches.

§

Lookahead

Lookahead assertion.

Fields

§positive: bool

True for positive lookahead, false for negative.

§nfa: Box<Nfa>

Sub-NFA to evaluate.

§literals: Vec<LiteralPattern>

Literal patterns used by the sub-NFA.

§next: StateId

Next state if assertion passes.

§

Lookbehind

Lookbehind assertion.

Fields

§positive: bool

True for positive lookbehind, false for negative.

§nfa: Box<Nfa>

Sub-NFA to evaluate.

§literals: Vec<LiteralPattern>

Literal patterns used by the sub-NFA.

§bridge: Option<Arc<FuzzyBridge>>

Pre-built FuzzyBridge for efficient matching (shared via Arc for Clone).

§next: StateId

Next state if assertion passes.

§

Backreference

Backreference - match the same text as a capture group.

Fields

§group: usize

The capture group to reference.

§limits: Option<FuzzyLimits>

Optional fuzzy limits for fuzzy backreference matching.

§next: StateId

Next state after matching.

§

Split

Split state for alternation (prioritized). Tries branches in order for greedy/non-greedy semantics.

Fields

§branches: Vec<StateId>

Branch states in priority order.

§greedy: bool

Whether this split is greedy (try first branch first) or non-greedy (try last branch first). For quantifiers like *, +, ?, this determines match preference.

§

ResetMatchStart

Reset match start - \K Resets the match start position to the current position. Everything before \K is matched but excluded from the final match.

Fields

§next: StateId

Next state after the reset.

§

AtomicGroup

Atomic group - (?>expr) Once matched, prevents backtracking within the group.

Fields

§nfa: Box<Nfa>

The sub-NFA for the expression inside the group.

§next: StateId

Next state after the atomic group.

§

RecursivePattern

Recursive pattern - (?R) Recursively matches the entire pattern.

Fields

§next: StateId

Next state after the recursive call.

§

RecursiveGroup

Recursive numbered group - (?1), (?2), etc.

Fields

§group: usize

The capture group number to recurse into.

§next: StateId

Next state after the recursive call.

§

RecursiveNamedGroup

Recursive named group - (?&name) or (?P>name)

Fields

§name: String

The name of the capture group to recurse into.

§next: StateId

Next state after the recursive call.

Implementations§

Source§

impl State

Source

pub fn epsilon(target: StateId) -> Self

Create an epsilon transition to a single target.

Source

pub fn epsilon_multi(targets: Vec<StateId>) -> Self

Create an epsilon transition to multiple targets.

Source

pub fn char_match(class: HirClass, next: StateId) -> Self

Create a character matching state.

Source

pub fn fuzzy_literal( pattern_index: PatternIndex, limits: Option<FuzzyLimits>, min_edits: Option<u8>, cost_constraint: Option<CostConstraint>, next: StateId, ) -> Self

Create a fuzzy literal state.

Source

pub fn capture_start(index: usize, next: StateId) -> Self

Create a capture start state.

Source

pub fn capture_end(index: usize, next: StateId) -> Self

Create a capture end state.

Source

pub fn anchor(kind: Anchor, next: StateId) -> Self

Create an anchor state.

Source

pub fn split(branches: Vec<StateId>) -> Self

Create a split state. Defaults to greedy.

Source

pub fn lookahead( positive: bool, nfa: Box<Nfa>, literals: Vec<LiteralPattern>, next: StateId, ) -> Self

Create a lookahead state.

Source

pub fn lookbehind( positive: bool, nfa: Box<Nfa>, literals: Vec<LiteralPattern>, next: StateId, ) -> Self

Create a lookbehind state with pre-built FuzzyBridge.

Source

pub fn backreference( group: usize, limits: Option<FuzzyLimits>, next: StateId, ) -> Self

Create a backreference state.

Source

pub fn next_states(&self) -> Vec<StateId>

Get the next state(s) from this state.

Trait Implementations§

Source§

impl Clone for State

Source§

fn clone(&self) -> State

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for State

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for State

§

impl !RefUnwindSafe for State

§

impl !Send for State

§

impl !Sync for State

§

impl Unpin for State

§

impl UnsafeUnpin for State

§

impl !UnwindSafe for State

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