summaryrefslogtreecommitdiff
path: root/grammar/src/lib.rs
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2023-02-12 12:07:34 +0800
committerJSDurand <mmemmew@gmail.com>2023-02-12 12:07:34 +0800
commit987c84f3454c687cca0efe0d471fcf00e052ecab (patch)
tree04b9cf073a12adfb5d07ae308c3809e88cf4ebd2 /grammar/src/lib.rs
parent265ff8f87dc7392fdf701f811eb2bf54d7bc6678 (diff)
Added the functionality of split or clone.
I need more than the ability to clone nodes: I also need to split the nodes. Now this seems to be correctly added.
Diffstat (limited to 'grammar/src/lib.rs')
-rw-r--r--grammar/src/lib.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/grammar/src/lib.rs b/grammar/src/lib.rs
index a8e0fd7..ab0f693 100644
--- a/grammar/src/lib.rs
+++ b/grammar/src/lib.rs
@@ -538,6 +538,15 @@ impl Grammar {
Ok(self.reduction_map.get(&(pos1, pos2)).map(AsRef::as_ref))
}
+ /// Set the reduction information.
+ ///
+ /// This is used to set the reduction information for the virtual
+ /// nodes that are added after the left closure has been computed.
+ #[inline]
+ pub fn set_reduction(&mut self, pos1: usize, pos2: usize, info: Vec<usize>) {
+ self.reduction_map.insert((pos1, pos2), info);
+ }
+
// REVIEW: Do we have a better way to record expansion and
// reduction information than to compute the transitive closure?