-
Notifications
You must be signed in to change notification settings - Fork 34
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
Require record fields to be simple identifiers #1086
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I.e., prevent records like `{a::b::c : 1}`. This includes refactoring the grammar so that qualified ids are now a grammar rule rather than a lexical rule.
The previous commit made the `reference` field in quint errors optional, this adapts the printer to handle that correctly.
The last three commits are generated/mechanical! |
Add the generated but uncommitted test fixtures.
Move some notes to correct section, and add an entry for the stricter rule for record labels.
5 tasks
thpani
approved these changes
Aug 2, 2023
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.
Looks great!
I have an alternative suggestion to making the error type fields optional; not sure myself if I prefer one over the other.
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When a
::
appears in a quint identifiers, I am referring to that identifier as"qualified". E.g.,
Foo::bar
is qualified, but_ding
is not.This takes care of one problem identified in #1081 by introducing a syntax error
a record field is a qualified identifier.
Along the way, the PR also gives further illustration of how we can address #17
by using error grammar rules. (There was already precedent for this in the
errorEq
rule checking for the misuse of=
for equality). This shows how wecan move stronger syntactic checks into the grammar without sacrificing the
quality of our error messages.
E.g., errors for this new rule look like so:
To enable this improvement in the grammar, we had to refactor the lexical rule
for
IDENTIFIER
: without splitting this into a lexical rule for theunqualified case and a grammar rule for the qualified, we end up with an
ambiguous lexical rule that makes parsing fail.
One incidental change is added to make the
reference
field in our error typeoptional. This is implied by the fact that parser errors are errors that should
be represented with this structure, but we may not have a reference for them yet.
CHANGELOG.md
for any new functionalityREADME.md
updated for any listed functionality