Skip to content

Commit 949b9ea

Browse files
fix: allow hyphens in tags props.
1 parent 63e092d commit 949b9ea

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

moz-webgpu-cts/src/wpt/metadata.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,34 @@ fn tags_parser<'a, T>(
181181
helper: &mut PropertiesParseHelper<'a>,
182182
conditional_term: impl Parser<'a, &'a str, T, ParseError<'a>>,
183183
) -> impl Parser<'a, &'a str, PropertyValue<T, Vec<String>>, ParseError<'a>> {
184+
use crate::chumsky::{error::Error, util::MaybeRef};
185+
186+
let tag_ident = {
187+
let underscore_or_hyphen = |c| matches!(c, '_' | '-');
188+
any()
189+
.try_map(move |c: char, span| {
190+
if c.is_ascii_alphabetic() || underscore_or_hyphen(c) {
191+
Ok(c)
192+
} else {
193+
Err(Error::<&'a str>::expected_found(
194+
[],
195+
Some(MaybeRef::Val(c)),
196+
span,
197+
))
198+
}
199+
})
200+
.then(
201+
any()
202+
.filter(move |c: &char| c.is_ascii_alphanumeric() || underscore_or_hyphen(*c))
203+
.repeated(),
204+
)
205+
.to_slice()
206+
};
184207
helper
185208
.parser(
186209
keyword("tags").to(()),
187210
conditional_term,
188-
ascii::ident()
211+
tag_ident
189212
.map(|i: &str| i.to_owned())
190213
.separated_by(just(',').padded_by(inline_whitespace()))
191214
.collect()

0 commit comments

Comments
 (0)