use std::rc::Rc; use crate::span::Spanned; #[derive(Clone, Debug, PartialEq, Eq)] pub struct LetVar { pub name: Spanned>, pub expr: Spanned, } #[derive(Clone, Debug, PartialEq, Eq)] pub enum Atom { Int(i64), Str(Rc), Sym(Rc), Bool(bool), Nil, } #[derive(Clone, Debug, PartialEq, Eq)] pub enum Expr { Fn { name: Spanned>, args: Vec>>, body: Vec>, }, Const { vars: Vec>, }, Let { vars: Vec>, body: Vec>, }, If { condition: Spanned>, then_expr: Spanned>, else_expr: Option>>, }, For { loop_var: Spanned>, from: Spanned>, to: Spanned>, body: Vec>, }, Set { target_var: Spanned>, expr: Spanned>, }, Do { body: Vec>, }, Call { fn_name: Spanned>, args: Vec>, }, Atom(Atom), } #[derive(Clone, Debug, PartialEq, Eq)] pub struct Ast(Vec>); impl Ast { pub fn new(ast: Vec>) -> Self { Self(ast) } pub fn inner(&self) -> &[Spanned] { &self.0 } pub fn into_inner(self) -> Vec> { self.0 } }