Clean up precedence parser codegen since DSL v2#699
Merged
Xanewok merged 18 commits intoNomicFoundation:mainfrom Dec 9, 2023
Merged
Clean up precedence parser codegen since DSL v2#699Xanewok merged 18 commits intoNomicFoundation:mainfrom
Xanewok merged 18 commits intoNomicFoundation:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 04a6e59 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This introduced individual rule kinds per each precedence expression and we lose the grouping rules such as BinaryExpression. Not sure how desirable they were in the first place but it seems better and easier to handle specific expressions rather than using grouping rule kinds like before.
Since it's the only place it's used and it's a small helper.
b2648f8 to
0293980
Compare
This also fixes a run-time regression introduced with duplicate operator parsers when migrating to v2. To support different associativity/models for precedence expressions across multiple versions, the parser generator now: - groups the operators by model for a given precedence expression - defines a sub-parser for (expression, model) as a choice over the operators with a given model - each of the precedence sub-parses reduces to the parent precedence expression rule kind.
This lets us completely get rid of the ProductionKind, as we support parsing every `RuleKind` now.
OmarTawfik
reviewed
Dec 8, 2023
OmarTawfik
reviewed
Dec 8, 2023
OmarTawfik
reviewed
Dec 9, 2023
OmarTawfik
reviewed
Dec 9, 2023
OmarTawfik
requested changes
Dec 9, 2023
Contributor
OmarTawfik
left a comment
There was a problem hiding this comment.
Thank you. Left a few suggestions/questions.
OmarTawfik
reviewed
Dec 9, 2023
OmarTawfik
approved these changes
Dec 9, 2023
Contributor
OmarTawfik
left a comment
There was a problem hiding this comment.
One question remaining about snapshot tests.
Co-authored-by: Omar Tawfik <15987992+OmarTawfik@users.noreply.github.com>
This reverts commit 0296bef.
Merged
14 tasks
github-merge-queue bot
pushed a commit
that referenced
this pull request
Dec 14, 2023
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing). If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @nomicfoundation/slang@0.12.0 ### Minor Changes - [#699](#699) [`ddfebfe9`](ddfebfe) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove `ProductionKind` in favor of `RuleKind` - [#699](#699) [`ddfebfe9`](ddfebfe) Thanks [@Xanewok](https://github.com/Xanewok)! - Allow parsing individual precedence expressions, like `ShiftExpression` - [#665](#665) [`4b5f8b46`](4b5f8b4) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove the CST Visitor API in favor of the Cursor API - [#666](#666) [`0434b68c`](0434b68) Thanks [@Xanewok](https://github.com/Xanewok)! - Add `Node::unparse()` that allows to reconstruct the source code from the CST node - [#675](#675) [`daea4b7f`](daea4b7) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `Cursor`'s `pathRuleNodes()` to `ancestors()` in the NodeJS API. - [#676](#676) [`b496d361`](b496d36) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Fix NAPI `cursor` types and expose `cursor.depth`. ### Patch Changes - [#685](#685) [`b5fca94a`](b5fca94) Thanks [@Xanewok](https://github.com/Xanewok)! - `bytes` is now properly recognized as a reserved word - [#660](#660) [`97028991`](9702899) Thanks [@Xanewok](https://github.com/Xanewok)! - Drop List suffix from collection grammar rule names Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
github-merge-queue bot
pushed a commit
that referenced
this pull request
Dec 21, 2023
remaining from #699
rollup-smithbm0p
added a commit
to rollup-smithbm0p/slang
that referenced
this pull request
Dec 26, 2025
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing). If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @nomicfoundation/slang@0.12.0 ### Minor Changes - [#699](NomicFoundation/slang#699) [`ddfebfe9`](NomicFoundation/slang@ddfebfe) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove `ProductionKind` in favor of `RuleKind` - [#699](NomicFoundation/slang#699) [`ddfebfe9`](NomicFoundation/slang@ddfebfe) Thanks [@Xanewok](https://github.com/Xanewok)! - Allow parsing individual precedence expressions, like `ShiftExpression` - [#665](NomicFoundation/slang#665) [`4b5f8b46`](NomicFoundation/slang@4b5f8b4) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove the CST Visitor API in favor of the Cursor API - [#666](NomicFoundation/slang#666) [`0434b68c`](NomicFoundation/slang@0434b68) Thanks [@Xanewok](https://github.com/Xanewok)! - Add `Node::unparse()` that allows to reconstruct the source code from the CST node - [#675](NomicFoundation/slang#675) [`daea4b7f`](NomicFoundation/slang@daea4b7) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `Cursor`'s `pathRuleNodes()` to `ancestors()` in the NodeJS API. - [#676](NomicFoundation/slang#676) [`b496d361`](NomicFoundation/slang@b496d36) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Fix NAPI `cursor` types and expose `cursor.depth`. ### Patch Changes - [#685](NomicFoundation/slang#685) [`b5fca94a`](NomicFoundation/slang@b5fca94) Thanks [@Xanewok](https://github.com/Xanewok)! - `bytes` is now properly recognized as a reserved word - [#660](NomicFoundation/slang#660) [`97028991`](NomicFoundation/slang@9702899) Thanks [@Xanewok](https://github.com/Xanewok)! - Drop List suffix from collection grammar rule names Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This file contains hidden or 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
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.
Part of #638
This PR:
PrecedenceExpression::rule_namein favour of using the name directly for its rule/node kindFieldKindfrom DSL v2 #687 (comment))ProductionKindin favour of the now-completeRuleKindI can split this up but since all of this is interconnected, it made sense to work on them at the same time and submit work that solves all of the aforementioned issues.