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

Function source

prqlc/prqlc-parser/src/parser/stmt.rs:20–37  ·  view source on GitHub ↗

The top-level parser for a PRQL file

()

Source from the content-addressed store, hash-verified

18
19/// The top-level parser for a PRQL file
20pub fn source<'a, I>() -> impl Parser<'a, I, Vec<Stmt>, ParserError<'a>> + Clone
21where
22 I: Input<'a, Token = lr::Token, Span = Span> + BorrowInput<'a> + chumsky::input::ValueInput<'a>,
23{
24 with_doc_comment(query_def())
25 .or_not()
26 .map(|opt| opt.into_iter().collect::<Vec<_>>())
27 .then(module_contents())
28 .map(|(mut first, mut second)| {
29 first.append(&mut second);
30 first
31 })
32 // This is the only instance we can consume newlines at the end of something, since
33 // this is the end of the file
34 .then_ignore(new_line().repeated().collect::<Vec<_>>())
35 .then_ignore(end())
36 .boxed()
37}
38
39fn module_contents<'a, I>() -> impl Parser<'a, I, Vec<Stmt>, ParserError<'a>> + Clone
40where

Callers 2

parse_sourceFunction · 0.85
parse_lr_to_prFunction · 0.85

Calls 7

with_doc_commentFunction · 0.85
query_defFunction · 0.85
module_contentsFunction · 0.85
new_lineFunction · 0.85
mapMethod · 0.80
into_iterMethod · 0.80
appendMethod · 0.80

Tested by 1

parse_sourceFunction · 0.68