[][src]Struct nifty::dfa::DFA

pub struct DFA<S, T> where
    S: Eq + Hash + Clone + Debug,
    T: Eq + Hash + Clone + Debug
{ /* fields omitted */ }

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]

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<R>(&mut self, inputs: impl Iterator<Item = R>) -> Evaluation where
    R: Borrow<T>, 
[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]

impl<S: Debug, T: Debug> Debug for DFA<S, T> where
    S: Eq + Hash + Clone + Debug,
    T: Eq + Hash + Clone + Debug
[src]

Auto Trait Implementations

impl<S, T> !Send for DFA<S, T>

impl<S, T> !Sync for DFA<S, T>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]