From 5a40d2cb79a791a46a579fdf6532e1b49053e96c Mon Sep 17 00:00:00 2001 From: JSDurand Date: Tue, 18 Jul 2023 16:26:54 +0800 Subject: Fix the bug of incorrectly setting the end of forest nodes Previously when generating a fragment of the forest corresponding to the expansion of a non-terminal by a terminal, we incorrectly set the end of every node within it to be one plus the start, if the expansion happens due to a reduction. Now this mistake is fixed and the ending positions are correctly set. --- chain/src/item/genins.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'chain/src/item/genins.rs') diff --git a/chain/src/item/genins.rs b/chain/src/item/genins.rs index 07dbdfb..1996545 100644 --- a/chain/src/item/genins.rs +++ b/chain/src/item/genins.rs @@ -335,7 +335,7 @@ impl DefaultForest> { if let Some(frag) = virtual_frag { let mut frag = (*frag.get(0).unwrap()).clone(); - frag.set_pos(node_label.label().start(), false)?; + frag.set_pos(atom, node_label.label().start(), false)?; let frag_nodes_len = frag.nodes_len(); @@ -720,15 +720,10 @@ impl DefaultForest> { // return Err(Error::CannotClose(nt, t, node, node_label_start)); // } - // FIXME: It is not correct to set the end of all - // nodes unconditionally here. - // - // We need to figure out the correct way to set the - // ending positions. - for frag in reduction_fragment.into_iter().flatten() { let mut frag = frag.clone(); - frag.set_pos(node_label_start, true)?; + + frag.set_pos(atom, node_label_start, true)?; node = self.plant_at_start(node, frag)?; } -- cgit v1.2.3-18-g5258