AstBuilder: initial outline
This commit is contained in:
parent
ba0aafd146
commit
2c15d8547d
2 changed files with 45 additions and 3 deletions
40
src/ast_builder.rs
Normal file
40
src/ast_builder.rs
Normal file
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue