pub struct Nfa<'a, T> { /* private fields */ }Expand description
A non-deterministic fintie automaton.
Implementations§
Source§impl<'a, const TARGETS_HINT: usize, Σ: Eq + Hash + Copy> Nfa<'a, State<TARGETS_HINT, Σ>>
impl<'a, const TARGETS_HINT: usize, Σ: Eq + Hash + Copy> Nfa<'a, State<TARGETS_HINT, Σ>>
Sourcepub fn new(start_node: &'a State<TARGETS_HINT, Σ>) -> Self
pub fn new(start_node: &'a State<TARGETS_HINT, Σ>) -> Self
Creates a new NFA with the given start node, consumes the arena where the nodes were made. TODO: This can just take any arena, and then we would be able to change the NFA after creation. is that a good idea?
Sourcepub fn as_dfa(&self, arena: &Corrida) -> Dfa<'a, Σ, PartialState<Σ>>
pub fn as_dfa(&self, arena: &Corrida) -> Dfa<'a, Σ, PartialState<Σ>>
Converts the NFA to a DFA using subset construction.
Sourcepub fn simulate_iter(&self, input: impl Iterator<Item = Σ>) -> bool
pub fn simulate_iter(&self, input: impl Iterator<Item = Σ>) -> bool
Simulates the NFA on the given input, returning if the NFA accepts the input.
Sourcepub fn simulate_slice(&self, input: &[Σ]) -> bool
pub fn simulate_slice(&self, input: &[Σ]) -> bool
Simulates the NFA on the given input, returning if the NFA accepts the input.
Sourcepub fn simulate_iter_friendly(&self, input: impl Iterator<Item = Σ>) -> bool
pub fn simulate_iter_friendly(&self, input: impl Iterator<Item = Σ>) -> bool
Simulates the NFA on the given input, returning if the NFA accepts the input. Will infinite loop on epsilon loops, so only use for ‘friendly’ NFAs where specific states are not reached many times at the same token.
Sourcepub fn simulate_slice_friendly(&self, input: &[Σ]) -> bool
pub fn simulate_slice_friendly(&self, input: &[Σ]) -> bool
Simulates the NFA on the given input, returning if the NFA accepts the input. Will infinite loop on epsilon loops, so only use for ‘friendly’ NFAs where specific states are not reached many times at the same token.