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.
Char
Match a single character from a class.
FuzzyChar
Match a single character from a class with fuzzy matching support.
Used for character classes inside fuzzy groups like (?:[a-z])~1.
Fields
limits: Option<FuzzyLimits>Fuzzy matching limits (insertions, deletions, substitutions).
cost_constraint: Option<CostConstraint>Cost constraint (optional).
FuzzyLiteral
Match a literal string with fuzzy matching. Uses Levenshtein automata for the match.
Fields
pattern_index: PatternIndexIndex into the pre-built pattern list.
limits: Option<FuzzyLimits>Per-pattern fuzzy limits.
cost_constraint: Option<CostConstraint>Cost constraint (optional).
CaptureStart
Start of a capture group.
CaptureEnd
End of a capture group.
Anchor
Anchor assertion.
Lookahead
Lookahead assertion.
Fields
literals: Vec<LiteralPattern>Literal patterns used by the sub-NFA.
Lookbehind
Lookbehind assertion.
Fields
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).
Backreference
Backreference - match the same text as a capture group.
Fields
limits: Option<FuzzyLimits>Optional fuzzy limits for fuzzy backreference matching.
Split
Split state for alternation (prioritized). Tries branches in order for greedy/non-greedy semantics.
Fields
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.
AtomicGroup
Atomic group - (?>expr) Once matched, prevents backtracking within the group.
Fields
RecursivePattern
Recursive pattern - (?R) Recursively matches the entire pattern.
RecursiveGroup
Recursive numbered group - (?1), (?2), etc.
Fields
RecursiveNamedGroup
Recursive named group - (?&name) or (?P>name)
Implementations§
Source§impl State
impl State
Sourcepub fn epsilon_multi(targets: Vec<StateId>) -> Self
pub fn epsilon_multi(targets: Vec<StateId>) -> Self
Create an epsilon transition to multiple targets.
Sourcepub fn char_match(class: HirClass, next: StateId) -> Self
pub fn char_match(class: HirClass, next: StateId) -> Self
Create a character matching state.
Sourcepub fn fuzzy_literal(
pattern_index: PatternIndex,
limits: Option<FuzzyLimits>,
min_edits: Option<u8>,
cost_constraint: Option<CostConstraint>,
next: StateId,
) -> Self
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.
Sourcepub fn capture_start(index: usize, next: StateId) -> Self
pub fn capture_start(index: usize, next: StateId) -> Self
Create a capture start state.
Sourcepub fn capture_end(index: usize, next: StateId) -> Self
pub fn capture_end(index: usize, next: StateId) -> Self
Create a capture end state.
Sourcepub fn lookahead(
positive: bool,
nfa: Box<Nfa>,
literals: Vec<LiteralPattern>,
next: StateId,
) -> Self
pub fn lookahead( positive: bool, nfa: Box<Nfa>, literals: Vec<LiteralPattern>, next: StateId, ) -> Self
Create a lookahead state.
Sourcepub fn lookbehind(
positive: bool,
nfa: Box<Nfa>,
literals: Vec<LiteralPattern>,
next: StateId,
) -> Self
pub fn lookbehind( positive: bool, nfa: Box<Nfa>, literals: Vec<LiteralPattern>, next: StateId, ) -> Self
Create a lookbehind state with pre-built FuzzyBridge.
Sourcepub fn backreference(
group: usize,
limits: Option<FuzzyLimits>,
next: StateId,
) -> Self
pub fn backreference( group: usize, limits: Option<FuzzyLimits>, next: StateId, ) -> Self
Create a backreference state.
Sourcepub fn next_states(&self) -> Vec<StateId> ⓘ
pub fn next_states(&self) -> Vec<StateId> ⓘ
Get the next state(s) from this state.