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

Method parse

crates/css_parse/src/syntax/declaration_rule_list.rs:69–96  ·  view source on GitHub ↗
(p: &mut Parser<'a, Iter>)

Source from the content-addressed store, hash-verified

67 Declaration<'a, D, M>: Parse<'a>,
68{
69 fn parse<Iter>(p: &mut Parser<'a, Iter>) -> Result<Self>
70 where
71 Iter: Iterator<Item = crate::Cursor> + Clone,
72 {
73 let open_curly = p.parse::<T!['{']>()?;
74 let mut declarations = Vec::new_in(p.bump());
75 let mut at_rules = Vec::new_in(p.bump());
76 let mut meta = Default::default();
77 loop {
78 if p.at_end() {
79 return Ok(Self { open_curly, declarations, at_rules, meta, close_curly: None });
80 }
81 let close_curly = p.parse_if_peek::<T!['}']>()?;
82 if close_curly.is_some() {
83 return Ok(Self { open_curly, declarations, at_rules, meta, close_curly });
84 }
85 let c = p.peek_n(1);
86 if <T![AtKeyword]>::peek(p, c) {
87 at_rules.push(p.parse::<R>()?);
88 } else if <T![Ident]>::peek(p, c) {
89 let rule = p.parse::<Declaration<'a, D, M>>()?;
90 meta = meta.merge(rule.metadata());
91 declarations.push(rule);
92 } else {
93 Err(Diagnostic::new(p.next(), Diagnostic::unexpected))?;
94 }
95 }
96 }
97}
98
99impl<'a, D, R, M> ToCursors for DeclarationRuleList<'a, D, R, M>

Callers

nothing calls this directly

Calls 7

ErrClass · 0.85
peek_nMethod · 0.80
bumpMethod · 0.45
at_endMethod · 0.45
mergeMethod · 0.45
metadataMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected