-
Notifications
You must be signed in to change notification settings - Fork 20
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
Implement the legalizer #438
Conversation
this contains all of the functions used in the legalizer as well as the recursive tree walk, but it does not contain the diagnostics, which will come in commits that follow.
Since open/close tokens are fused, when we set the `idx` for `NewCursorAt` for close tokens, we need to use the offset to set it to the open token.
Add a setter for brackets on `TypeList` and set them in the parser.
This PR adds basic text wrapping to diagnostic messages (except those attached to snippets) to avoid needing to wrap notes/helps by hand when writing diagnostics.
This PR also adds a test to exercise the corner case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've gone through all of your later commits. Thanks for making the changes -- this is looking really good.
But it looks like the later commits are cherry-picked from main. Please instead merge from main. It makes the commit list more clear for reviewers (and it would just be one commit in the branch to skip over instead of many).
experimental/parser/testdata/parser/method/incomplete.proto.stderr.txt
Outdated
Show resolved
Hide resolved
experimental/parser/testdata/parser/method/incomplete.proto.stderr.txt
Outdated
Show resolved
Hide resolved
internal/ext/iterx/iterx.go
Outdated
@@ -170,3 +170,19 @@ func Join[T any](seq iter.Seq[T], sep string) string { | |||
}) | |||
return out.String() | |||
} | |||
|
|||
// Chain returns an iterator that calls a sequence of iterators in sequence. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I usually see this function called Flatten
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have called it Flatten if it took an iterator of iterators.
This PR adds the legalizer: a collection of diagnostics that follow parsing to eliminate and diagnose invalid constructs that the parser accepted in order the make progress.
This PR also adds a new
syntax
package for e.g.syntax.Proto2
and other editions knowledge. It adds functions for classifyingpredeclared.Name
s and some newtaxa.Noun
s for naming concepts in diagnostics relevant to the legalizer. Parsing is also tweaked in a few places to generate better diagnostics.