diff --git a/src/ast_builder.rs b/src/ast_builder.rs new file mode 100644 index 0000000..a5050b0 --- /dev/null +++ b/src/ast_builder.rs @@ -0,0 +1,40 @@ +use crate::params::Params; +use crate::ast::{ + Quantifier, + BaseType, + GlobalBlock, + Block, + Literal, + Declaration, + Variable, + BinaryOperator, +}; + +pub struct AstBuilder { + params: Params, + ast: GlobalBlock, +} + +impl AstBuilder { + pub fn from(params: Params) -> Self { + Self { + params, + ast: GlobalBlock::default(), + } + } + + pub fn generate(&self) { + } +} + +impl ToString for AstBuilder { + fn to_string(&self) -> String { + let mut s = format!("// Generated by {} v{}\n", + env!("CARGO_PKG_NAME"), + env!("CARGO_PKG_VERSION"), + ); + + s.push_str(&self.ast.to_string()); + s + } +} diff --git a/src/main.rs b/src/main.rs index 506e701..0d73611 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,3 @@ -use std::fs; use std::path::PathBuf; use clap::Parser; @@ -6,9 +5,11 @@ use clap::Parser; extern crate derive_builder; mod ast; +mod ast_builder; mod params; use params::Params; +use ast_builder::AstBuilder; #[derive(Parser)] #[command(author, version, about, long_about = None)] @@ -18,7 +19,8 @@ struct Args { fn main() { let args = Args::parse(); - let params_toml = Params::parse(&args.config); + let params = Params::parse(&args.config); + let builder = AstBuilder::from(params); - println!("{}", params_toml.global_flow.gen_decl); + println!("{}", builder.to_string()); }