Parse a sequence, allowing commas and new lines between items. Doesn't include the surrounding delimiters.
(parser: P)
| 163 | /// Parse a sequence, allowing commas and new lines between items. Doesn't |
| 164 | /// include the surrounding delimiters. |
| 165 | fn sequence<'a, I, P, O>(parser: P) -> impl Parser<'a, I, Vec<O>, ParserError<'a>> + Clone + 'a |
| 166 | where |
| 167 | I: Input<'a, Token = lr::Token, Span = Span> + BorrowInput<'a>, |
| 168 | P: Parser<'a, I, O, ParserError<'a>> + Clone + 'a, |
| 169 | O: 'a, |
| 170 | { |
| 171 | parser |
| 172 | .separated_by(ctrl(',').then_ignore(new_line().repeated())) |
| 173 | .allow_trailing() |
| 174 | .collect() |
| 175 | // Note because we pad rather than only take the ending new line, we |
| 176 | // can't put items that require a new line in a tuple, like: |
| 177 | // |
| 178 | // ``` |
| 179 | // { |
| 180 | // !# doc comment |
| 181 | // a, |
| 182 | // } |
| 183 | // ``` |
| 184 | // ...but I'm not sure there's a way around it, since we do need to |
| 185 | // consume newlines in tuples... |
| 186 | .padded_by(new_line().repeated()) |
| 187 | } |
| 188 | |
| 189 | fn pipe<'a, I>() -> impl Parser<'a, I, (), ParserError<'a>> + Clone |
| 190 | where |