Skip to content
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

Merged
merged 70 commits into from
Feb 28, 2025
Merged

Implement the legalizer #438

merged 70 commits into from
Feb 28, 2025

Conversation

mcy
Copy link
Member

@mcy mcy commented Jan 29, 2025

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 classifying predeclared.Names and some new taxa.Nouns for naming concepts in diagnostics relevant to the legalizer. Parsing is also tweaked in a few places to generate better diagnostics.

@mcy mcy requested a review from jhump January 29, 2025 23:20
@mcy mcy requested review from emcfarlane and doriable February 3, 2025 18:17
dependabot bot and others added 8 commits February 12, 2025 15:37
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.
Copy link
Member

@jhump jhump left a 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).

@@ -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.
Copy link
Member

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.

Copy link
Member Author

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.

@mcy mcy requested a review from jhump February 26, 2025 23:10
@mcy mcy enabled auto-merge (squash) February 28, 2025 19:41
@mcy mcy merged commit 06387a8 into main Feb 28, 2025
8 checks passed
@mcy mcy deleted the mcy/legalize branch February 28, 2025 19:48
@mcy mcy mentioned this pull request Feb 28, 2025
mcy added a commit that referenced this pull request Feb 28, 2025
#438 and #460 interacted poorly and broke CI. This regenerated some
generated code to fix it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants