MCPcopy Create free account
hub / github.com/csskit/csskit / parse

Method parse

crates/css_ast/src/functions/attr_function.rs:38–60  ·  view source on GitHub ↗
(p: &mut Parser<'a, I>)

Source from the content-addressed store, hash-verified

36
37impl<'a> Parse<'a> for AttrName {
38 fn parse<I>(p: &mut Parser<'a, I>) -> ParserResult<Self>
39 where
40 I: Iterator<Item = Cursor> + Clone,
41 {
42 let a = p.parse_if_peek::<T![Ident]>()?;
43 let b = p.parse_if_peek::<T![|]>()?;
44
45 if a.is_some() && b.is_none() {
46 return Ok(Self(None, None, a));
47 }
48
49 if a.is_none() && b.is_some() {
50 return Ok(Self(None, b, Some(p.parse::<T![Ident]>()?)));
51 }
52
53 if a.is_none() && b.is_none() {
54 Err(Diagnostic::new(p.next(), Diagnostic::expected_ident))?
55 }
56
57 debug_assert!(a.is_some() && b.is_some());
58
59 Ok(Self(a, b, Some(p.parse::<T![Ident]>()?)))
60 }
61}
62
63/// ```text,ignore

Callers

nothing calls this directly

Calls 2

ErrClass · 0.85
nextMethod · 0.45

Tested by

no test coverage detected