-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for semicolon delimiters to wit-parser (#1212)
* Add support for semicolon delimiters to `wit-parser` This commit is an implementation of WebAssembly/component-model#142 to add semicolon delimiters to the WIT text format. The intention of this change is to be rolled out gradually to minimize ecosystem disruption (although some is inevitable). The strategy implemented in this commit is to add support to parse semicolons but optionally do so. Requiring semicolons is configured via: * A new `WIT_REQUIRE_SEMICOLONS` environment variable is now read. If set to `1` then semicolons are required during parsing. * A new `SourceMap::set_require_semicolons` is provided to programmatically indicate what to do. When semicolons are not required they are still parsed, but a failure is not generated if they're not present. This should allow semicolon-using WIT to coexist with non-semicolon-using WIT for a transitionary period. After a release or two the default for requiring semicolons will switch to `true` from the current `false`. That means that `WIT_REQUIRE_SEMICOLONS=0` can be used to keep old WITs compiling. The after a few releases of that support for optionally parsing semicolons will be removed and they'll be unconditionally required. * Update all in-repo tests to use semicolons Additionally add environment-variable support to WIT printing to optionally print semicolons, disabled for now.
- Loading branch information
1 parent
113d753
commit 553ec51
Showing
394 changed files
with
1,273 additions
and
1,194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
crates/wit-component/tests/components/adapt-empty-interface/adapt-old.wit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
world adapt-old { | ||
import new: interface { | ||
thunk-that-is-not-called: func() | ||
thunk-that-is-not-called: func(); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
crates/wit-component/tests/components/adapt-export-default/adapt-old.wit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
world adapt-old { | ||
export entrypoint: func() | ||
export entrypoint: func(); | ||
} |
4 changes: 2 additions & 2 deletions
4
crates/wit-component/tests/components/adapt-export-namespaced/adapt-old.wit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
interface new { | ||
entrypoint: func() | ||
entrypoint: func(); | ||
} | ||
|
||
world adapt-old { | ||
export new | ||
export new; | ||
} |
4 changes: 2 additions & 2 deletions
4
crates/wit-component/tests/components/adapt-export-reallocs/adapt-old.wit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
world adapt-old { | ||
import new: interface { | ||
read: func(amt: u32) -> list<u8> | ||
read: func(amt: u32) -> list<u8>; | ||
} | ||
export entrypoint: func(args: list<string>) | ||
export entrypoint: func(args: list<string>); | ||
} |
2 changes: 1 addition & 1 deletion
2
crates/wit-component/tests/components/adapt-export-save-args/adapt-old.wit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
world adapt-old { | ||
export entrypoint: func(nargs: u32) | ||
export entrypoint: func(nargs: u32); | ||
} |
4 changes: 2 additions & 2 deletions
4
crates/wit-component/tests/components/adapt-export-with-post-return/adapt-old.wit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
interface new { | ||
foo: func() -> string | ||
foo: func() -> string; | ||
} | ||
|
||
world adapt-old { | ||
export new | ||
export new; | ||
} |
6 changes: 3 additions & 3 deletions
6
crates/wit-component/tests/components/adapt-import-only-used-in-adapter/adapt-unused.wit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
interface adapter-imports { | ||
foo: func(x: string) | ||
foo: func(x: string); | ||
} | ||
|
||
world adapt-unused { | ||
import adapter-imports | ||
import adapter-imports; | ||
|
||
export adapter-bar: func(x: string) | ||
export adapter-bar: func(x: string); | ||
} |
4 changes: 2 additions & 2 deletions
4
crates/wit-component/tests/components/adapt-import-only-used-in-adapter/module.wit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package foo:foo | ||
|
||
world module { | ||
import foo: func(x: string) | ||
export bar: func() | ||
import foo: func(x: string); | ||
export bar: func(); | ||
} |
2 changes: 1 addition & 1 deletion
2
crates/wit-component/tests/components/adapt-inject-stack-with-adapt-realloc/adapt-old.wit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
world adapt-old { | ||
import new: interface { | ||
get-two: func() -> (a: u32, b: u32) | ||
get-two: func() -> (a: u32, b: u32); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
crates/wit-component/tests/components/adapt-inject-stack-with-realloc-no-state/adapt-old.wit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
world adapt-old { | ||
import new: interface { | ||
get-two: func() -> (a: u32, b: u32) | ||
get-two: func() -> (a: u32, b: u32); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
crates/wit-component/tests/components/adapt-inject-stack-with-realloc/adapt-old.wit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
world adapt-old { | ||
import new: interface { | ||
get-two: func() -> (a: u32, b: u32) | ||
get-two: func() -> (a: u32, b: u32); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...s/wit-component/tests/components/adapt-inject-stack-with-reallocing-adapter/adapt-old.wit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
world adapt-old { | ||
import new: interface { | ||
get-two: func() -> (a: u32, b: u32) | ||
get-two: func() -> (a: u32, b: u32); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
crates/wit-component/tests/components/adapt-inject-stack/adapt-old.wit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
world adapt-old { | ||
import new: interface { | ||
get-two: func() -> (a: u32, b: u32) | ||
get-two: func() -> (a: u32, b: u32); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
crates/wit-component/tests/components/adapt-list-return/adapt-old.wit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
world adapt-old { | ||
import new: interface { | ||
read: func() -> list<u8> | ||
read: func() -> list<u8>; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
crates/wit-component/tests/components/adapt-memory-simple/adapt-old.wit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
world adapt-old { | ||
import new: interface { | ||
log: func(s: string) | ||
log: func(s: string); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
crates/wit-component/tests/components/adapt-multiple/adapt-foo.wit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
world adapt-foo { | ||
import other1: interface { | ||
foo: func() | ||
foo: func(); | ||
} | ||
import other2: interface { | ||
bar: func() | ||
bar: func(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,6 @@ package foo:foo | |
|
||
world module { | ||
import foo: interface { | ||
foo: func() | ||
foo: func(); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
crates/wit-component/tests/components/adapt-unused/adapt-old.wit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
world adapt-old { | ||
import new: interface { | ||
log: func(s: string) | ||
log: func(s: string); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package foo:foo | ||
world module { | ||
import foo: func() | ||
import bar: func() -> string | ||
export baz: func() | ||
export foo2: func(x: string) -> option<list<u8>> | ||
import foo: func(); | ||
import bar: func() -> string; | ||
export baz: func(); | ||
export foo2: func(x: string) -> option<list<u8>>; | ||
} |
8 changes: 4 additions & 4 deletions
8
crates/wit-component/tests/components/ensure-default-type-exports/module.wit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
package foo:foo | ||
|
||
interface foo { | ||
type foo = u8 | ||
type foo = u8; | ||
|
||
record bar { | ||
x: foo | ||
} | ||
|
||
a: func(b: bar) | ||
a: func(b: bar); | ||
} | ||
|
||
world module { | ||
import foo | ||
import foo; | ||
|
||
export a: func(b: u8) | ||
export a: func(b: u8); | ||
} |
2 changes: 1 addition & 1 deletion
2
crates/wit-component/tests/components/error-adapt-missing-memory/adapt-old.wit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
world adapt-old { | ||
import new: interface { | ||
log: func(s: string) | ||
log: func(s: string); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
crates/wit-component/tests/components/error-default-export-sig-mismatch/module.wit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package foo:foo | ||
|
||
world module { | ||
export a: func(x: string) -> string | ||
export a: func(x: string) -> string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
crates/wit-component/tests/components/error-import-resource-rep/module.wit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package foo:bar | ||
|
||
world module { | ||
resource a | ||
resource a; | ||
} |
2 changes: 1 addition & 1 deletion
2
crates/wit-component/tests/components/error-import-resource-wrong-signature/module.wit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package foo:bar | ||
|
||
world module { | ||
resource a | ||
resource a; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,6 @@ package foo:foo | |
|
||
world module { | ||
import foo: interface { | ||
bar: func(s: string) | ||
bar: func(s: string); | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
crates/wit-component/tests/components/error-link-duplicate-symbols/lib-foo.wit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
package test:test | ||
|
||
interface test { | ||
foo: func(v: s32) -> s32 | ||
foo: func(v: s32) -> s32; | ||
} | ||
|
||
world lib-foo { | ||
import test | ||
export test | ||
import test; | ||
export test; | ||
} |
Oops, something went wrong.