Struct Automaton

Source
pub struct Automaton { /* private fields */ }
Expand description

Deterministic finite state automaton

Implementations§

Source§

impl Automaton

Source

pub fn initial_state(&self) -> &State

Get the initial state

Source

pub fn state(&self, id: usize) -> &State

Get a state from its id panics if the id is out of range

Source

pub fn num_states(&self) -> usize

Number of states

Source

pub fn num_final_states(&self) -> usize

Number of final states

Source

pub fn default_successor(&self, s: &State) -> Option<&State>

Default successor of a state

Source

pub fn class_next(&self, s: &State, cid: ClassId) -> &State

Successor for a character class

The class id must be valid for state s

§Panics

If cid is of the form ClassId::Interval(i) but i is larger than the number of successors of s.

If cid is of the form ClassId::Complement but s has no default successor.

Source

pub fn char_set_next(&self, s: &State, set: &CharSet) -> Result<&State, Error>

Successor of a state via a character set

§Errors

If this set overlaps two or more successor classes, produce Error::AmbiguousCharSet.

Source

pub fn next(&self, s: &State, c: u32) -> &State

Successor of a state via a character

Source

pub fn str_next<'a>(&'a self, s: &'a State, str: &SmtString) -> &'a State

Successor of a state via an SMT string

Source

pub fn accepts(&self, str: &SmtString) -> bool

Check whether an SMT string is accepted

Source

pub fn states(&self) -> impl Iterator<Item = &State>

Iterator to got through the states

Source

pub fn edges<'a>(&'a self, s: &'a State) -> EdgeIterator<'a>

Iterator to list the out edges of a state

The iterator produces a list of pairs (ClassId, SuccessorState) for every class in the state’s character partition.

Source

pub fn final_states(&self) -> FinalStateIterator<'_>

Iterator to list the final states

Source

pub fn combined_char_partition(&self) -> CharPartition

Merge the state partitions and return the result. This returns an abstraction of the automaton’s alphabet.

Every class in the returned partition contains equivalent characters: if c1 and c2 are in one class, then delta(s, c1) = delta(s, c2) for every state s of the automaton.

Source

pub fn pick_alphabet(&self) -> Vec<u32>

Get a representative character from the combined partition

Source

pub fn compile_successors(&self) -> CompactTable

Compile the successor function.

The successor function is defined on state indices and character indices and it returns a state index. More precisely, it starts with building the representative alphabet for this automaton (see pick_alphabet). If the automaton has N states and the representative alphabet has M characters, then the compiled successor function is defined on [0 .. N-1] x [0 .. M-1] and return an index in [0 .. N-1].

Source

pub fn remove_unreachable_states(&mut self)

Remove unreachable states

Source

pub fn minimize(&mut self)

Minimize the automaton

Trait Implementations§

Source§

impl Debug for Automaton

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Automaton

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.