Skip to content

feat(grammar): added support for map types, nested packages, external-ids, and fallible constructors - #30

Merged
mkatychev merged 3 commits into
mainfrom
feat/map-support
Jul 15, 2026
Merged

feat(grammar): added support for map types, nested packages, external-ids, and fallible constructors#30
mkatychev merged 3 commits into
mainfrom
feat/map-support

Conversation

@mkatychev

Copy link
Copy Markdown
Member

Created decl_head for the package_decl contents without semicolon.
This pattern, though not following the spec, makes it easier to reconcile with nested packages:

decl_head: $ =>
seq(
'package',
repeat1($._uri_head),
$.id,
repeat($._uri_tail),
optional($._version),
),

Named interfaces and exports:

==================
Named interface imports and exports
==================
world my-world {
import primary: wasi:keyvalue/store;
import secondary: wasi:keyvalue/store;
export my-handler: wasi:http/handler;
import cache: store;
}
---

@mkatychev
mkatychev merged commit 00ae787 into main Jul 15, 2026
6 checks passed
mkatychev pushed a commit that referenced this pull request Aug 1, 2026
### 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 parse` fails on [valid code](https://github.com/WebAssembly/wasi-http/blob/7c678c4c10238a4bf4db91a0e27023d680ff65fe/wit/deps/io/poll.wit) with gates inside resources:

```wit
interface poll {
    resource pollable {
        @SInCE(version = 0.2.0)
        ready: func() -> bool;
    }
}
```

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_body` and `_interface_body` to hoist the gate parsing out of the specific item choices. This aligns the grammar structure with the spec:

```ebnf
world-items ::= gate world-definition
```

matching the existing implementation for `_resource_body`.
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.

1 participant