forked from Orchid/orchid
Final fixes
This commit is contained in:
@@ -88,6 +88,7 @@ where F: FnMut(Mrc<[Expr]>) -> Option<Mrc<[Expr]>> {
|
||||
|
||||
/// Fill in a template from a state as produced by a pattern
|
||||
fn write_slice(state: &State, tpl: &Mrc<[Expr]>) -> Mrc<[Expr]> {
|
||||
eprintln!("Writing {tpl:?} with state {state:?}");
|
||||
tpl.iter().flat_map(|Expr(clause, xpr_typ)| match clause {
|
||||
Clause::Auto(name_opt, typ, body) => box_once(Expr(Clause::Auto(
|
||||
name_opt.as_ref().and_then(|name| {
|
||||
@@ -142,7 +143,6 @@ pub fn execute(mut src: Mrc<[Expr]>, mut tgt: Mrc<[Expr]>, input: Mrc<[Expr]>)
|
||||
slice_to_vec(&mut src, &mut tgt);
|
||||
// Generate matcher
|
||||
let matcher = SliceMatcherDnC::new(src);
|
||||
println!("Matcher: {matcher:#?}");
|
||||
let matcher_cache = SliceMatcherDnC::get_matcher_cache();
|
||||
Ok(update_all_seqs(Mrc::clone(&input), &mut |p| {
|
||||
let state = matcher.match_range_cached(p, &matcher_cache)?;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
||||
use mappable_rc::Mrc;
|
||||
@@ -131,17 +130,6 @@ impl SliceMatcherDnC {
|
||||
None,
|
||||
Some(Box::new(Self::new(mrc_derive(&pattern, |p| &p[1..]))))
|
||||
));
|
||||
// let (Expr(clause, _), left_subm, right_subm) = if pattern.len() == 1 {
|
||||
// (&pattern[0], None, None)
|
||||
// } else if let Some((left, _, right)) = split_at_max_vec(pattern) {(
|
||||
// &pattern[left.len()],
|
||||
// Some(Box::new(Self::new(left))),
|
||||
// Some(Box::new(Self::new(right)))
|
||||
// )} else {(
|
||||
// &pattern[0],
|
||||
// None,
|
||||
// Some(Box::new(Self::new(&pattern[1..])))
|
||||
// )};
|
||||
Self {
|
||||
pattern, right_subm, left_subm,
|
||||
clause: Mrc::clone(&clause),
|
||||
@@ -285,7 +273,6 @@ impl SliceMatcherDnC {
|
||||
target: Mrc<[Expr]>,
|
||||
cache: &Cache<CacheEntry<'a>, Option<State>>
|
||||
) -> Option<State> {
|
||||
eprintln!("Matching {target:?} with {:?}", self.pattern);
|
||||
if self.pattern.is_empty() {
|
||||
return if target.is_empty() {Some(State::new())} else {None}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ impl State {
|
||||
}
|
||||
pub fn insert_vec<S>(mut self, k: &S, v: &[Expr]) -> Option<Self>
|
||||
where S: AsRef<str> + ToString + ?Sized + Debug {
|
||||
eprintln!("{:?} + {k:?}-{v:?}", self.0);
|
||||
if let Some(old) = self.0.get(k.as_ref()) {
|
||||
if let Entry::Vec(val) = old {
|
||||
if val.as_slice() != v {return None}
|
||||
@@ -138,3 +137,9 @@ impl IntoIterator for State {
|
||||
self.0.into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl Debug for State {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{:?}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user