2021-12-27 22:19:29 +00:00
|
|
|
use std::rc::Rc;
|
|
|
|
|
2021-12-28 01:42:17 +00:00
|
|
|
#[derive(Debug /*/*, debug2::Debug*/*/, PartialEq)]
|
2021-12-27 22:19:29 +00:00
|
|
|
|
|
|
|
crate enum Tree {
|
|
|
|
Leaf(Literal),
|
|
|
|
Define(String, Box<Tree>),
|
2021-12-29 02:09:34 +00:00
|
|
|
Set(String, Box<Tree>),
|
2021-12-27 22:19:29 +00:00
|
|
|
If(Box<[Tree; 3]>),
|
2021-12-28 01:42:17 +00:00
|
|
|
// Its easier to box the lambdas in the parser than the vm, as
|
|
|
|
// here we see all of them exactly once
|
|
|
|
Func(Rc<Func>),
|
2021-12-27 22:19:29 +00:00
|
|
|
Branch(Vec<Tree>),
|
|
|
|
}
|
|
|
|
|
2021-12-28 01:42:17 +00:00
|
|
|
#[derive(Debug /*/*, debug2::Debug*/*/, PartialEq)]
|
|
|
|
crate struct Func {
|
|
|
|
crate args: Vec<String>,
|
|
|
|
crate body: Vec<Tree>,
|
|
|
|
}
|
2021-12-27 22:19:29 +00:00
|
|
|
|
2021-12-28 01:42:17 +00:00
|
|
|
#[derive(Debug /*/*, debug2::Debug*/*/, PartialEq)]
|
2021-12-27 22:19:29 +00:00
|
|
|
|
|
|
|
crate enum Literal {
|
|
|
|
Sym(String),
|
|
|
|
Num(f64),
|
|
|
|
Bool(bool),
|
|
|
|
}
|