pub struct DFA<A: Atom> { /* private fields */ }Implementations§
Source§impl<A: Atom> DFA<A>
impl<A: Atom> DFA<A>
Sourcepub fn assemble(ast: Option<&ASTNode<A>>) -> Result<DFA<A>, FAAssembleError>
pub fn assemble(ast: Option<&ASTNode<A>>) -> Result<DFA<A>, FAAssembleError>
Build a DFA from the AST. If the build fails, return Err.
If None is entered, this function always returns Ok.
In this case, the DFA has only one state that is both the input state and the accepting state.
For example, it is likely that the regular expression converted to AST would be an empty string.
Sourcepub fn initial_state(&self) -> State<A>
pub fn initial_state(&self) -> State<A>
Returns the initial state.
Sourcepub fn transition(
&self,
initial_state: State<A>,
input: impl Iterator<Item = A>,
) -> Result<State<A>, TransitionError>
pub fn transition( &self, initial_state: State<A>, input: impl Iterator<Item = A>, ) -> Result<State<A>, TransitionError>
Returns the destination state when input is entered, using initial_state as the initial state.
initial_state does not need to be a state generated by DFA::initial_state; it can also be a state generated by DFA::transition, etc.
For example, you can use this when you want to enter a chunked string little by little.
Sourcepub fn is_match(&self, input: impl Iterator<Item = A>) -> bool
pub fn is_match(&self, input: impl Iterator<Item = A>) -> bool
Check whether the entered string is accepted.
Sourcepub fn is_accepted(&self, state: State<A>) -> bool
pub fn is_accepted(&self, state: State<A>) -> bool
Check if the given state is an accepted state.
If the given state is not generated from this DFA, always return false.