Skip to content

Commit 566e6f1

Browse files
authored
internal: Add Clone to parsers (#4642)
1 parent 601a61d commit 566e6f1

4 files changed

Lines changed: 13 additions & 13 deletions

File tree

prqlc/prqlc-parser/src/parser/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::lexer::lr::TokenKind;
55
use crate::parser::pr::{Annotation, Expr, ExprKind, Stmt, StmtKind, Ty, TyKind};
66
use crate::span::Span;
77

8-
pub fn ident_part() -> impl Parser<TokenKind, String, Error = PError> {
8+
pub fn ident_part() -> impl Parser<TokenKind, String, Error = PError> + Clone {
99
return select! {
1010
TokenKind::Ident(ident) => ident,
1111
TokenKind::Keyword(ident) if &ident == "module" => ident,

prqlc/prqlc-parser/src/parser/expr.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::parser::pr::*;
1212
use crate::parser::types::type_expr;
1313
use crate::span::Span;
1414

15-
pub fn expr_call() -> impl Parser<TokenKind, Expr, Error = PError> {
15+
pub fn expr_call() -> impl Parser<TokenKind, Expr, Error = PError> + Clone {
1616
let expr = expr();
1717

1818
lambda_func(expr.clone()).or(func_call(expr))
@@ -231,9 +231,9 @@ pub fn expr() -> impl Parser<TokenKind, Expr, Error = PError> + Clone {
231231
})
232232
}
233233

234-
pub fn pipeline<E>(expr: E) -> impl Parser<TokenKind, Expr, Error = PError>
234+
pub fn pipeline<E>(expr: E) -> impl Parser<TokenKind, Expr, Error = PError> + Clone
235235
where
236-
E: Parser<TokenKind, Expr, Error = PError>,
236+
E: Parser<TokenKind, Expr, Error = PError> + Clone,
237237
{
238238
// expr has to be a param, because it can be either a normal expr() or
239239
// a recursive expr called from within expr()
@@ -266,7 +266,7 @@ where
266266
pub fn binary_op_parser<'a, Term, Op>(
267267
term: Term,
268268
op: Op,
269-
) -> impl Parser<TokenKind, Expr, Error = PError> + 'a
269+
) -> impl Parser<TokenKind, Expr, Error = PError> + 'a + Clone
270270
where
271271
Term: Parser<TokenKind, Expr, Error = PError> + 'a,
272272
Op: Parser<TokenKind, BinOp, Error = PError> + 'a,
@@ -292,7 +292,7 @@ where
292292
.boxed()
293293
}
294294

295-
fn func_call<E>(expr: E) -> impl Parser<TokenKind, Expr, Error = PError>
295+
fn func_call<E>(expr: E) -> impl Parser<TokenKind, Expr, Error = PError> + Clone
296296
where
297297
E: Parser<TokenKind, Expr, Error = PError> + Clone,
298298
{
@@ -344,7 +344,7 @@ where
344344
.labelled("function call")
345345
}
346346

347-
fn lambda_func<E>(expr: E) -> impl Parser<TokenKind, Expr, Error = PError>
347+
fn lambda_func<E>(expr: E) -> impl Parser<TokenKind, Expr, Error = PError> + Clone
348348
where
349349
E: Parser<TokenKind, Expr, Error = PError> + Clone + 'static,
350350
{
@@ -404,7 +404,7 @@ where
404404
.labelled("function definition")
405405
}
406406

407-
pub fn ident() -> impl Parser<TokenKind, Ident, Error = PError> {
407+
pub fn ident() -> impl Parser<TokenKind, Ident, Error = PError> + Clone {
408408
ident_part()
409409
.separated_by(ctrl('.'))
410410
.at_least(1)

prqlc/prqlc-parser/src/parser/stmt.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn module_contents() -> impl Parser<TokenKind, Vec<Stmt>, Error = PError> {
4343
})
4444
}
4545

46-
fn query_def() -> impl Parser<TokenKind, Stmt, Error = PError> {
46+
fn query_def() -> impl Parser<TokenKind, Stmt, Error = PError> + Clone {
4747
new_line()
4848
.repeated()
4949
.ignore_then(keyword("prql"))
@@ -112,7 +112,7 @@ fn query_def() -> impl Parser<TokenKind, Stmt, Error = PError> {
112112
.labelled("query header")
113113
}
114114

115-
fn var_def() -> impl Parser<TokenKind, StmtKind, Error = PError> {
115+
fn var_def() -> impl Parser<TokenKind, StmtKind, Error = PError> + Clone {
116116
let let_ = keyword("let")
117117
.ignore_then(ident_part())
118118
.then(type_expr().delimited_by(ctrl('<'), ctrl('>')).or_not())
@@ -150,15 +150,15 @@ fn var_def() -> impl Parser<TokenKind, StmtKind, Error = PError> {
150150
let_.or(main_or_into)
151151
}
152152

153-
fn type_def() -> impl Parser<TokenKind, StmtKind, Error = PError> {
153+
fn type_def() -> impl Parser<TokenKind, StmtKind, Error = PError> + Clone {
154154
keyword("type")
155155
.ignore_then(ident_part())
156156
.then(ctrl('=').ignore_then(type_expr()).or_not())
157157
.map(|(name, value)| StmtKind::TypeDef(TypeDef { name, value }))
158158
.labelled("type definition")
159159
}
160160

161-
fn import_def() -> impl Parser<TokenKind, StmtKind, Error = PError> {
161+
fn import_def() -> impl Parser<TokenKind, StmtKind, Error = PError> + Clone {
162162
keyword("import")
163163
.ignore_then(ident_part().then_ignore(ctrl('=')).or_not())
164164
.then(ident())

prqlc/prqlc-parser/src/parser/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::lexer::lr::TokenKind;
66
use crate::parser::expr::ident;
77
use crate::parser::pr::*;
88

9-
pub fn type_expr() -> impl Parser<TokenKind, Ty, Error = PError> {
9+
pub fn type_expr() -> impl Parser<TokenKind, Ty, Error = PError> + Clone {
1010
recursive(|nested_type_expr| {
1111
let basic = select! {
1212
TokenKind::Literal(lit) => TyKind::Singleton(lit),

0 commit comments

Comments
 (0)