From 81854107bcf0b4480cfb11e8af7fec6894240c0c Mon Sep 17 00:00:00 2001 From: JSDurand Date: Tue, 1 Aug 2023 11:47:44 +0800 Subject: 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. --- chain/src/default.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'chain/src/default.rs') 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(); -- cgit v1.2.3-18-g5258