diff options
author | JSDurand <mmemmew@gmail.com> | 2023-06-18 15:03:34 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2023-06-18 15:03:34 +0800 |
commit | a80db17473ff09cc72acba2c1975101e6dbedf39 (patch) | |
tree | 4d5dfcdfcd1537b51b92349d9a5274aa90a6d110 /chain/src/atom/mod.rs | |
parent | 6ce44bb3bdb79e8e727ee6fc7f5c6cd7fa0bb51e (diff) |
fixed the bugs of node duplications and left-open nodes
There were two main issues in the previous version.
One is that there are lots of duplications of nodes when manipulating
the forest. This does not mean that labels repeat: by the use of the
data type this cannot happen. What happened is that there were cloned
nodes whose children are exactly equal. In this case there is no need
to clone that node in the first place. This is now fixed by checking
carefully before cloning, so that we do not clone unnecessary nodes.
The other issue, which is perhaps more important, is that there are
nodes which are not closed. This means that when there should be a
reuction of grammar rules, the forest does not mark the corresponding
node as already reduced. The incorrect forests thus caused is hard to
fix: I tried several different approaches to fix it afterwards, but
all to no avail. I also tried to record enough information to fix
these nodes during the manipulations. It turned out that recording
nodes is a dead end, as I cannot properly syncronize the information
in the forest and the information in the chain-rule machine. Any
inconsistencies will result in incorrect operations later on.
The approach I finally adapt is to perform every possible reduction at
each step. This might lead to some more nodes than what we need. But
those are technically expected to be there after all, and it is easy
to filter them out, so it is fine, from my point of view at the
moment.
Therefore, what remains is to filter those nodes out and connect it to
the holy Emacs. :D
Diffstat (limited to 'chain/src/atom/mod.rs')
-rw-r--r-- | chain/src/atom/mod.rs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/chain/src/atom/mod.rs b/chain/src/atom/mod.rs index c9dadb2..4b3bfce 100644 --- a/chain/src/atom/mod.rs +++ b/chain/src/atom/mod.rs @@ -32,6 +32,9 @@ pub trait Atom: Nfa<LabelType<TNT>> + Deref<Target = Grammar> { /// Tell whether a node is accepting. fn is_accepting(&self, node_id: usize) -> Result<bool, GrammarError>; + + /// Return the bound for `is_accepting`. + fn accepting_len(&self) -> usize; } pub mod default; |