forked from Orchid/orchid
bug fixes and performance improvements
This commit is contained in:
19
src/rule/matcher_second/any_match.rs
Normal file
19
src/rule/matcher_second/any_match.rs
Normal file
@@ -0,0 +1,19 @@
|
||||
use crate::{ast::Expr, rule::state::State};
|
||||
|
||||
use super::{shared::AnyMatcher, scal_match::scalv_match, vec_match::vec_match};
|
||||
|
||||
pub fn any_match<'a>(matcher: &AnyMatcher, seq: &'a [Expr])
|
||||
-> Option<State<'a>>
|
||||
{
|
||||
match matcher {
|
||||
AnyMatcher::Scalar(scalv) => scalv_match(scalv, seq),
|
||||
AnyMatcher::Vec{ left, mid, right } => {
|
||||
let left_split = left.len();
|
||||
let right_split = seq.len() - right.len();
|
||||
let mut state = scalv_match(left, &seq[..left_split])?;
|
||||
state.extend(scalv_match(right, &seq[right_split..])?);
|
||||
state.extend(vec_match(mid, &seq[left_split..right_split])?);
|
||||
Some(state)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user