| 60 | M: NodeMetadata, |
| 61 | { |
| 62 | fn parse<Iter>(p: &mut Parser<'a, Iter>) -> Result<Self> |
| 63 | where |
| 64 | Iter: Iterator<Item = crate::Cursor> + Clone, |
| 65 | { |
| 66 | let open_curly = p.parse::<T!['{']>()?; |
| 67 | let mut declarations = Vec::new_in(p.bump()); |
| 68 | let mut meta: M = Default::default(); |
| 69 | loop { |
| 70 | if p.at_end() { |
| 71 | meta = meta.with_size(declarations.len().min(u16::MAX as usize) as u16); |
| 72 | return Ok(Self { open_curly, declarations, close_curly: None, meta }); |
| 73 | } |
| 74 | let close_curly = p.parse_if_peek::<T!['}']>()?; |
| 75 | if close_curly.is_some() { |
| 76 | meta = meta.with_size(declarations.len().min(u16::MAX as usize) as u16); |
| 77 | return Ok(Self { open_curly, declarations, close_curly, meta }); |
| 78 | } |
| 79 | let declaration = p.parse::<Declaration<'a, V, M>>()?; |
| 80 | meta = meta.merge(declaration.metadata()); |
| 81 | declarations.push(declaration); |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | impl<'a, V, M> ToCursors for DeclarationList<'a, V, M> |