From fba9a90cfc6aca2a26cce72f55fb261789139781 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Fri, 16 Oct 2026 14:01:01 +0800 Subject: new start Now I tested and discussed with claude, and had a working version of this project. The rest is to port the claude version to my own writings. So this serves as the starting point before that attempt. In the new attempt the design is better, and a number of bugs were found and supposedly fixed, so let us see how this goes at the end. --- forest/src/archive_default.txt | 81 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) (limited to 'forest/src/archive_default.txt') diff --git a/forest/src/archive_default.txt b/forest/src/archive_default.txt index 5572ecc..d6e4e2e 100644 --- a/forest/src/archive_default.txt +++ b/forest/src/archive_default.txt @@ -523,3 +523,84 @@ mod forest_test { Ok(()) } } + +// #[derive(Debug, Clone, Copy)] +// enum Item { +// Seen(T), +// Unseen(T), +// } + +// use Item::*; + +// impl Item { +// fn is_seen(self) -> bool { +// matches!(self, Self::Seen(_)) +// } + +// fn value(&self) -> T { +// match self { +// Seen(v) => *v, +// Unseen(v) => *v, +// } +// } +// } + +// let query_len = self.query.nodes_len(); + +// let forest_len = forest.nodes_len(); + +// let mut stack: Vec<(SkipState, usize)> = Vec::with_capacity(forest_len); + +// stack.push((SkipState::Any, root)); + +// let mut query_stack: Vec = Vec::with_capacity(query_len); + +// query_stack.push(query_root); + +// let mut match_result = false; + +// 'search: while let Some(item) = stack.pop() { +// // if item.is_seen() { +// // if match_result { +// // continue; +// // } + +// // // fallback +// // } + +// let (state, top) = item; + +// let qtop = if let Some(qtop) = query_stack.last() { +// *qtop +// } else { +// panic!("Query stack becomes empty"); +// }; + +// let top_label = forest.vertex_label(top)?.ok_or(QRError::NodeNoLabel(top))?; + +// // let top_status = top_label.status(); + +// if top_label.is_packed() { +// self.packs.push((top, 0)); + +// stack.try_reserve(forest.degree(top)?)?; + +// stack.extend(forest.children_of(top)?.map(|child| (state, child))); + +// continue 'search; +// } + +// let query_label = self.query.label_of_vertex(qtop)?; + +// if query_label.matches(top_label.label(), top_label.status()) { +// // Success branch + +// match_result = true; + +// // TODO: Deal with captures later +// } else { +// // Failure branch + +// match_result = false; +// } +// } -- cgit v1.2.3-18-g5258