Skip to content

Commit c9e383d

Browse files
Merge pull request #83 from fibonacci1729/profiles
WIT Syntax: `world`
2 parents 52c6a0f + 8a5669d commit c9e383d

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

design/mvp/WIT.md

+25-8
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ keyword ::= 'use'
112112
| 'tuple'
113113
| 'future'
114114
| 'stream'
115+
| 'world'
116+
| 'import'
117+
| 'export'
115118
```
116119

117120
## Top-level items
@@ -122,20 +125,32 @@ readability but this isn't required.
122125

123126
Concretely, the structure of a `wit` document is:
124127
```
125-
wit-document ::= interface-item*
128+
wit-document ::= (interface-item | world-item)*
126129
```
127130

128-
## Item: `interface`
131+
## Item: `world`
129132

130-
Interfaces can be defined in a `wit` document. Interfaces have a name and a sequence of items and functions.
133+
Worlds define a [componenttype](https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md#type-definitions) as a collection of imports and exports.
134+
135+
Concretely, the structure of a world is:
131136

132137
```wit
133-
interface example {
134-
thunk: func() -> ()
135-
fibonacci: func(n: u32) -> u32
136-
}
138+
world-item ::= 'world' id '{' world-items* '}'
139+
140+
world-items ::= export-item | import-item
141+
142+
export-item ::= 'export' id ':' extern-type
143+
import-item ::= 'import' id ':' extern-type
144+
145+
extern-type ::= ty | func-type | interface-type
146+
147+
interface-type ::= 'interface' '{' interface-items* '}'
137148
```
138149

150+
## Item: `interface`
151+
152+
Interfaces can be defined in a `wit` document. Interfaces have a name and a sequence of items and functions.
153+
139154
Specifically interfaces have the structure:
140155

141156
```wit
@@ -151,7 +166,9 @@ interface-items ::= resource-item
151166
| use-item
152167
| func-item
153168
154-
func-item ::= id ':' 'func' param-list '->' result-list
169+
func-item ::= id ':' func-type
170+
171+
func-type ::= 'func' param-list '->' result-list
155172
156173
param-list ::= '(' named-type-list ')'
157174

0 commit comments

Comments
 (0)