|
2 | 2 |
|
3 | 3 | WAC is a superset of the [WIT language](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md). |
4 | 4 |
|
| 5 | +However, unlike WIT, WAC is evaluated in a top-down fashion and is not a |
| 6 | +declarative language. Consequently, types must be declared before they are used |
| 7 | +in WAC. |
| 8 | + |
5 | 9 | In addition to being able to declare types, interfaces, and worlds, WAC |
6 | 10 | also allows for defining a _composition_. |
7 | 11 |
|
8 | 12 | In the simplest terms, a composition is a collection of components that |
9 | 13 | are instantiated in a topological order and certain exports from those |
10 | 14 | instances are made available as exports of the composition itself. |
11 | 15 |
|
| 16 | +## Package Directive |
| 17 | + |
| 18 | +Each WAC document must begin with a `package` directive: |
| 19 | + |
| 20 | +```wac |
| 21 | +package example:composition; |
| 22 | +``` |
| 23 | + |
| 24 | +The directive identifies the namespace and name of the package being defined. |
| 25 | + |
| 26 | +Additionally, the `package` directive may include a `targets` clause: |
| 27 | + |
| 28 | +```wac |
| 29 | +package example:composition targets wasi:http/proxy; |
| 30 | +``` |
| 31 | + |
| 32 | +The package path following a `targets` clause must name a world. The parser |
| 33 | +will then ensure that the composition is valid for the given world. |
| 34 | + |
| 35 | +If the composition is not valid for the given world, then an error will be |
| 36 | +emitted. |
| 37 | + |
| 38 | +## Statements |
| 39 | + |
12 | 40 | WAC currently has three statements that extend the WIT language: import |
13 | 41 | statements, let statements, and export statements. |
14 | 42 |
|
@@ -398,7 +426,7 @@ export my-instance...; |
398 | 426 | Then the `run` function exported by the composition will be from the instance |
399 | 427 | named `b:c` and not the instance named `a:b`. |
400 | 428 |
|
401 | | -### WAC Grammar |
| 429 | +## WAC Grammar |
402 | 430 |
|
403 | 431 | The current WAC grammar: |
404 | 432 |
|
|
0 commit comments