diff options
Diffstat (limited to 'chain/src/default.rs')
| -rw-r--r-- | chain/src/default.rs | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/chain/src/default.rs b/chain/src/default.rs index 042f84e..db42ef8 100644 --- a/chain/src/default.rs +++ b/chain/src/default.rs @@ -224,6 +224,9 @@ pub struct DefaultChain { accepting_sources: Vec<PaVi>, } +// TODO: Implement saving the chain on disk, so that we do not have to +// load the grammar every time. + impl DefaultChain { /// Return the current node. #[inline] @@ -311,6 +314,7 @@ impl DefaultChain { let mut file = std::fs::File::options() .write(true) .create(true) + .truncate(true) .open(&filename)?; use std::io::Write; @@ -320,21 +324,25 @@ impl DefaultChain { } impl LabelGraph<Edge> for DefaultChain { - type Iter<'a> = <DLGraph<Edge> as LabelGraph<Edge>>::Iter<'a> + type Iter<'a> + = <DLGraph<Edge> as LabelGraph<Edge>>::Iter<'a> where Self: 'a; - type TupleIter<'a> = <DLGraph<Edge> as LabelGraph<Edge>>::TupleIter<'a> + type TupleIter<'a> + = <DLGraph<Edge> as LabelGraph<Edge>>::TupleIter<'a> where Self: 'a, Edge: 'a; - type LabelIter<'a> = <DLGraph<Edge> as LabelGraph<Edge>>::LabelIter<'a> + type LabelIter<'a> + = <DLGraph<Edge> as LabelGraph<Edge>>::LabelIter<'a> where Self: 'a, Edge: 'a; - type EdgeLabelIter<'a> = <DLGraph<Edge> as LabelGraph<Edge>>::EdgeLabelIter<'a> + type EdgeLabelIter<'a> + = <DLGraph<Edge> as LabelGraph<Edge>>::EdgeLabelIter<'a> where Self: 'a, Edge: 'a; @@ -554,7 +562,7 @@ impl Chain for DefaultChain { /// to save some allocations. fn generate_edges( input: GeneratorInput<'_>, - mut child_iter: impl Iterator<Item = usize> + ExactSizeIterator + Clone, + mut child_iter: impl ExactSizeIterator<Item = usize> + Clone, atom_child_iter: impl Iterator<Item = usize> + Clone, mut output: impl AsMut<Vec<(Roi, usize)>>, ) -> Result<bool, Error> { @@ -693,6 +701,15 @@ impl Chain for DefaultChain { let new_pavi = if !no_item { // prepare forest fragment + // if ter == 0 { + // println!("{ter}, {t}, {atom_moved}, {atom_label}"); + // println!( + // "hey: {:?}", + // self.atom.labels_of(0).unwrap().collect::<Vec<_>>() + // ); + // panic!("test"); + // } + let fragment = generate_fragment([atom_moved.into(), Ter(ter).into()], pos)?; |
