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

60 lines
1.1 KiB
Rust
Raw Normal View History

2023-04-13 23:50:07 -05:00
use syntax::{
expr::{
BinaryOp,
UnaryOp,
Lit,
Spanned,
},
ty::Type,
2023-03-28 08:32:30 -05:00
};
// Typed version of the expression.
#[derive(Clone, Debug)]
pub enum TExpr<'src> {
Lit(Lit<'src>),
2023-04-11 22:35:35 -05:00
Ident(&'src str),
2023-03-28 08:32:30 -05:00
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 {
2023-04-11 22:35:35 -05:00
name: &'src str,
ty: Type,
value: Spanned<Box<Self>>,
2023-03-28 08:32:30 -05:00
body: Spanned<Box<Self>>,
},
2023-04-11 22:35:35 -05:00
Define {
name: &'src str,
ty: Type,
value: Spanned<Box<Self>>,
},
2023-03-28 08:32:30 -05:00
Block {
2023-03-29 08:47:48 -05:00
exprs: Vec<Spanned<Self>>,
void: bool,
2023-03-28 08:32:30 -05:00
ret_ty: Type,
},
2023-04-14 01:16:15 -05:00
}