use crate::nfa::Nfa;
use super::interpreter::PikeVm;
use super::shared::PikeVmContext;
pub struct PikeVmEngine {
vm: PikeVm,
}
impl std::fmt::Debug for PikeVmEngine {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("PikeVmEngine").finish()
}
}
impl PikeVmEngine {
pub fn new(nfa: Nfa) -> Self {
Self {
vm: PikeVm::new(nfa),
}
}
#[inline]
pub fn is_match(&self, input: &[u8]) -> bool {
self.vm.is_match(input)
}
#[inline]
pub fn find(&self, input: &[u8]) -> Option<(usize, usize)> {
self.vm.find(input)
}
#[inline]
pub fn find_at(&self, input: &[u8], pos: usize) -> Option<(usize, usize)> {
self.vm.find_at(input, pos)
}
#[inline]
pub fn captures(&self, input: &[u8]) -> Option<Vec<Option<(usize, usize)>>> {
self.vm.captures(input)
}
#[inline]
pub fn captures_from_start(&self, input: &[u8]) -> Option<Vec<Option<(usize, usize)>>> {
self.vm.captures_from_start(input)
}
pub fn create_context(&self) -> PikeVmContext {
self.vm.create_context()
}
#[inline]
pub fn captures_from_start_with_context(
&self,
input: &[u8],
ctx: &mut PikeVmContext,
) -> Option<Vec<Option<(usize, usize)>>> {
self.vm.captures_from_start_with_context(input, ctx)
}
#[inline]
pub fn captures_with_context(
&self,
input: &[u8],
ctx: &mut PikeVmContext,
start_pos: usize,
) -> Option<Vec<Option<(usize, usize)>>> {
self.vm.captures_with_context(input, ctx, start_pos)
}
pub fn vm(&self) -> &PikeVm {
&self.vm
}
pub fn is_jit(&self) -> bool {
false
}
}