summaryrefslogtreecommitdiff
path: root/chain/src/item/genins.rs
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2023-07-18 16:26:54 +0800
committerJSDurand <mmemmew@gmail.com>2023-07-18 16:26:54 +0800
commit5a40d2cb79a791a46a579fdf6532e1b49053e96c (patch)
treed30771829cf43455283893c5ea69728243f48c18 /chain/src/item/genins.rs
parent0fa0622a24dbdf0c2bd0fbf6bedf4cad5ed8d311 (diff)
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.
Diffstat (limited to 'chain/src/item/genins.rs')
-rw-r--r--chain/src/item/genins.rs11
1 files changed, 3 insertions, 8 deletions
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<ForestLabel<GrammarLabel>> {
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<ForestLabel<GrammarLabel>> {
// 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)?;
}