by conradludgate · 5y ago · 0 comments
enum Expr {
Literal(Literal),
Binary(Op, Box<Expr>, Box<Expr>),
//...
}
A value with type of Expr could be a literal or a binary expression. Binary expressions contain an operator and two other expressions (boxed to prevent infinite sized types).This is the building block for your tree
pub enum Expr {
Binary(BinaryExpr),
Grouping(GroupingExpr),
LiteralBool(bool),
LiteralNil,
LiteralNumber(f32),
LiteralString(String),
Unary(UnaryExpr)
}