From 1a8be916cdd1eb7bc634c4ed2bfc3e6cfa5adec2 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Sun, 14 Jul 2024 14:33:26 -0700 Subject: [PATCH] internal: Further restrict visibility of some items Now they're in `mod` they don't even need to be `pub(crate)` --- prqlc/prqlc-parser/src/parser/mod.rs | 20 ++++++++------------ prqlc/prqlc-parser/src/parser/stmt.rs | 5 +---- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/prqlc/prqlc-parser/src/parser/mod.rs b/prqlc/prqlc-parser/src/parser/mod.rs index b572676f55e9..480093ae8c60 100644 --- a/prqlc/prqlc-parser/src/parser/mod.rs +++ b/prqlc/prqlc-parser/src/parser/mod.rs @@ -61,7 +61,7 @@ pub(crate) fn prepare_stream( Stream::from_iter(eoi, tokens) } -pub(crate) fn ident_part() -> impl Parser + Clone { +fn ident_part() -> impl Parser + Clone { select! { TokenKind::Ident(ident) => ident, TokenKind::Keyword(ident) if &ident == "module" => ident, @@ -75,7 +75,7 @@ pub(crate) fn ident_part() -> impl Parser + C }) } -pub(crate) fn keyword(kw: &'static str) -> impl Parser + Clone { +fn keyword(kw: &'static str) -> impl Parser + Clone { just(TokenKind::Keyword(kw.to_string())).ignored() } @@ -92,11 +92,11 @@ pub(crate) fn new_line() -> impl Parser + Clone { .labelled("new line") } -pub(crate) fn ctrl(char: char) -> impl Parser + Clone { +fn ctrl(char: char) -> impl Parser + Clone { just(TokenKind::Control(char)).ignored() } -pub(crate) fn into_stmt((annotations, kind): (Vec, StmtKind), span: Span) -> Stmt { +fn into_stmt((annotations, kind): (Vec, StmtKind), span: Span) -> Stmt { Stmt { kind, span: Some(span), @@ -105,7 +105,7 @@ pub(crate) fn into_stmt((annotations, kind): (Vec, StmtKind), span: } } -pub(crate) fn doc_comment() -> impl Parser + Clone { +fn doc_comment() -> impl Parser + Clone { // doc comments must start on a new line, so we enforce a new line (which // can also be a file start) before the doc comment // @@ -121,9 +121,7 @@ pub(crate) fn doc_comment() -> impl Parser + .labelled("doc comment") } -pub(crate) fn with_doc_comment<'a, P, O>( - parser: P, -) -> impl Parser + Clone + 'a +fn with_doc_comment<'a, P, O>(parser: P) -> impl Parser + Clone + 'a where P: Parser + Clone + 'a, O: SupportsDocComment + 'a, @@ -138,15 +136,13 @@ where /// to be added to the result, as long as the result implements `SupportsDocComment`. /// /// We could manage without it tbh, -pub(crate) trait SupportsDocComment { +trait SupportsDocComment { fn with_doc_comment(self, doc_comment: Option) -> Self; } /// Parse a sequence, allowing commas and new lines between items. Doesn't /// include the surrounding delimiters. -pub(crate) fn sequence<'a, P, O>( - parser: P, -) -> impl Parser, Error = PError> + Clone + 'a +fn sequence<'a, P, O>(parser: P) -> impl Parser, Error = PError> + Clone + 'a where P: Parser + Clone + 'a, O: 'a, diff --git a/prqlc/prqlc-parser/src/parser/stmt.rs b/prqlc/prqlc-parser/src/parser/stmt.rs index 08675cb68d44..6b63fdfa6400 100644 --- a/prqlc/prqlc-parser/src/parser/stmt.rs +++ b/prqlc/prqlc-parser/src/parser/stmt.rs @@ -181,10 +181,7 @@ fn var_def() -> impl Parser + Clone { value: Some(value), ty: None, }) - }) - // TODO: this isn't really accurate, since a standard `from artists` - // also counts as this; we should change - .labelled("variable definition"); + }); let_.or(main_or_into) }