[−][src]Struct nifty::dfa::DFA
A Deterministic Finite State Automaton (DFA) [wikipedia]
The DFA
struct aims to preserve the integrity of a DFA state diagram.
- A dead state is defined as a non-accept state from which all transitions implicitly lead back to itself.
- A goal state is defined as an accept state from which all transitions implicitly lead back to itself.
Methods
impl<S, T> DFA<S, T> where
S: Eq + Hash + Clone + Debug,
T: Eq + Hash + Clone + Debug,
[src]
S: Eq + Hash + Clone + Debug,
T: Eq + Hash + Clone + Debug,
pub fn recognizes(&self) -> &str
[src]
Returns a description of the language that this DFA
recognizes.
pub fn states(&self) -> impl Iterator<Item = Rc<S>> + '_
[src]
Returns an iterator over the DFA
's states in no particular order.
pub fn dead_states(&self) -> impl Iterator<Item = Rc<S>> + '_
[src]
Returns an iterator over the DFA
's dead states in no particular order.
pub fn goal_states(&self) -> impl Iterator<Item = Rc<S>> + '_
[src]
Returns an iterator over the DFA
's goal states in no particular order.
pub fn alphabet(&self) -> impl Iterator<Item = T> + '_
[src]
Returns an iterator over the DFA
's alphabet in no particular order.
pub fn start(&self) -> Rc<S>
[src]
Returns the start state of the DFA
.
- Panics if no start state is defined for the DFA.
pub fn current(&self) -> Rc<S>
[src]
Returns the current state that the DFA is in.
pub fn restart(&mut self)
[src]
Moves the current state back to the start state.
pub fn next(&mut self, transition: &T)
[src]
Moves the current state to the next state given some transition.
- Panics if the transition is not part of the alphabet.
- Panics if the transition has no defined destination from the current state.
pub fn get_next(&mut self, transition: &T) -> Rc<S>
[src]
Moves the current state to the next state given a transition and returns new state.
- Panics if the transition is not part of the alphabet.
- Panics if the transition has no defined destination from the current state.
pub fn eval_current(&self) -> Evaluation
[src]
Evaluates the current state on whether or not it is an accept state.
pub fn evaluate(&mut self, inputs: impl Iterator<Item = T>) -> Evaluation
[src]
Evaluates an input that will be either accepted or rejected by the DFA.
- Panics if the input contains symbols that are not in the DFA's alphabet.
Trait Implementations
impl<S: Default, T: Default> Default for DFA<S, T> where
S: Eq + Hash + Clone + Debug,
T: Eq + Hash + Clone + Debug,
[src]
S: Eq + Hash + Clone + Debug,
T: Eq + Hash + Clone + Debug,
impl<S: Debug, T: Debug> Debug for DFA<S, T> where
S: Eq + Hash + Clone + Debug,
T: Eq + Hash + Clone + Debug,
[src]
S: Eq + Hash + Clone + Debug,
T: Eq + Hash + Clone + Debug,
Auto Trait Implementations
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,