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

Describe "explicit"-style WIT package grammar #340

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 44 additions & 4 deletions design/mvp/WIT.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,22 @@ or
package wasi:clocks@1.2.0;
```

WIT packages can be defined in a collection of files and at least one of them
must specify a package name. Multiple files can specify a `package` and
they must all agree on what the package name is.
WIT packages can be defined in a collection of files. At least one of these
files must specify a package name. Multiple files can specify the `package`,
though they must all agree on what the package name is.

Alternatively, many packages can be declared consecutively in one or more
files, if the "explicit" package notation is used:

```wit
package local:a {
interface foo {}
}

package local:b {
interface bar {}
}
```

Package names are used to generate the [names of imports and exports]
in the Component Model's representation of [`interface`s][interfaces] and
Expand Down Expand Up @@ -848,7 +861,34 @@ readability but this isn't required.
Concretely, the structure of a `wit` file is:

```ebnf
wit-file ::= package-decl? (toplevel-use-item | interface-item | world-item)*
wit-file ::= explicit-package-list | implicit-package-definition
```

Files may be organized in two arrangements. The first of these is as a series
of multiple consecutive "explicit" `package ... {...}` declarations, with the
package's contents contained within the brackets.

```ebnf
explicit-package-list ::= explicit-package-definition*

explicit-package-definition ::= package-decl '{' package-items* '}'
```

Alternatively, a file may "implicitly" consist of an optional `package ...;`
declaration, followed by a list of package items.

```ebnf
implicit-package-definition ::= package-decl? package-items*
```

These two structures cannot be mixed: a file may be written in either in the
explicit or implicit styles, but not both at once.

All other declarations in a `wit` document are tied to a package, and defined
as follows. A package definition consists of one or more such items:

```ebnf
package-items ::= toplevel-use-item | interface-item | world-item
```

## Package declaration
Expand Down
Loading