Skip to main content

Crate automata_core

Crate automata_core 

Source
Expand description

automata_core: small, explicit automata algorithms in Rust.

The crate is layered as follows:

There are no ε-transitions in the public trait layer.

§Quick example

Build a DFA for the language “even-length words over { 'a' }” and test acceptance.

use automata_core::simple::SimpleDFA;
use automata_core::arbitrary::DeterministicAutomaton;
use automata_core::finite::DeterministicFiniteAutomaton;

let alphabet = ['a'];
// 0 = even length, 1 = odd length
let edges = [(0usize, 'a', 1usize), (1usize, 'a', 0usize)];
let dfa = SimpleDFA::try_new(2, 0, [0], alphabet, edges).unwrap();

assert!(dfa.accepts(&[]));
assert!(!dfa.accepts(&['a']));
assert!(dfa.accepts(&['a', 'a']));

§Module organization

Modules§

arbitrary
Unlabeled automata traits (Label = ()): same trait shapes as crate::labeled::arbitrary. State sets and alphabets are not assumed finite.
finite
Finite automata in the unlabeled API (Label = ()).
labeled
Labeled automata: states can carry an output label type Label.
simple
Unlabeled reference automata (Label = ()).