Skip to content

Commit 080a8bb

Browse files
authored
tweak: Add code comment (#4722)
1 parent f70d8e3 commit 080a8bb

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

prqlc/prqlc-parser/src/lexer/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ pub mod lr;
1010
#[cfg(test)]
1111
mod test;
1212

13-
// TODO: we have `lex_source` and `lex_source_recovery` and don't have the same
14-
// structure for PR. Probably we should have a single approach to the inclusion
15-
// and naming of a function which returns both the tokens & errors, and a
16-
// function that returns both.
17-
1813
/// Lex PRQL into LR, returning both the LR and any errors encountered
1914
pub fn lex_source_recovery(source: &str, source_id: u16) -> (Option<Vec<Token>>, Vec<Error>) {
2015
let (tokens, lex_errors) = lexer().parse_recovery(source);

prqlc/prqlc-parser/src/parser/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ pub(crate) mod stmt;
1414
mod test;
1515
mod types;
1616

17+
// Note that `parse_source` is in `prqlc` crate, not in `prqlc-parser` crate,
18+
// because it logs using the logging framework in `prqlc`.
19+
1720
pub fn parse_lr_to_pr(
1821
source: &str,
1922
source_id: u16,
2023
lr: Vec<lr::Token>,
2124
) -> (Option<Vec<pr::Stmt>>, Vec<Error>) {
22-
// We don't want comments in the AST (but we do intend to use them as part of
23-
// formatting)
2425
let stream = prepare_stream(lr.into_iter(), source, source_id);
2526
let (pr, parse_errors) = stmt::source().parse_recovery(stream);
2627

prqlc/prqlc/src/parser.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ pub fn parse(file_tree: &SourceTree) -> Result<pr::ModuleDef, Errors> {
5353
}
5454

5555
/// Build PR AST from a PRQL query string.
56+
// We have this function in `prqlc` rather than in `prqlc-parser` crate since
57+
// our logging is in `prqlc` and we want to log the LR. (We could split the logging
58+
// out into a separate crate, but it has dependencies on `prqlc` internals and
59+
// would be an effort)
5660
pub(crate) fn parse_source(source: &str, source_id: u16) -> Result<Vec<pr::Stmt>, Vec<Error>> {
5761
let (tokens, mut errors) = prqlc_parser::lexer::lex_source_recovery(source, source_id);
5862

0 commit comments

Comments
 (0)