summaryrefslogtreecommitdiff
path: root/chain/src/item/default/mod.rs
AgeCommit message (Collapse)Author
2023-08-10Move the trait `Forest` to the crate "forest".JSDurand
The purpose of this change is to share this trait with other crates, such as the forth-coming "semiring" crate that will be responsible for handling some simple semiring operations as well as the querying, in my plans.
2023-08-01Fix some bugsJSDurand
Some bugs are fixed: 1. If a non-terminal expansion can be reduced immediately, previously an extra node would be created that had no parents. Now this strange behaviour is corrected. 2. When performing reductions, a leaf non-terminal node would previously be regarded as completed. Now we will first try to complete that node, and then determine if the completion is successful, and finally determine the completedness according to the result. Of course some more tests are still pending, before I can confirm that no more bugs lurk around.
2023-07-21Print graphs with edges in orderJSDurand
* chain/src/item/default/mod.rs: * graph/src/labelled/binary.rs: * graph/src/labelled/double.rs: * graph/src/lib.rs: If we set the option "ordering" to be "out" in the declaration of nodes at the beginning, then GraphViz will not change the order of children out of nodes. This is much better looking in my opinion. * INSTALL: make insists in changing this file, so let it be.
2023-07-21bump versionJSDurand
This bumping of version is insignificant. I just find it notable that I seem to finally obtain a version without trivial bugs. Hooray!
2023-07-18chain/src/item/default/mod.rs: Add a unit test for `set_pos`JSDurand
The function `set_pos` is kind of subtle and its behaviour needs a unit test so that we can be sure that it does not accidentally set the ending positions in a careless manner.
2023-07-18Fix the bug of incorrectly setting the end of forest nodesJSDurand
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.
2023-07-18Fix a bug of unnecessarily cloning nodes.JSDurand
* chain/src/item/default/splone.rs: Previously when we split nodes, we always clone the parent if the labels differ. This turns out to be incorrect if the new label is open whereas the old label is closed. In that case, the old parent should not contain the new node as a child, as a closed node should not contain an open node. I am not yet entirely sure this fix is correct, so more test await us.
2023-07-16Fix the bug of forgetting to check cloned nodes.JSDurand
In the process of splitting, cloning, and planting the forest, I forgot to check whether some cloned node of the node inquestion satisfy the condition. This used to cause forests that violate some fundamental assumptions. Now this is supposed to be fixed, but more tests await us.
2023-07-12Fix the bug of testing prefixes and plantingJSDurand
Previously the functions `is_prefix` and `plant` did not take the situation of packed nodes into considerations. That was because I only dealt with non-packed nodes in the past: the fragment to test for prefixes and for planting did not intersect the packed nodes in the forest, and the grammar is so simple that the fragments do not contain packed nodes. Then a test revealed this situation, so I have to fix this lack of considerations now. This commit attempts to fix this issue. From the newly added unit-tests, it seems that this fix works. :)
2023-07-08Finished the Emacs binding.JSDurand
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.
2023-06-18fixed the bugs of node duplications and left-open nodesJSDurand
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
2023-06-02Fix a bug of duplication from planting after sploingJSDurand
I should have staged and committed these changes separately, but I am too lazy to deal with that. The main changes in this commit are that I added the derive macro that automates the delegation of the Graph trait. This saves a lot of boiler-plate codes. The second main change, perhaps the most important one, is that I found and tried to fix a bug that caused duplication of nodes. The bug arises from splitting or cloning a node multiple times, and immediately planting the same fragment under the new "sploned" node. That is, when we try to splone the node again, we found that we need to splone, because the node that was created by the same sploning process now has a different label because of the planting of the fragment. Then after the sploning, we plant the fragment again. This makes the newly sploned node have the same label (except for the clone index) and the same children as the node that was sploned and planted in the previous rounds. The fix is to check for the existence of a node that has the same set of children as the about-to-be-sploned node, except for the last one, which contains the about-to-be-planted fragment as a prefix. If that is the case, treat it as an already existing node, so that we do not have to splone the node again. This is consistent with the principle to not create what we do not need.
2023-03-02extra reductionsJSDurand
Finished the function of performing extra reductions. Still untested though.
2023-02-27before a major refactorJSDurand
I decide to adopt a new approach of recording and updating item derivation forests. Since this affects a lot of things, I decide to commit before the refactor, so that I can create a branch for that refactor.
2023-02-12fix clone not changing the rootJSDurand
Previously cloning a node does not alter the root of the forest, while it should alter the root if the cloned node was the root. This would affect how we compare the equalities of forests. It indeed resulted in anomalies that were hard to solve.
2023-02-12Added the functionality of split or clone.JSDurand
I need more than the ability to clone nodes: I also need to split the nodes. Now this seems to be correctly added.