| 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 | |
| 99 | impl<'a, D, R, M> ToCursors for DeclarationRuleList<'a, D, R, M> |