aboutsummaryrefslogtreecommitdiff
path: root/chain/src/item/default/splone.rs
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2026-10-16 14:01:01 +0800
committerJSDurand <mmemmew@gmail.com>2026-10-16 14:02:10 +0800
commitfba9a90cfc6aca2a26cce72f55fb261789139781 (patch)
treeb4b121791ad639e745df689c0d5a8ed7a9e5dcc4 /chain/src/item/default/splone.rs
parent3ae0cf9898485a2ec35df7d23cd274e7dea5796d (diff)
new startHEADmaster
Now I tested and discussed with claude, and had a working version of this project. The rest is to port the claude version to my own writings. So this serves as the starting point before that attempt. In the new attempt the design is better, and a number of bugs were found and supposedly fixed, so let us see how this goes at the end.
Diffstat (limited to 'chain/src/item/default/splone.rs')
-rw-r--r--chain/src/item/default/splone.rs41
1 files changed, 21 insertions, 20 deletions
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);
}
}