Ast: derive builders

This commit is contained in:
Akemi Izuko 2023-11-16 12:56:22 -07:00
parent 889cff56b3
commit a2c4b71c14
Signed by: akemi
GPG key ID: 8DE0764E1809E9FC
2 changed files with 4 additions and 0 deletions

View file

@ -7,4 +7,5 @@ edition = "2021"
[dependencies] [dependencies]
clap = { version = "4.4.8", features = ["derive"]} clap = { version = "4.4.8", features = ["derive"]}
derive_builder = "0.12.0"
toml = "0.8.8" toml = "0.8.8"

View file

@ -41,6 +41,7 @@ impl ToString for BaseType {
} }
} }
#[derive(Builder)]
pub struct Block<T: Statement> { pub struct Block<T: Statement> {
statements: Vec<T>, statements: Vec<T>,
} }
@ -88,6 +89,7 @@ impl Expr for Literal {
} }
} }
#[derive(Builder)]
pub struct Declaration <T: Expr> { pub struct Declaration <T: Expr> {
variable: Variable, variable: Variable,
assn: T, assn: T,
@ -114,6 +116,7 @@ impl<T: Expr> AstNode for Declaration<T> {}
impl<T: Expr> Statement for Declaration<T> {} impl<T: Expr> Statement for Declaration<T> {}
#[derive(Clone, Builder)]
pub struct Variable { pub struct Variable {
type_: BaseType, type_: BaseType,
quantifer: Quantifier, quantifer: Quantifier,