diff options
author | JSDurand <mmemmew@gmail.com> | 2023-07-08 12:30:21 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2023-07-08 12:31:13 +0800 |
commit | 9a317e56f8a6126583f7d0c431bf878d9b1fe7b1 (patch) | |
tree | 7bb6004196b38446a5ab0cb3a0ab642d35f113e9 /chain/src/archive.txt | |
parent | 691f969eb104fa3d4c2a1667693fd0382eb9d6b5 (diff) |
Finished the Emacs binding.
Now the binding part is finished.
What remains is a bug encountered when planting a fragment to the
forest which intersects a packed node, which would lead to invalid
forests. This will also cause problem when planting a packed
fragment, but until now my testing grammars do not produce packed
fragments, so this problem is not encountered yet.
I am still figuring out efficient ways to solve this problem.
Diffstat (limited to 'chain/src/archive.txt')
-rw-r--r-- | chain/src/archive.txt | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/chain/src/archive.txt b/chain/src/archive.txt index 030ccba..7bd6f31 100644 --- a/chain/src/archive.txt +++ b/chain/src/archive.txt @@ -493,3 +493,50 @@ // PaVi::Empty => Ok(self.root().ok_or(Error::IndexOutOfBounds(0, 0))?), // } // } + +// /// Find the last child of the given node whose start and end +// /// positions contain the given position. If no such child is +// /// found, return `Ok(None)`. +// /// +// /// The returned tuple is of the form (child, index), where +// /// `child` is the index of the child node in question, and +// /// `index` means that the child is the `index`-th child of the +// /// node. +// #[allow(dead_code)] +// pub(crate) fn position_search( +// &self, +// node: usize, +// pos: usize, +// ) -> Result<Option<(usize, usize)>, Error> { +// fn range_contains(label: GrammarLabel, pos: usize) -> bool { +// let start = label.start(); +// +// if let Some(end) = label.end() { +// (start..end).contains(&pos) +// } else { +// (start..).contains(&pos) +// } +// } +// +// let node_label = self +// .vertex_label(node)? +// .ok_or(Error::NodeNoLabel(node))? +// .label(); +// +// if !range_contains(node_label, pos) { +// return Ok(None); +// } +// +// for (index, child) in self.children_of(node)?.enumerate().rev() { +// let child_label = self +// .vertex_label(child)? +// .ok_or(Error::NodeNoLabel(child))? +// .label(); +// +// if range_contains(child_label, pos) { +// return Ok(Some((child, index))); +// } +// } +// +// Ok(None) +// } |