summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chain/src/default.rs21
-rw-r--r--chain/src/item/genins.rs6
2 files changed, 21 insertions, 6 deletions
diff --git a/chain/src/default.rs b/chain/src/default.rs
index 7ee460c..da665bf 100644
--- a/chain/src/default.rs
+++ b/chain/src/default.rs
@@ -17,7 +17,10 @@ use graph::{
labelled::DLGBuilder, Builder, DLGraph, Graph, LabelExtGraph, LabelGraph, ParentsGraph,
};
-use std::collections::{HashMap as Map, HashSet, TryReserveError};
+use std::{
+ borrow::Borrow,
+ collections::{HashMap as Map, HashSet, TryReserveError},
+};
/// The errors related to taking derivatives by chain rule.
#[non_exhaustive]
@@ -194,6 +197,16 @@ impl Iterator for DerIter {
}
}
+// TODO: Add a hashmap mapping tuples of forest positions (top,
+// bottom) to vectors of tuples of unsigned integers. Each tuple
+// represents a non-terminal and a rule. The tuple means that we need
+// to close the expansion of the non-terminal by the rule position, if
+// we want to move from bottom to top.
+//
+// After we move up one layer, we are now in a new forest position, so
+// we just query again with the new bottom and top. This means we do
+// not need to clear the map.
+
/// A default implementation for the [`Chain`] trait.
#[derive(Debug, Clone, Default)]
pub struct DefaultChain {
@@ -739,7 +752,7 @@ impl Chain for DefaultChain {
let mut new_edges = Vec::new();
let virtual_accepting = generate_edges(
- self,
+ self.borrow(),
child_iter.clone(),
atom_child_iter.clone(),
first_segment_pavi,
@@ -753,6 +766,7 @@ impl Chain for DefaultChain {
if accepting {
accepting_pavi.insert(virtual_pavi);
+ // FIXME: set true_source here
der_iter.singles.extend(new_edges.clone());
}
@@ -787,6 +801,8 @@ impl Chain for DefaultChain {
if self.atom.is_empty_node(atom_child).unwrap() {
// REVIEW: flat flat map,
// hmm...
+
+ // FIXME: Set true_source as well.
der_iter.singles.extend(child_iter.clone().flat_map(
|child| {
self.graph.labels_of(child).unwrap().flat_map(
@@ -810,6 +826,7 @@ impl Chain for DefaultChain {
}
}
+ self.accepting_sources.clear();
self.accepting_sources.extend(accepting_pavi);
Ok(der_iter)
diff --git a/chain/src/item/genins.rs b/chain/src/item/genins.rs
index feb45c6..41972c1 100644
--- a/chain/src/item/genins.rs
+++ b/chain/src/item/genins.rs
@@ -200,9 +200,7 @@ impl DefaultForest<ForestLabel<GrammarLabel>> {
if matches!(nth_child_label.label().label().tnt(), Some(TNT::Non(_)))
&& !nth_child_label.is_packed()
{
- let sploned = self.splone(nth_child, Some(pos), nth_child_last, false)?;
-
- sploned
+ self.splone(nth_child, Some(pos), nth_child_last, false)?
} else {
nth_child
}
@@ -587,7 +585,7 @@ impl DefaultForest<ForestLabel<GrammarLabel>> {
if pos == 4 && matches!(true_source, PaVi::Virtual(_, _, _)) {
dbg!(&stack, reduction_info, true_source, pavi);
- self.print_viz(&format!("pos4ib.gv")).unwrap();
+ self.print_viz("pos4ib.gv").unwrap();
}
for parent in stack {