summaryrefslogtreecommitdiff
path: root/chain/src/item
AgeCommit message (Collapse)Author
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-02review of previous bug fixJSDurand
Generally speaking the algorithm now works correctly and produces the right shape of forest for the test ambiguous grammar as well. It does not correctly perform the "reductions". It seems that I deliberately disabled this part of the functionalities in a previous debugging tour. So I have to enable it again and see if it works.
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-28Add a type Reducer for recording extra reductionsJSDurand
In the chain-rule machine, we need to skip through edges whose labels are "accepting", otherwise the time complexity will be high even for simple grammars. This implies that we will skip some "jumping up" in the item derivation forest. So we need to record these extra jumping up, in order to jump up at a later point. This Reducer type plays this role. But I still need more experiments to see if this approach works out as I intended.
2023-02-28genins: fix minor error according to clippyJSDurand
* chain/src/item/genins.rs: Some minor fixes according to clippy.
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-13Fix phantom edgesJSDurand
Previously there was a minor bug: if the chain-rule machine ended in a node without children, which node should be accepting because of edges that have no children and hence were ignored, then since the node has no children, it would be regarded as not accepting. Now this issue is fixed by introducting real or imaginary edges, where an imaginary edge is used to determine the acceptance of nodes without chidlren.
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.
2023-02-03Finally produced the first correct forestJSDurand
Finally the prototype parser has produced the first correct forest. It is my first time to generate a correct forest, in fact, ever since the beginning of this project.
2023-01-28a prototype of an item derivation forestJSDurand
It seems to be complete now, but still awaits more tests to see where the errors are, which should be plenty, haha.