Skip to content

Commit 205dc16

Browse files
authored
Merge pull request #7 from peterhuene/logos
Remove dependency on pest and pest-ast.
2 parents 8f8867c + 6d3a994 commit 205dc16

122 files changed

Lines changed: 7849 additions & 8221 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 108 additions & 186 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,15 @@ wasmparser = "0.115.0"
4040
wit-component = "0.16.0"
4141
anyhow = "1.0.75"
4242
clap = { version = "4.4.6", features = ["derive"] }
43-
pest = "2.7.4"
44-
pest_derive = "2.7.4"
45-
from-pest = "0.3.2"
46-
pest-ast = "0.3.4"
4743
semver = "1.0.20"
4844
pretty_env_logger = "0.5.0"
4945
log = "0.4.20"
5046
tokio = { version = "1.33.0", default-features = false, features = ["macros", "rt-multi-thread"] }
51-
owo-colors = "3.5.0"
47+
owo-colors = { version = "3.5.0", features = ["supports-colors"] }
5248
indexmap = { version = "2.0.2", features = ["serde"] }
5349
id-arena = "2.2.1"
5450
serde = { version = "1.0.189", features = ["derive"] }
5551
serde_json = "1.0.107"
5652
wat = "1.0.77"
53+
logos = "0.13.0"
54+
thiserror = "1.0.50"

README.md

Lines changed: 117 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,117 @@
1-
# wac
1+
# WAC grammar
2+
3+
The current WAC grammar:
4+
5+
```ebnf
6+
document ::= statement*
7+
statement ::= import-statement
8+
| type-statement
9+
| let-statement
10+
| export-statement
11+
12+
import-statement ::= 'import' id ('with' string)? ':' import-type ';'
13+
import-type ::= package-path | func-type | inline-interface | id
14+
package-path ::= package-name ('/' id)+ ('@' package-version)?
15+
package-name ::= id (':' id)+
16+
package-version ::= <SEMVER>
17+
18+
type-statement ::= interface-decl | world-decl | type-decl
19+
interface-decl ::= 'interface' id '{' interface-item* '}'
20+
interface-item ::= use-type | item-type-decl | interface-export
21+
use-type ::= 'use' use-path '.' '{' use-items '}' ';'
22+
use-path ::= package-path | id
23+
use-items ::= use-item (',' use-item)* ','?
24+
use-item ::= id ('as' id)?
25+
interface-export ::= id ':' func-type-ref ';'
26+
world-decl ::= 'world' id '{' world-item* '}'
27+
world-item ::= use-type
28+
| item-type-decl
29+
| world-import
30+
| world-export
31+
| world-include
32+
world-import ::= 'import' world-item-path ';'
33+
world-export ::= 'export' world-item-path ';'
34+
world-item-path ::= named-world-item | package-path | id
35+
named-world-item ::= id ':' extern-type
36+
extern-type ::= func-type | inline-interface | id
37+
inline-interface ::= 'interface' '{' interface-item* '}'
38+
world-include ::= 'include' world-ref ('with' '{' world-include-items '}')? ';'
39+
world-include-items ::= world-include-item (',' world-include-item)* ','?
40+
world-include-item ::= id 'as' id
41+
world-ref ::= package-path | id
42+
type-decl ::= variant-decl | record-decl | flags-decl | enum-decl | type-alias
43+
item-type-decl ::= resource-decl | type-decl
44+
resource-decl ::= 'resource' id '{' resource-item* '}'
45+
resource-item ::= constructor | method
46+
constructor ::= 'constructor' param-list
47+
method ::= id ':' 'static'? func-type-ref
48+
variant-decl ::= 'variant' id '{' variant-cases '}'
49+
variant-cases ::= variant-case (',' variant-case)* ','?
50+
variant-case ::= id ('(' type ')')?
51+
record-decl ::= 'record' id '{' fields '}'
52+
fields ::= named-type (',' named-type)* ','?
53+
flags-decl ::= 'flags' id '{' ids '}'
54+
ids ::= id (',' id)* ','?
55+
enum-decl ::= 'enum' id '{' ids '}'
56+
type-alias ::= 'type' id '=' (func-type | type) ';'
57+
func-type-ref ::= func-type | id
58+
func-type ::= '(' params? ')' ('->' results)?
59+
params ::= named-type (',' named-type)* ','?
60+
results ::= type
61+
| '(' named-type (',' named-type)* ','? ')'
62+
named-type ::= id ':' type
63+
type ::= u8
64+
| s8
65+
| u16
66+
| s16
67+
| u32
68+
| s32
69+
| u64
70+
| s64
71+
| float32
72+
| float64
73+
| char
74+
| bool
75+
| string
76+
| tuple
77+
| list
78+
| option
79+
| result
80+
| borrow
81+
| id
82+
tuple ::= 'tuple' '<' type (',' type)* ','? '>'
83+
list ::= 'list' '<' type '>'
84+
option ::= 'option' '<' type '>'
85+
result ::= 'result'
86+
| 'result' '<' type '>'
87+
| 'result' '<' '_' ',' type '>'
88+
| 'result' '<' type ',' type '>'
89+
borrow ::= 'borrow' '<' type '>'
90+
91+
let-statement ::= 'let' id '=' expr ';'
92+
expr ::= primary-expr postfix-expr*
93+
primary-expr ::= new-expr | nested-expr | id
94+
new-expr ::= 'new' package-name '{' instantiation-args '}'
95+
instantiation-args ::= instantiation-arg (',' instantiation-arg)* (',' '...'?)?
96+
instantiation-arg ::= named-instantiation-arg | id
97+
named-instantiation-arg ::= (id | string) ':' expr
98+
nested-expr ::= '(' expr ')'
99+
postfix-expr ::= access-expr | named-access-expr
100+
access-expr ::= '.' id
101+
named-access-expr ::= '[' string ']'
102+
103+
export-statement ::= 'export' expr ('with' string)? ';'
104+
105+
id ::= '%'?[a-z][a-z0-9]*('-'[a-z][a-z0-9]*)*
106+
string ::= '"' character-that-is-not-a-double-quote* '"'
107+
```
108+
109+
Whitespace (may appear anywhere between tokens):
110+
111+
```ebnf
112+
whitespace ::= ' ' | '\n' | '\r' | '\t' | comment
113+
comment ::= '//' character-that-is-not-a-newline*
114+
| '/*' any-unicode-character* '*/'
115+
```
116+
117+
Note: block comments are allowed to be nested.

crates/wac-parser/Cargo.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@ repository = { workspace = true }
1111

1212
[dependencies]
1313
anyhow = { workspace = true }
14-
clap = { workspace = true }
15-
pest = { workspace = true }
16-
pest_derive = { workspace = true }
17-
pest-ast = { workspace = true }
18-
from-pest = { workspace = true }
14+
logos = { workspace = true }
15+
thiserror = { workspace = true }
1916
semver = { workspace = true }
2017
log = { workspace = true }
2118
indexmap = { workspace = true }
@@ -25,6 +22,7 @@ wasmparser = { workspace = true }
2522
wit-parser = { workspace = true }
2623
wit-component = { workspace = true }
2724
wat = { workspace = true, optional = true }
25+
owo-colors = { workspace = true }
2826

2927
[features]
3028
default = ["wat"]

0 commit comments

Comments
 (0)