Skip to content

Commit

Permalink
feat: cli commands collect and expand-pl (#3739)
Browse files Browse the repository at this point in the history
  • Loading branch information
aljazerzen authored Oct 24, 2023
1 parent a0ad7ac commit 82f53d2
Show file tree
Hide file tree
Showing 24 changed files with 726 additions and 371 deletions.
8 changes: 7 additions & 1 deletion prqlc/prql-compiler/src/codegen/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,13 @@ impl WriteSource for Stmt {
}
StmtKind::VarDef(var_def) => match var_def.kind {
VarDefKind::Let => {
r += opt.consume(&format!("let {} = ", var_def.name))?;
let typ = if let Some(ty) = &var_def.ty_expr {
format!("<{}> ", ty.write(opt.clone())?)
} else {
"".to_string()
};

r += opt.consume(&format!("let {} {}= ", var_def.name, typ))?;

r += &var_def.value.write(opt)?;
r += "\n";
Expand Down
18 changes: 18 additions & 0 deletions prqlc/prql-compiler/src/ir/pl/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,21 @@ pub struct FuncParam {
pub type Range = generic::Range<Box<Expr>>;
pub type InterpolateItem = generic::InterpolateItem<Expr>;
pub type SwitchCase = generic::SwitchCase<Box<Expr>>;

impl From<Literal> for ExprKind {
fn from(value: Literal) -> Self {
ExprKind::Literal(value)
}
}

impl From<Ident> for ExprKind {
fn from(value: Ident) -> Self {
ExprKind::Ident(value)
}
}

impl From<Func> for ExprKind {
fn from(value: Func) -> Self {
ExprKind::Func(Box::new(value))
}
}
19 changes: 0 additions & 19 deletions prqlc/prql-compiler/src/ir/pl/extra/expr.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use enum_as_inner::EnumAsInner;
use prqlc_ast::expr::{Ident, Literal};
use serde::{Deserialize, Serialize};

use crate::ir::generic::WindowKind;
Expand Down Expand Up @@ -133,21 +132,3 @@ impl Expr {
}
}
}

impl From<Literal> for ExprKind {
fn from(value: Literal) -> Self {
ExprKind::Literal(value)
}
}

impl From<Ident> for ExprKind {
fn from(value: Ident) -> Self {
ExprKind::Ident(value)
}
}

impl From<Func> for ExprKind {
fn from(value: Func) -> Self {
ExprKind::Func(Box::new(value))
}
}
Loading

0 comments on commit 82f53d2

Please sign in to comment.