handball/src/ast.rs

29 lines
602 B
Rust
Raw Normal View History

2021-12-27 22:19:29 +00:00
use std::rc::Rc;
#[derive(Debug /*/*, debug2::Debug*/*/, PartialEq)]
2021-12-27 22:19:29 +00:00
crate enum Tree {
Leaf(Literal),
Define(String, Box<Tree>),
Set(String, Box<Tree>),
2021-12-27 22:19:29 +00:00
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>),
2021-12-27 22:19:29 +00:00
Branch(Vec<Tree>),
}
#[derive(Debug /*/*, debug2::Debug*/*/, PartialEq)]
crate struct Func {
crate args: Vec<String>,
crate body: Vec<Tree>,
}
2021-12-27 22:19:29 +00:00
#[derive(Debug /*/*, debug2::Debug*/*/, PartialEq)]
2021-12-27 22:19:29 +00:00
crate enum Literal {
Sym(String),
Num(f64),
Bool(bool),
}