1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
#[derive(Debug)] pub struct Program(pub Vec<Statement>); #[derive(Debug)] pub struct Block { pub statements: Vec<Statement>, pub expression: Option<Expr>, } #[derive(Debug)] pub enum Statement { Let { pattern: Pattern, value: Expr, recursive: bool, }, Set { variable: Box<Expr>, new_value: Box<Expr>, }, Expr(Expr), } #[derive(Debug)] pub enum Expr { Unit, Boolean(bool), Number(f64), String(String), Variable(String), Block(Box<Block>), Array(Vec<Expr>), Map(Vec<(Expr, Expr)>), Index { variable: Box<Expr>, index: Box<Expr>, }, Dot { variable: Box<Expr>, field: String, }, Lambda { arguments: Vec<Pattern>, body: Box<Expr>, }, Application { function: Box<Expr>, arguments: Vec<Expr>, }, If { condition: Box<Expr>, if_body: Box<Expr>, else_body: Box<Expr>, }, Raw(String), } #[derive(Debug)] pub enum Pattern { Unit, Binding(String), }