MCPcopy Create free account
hub / github.com/PRQL/prql / sequence

Function sequence

prqlc/prqlc-parser/src/parser/mod.rs:165–187  ·  view source on GitHub ↗

Parse a sequence, allowing commas and new lines between items. Doesn't include the surrounding delimiters.

(parser: P)

Source from the content-addressed store, hash-verified

163/// Parse a sequence, allowing commas and new lines between items. Doesn't
164/// include the surrounding delimiters.
165fn sequence<'a, I, P, O>(parser: P) -> impl Parser<'a, I, Vec<O>, ParserError<'a>> + Clone + 'a
166where
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
189fn pipe<'a, I>() -> impl Parser<'a, I, (), ParserError<'a>> + Clone
190where

Callers 4

type_exprFunction · 0.85
tupleFunction · 0.85
arrayFunction · 0.85
caseFunction · 0.85

Calls 3

ctrlFunction · 0.85
new_lineFunction · 0.85
collectMethod · 0.45

Tested by

no test coverage detected