Skip to content

Commit 2e48008

Browse files
authored
Fix grammar for names and add some more tests (#620)
Resolves #619
1 parent c7176a5 commit 2e48008

File tree

2 files changed

+48
-6
lines changed

2 files changed

+48
-6
lines changed

design/mvp/Explainer.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2539,17 +2539,18 @@ plainname ::= <label>
25392539
| '[method]' <label> '.' <label>
25402540
| '[static]' <label> '.' <label>
25412541
label ::= <first-fragment> ( '-' <fragment> )*
2542-
first-fragment ::= [a-z] <word>
2543-
| [A-Z] <acronym>
2542+
first-fragment ::= <first-word>
2543+
| <first-acronym>
2544+
first-word ::= [a-z] [0-9a-z]*
2545+
first-acronym ::= [A-Z] [0-9A-Z]*
25442546
fragment ::= <word>
25452547
| <acronym>
2546-
word ::= [0-9a-z]*
2547-
acronym ::= [0-9A-Z]*
2548+
word ::= [0-9a-z]+
2549+
acronym ::= [0-9A-Z]+
25482550
interfacename ::= <namespace> <label> <projection> <interfaceversion>?
25492551
| <namespace>+ <label> <projection>+ <interfaceversion>? 🪺
25502552
namespace ::= <words> ':'
2551-
words ::= <word>
2552-
| <words> '-' <word>
2553+
words ::= <first-word> ( '-' <word> )*
25532554
projection ::= '/' <label>
25542555
interfaceversion ::= '@' <valid semver>
25552556
| '@' <canonversion> 🔗

test/names/kebab.wast

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
(import "B-1" (func))
99
(import "B-1-C-2-D-3" (func))
1010
(import "a11-B11-123-ABC-abc" (func))
11+
(import "ns-1-a:b-1-c/D-2" (func))
1112
))
1213
(assert_invalid
1314
(component
@@ -17,3 +18,43 @@
1718
(component
1819
(import "1-a" (func)))
1920
"is not in kebab case")
21+
(assert_invalid
22+
(component
23+
(import "" (func)))
24+
"is not in kebab case")
25+
(assert_invalid
26+
(component
27+
(import "a-" (func)))
28+
"is not in kebab case")
29+
(assert_invalid
30+
(component
31+
(import "a--" (func)))
32+
"is not in kebab case")
33+
(assert_invalid
34+
(component
35+
(import "1:a/b" (func)))
36+
"is not in kebab case")
37+
(assert_invalid
38+
(component
39+
(import "A:b/c" (func)))
40+
"is not a valid extern name")
41+
(assert_invalid
42+
(component
43+
(import "1:b/c" (func)))
44+
"is not a valid extern name")
45+
(assert_invalid
46+
(component
47+
(import "ns-A:b/c" (func)))
48+
"is not a valid extern name")
49+
(assert_invalid
50+
(component
51+
(import "ns:A/b" (func)))
52+
"is not a valid extern name")
53+
(assert_invalid
54+
(component
55+
(import "ns:1/a" (func)))
56+
"is not a valid extern name")
57+
(assert_invalid
58+
(component
59+
(import "ns:pkg-A/b" (func)))
60+
"is not a valid extern name")

0 commit comments

Comments
 (0)