handball/src/ast.rs

29 lines
602 B
Rust

use std::rc::Rc;
#[derive(Debug /*/*, debug2::Debug*/*/, PartialEq)]
crate enum Tree {
Leaf(Literal),
Define(String, Box<Tree>),
Set(String, Box<Tree>),
If(Box<[Tree; 3]>),
// Its easier to box the lambdas in the parser than the vm, as
// here we see all of them exactly once
Func(Rc<Func>),
Branch(Vec<Tree>),
}
#[derive(Debug /*/*, debug2::Debug*/*/, PartialEq)]
crate struct Func {
crate args: Vec<String>,
crate body: Vec<Tree>,
}
#[derive(Debug /*/*, debug2::Debug*/*/, PartialEq)]
crate enum Literal {
Sym(String),
Num(f64),
Bool(bool),
}