summaryrefslogtreecommitdiff
path: root/chain/src/default.rs
diff options
context:
space:
mode:
Diffstat (limited to 'chain/src/default.rs')
-rw-r--r--chain/src/default.rs21
1 files changed, 19 insertions, 2 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)