aboutsummaryrefslogtreecommitdiff
path: root/nfa/src
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2024-01-08 16:13:19 +0800
committerJSDurand <mmemmew@gmail.com>2024-01-08 16:13:19 +0800
commit3ae0cf9898485a2ec35df7d23cd274e7dea5796d (patch)
tree35acbd1223288eb6f62ab281b57845c0ce2ed1c5 /nfa/src
parent55f7068e91182dfe458fad41c3251388ea461569 (diff)
a commit before the forst query
I think the main functionalities are already there, but the lack of querying capabilities makes this not very useful at the moment. This commit is right before an attempt to add this missing piece.
Diffstat (limited to 'nfa/src')
-rw-r--r--nfa/src/default/nfa.rs10
-rw-r--r--nfa/src/default/regex.rs6
2 files changed, 16 insertions, 0 deletions
diff --git a/nfa/src/default/nfa.rs b/nfa/src/default/nfa.rs
index e38a1a9..42f7fd8 100644
--- a/nfa/src/default/nfa.rs
+++ b/nfa/src/default/nfa.rs
@@ -43,6 +43,11 @@ impl<T: GraphLabel> LabelGraph<T> for DefaultNFA<T> {
Self: 'a,
T: 'a;
+ type TupleIter<'a> = <DLGraph<T> as LabelGraph<T>>::TupleIter<'a>
+ where
+ Self: 'a,
+ T: 'a;
+
#[inline]
fn vertex_label(&self, node_id: usize) -> Result<Option<T>, GError> {
if self.has_node(node_id) {
@@ -67,6 +72,11 @@ impl<T: GraphLabel> LabelGraph<T> for DefaultNFA<T> {
}
#[inline]
+ fn tuples_of(&self, node_id: usize) -> Result<Self::TupleIter<'_>, GError> {
+ self.graph.tuples_of(node_id)
+ }
+
+ #[inline]
fn labels_of(&self, node_id: usize) -> Result<Self::LabelIter<'_>, GError> {
self.graph.labels_of(node_id)
}
diff --git a/nfa/src/default/regex.rs b/nfa/src/default/regex.rs
index 8185ca5..261b10c 100644
--- a/nfa/src/default/regex.rs
+++ b/nfa/src/default/regex.rs
@@ -211,6 +211,12 @@ where
.take(self.len())
.collect();
+ // FIXME: This seems wrong: we shall perform a depth-first
+ // search to find nodes without children and collect their
+ // results first. However this function is not actually used
+ // elsewhere, so it is left unfixed until it is needed in the
+ // future.
+
for index in 0..=self.len() {
let algebra_result = {
let results_of_children: Vec<T> = self