aboutsummaryrefslogtreecommitdiff
path: root/chain/src/item/genins.rs
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2026-10-16 14:01:01 +0800
committerJSDurand <mmemmew@gmail.com>2026-10-16 14:02:10 +0800
commitfba9a90cfc6aca2a26cce72f55fb261789139781 (patch)
treeb4b121791ad639e745df689c0d5a8ed7a9e5dcc4 /chain/src/item/genins.rs
parent3ae0cf9898485a2ec35df7d23cd274e7dea5796d (diff)
new startHEADmaster
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.
Diffstat (limited to 'chain/src/item/genins.rs')
-rw-r--r--chain/src/item/genins.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/chain/src/item/genins.rs b/chain/src/item/genins.rs
index e3e79b6..7ac771c 100644
--- a/chain/src/item/genins.rs
+++ b/chain/src/item/genins.rs
@@ -180,7 +180,7 @@ impl DefaultForest<ForestLabel<GrammarLabel>> {
label: Edge,
ter: usize,
fragment: impl Borrow<DefaultForest<ForestLabel<GrammarLabel>>>,
- atom_child_iter: impl Iterator<Item = usize> + ExactSizeIterator + Clone,
+ atom_child_iter: impl ExactSizeIterator<Item = usize> + Clone,
atom: &DefaultAtom,
) -> Result<PaVi, Error> {
let root = if let Some(root) = self.root() {
@@ -304,7 +304,7 @@ impl DefaultForest<ForestLabel<GrammarLabel>> {
let is_empty_segment = pavi.is_empty();
if true_source.is_virtual() {
- self.close_pavi(atom.borrow(), true_source, pos)?;
+ self.close_pavi(atom, true_source, pos)?;
if to_print {
self.print_viz(&format!(
@@ -330,7 +330,7 @@ impl DefaultForest<ForestLabel<GrammarLabel>> {
let virtual_frag = atom.generate_virtual_frags(nt, t, Some(rule));
if let Some(frag) = virtual_frag {
- let mut frag = (*frag.get(0).unwrap()).clone();
+ let mut frag = (*frag.first().unwrap()).clone();
frag.set_pos(atom, node_label.label().start(), true)?;
@@ -377,7 +377,7 @@ impl DefaultForest<ForestLabel<GrammarLabel>> {
if let PaVi::Parent(node, edge, _) = pavi {
let nth_child = self.nth_child(node, edge)?;
- let reduced = self.reduction(nth_child, pos, ter, atom.borrow(), false)?;
+ let reduced = self.reduction(nth_child, pos, ter, atom, false)?;
// dbg!(reduced, nth_child, self.is_empty_node(reduced)?);
@@ -543,7 +543,9 @@ impl DefaultForest<ForestLabel<GrammarLabel>> {
self.print_viz("dbg forest.gv").unwrap();
- #[cfg(test)]
+ // atom.print_nfa("nfa.gv").unwrap();
+
+ // #[cfg(test)]
crate::item::default::print_labels(atom, self.borrow()).unwrap();
return Err(Error::CannotPlant);