1
1
Fork 0
mirror of https://github.com/azur1s/bobbylisp.git synced 2024-10-16 02:37:40 -05:00
bobbylisp/src/typing/typed.rs

59 lines
1.1 KiB
Rust

use super::ty::Type;
use crate::parse::parser::{
BinaryOp,
UnaryOp,
Lit,
Spanned,
};
// Typed version of the expression.
#[derive(Clone, Debug)]
pub enum TExpr<'src> {
Lit(Lit<'src>),
Ident(&'src str),
Unary {
op: UnaryOp,
expr: Spanned<Box<Self>>,
ret_ty: Type,
},
Binary {
op: BinaryOp,
lhs: Spanned<Box<Self>>,
rhs: Spanned<Box<Self>>,
ret_ty: Type,
},
Lambda {
params: Vec<(&'src str, Type)>,
body: Spanned<Box<Self>>,
ret_ty: Type,
},
Call {
func: Spanned<Box<Self>>,
args: Vec<Spanned<Self>>,
},
If {
cond: Spanned<Box<Self>>,
t: Spanned<Box<Self>>,
f: Spanned<Box<Self>>,
br_ty: Type,
},
Let {
name: &'src str,
ty: Type,
value: Spanned<Box<Self>>,
body: Spanned<Box<Self>>,
},
Define {
name: &'src str,
ty: Type,
value: Spanned<Box<Self>>,
},
Block {
exprs: Vec<Spanned<Self>>,
void: bool,
ret_ty: Type,
},
}