Closed dnicolodi closed 2 years ago
The problem comes from different options in a choice being able to return AST with completely different structure, which is the desirable behavior.
In this case it seems that the behavior of the dynamic parser is the correct one.
I agree that the behavior of the dynamic parser is the correct one. I think the difference in behavior comes from ParseContect._define
doing nothing if the current ast node is empty. However, relaxing the condition at the beginning of _define
causes some test cases to fail. I need to spend some more time analyzing what the code does.
The problem is that the expression doing the defines should be the first level sequence in the rhs of a rule. It would work for rules that have a choice as main expression, like in this case.
Fixed on this commit https://github.com/neogeny/TatSu/commit/852f6579e6c4dd06659b560339608f73c0a14281
I was in a hurry, and skipped the pull request by mistake.
I found a difference between the AST returned by the dynamic parser and the generated code parser. Here is a minimal example:
The dynamic parser always returns a dict with two elements "a" and "b", the parser from the generated code parses 'TEST' to 'TEST'. The output of the above code is:
It is also surprising that the generated code parser requires to explicitly pass the name of the grammar start rule, while the dynamic parser does not.