-
Notifications
You must be signed in to change notification settings - Fork 3
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
Simplify generated CST #12
base: main
Are you sure you want to change the base?
Conversation
@ckreibich It looks like the test step is failing for me even locally when running the current |
8596344
to
2465478
Compare
This allows users to use a uniform approach to match for variable declarations, and also even allows distinguishing declarations `of` local variables from assignments (in case they have an initializer).
2465478
to
e50434e
Compare
I rebased this on a recent The error I talked about previously was introduced by a patch originally in this PR which was making carriage return optional everywhere, i.e., use |
Closes #15.
This gives the operations a name so they can be matched on by users. We also fix the definitions so they have same precedence.
We also flatten the nide hierarchy for function-like constructs (`function`, `hook`, `event`) so they are exposed directly as top-level declarations.
This node has no additional semantic meaning beyond the `stmt_list` it wraps.
The previous name sounded a lot like a class initializer which this is not.
e50434e
to
f0f0698
Compare
Currently the generated CST contains many nodes which have the exact same range. Such nodes not only make the generated CST pretty cluttered, they also make it harder than needed to find good matchings between source locations and CST nodes (e.g., in a language server).
This PR somewhat flattens the generated CST so it contains less nodes which are mostly there for developer ergonomics while writing the parser. For that I make them either anonymous nodes, or simplify the grammar. While I was at it I also added explicit CST nodes which previously where not exposed directly.
To make the effects of this PR easier to understand I added a simple corpus. It is still hard to write minimal examples, but observing how the CST changes with each patch maybe makes the changes more transparent.
This is a cleaned up version of #1 which we closed at the time without merged.