summaryrefslogtreecommitdiff
path: root/chain/src/lib.rs
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2023-01-28 10:17:24 +0800
committerJSDurand <mmemmew@gmail.com>2023-01-28 10:22:57 +0800
commitf28155105134b90fd86049c65478d307e0d8dbbc (patch)
tree72b3b4872d5dba89413eca70bcaae9e421def7ee /chain/src/lib.rs
parente8ea01319b3a9032a3f4f69f65e9ca96562b87b9 (diff)
a prototype of an item derivation forest
It seems to be complete now, but still awaits more tests to see where the errors are, which should be plenty, haha.
Diffstat (limited to 'chain/src/lib.rs')
-rw-r--r--chain/src/lib.rs26
1 files changed, 14 insertions, 12 deletions
diff --git a/chain/src/lib.rs b/chain/src/lib.rs
index a3d420b..916678f 100644
--- a/chain/src/lib.rs
+++ b/chain/src/lib.rs
@@ -10,9 +10,16 @@
pub mod atom;
-use graph::{error::Error as GError, LabelExtGraph, Parent};
+pub mod item;
-use forest::Error as ForestError;
+// TODO: We need a module for items, that serve the role of the
+// forests now.
+
+use graph::{error::Error as GError, LabelExtGraph};
+
+use item::default::Error as ForestError;
+
+use item::PaSe;
/// An edge in the Chain-Rule machine.
#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)]
@@ -20,14 +27,14 @@ pub struct Edge {
/// The position in the atomic languages.
label: usize,
/// The source of the associated forest edge.
- forest_source: Parent,
+ forest_source: PaSe,
/// Whether or not this edge is "accepting".
accepting: bool,
}
impl Edge {
/// Construct a new edge.
- pub fn new(label: usize, forest_source: Parent, accepting: bool) -> Self {
+ pub fn new(label: usize, forest_source: PaSe, accepting: bool) -> Self {
Self {
label,
forest_source,
@@ -46,7 +53,7 @@ impl Edge {
}
/// Return the associated forest edge of the edge.
- pub fn forest_source(&self) -> Parent {
+ pub fn forest_source(&self) -> PaSe {
self.forest_source
}
}
@@ -56,12 +63,7 @@ impl core::fmt::Display for Edge {
let label = self.label();
let forest_source = self.forest_source();
- write!(
- f,
- "edge label {label} with forest source {} and edge index {}",
- forest_source.node(),
- forest_source.edge()
- )
+ write!(f, "edge label {label} with item {}", forest_source)
}
}
@@ -84,7 +86,7 @@ pub enum TwoLayers {
/// the source of the associated forest edge of the second layer,
/// and the third is a list of edges, which are the common first
/// layers.
- Two(usize, Parent, bool, Vec<(Edge, usize)>),
+ Two(usize, PaSe, bool, Vec<(Edge, usize)>),
}
/// The type of a collapsed iterator.