diff --git a/prqlc/prqlc-parser/src/parser/common.rs b/prqlc/prqlc-parser/src/parser/common.rs index 2941e807ed3b..0b0848838949 100644 --- a/prqlc/prqlc-parser/src/parser/common.rs +++ b/prqlc/prqlc-parser/src/parser/common.rs @@ -5,7 +5,7 @@ use crate::lexer::lr::TokenKind; use crate::parser::pr::{Annotation, Expr, ExprKind, Stmt, StmtKind, Ty, TyKind}; use crate::span::Span; -pub fn ident_part() -> impl Parser { +pub fn ident_part() -> impl Parser + Clone { return select! { TokenKind::Ident(ident) => ident, TokenKind::Keyword(ident) if &ident == "module" => ident, diff --git a/prqlc/prqlc-parser/src/parser/expr.rs b/prqlc/prqlc-parser/src/parser/expr.rs index 9db876afd4ec..f99135365e82 100644 --- a/prqlc/prqlc-parser/src/parser/expr.rs +++ b/prqlc/prqlc-parser/src/parser/expr.rs @@ -12,7 +12,7 @@ use crate::parser::pr::*; use crate::parser::types::type_expr; use crate::span::Span; -pub fn expr_call() -> impl Parser { +pub fn expr_call() -> impl Parser + Clone { let expr = expr(); lambda_func(expr.clone()).or(func_call(expr)) @@ -231,9 +231,9 @@ pub fn expr() -> impl Parser + Clone { }) } -pub fn pipeline(expr: E) -> impl Parser +pub fn pipeline(expr: E) -> impl Parser + Clone where - E: Parser, + E: Parser + Clone, { // expr has to be a param, because it can be either a normal expr() or // a recursive expr called from within expr() @@ -266,7 +266,7 @@ where pub fn binary_op_parser<'a, Term, Op>( term: Term, op: Op, -) -> impl Parser + 'a +) -> impl Parser + 'a + Clone where Term: Parser + 'a, Op: Parser + 'a, @@ -292,7 +292,7 @@ where .boxed() } -fn func_call(expr: E) -> impl Parser +fn func_call(expr: E) -> impl Parser + Clone where E: Parser + Clone, { @@ -344,7 +344,7 @@ where .labelled("function call") } -fn lambda_func(expr: E) -> impl Parser +fn lambda_func(expr: E) -> impl Parser + Clone where E: Parser + Clone + 'static, { @@ -404,7 +404,7 @@ where .labelled("function definition") } -pub fn ident() -> impl Parser { +pub fn ident() -> impl Parser + Clone { ident_part() .separated_by(ctrl('.')) .at_least(1) diff --git a/prqlc/prqlc-parser/src/parser/stmt.rs b/prqlc/prqlc-parser/src/parser/stmt.rs index 0206c14789e7..16ca656a468d 100644 --- a/prqlc/prqlc-parser/src/parser/stmt.rs +++ b/prqlc/prqlc-parser/src/parser/stmt.rs @@ -43,7 +43,7 @@ fn module_contents() -> impl Parser, Error = PError> { }) } -fn query_def() -> impl Parser { +fn query_def() -> impl Parser + Clone { new_line() .repeated() .ignore_then(keyword("prql")) @@ -112,7 +112,7 @@ fn query_def() -> impl Parser { .labelled("query header") } -fn var_def() -> impl Parser { +fn var_def() -> impl Parser + Clone { let let_ = keyword("let") .ignore_then(ident_part()) .then(type_expr().delimited_by(ctrl('<'), ctrl('>')).or_not()) @@ -150,7 +150,7 @@ fn var_def() -> impl Parser { let_.or(main_or_into) } -fn type_def() -> impl Parser { +fn type_def() -> impl Parser + Clone { keyword("type") .ignore_then(ident_part()) .then(ctrl('=').ignore_then(type_expr()).or_not()) @@ -158,7 +158,7 @@ fn type_def() -> impl Parser { .labelled("type definition") } -fn import_def() -> impl Parser { +fn import_def() -> impl Parser + Clone { keyword("import") .ignore_then(ident_part().then_ignore(ctrl('=')).or_not()) .then(ident()) diff --git a/prqlc/prqlc-parser/src/parser/types.rs b/prqlc/prqlc-parser/src/parser/types.rs index 337a4e335fe0..7833904566a8 100644 --- a/prqlc/prqlc-parser/src/parser/types.rs +++ b/prqlc/prqlc-parser/src/parser/types.rs @@ -6,7 +6,7 @@ use crate::lexer::lr::TokenKind; use crate::parser::expr::ident; use crate::parser::pr::*; -pub fn type_expr() -> impl Parser { +pub fn type_expr() -> impl Parser + Clone { recursive(|nested_type_expr| { let basic = select! { TokenKind::Literal(lit) => TyKind::Singleton(lit),