feat(grammar): support feature gates on nested items - #31
Open
avasich wants to merge 1 commit into
Open
Conversation
…arsing with spec - Allows feature gates (`@since`, etc.) on resource methods, record fields, variant cases, and enum cases. Official Wasm repos utilize these nested gates despite them lacking explicit definitions in the spec: https://github.com/WebAssembly/wasi-http/blob/7c678c4c10238a4bf4db91a0e27023d680ff65fe/wit/deps/io/poll.wit - Refactors `_world_body` and `_interface_body` to hoist `optional($._gate)` out of the item definitions, mirroring the spec's `world-items ::= gate world-definition` structure.
Member
|
Hi @avasich thanks for the submission. I will get to this later this week, was preoccupied with other projects. |
mkatychev
self-requested a review
July 29, 2026 17:16
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.
Description
This PR fixes a parse error where nested feature gates were not recognized by the grammar, and does a minor refactor to align item bodies closer to the spec.
1. Nested Feature Gates
Currently,
tree-sitter parsefails on valid code with gates inside resources:This patch adds
optional($._gate)to_resource_body.Furthermore, I added
optional($._gate)to_record_fields,_flags_fields,_variant_cases, and_enum_cases. Given the precedent of prioritizing practicality over strict spec adherence (e.g. #30), supporting these seems appropriate.2. Grammar Shape Refactoring
Refactored
_world_bodyand_interface_bodyto hoist the gate parsing out of the specific item choices. This aligns the grammar structure with the spec:matching the existing implementation for
_resource_body.