summaryrefslogtreecommitdiff
path: root/chain/src/item/genins.rs
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2023-07-08 12:30:21 +0800
committerJSDurand <mmemmew@gmail.com>2023-07-08 12:31:13 +0800
commit9a317e56f8a6126583f7d0c431bf878d9b1fe7b1 (patch)
tree7bb6004196b38446a5ab0cb3a0ab642d35f113e9 /chain/src/item/genins.rs
parent691f969eb104fa3d4c2a1667693fd0382eb9d6b5 (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/item/genins.rs')
-rw-r--r--chain/src/item/genins.rs18
1 files changed, 11 insertions, 7 deletions
diff --git a/chain/src/item/genins.rs b/chain/src/item/genins.rs
index 19f835b..e409c3c 100644
--- a/chain/src/item/genins.rs
+++ b/chain/src/item/genins.rs
@@ -32,7 +32,7 @@ pub(crate) fn index_out_of_bounds_conversion(ge: GrammarError) -> Error {
/// Determine if a label is labelled by a terminal.
fn is_labelled_by_terminal(label: GrammarLabelType) -> bool {
- matches!(label.tnt(), Some(t) if matches!(t, TNT::Ter(_)))
+ matches!(label.tnt(), Some(tnt) if matches!(tnt, TNT::Ter(_)))
}
/// A helper function to generate a fragment of forest.
@@ -211,7 +211,7 @@ impl DefaultForest<ForestLabel<GrammarLabel>> {
// Whether or not to print detailed graphs of each step of
// operation for debugging purposes.
- let to_print = false;
+ let to_print = true;
let tnt_string = {
let empty_p = atom_child_iter.len() == 0;
@@ -376,7 +376,7 @@ impl DefaultForest<ForestLabel<GrammarLabel>> {
if let PaVi::Parent(node, edge, _) = pavi {
let nth_child = self.nth_child(node, edge)?;
- let reduced = self.reduction(nth_child, pos, ter, atom.borrow())?;
+ let reduced = self.reduction(nth_child, pos, ter, atom.borrow(), false)?;
if reduced != nth_child && !self.is_empty_node(reduced)? {
parents.clear();
@@ -700,10 +700,14 @@ impl DefaultForest<ForestLabel<GrammarLabel>> {
let reduction_fragment = atom.generate_virtual_frags(nt, t, None);
- // NOTE: the case of the root is exceptional
- if reduction_fragment.is_none() && self.root() != Some(node) {
- return Err(Error::CannotClose(nt, t, node, node_label_start));
- }
+ // Maybe we do not have to force the reduciton here?
+
+ // // NOTE: the case of the root is exceptional
+ // if reduction_fragment.is_none() && self.root() != Some(node) {
+ // dbg!(self.root());
+ // self.print_viz("cannot close.gv").unwrap();
+ // return Err(Error::CannotClose(nt, t, node, node_label_start));
+ // }
for frag in reduction_fragment.into_iter().flatten() {
let mut frag = frag.clone();