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

Function pipeline

prqlc/prqlc-parser/src/parser/expr.rs:340–368  ·  view source on GitHub ↗

A pipeline of `expr`, separated by pipes. Doesn't require parentheses.

(expr: E)

Source from the content-addressed store, hash-verified

338
339/// A pipeline of `expr`, separated by pipes. Doesn't require parentheses.
340pub(crate) fn pipeline<'a, I, E>(expr: E) -> impl Parser<'a, I, Expr, ParserError<'a>> + Clone + 'a
341where
342 I: Input<'a, Token = lr::Token, Span = Span> + BorrowInput<'a>,
343 E: Parser<'a, I, Expr, ParserError<'a>> + Clone + 'a,
344{
345 // expr has to be a param, because it can be either a normal expr() or a
346 // recursive expr called from within expr(), which causes a stack overflow
347
348 // TODO: do we need the `maybe_aliased` here rather than in `expr`? We had
349 // tried `with_doc_comment(expr)` in #4775 (and push an aliased expr into
350 // `expr`) but couldn't get it work.
351 with_doc_comment(maybe_aliased(expr))
352 .separated_by(pipe())
353 .at_least(1)
354 .collect::<Vec<_>>()
355 .map_with(|exprs: Vec<Expr>, extra| {
356 let span = extra.span();
357 // If there's only one expr, then we don't need to wrap it
358 // in a pipeline — just return the lone expr. Otherwise,
359 // wrap them in a pipeline.
360 exprs.into_iter().exactly_one().unwrap_or_else(|exprs| {
361 ExprKind::Pipeline(Pipeline {
362 exprs: exprs.collect(),
363 })
364 .into_expr(span)
365 })
366 })
367 .labelled("pipeline")
368}
369
370// Can remove if we don't end up using this
371#[allow(dead_code)]

Callers 3

var_defFunction · 0.85
expr_callFunction · 0.85
exprFunction · 0.85

Calls 8

with_doc_commentFunction · 0.85
maybe_aliasedFunction · 0.85
pipeFunction · 0.85
PipelineClass · 0.85
into_iterMethod · 0.80
into_exprMethod · 0.80
spanMethod · 0.45
collectMethod · 0.45

Tested by

no test coverage detected