diff options
Diffstat (limited to 'chain/src/item/default')
| -rw-r--r-- | chain/src/item/default/extract.rs | 2 | ||||
| -rw-r--r-- | chain/src/item/default/mod.rs | 16 | ||||
| -rw-r--r-- | chain/src/item/default/splone.rs | 41 |
3 files changed, 28 insertions, 31 deletions
diff --git a/chain/src/item/default/extract.rs b/chain/src/item/default/extract.rs index c34f1da..2f9d6da 100644 --- a/chain/src/item/default/extract.rs +++ b/chain/src/item/default/extract.rs @@ -15,7 +15,7 @@ //! //! 1. Every node in *S* is complete. //! 2. For every node *n* in *S*, the subtree of *F* rooted at *n* -//! consists entirely of complete nodes. +//! consists entirely of complete nodes. //! //! # Uniqueness of the maximal completed sub-forest //! diff --git a/chain/src/item/default/mod.rs b/chain/src/item/default/mod.rs index f532805..eef7def 100644 --- a/chain/src/item/default/mod.rs +++ b/chain/src/item/default/mod.rs @@ -535,7 +535,7 @@ impl<T: GraphLabel> Forest<T> for DefaultForest<ForestLabel<T>> { builder.add_edge(f_node, f_child, node_label)?; } } - } else if !children_match_p(&builder, f_node, fragment.borrow(), node)? { + } else if !children_match_p(&builder, f_node, fragment, node)? { let cloned = self.clone_node(f_node, 0, false)?; let mut builder = PLGBuilderMut::from_graph_mut(&mut self.graph); @@ -594,8 +594,7 @@ impl<T: GraphLabel> Forest<T> for DefaultForest<ForestLabel<T>> { for cloned_child in fragment.children_of(node)? { let builder = PLGBuilderMut::from_graph_mut(&mut self.graph); - if !children_match_p(&builder, f_node, fragment.borrow(), cloned_child)? - { + if !children_match_p(&builder, f_node, fragment, cloned_child)? { let cloned = self.clone_node(f_node, 0, false)?; let mut builder = PLGBuilderMut::from_graph_mut(&mut self.graph); @@ -652,7 +651,7 @@ impl<T: GraphLabel> Forest<T> for DefaultForest<ForestLabel<T>> { continue 'node_loop; } - if children_match_p(&builder, f_node_clone, fragment.borrow(), node)? { + if children_match_p(&builder, f_node_clone, fragment, node)? { continue 'node_loop; } } @@ -720,12 +719,8 @@ impl<T: GraphLabel> Forest<T> for DefaultForest<ForestLabel<T>> { continue 'node_loop; } - if children_match_p( - &builder, - f_node_clone, - fragment.borrow(), - cloned_child, - )? { + if children_match_p(&builder, f_node_clone, fragment, cloned_child)? + { continue 'cloned_loop; } } @@ -1187,6 +1182,7 @@ impl DefaultForest<ForestLabel<GrammarLabel>> { let mut file = std::fs::File::options() .write(true) .create(true) + .truncate(true) .open(&filename)?; use std::io::Write; diff --git a/chain/src/item/default/splone.rs b/chain/src/item/default/splone.rs index f540000..8a81bf6 100644 --- a/chain/src/item/default/splone.rs +++ b/chain/src/item/default/splone.rs @@ -41,26 +41,26 @@ impl DefaultForest<ForestLabel<GrammarLabel>> { /// 1. Make sure it is labelled by a nonterminal. /// /// 2. Check the status of the node. If it is packed, return an - /// error. + /// error. /// /// 3. Make a new label according to the given `end`. See the - /// function - /// [`create_new_label`][DefaultForest::<ForestLabel<GrammarLabel>>::create_new_label] - /// for the process of making new labels. + /// function + /// [`create_new_label`][DefaultForest::<ForestLabel<GrammarLabel>>::create_new_label] + /// for the process of making new labels. /// /// 4. If the new label is equal to the old label, and if - /// `edge_index + 1` is equal to the degree of the node, then do - /// nothing. + /// `edge_index + 1` is equal to the degree of the node, then + /// do nothing. /// /// 5. If the new label is equal to the old label but - /// `edge_index+1` is not equal to the degree of the node, then - /// clone the node while preserving `edge_index + 1` many - /// children. + /// `edge_index+1` is not equal to the degree of the node, then + /// clone the node while preserving `edge_index + 1` many + /// children. /// /// 6. If the new label is not equal to the old label, then split - /// the node. See the function - /// [`split_node`][DefaultForest::<ForestLabel<GrammarLabel>>::split_node] - /// for details. + /// the node. See the function + /// [`split_node`][DefaultForest::<ForestLabel<GrammarLabel>>::split_node] + /// for details. /// /// # `completingp` /// @@ -291,9 +291,10 @@ impl DefaultForest<ForestLabel<GrammarLabel>> { /// 2. Preserve the old children as specified by `edge_index + 1`. /// /// 3. If the new node is closed or if the new node is not cloned, - /// then for each parent, clone the parent. Replace the original - /// child of the parent, which pointed to the old node, by this - /// new node. Other children are inherited from the old parent. + /// then for each parent, clone the parent. Replace the + /// original child of the parent, which pointed to the old + /// node, by this new node. Other children are inherited from + /// the old parent. /// /// # Return /// @@ -382,13 +383,13 @@ impl DefaultForest<ForestLabel<GrammarLabel>> { /// /// 3. Pack the label. /// - /// 4. Check if this label already exists. If so, clone the label and - /// return it. + /// 4. Check if this label already exists. If so, clone the label + /// and return it. /// /// 5. Else set the label to be a plain label. /// /// 6. Check if this plain label already exists. If so, clone the - /// existing label, and return the clone of the cloned label. + /// existing label, and return the clone of the cloned label. /// /// 7. Else return the plain label. /// @@ -590,7 +591,7 @@ impl DefaultForest<ForestLabel<GrammarLabel>> { if degree >= edge_index + 2 { let index_child = self.nth_child(clone, edge_index + 1)?; - if self.is_prefix(index_child, fragment.borrow())? { + if self.is_prefix(index_child, fragment)? { return Ok(None); } } @@ -614,7 +615,7 @@ impl DefaultForest<ForestLabel<GrammarLabel>> { if degree >= edge_index + 2 { let index_child = self.nth_child(node, edge_index + 1)?; - if self.is_prefix(index_child, fragment.borrow())? { + if self.is_prefix(index_child, fragment)? { return Ok(None); } } |
