-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[ANTLR] Various changes. #52293
[ANTLR] Various changes. #52293
Conversation
See the added changelog entry.
Thank you for your contribution. This project uses Gerrit for code reviews. Your pull request has automatically been converted into a code review at: https://dart-review.googlesource.com/c/sdk/+/301728 Please wait for a developer to review your code review at the above link. See CONTRIBUTING.md to learn how to upload changes to Gerrit directly. You can speed up the review if you sign into Gerrit and manually add a reviewer that has recently worked on the relevant code and they will help you. You can also push additional commits to this pull request to update the code review. |
https://dart-review.googlesource.com/c/sdk/+/301728 has been updated with the latest commits from this pull request. |
1 similar comment
https://dart-review.googlesource.com/c/sdk/+/301728 has been updated with the latest commits from this pull request. |
https://dart-review.googlesource.com/c/sdk/+/301728 has been updated with the latest commits from this pull request. |
2 similar comments
https://dart-review.googlesource.com/c/sdk/+/301728 has been updated with the latest commits from this pull request. |
https://dart-review.googlesource.com/c/sdk/+/301728 has been updated with the latest commits from this pull request. |
Hi @modulovalue, thanks for the input! This PR makes a lot of changes to the grammar, and this is usually something that involves discussions for quite a while. For instance, the Could you say something about your motivation for proposing these changes? |
To be clear, I don't intend for the
I completely understand that this is important and should be considered. If you strongly feel that any of the changes proposed here diverge too much from the goals that you have for the specification, then I can remove them and perhaps open a separate issue for them.
I've been making great progress on parsing Dart using a custom GLR-style parser generator and my goal is to have my grammar not diverge too much from the specification. One of the issues that I need to solve to make that practical is to automatically transform parse trees into shallow ASTs. I plan to do this by transforming chains of composed expressions (e.g. ifNullExpression -> logicalOrExpression -> logicalAndExpression -> ...) into a single sum type. I plan to do this by allowing my grammar to specify spanning trees (in addition to the usual one level deep alternations). A spanning tree should then be able to break cycles that can't be removed manually (because converting their recursive rules into equivalent iterative ones is not possible). Unfortunately, small cycles like the Also, it looks like the recursive view of |
(assigning a reviewer to remove this from the triage queue) |
@eernstg ping? |
Quote:
I was planning to revisit this. I will close it until then. |
This PR proposes the following changes:
Convert left-recursion in
cascade
to iteration.Since one of the goals of the grammar is to be a reference for recursive-descent-style parsers, I believe this is a desirable change.
Convert right-recursion in
unaryExpression
to iteration.In the spirit of the PR that added the previous changelog entry, this simplifies the grammar by making it explicit that unary expressions have a regular structure.
Remove the dependency on order for disambiguating
<typeArguments> <arguments>
and<arguments>
in selectors.Closes dart-lang/language#3039
Fix inconsistent order-dependent disambiguation between methods and external constructors.
The following program
has the following parse tree:
Notice how the external method is recognized as being a constructor. This is inconsistent with how non-external constructors are being recognized. This PR fixes this to treat external methods and constructors the way that non-external methods and constructors are being treated.
Minor formatting changes.
I think the changes related to formatting are self-explanatory. They are meant to make those parts match how the rest of the file is formatted.