Skip to content

Commit 290c100

Browse files
authored
Update semver regex to not swallow trailing . (#129)
Signed-off-by: itowlson <ivan.towlson@fermyon.com>
1 parent 4c96def commit 290c100

File tree

3 files changed

+133
-1
lines changed

3 files changed

+133
-1
lines changed

crates/wac-parser/src/lexer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ fn detect_invalid_input(source: &str) -> Result<(), (Error, SourceSpan)> {
9595
#[logos(subpattern word = r"[a-z][a-z0-9]*|[A-Z][A-Z0-9]*")]
9696
#[logos(subpattern id = r"%?(?&word)(-(?&word))*")]
9797
#[logos(subpattern package_name = r"(?&id)(:(?&id))+")]
98-
#[logos(subpattern semver = r"[0-9a-zA-Z-\.\+]+")]
98+
#[logos(subpattern semver = r"([0-9]+)(\.[0-9a-zA-Z-\+]+)*")]
9999
pub enum Token {
100100
/// A comment.
101101
#[regex(r"//[^\n]*", logos::skip)]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package test:comp;
2+
3+
interface my-handler {
4+
use wasi:http/types@0.2.0.{incoming-request, response-outparam};
5+
handle: func(request: incoming-request, response-out: response-outparam);
6+
}
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
{
2+
"docs": [],
3+
"directive": {
4+
"package": {
5+
"string": "test:comp",
6+
"name": "test:comp",
7+
"version": null,
8+
"span": {
9+
"offset": 8,
10+
"length": 9
11+
}
12+
}
13+
},
14+
"statements": [
15+
{
16+
"Type": {
17+
"interface": {
18+
"docs": [],
19+
"id": {
20+
"string": "my-handler",
21+
"span": {
22+
"offset": 30,
23+
"length": 10
24+
}
25+
},
26+
"items": [
27+
{
28+
"use": {
29+
"docs": [],
30+
"path": {
31+
"package": {
32+
"span": {
33+
"offset": 51,
34+
"length": 21
35+
},
36+
"string": "wasi:http/types@0.2.0",
37+
"name": "wasi:http",
38+
"segments": "types",
39+
"version": "0.2.0"
40+
}
41+
},
42+
"items": [
43+
{
44+
"id": {
45+
"string": "incoming-request",
46+
"span": {
47+
"offset": 74,
48+
"length": 16
49+
}
50+
},
51+
"asId": null
52+
},
53+
{
54+
"id": {
55+
"string": "response-outparam",
56+
"span": {
57+
"offset": 92,
58+
"length": 17
59+
}
60+
},
61+
"asId": null
62+
}
63+
]
64+
}
65+
},
66+
{
67+
"export": {
68+
"docs": [],
69+
"id": {
70+
"string": "handle",
71+
"span": {
72+
"offset": 116,
73+
"length": 6
74+
}
75+
},
76+
"ty": {
77+
"func": {
78+
"params": [
79+
{
80+
"id": {
81+
"string": "request",
82+
"span": {
83+
"offset": 129,
84+
"length": 7
85+
}
86+
},
87+
"ty": {
88+
"ident": {
89+
"string": "incoming-request",
90+
"span": {
91+
"offset": 138,
92+
"length": 16
93+
}
94+
}
95+
}
96+
},
97+
{
98+
"id": {
99+
"string": "response-out",
100+
"span": {
101+
"offset": 156,
102+
"length": 12
103+
}
104+
},
105+
"ty": {
106+
"ident": {
107+
"string": "response-outparam",
108+
"span": {
109+
"offset": 170,
110+
"length": 17
111+
}
112+
}
113+
}
114+
}
115+
],
116+
"results": "empty"
117+
}
118+
}
119+
}
120+
}
121+
]
122+
}
123+
}
124+
}
125+
]
126+
}

0 commit comments

Comments
 (0)