summaryrefslogtreecommitdiff
path: root/chain/src/default.rs
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2023-08-01 11:47:44 +0800
committerJSDurand <mmemmew@gmail.com>2023-08-01 11:47:44 +0800
commit81854107bcf0b4480cfb11e8af7fec6894240c0c (patch)
treedb85df073d1f5201545aa463ef34307d763e7095 /chain/src/default.rs
parentca56b918b48cc08d8a43660a5e6f82c946fad8a0 (diff)
Fix some bugs
Some bugs are fixed: 1. If a non-terminal expansion can be reduced immediately, previously an extra node would be created that had no parents. Now this strange behaviour is corrected. 2. When performing reductions, a leaf non-terminal node would previously be regarded as completed. Now we will first try to complete that node, and then determine if the completion is successful, and finally determine the completedness according to the result. Of course some more tests are still pending, before I can confirm that no more bugs lurk around.
Diffstat (limited to 'chain/src/default.rs')
-rw-r--r--chain/src/default.rs11
1 files changed, 4 insertions, 7 deletions
diff --git a/chain/src/default.rs b/chain/src/default.rs
index 5f83115..618e560 100644
--- a/chain/src/default.rs
+++ b/chain/src/default.rs
@@ -594,13 +594,10 @@ impl Chain for DefaultChain {
&& matches!(self.forest.degree(1), Ok(d) if d > 0)
{
// dbg!(self.forest.vertex_label(1)?, self.atom.empty());
- match self.forest.vertex_label(1) {
- Ok(Some(label)) => {
- if label.label().label().rule().map(|n| n << 1) == Some(self.atom.empty()) {
- self.forest.remove_node(1)?;
- }
+ if let Ok(Some(label)) = self.forest.vertex_label(1) {
+ if label.label().label().rule().map(|n| n << 1) == Some(self.atom.empty()) {
+ self.forest.remove_node(1)?;
}
- _ => {}
}
}
@@ -1189,7 +1186,7 @@ mod test_chain {
let no_item = false;
- let input: &[usize] = &[3, 0, 2, 2, 2, 1, 1, 0, 1, 4, 2, 2, 1];
+ let input: &[usize] = &[3, 0, 2, 1, 1, 0, 1, 4, 0, 2, 1];
let input_len = input.len();