pub struct FsmWithStartEnd { /* private fields */ }Expand description
A mutable FSM together with a start state and accepting states.
Implementations§
Source§impl FsmWithStartEnd
impl FsmWithStartEnd
Source§impl FsmWithStartEnd
impl FsmWithStartEnd
Sourcepub fn minimize_dfa(
&self,
max_num_states: usize,
) -> Result<FsmWithStartEnd, String>
pub fn minimize_dfa( &self, max_num_states: usize, ) -> Result<FsmWithStartEnd, String>
Hopcroft DFA minimization. Returns Err over the state cap.
Sourcepub fn not(
&self,
max_result_num_states: usize,
) -> Result<FsmWithStartEnd, String>
pub fn not( &self, max_result_num_states: usize, ) -> Result<FsmWithStartEnd, String>
The complement of the FSM’s language. Only valid for leaf FSMs (no rule references).
Sourcepub fn intersect(
lhs: &FsmWithStartEnd,
rhs: &FsmWithStartEnd,
_max_result_num_states: usize,
) -> Result<FsmWithStartEnd, String>
pub fn intersect( lhs: &FsmWithStartEnd, rhs: &FsmWithStartEnd, _max_result_num_states: usize, ) -> Result<FsmWithStartEnd, String>
Intersection of two leaf FSMs (product construction over DFAs).
Source§impl FsmWithStartEnd
impl FsmWithStartEnd
Sourcepub fn star(&self) -> FsmWithStartEnd
pub fn star(&self) -> FsmWithStartEnd
self* — Kleene star.
Sourcepub fn plus(&self) -> FsmWithStartEnd
pub fn plus(&self) -> FsmWithStartEnd
self+ — one or more.
Sourcepub fn optional(&self) -> FsmWithStartEnd
pub fn optional(&self) -> FsmWithStartEnd
self? — optional.
Sourcepub fn union(fsms: &[FsmWithStartEnd]) -> FsmWithStartEnd
pub fn union(fsms: &[FsmWithStartEnd]) -> FsmWithStartEnd
Parallel union of several FSMs — accepts any of their languages.
Sourcepub fn concat(fsms: &[FsmWithStartEnd]) -> FsmWithStartEnd
pub fn concat(fsms: &[FsmWithStartEnd]) -> FsmWithStartEnd
Sequential concatenation of several FSMs.
Source§impl FsmWithStartEnd
impl FsmWithStartEnd
Sourcepub fn simplify_epsilon(&self) -> FsmWithStartEnd
pub fn simplify_epsilon(&self) -> FsmWithStartEnd
Merge states linked by removable epsilon transitions.
a --eps--> b is collapsible when either (1) a has no other
outgoing edge, or (2) b has no other incoming edge.
Sourcepub fn merge_equivalent_successors(&self) -> FsmWithStartEnd
pub fn merge_equivalent_successors(&self) -> FsmWithStartEnd
Merge states with identical incoming or outgoing transition
structure (ab | ac | ad -> a(b|c|d), and the mirror case).
Upstream renamed this MergeEquivalentStates (commit 8d22ba0);
the port keeps the original name.
The incoming/outgoing edge relations are stored in two reused
CSR arrays (EdgeCsr) instead of per-state hash maps — port
of upstream commit 96ae88b (#616), which found build_maps
dominated the pass through hash-map and small-vector churn.
Source§impl FsmWithStartEnd
impl FsmWithStartEnd
Sourcepub fn is_end_state(&self, state: usize) -> bool
pub fn is_end_state(&self, state: usize) -> bool
True if state is accepting.
Sourcepub fn num_states(&self) -> usize
pub fn num_states(&self) -> usize
Total number of states.
Sourcepub fn set_start_state(&mut self, state: usize)
pub fn set_start_state(&mut self, state: usize)
Set the start state.
Sourcepub fn add_end_state(&mut self, state: usize)
pub fn add_end_state(&mut self, state: usize)
Mark state accepting.
Sourcepub fn set_end_states(&mut self, ends: Vec<bool>)
pub fn set_end_states(&mut self, ends: Vec<bool>)
Replace the accepting-state bitmap.
Sourcepub fn is_scanable_state(&self, state: usize) -> bool
pub fn is_scanable_state(&self, state: usize) -> bool
True if state has at least one outgoing char-range edge.
Sourcepub fn is_non_terminal_state(&self, state: usize) -> bool
pub fn is_non_terminal_state(&self, state: usize) -> bool
True if state has a rule-ref / epsilon / repeat-ref edge.
Sourcepub fn accept_string(&self, bytes: &[u8]) -> bool
pub fn accept_string(&self, bytes: &[u8]) -> bool
True if the FSM accepts the byte string str.
Sourcepub fn reachable_states(&self, result: &mut AHashSet<i32>)
pub fn reachable_states(&self, result: &mut AHashSet<i32>)
All states reachable from the start state.
Sourcepub fn copy(&self) -> FsmWithStartEnd
pub fn copy(&self) -> FsmWithStartEnd
A deep copy.
Sourcepub fn rebuild_with_mapping(
&self,
state_mapping: &[usize],
new_num_states: usize,
) -> FsmWithStartEnd
pub fn rebuild_with_mapping( &self, state_mapping: &[usize], new_num_states: usize, ) -> FsmWithStartEnd
Rebuild with remapped state ids.
Sourcepub fn add_to_complete_fsm(&self, complete_fsm: &mut Fsm) -> FsmWithStartEnd
pub fn add_to_complete_fsm(&self, complete_fsm: &mut Fsm) -> FsmWithStartEnd
Splice this FSM into complete_fsm, returning a view onto it.
Sourcepub fn to_compact(&self) -> CompactFsmWithStartEnd
pub fn to_compact(&self) -> CompactFsmWithStartEnd
Pack into the compact form.
Trait Implementations§
Source§impl Clone for FsmWithStartEnd
impl Clone for FsmWithStartEnd
Source§fn clone(&self) -> FsmWithStartEnd
fn clone(&self) -> FsmWithStartEnd
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FsmWithStartEnd
impl Debug for FsmWithStartEnd
Source§impl Default for FsmWithStartEnd
impl Default for FsmWithStartEnd
Source§fn default() -> FsmWithStartEnd
fn default() -> FsmWithStartEnd
Source§impl PartialEq for FsmWithStartEnd
impl PartialEq for FsmWithStartEnd
impl Eq for FsmWithStartEnd
impl StructuralPartialEq for FsmWithStartEnd
Auto Trait Implementations§
impl Freeze for FsmWithStartEnd
impl RefUnwindSafe for FsmWithStartEnd
impl Send for FsmWithStartEnd
impl Sync for FsmWithStartEnd
impl Unpin for FsmWithStartEnd
impl UnwindSafe for FsmWithStartEnd
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Conv for T
impl<T> Conv for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.