-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Symbols with empty match are not preserved #59
Comments
That was an early design decision, to remove elements that consume no input from the tree. IIRC the motivation was to make parse tree minimal and thus lower memory consumption but albeit it lead to the difficulties in processing parse trees as now you can't rely on the constant number of child nodes. I don't think this behavior will change any time soon as all users of Arpeggio depend on it (e.g. textX) so it would be a very disruptive change. There is a way to access nodes in non-terminal by name which might be a good general solution that wouldn't require change in the current behavior. I haven't checked if that is working at the moment for non-existing nodes but I guess that returning |
@igordejanovic Hi! I try the method you provided. The empty NonTerminals still don't appear when accessed by rule name. That causes problem with grammar like this:
Now I have to check the content for every combination of Would it be possible to have an option to retain all the childrens? |
Probably it would. I'm trying to figure out a general solution.
And there is also
All the grammars above match your input and return the same tree. Let's leave this open as a feature request. It seems that this needs more analysis. |
Here is a minimal example.
Given the grammar:
When it parses "abc" the result is normal,
but when it parses "ac" the NonTerminal
b
just disapper in the parse tree like this:The result is the same when using
b = "b"?
instead.Since
b
is actually matched, shouldn't it be in the parse tree (likea
orc
) withnode.value == ''
?The text was updated successfully, but these errors were encountered: