summaryrefslogtreecommitdiff
path: root/chain/src
diff options
context:
space:
mode:
Diffstat (limited to 'chain/src')
-rw-r--r--chain/src/default.rs19
-rw-r--r--chain/src/item/genins.rs11
-rw-r--r--chain/src/lib.rs9
3 files changed, 31 insertions, 8 deletions
diff --git a/chain/src/default.rs b/chain/src/default.rs
index 1e0eba2..11f0c93 100644
--- a/chain/src/default.rs
+++ b/chain/src/default.rs
@@ -633,6 +633,7 @@ impl Chain for DefaultChain {
let mut new_label = *child_label;
new_label.set_true_source(true_pavi);
+ // new_label.set_forest_source(pavi);
output.extend(
std::iter::repeat(new_label.into())
@@ -723,6 +724,20 @@ impl Chain for DefaultChain {
continue;
}
+ #[allow(clippy::single_match)]
+ match label.forest_source() {
+ PaVi::Parent(node, _, _) => match self.forest.vertex_label(node) {
+ Ok(Some(label)) => match label.label().end() {
+ Some(end) if end != pos => {
+ continue;
+ }
+ _ => {}
+ },
+ _ => {}
+ },
+ _ => {}
+ }
+
let virtual_node = self
.atom
.atom(non, t)
@@ -911,7 +926,7 @@ impl Chain for DefaultChain {
// First perform reduction.
- let _ = self.forest.print_viz("forest before reduction.gv");
+ // let _ = self.forest.print_viz("forest before reduction.gv");
// self.forest.reduction(root, pos, ter, &self.atom, true)?;
@@ -1070,7 +1085,7 @@ impl Chain for DefaultChain {
self.atom.print_virtual();
let _ = item::default::print_labels(&self.atom, &self.forest);
- let _ = self.forest.print_viz("forest before extraction.gv");
+ // let _ = self.forest.print_viz("forest before extraction.gv");
result = self.forest.extract(pos)?;
diff --git a/chain/src/item/genins.rs b/chain/src/item/genins.rs
index 262728f..e3e79b6 100644
--- a/chain/src/item/genins.rs
+++ b/chain/src/item/genins.rs
@@ -212,7 +212,7 @@ impl DefaultForest<ForestLabel<GrammarLabel>> {
// Whether or not to print detailed graphs of each step of
// operation for debugging purposes.
let mut to_print = false;
- // let mut to_print = (8..=10).contains(&pos);
+ // let mut to_print = (11..=12).contains(&pos);
if std::fs::metadata("output/").is_err() {
to_print = false;
@@ -419,8 +419,8 @@ impl DefaultForest<ForestLabel<GrammarLabel>> {
.collect();
}
- // if pos == 9 {
- // dbg!(&parents);
+ // if pos == 12 {
+ // dbg!(num, &parents, pavi, label);
// }
let mut non_empty = false;
@@ -535,7 +535,6 @@ impl DefaultForest<ForestLabel<GrammarLabel>> {
parents,
reduction_info,
atom.query_reduction(label.label(), atom_child).unwrap(),
- is_empty_segment,
atom.trace(0, 3, atom_child)
.into_iter()
.flatten()
@@ -616,6 +615,10 @@ impl DefaultForest<ForestLabel<GrammarLabel>> {
unreachable!("the forest is wrongly planted");
}
+ // if pos == 11 {
+ // dbg!(root_label, node, edge, child);
+ // }
+
// dbg!(node, edge, root_label, leaf_label);
PaVi::Parent(node, edge, child)
} else {
diff --git a/chain/src/lib.rs b/chain/src/lib.rs
index bf3a8b4..f16ebb2 100644
--- a/chain/src/lib.rs
+++ b/chain/src/lib.rs
@@ -61,8 +61,13 @@ impl Edge {
self.forest_source
}
- /// Return the associated bottom edge of the edge from which
- /// onwards we shall perform the reduction.
+ /// Set the associated forest edge of the edge of the edge.
+ pub fn set_forest_source(&mut self, source: PaVi) {
+ self.forest_source = source;
+ }
+
+ /// Set the associated bottom edge of the edge from which onwards
+ /// we shall perform the reduction.
pub fn set_true_source(&mut self, true_source: PaVi) {
self.true_source = true_source;
}