use crate::nfa::Nfa;
use super::super::lazy::LazyDfa;
use super::interpreter::EagerDfa;
pub struct EagerDfaEngine {
dfa: EagerDfa,
}
impl std::fmt::Debug for EagerDfaEngine {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("EagerDfaEngine")
.field("state_count", &self.dfa.state_count())
.finish()
}
}
impl EagerDfaEngine {
pub fn new(nfa: Nfa) -> Self {
let mut lazy = LazyDfa::new(nfa);
Self {
dfa: EagerDfa::from_lazy(&mut lazy),
}
}
pub fn from_lazy(lazy: &mut LazyDfa) -> Self {
Self {
dfa: EagerDfa::from_lazy(lazy),
}
}
#[inline]
pub fn find(&self, input: &[u8]) -> Option<(usize, usize)> {
self.dfa.find(input)
}
#[inline]
pub fn find_at(&self, input: &[u8], pos: usize) -> Option<usize> {
self.dfa.find_at(input, pos)
}
pub fn state_count(&self) -> usize {
self.dfa.state_count()
}
pub fn dfa(&self) -> &EagerDfa {
&self.dfa
}
pub fn is_jit(&self) -> bool {
false
}
pub fn has_word_boundary(&self) -> bool {
self.dfa.has_word_boundary()
}
pub fn has_anchors(&self) -> bool {
self.dfa.has_anchors()
}
pub fn has_start_anchor(&self) -> bool {
self.dfa.has_start_anchor()
}
pub fn has_end_anchor(&self) -> bool {
self.dfa.has_end_anchor()
}
pub fn has_multiline_anchors(&self) -> bool {
self.dfa.has_multiline_anchors()
}
}