Skip to content

Commit ae26b28

Browse files
committed
feat: implement sized list syntax support (list<type, size>)
Fizes #57 Signed-off-by: Gordon Smith <GordonJSmith@gmail.com>
1 parent e686416 commit ae26b28

File tree

6 files changed

+314
-1
lines changed

6 files changed

+314
-1
lines changed

syntaxes/wit.tmLanguage.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@
12001200
},
12011201
"list": {
12021202
"name": "meta.list.ty.wit",
1203-
"comment": "Syntax for WIT types such as list",
1203+
"comment": "Syntax for WIT types such as list with optional size parameter",
12041204
"begin": "\\b(list)\\b(\\<)",
12051205
"beginCaptures": {
12061206
"1": {
@@ -1218,6 +1218,24 @@
12181218
"name": "meta.types.list.wit",
12191219
"include": "#types"
12201220
},
1221+
{
1222+
"name": "meta.list-size-separator.wit",
1223+
"match": "\\s*(,)\\s*",
1224+
"captures": {
1225+
"1": {
1226+
"name": "punctuation.comma.wit"
1227+
}
1228+
}
1229+
},
1230+
{
1231+
"name": "meta.list-size.wit",
1232+
"match": "\\b([0-9]+)\\b",
1233+
"captures": {
1234+
"1": {
1235+
"name": "constant.numeric.integer.list-size.wit"
1236+
}
1237+
}
1238+
},
12211239
{
12221240
"include": "#whitespace"
12231241
}

test-unused-imports.wit

Whitespace-only changes.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package foo:foo;
2+
3+
interface sized-lists {
4+
// Regular lists without size
5+
simple-list: func(l: list<u32>);
6+
7+
// Sized lists with fixed length
8+
ipv4-address: func() -> list<u8, 4>;
9+
ipv6-address: func() -> list<u16, 8>;
10+
small-buffer: func(data: list<u8, 16>) -> list<u8, 32>;
11+
12+
// Nested structures with sized lists
13+
complex-data: func() -> tuple<list<u32, 4>, list<string, 2>>;
14+
record-with-sized-list: func() -> record-type;
15+
}
16+
17+
record record-type {
18+
id: u32,
19+
data: list<u8, 10>,
20+
tags: list<string, 5>,
21+
}
22+
23+
world sized-lists-world {
24+
export sized-lists;
25+
}

0 commit comments

Comments
 (0)