[][src]Struct nifty::dfa::DFABuilder

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

A builder for the DFA struct.

Methods

impl<'a, S, T> DFABuilder<S, T> where
    S: Eq + Hash + Clone + Debug,
    T: Eq + Hash + Clone + Debug
[src]

pub fn recognizes(self, description: &str) -> Self[src]

Adds a description of the language that this DFA will recognize.

pub fn add_state(self, state: &S) -> Self[src]

Adds a state to the DFA.

  • Panics if a state is added after any transition has been added. Must add all states before transitions.

pub fn mark_accept_state(self, state: &S) -> Self[src]

Marks a state as an accept state.

  • Panics if the provided state does not exist in this DFA.

pub fn mark_goal_state(self, state: &S) -> Self[src]

Marks a state as a goal state.

  • This will automatically add the goal state to the list of accept states.
  • Panics if the provided state does not exist in this DFA.

pub fn mark_dead_state(self, state: &S) -> Self[src]

Marks a state as a dead state.

  • Panics if the provided state does not exist in this DFA.

pub fn mark_start_state(self, state: &S) -> Self[src]

Marks a state as the start state.

  • Panics if the provided state does not exist in this DFA.
  • Panics if the DFA already has a defined start state.

pub fn add_transition(self, from: &S, transition: &T, to: &S) -> Self[src]

Adds a transition from one state to another.

  • Panics if the transition is coming from a dead state. A dead state's transitions cannot be overwritten.
  • Panics if the transition is coming from a goal state. A goal state's transitions cannot be overwritten.
  • Panics if the from state does not exist in the DFA.
  • Panics if the to state does not exist in the DFA.

pub fn build(self) -> DFA<S, T>[src]

Builds a DFA and consumes the builder.

  • Panics if the DFA has no states.
  • Panics if the DFA has no defined start state.
  • Panics if each state in the DFA does not have a transition for every symbol in the alphabet.

Trait Implementations

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

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

Auto Trait Implementations

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

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

Blanket Implementations

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

impl<T, U> Into<U> for T where
    U: From<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]