This commit is contained in:
parent
889a4d54b9
commit
096aa39b05
2 changed files with 66 additions and 5 deletions
61
src/ast/mod.rs
Normal file
61
src/ast/mod.rs
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
mod expr;
|
||||||
|
|
||||||
|
use expr::{
|
||||||
|
Expr,
|
||||||
|
Literal,
|
||||||
|
Variable,
|
||||||
|
BinaryOperator,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub trait GazType {
|
||||||
|
fn get_base(&self) -> BaseType;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
pub enum Quantifier {
|
||||||
|
Const,
|
||||||
|
Var,
|
||||||
|
Unset,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Quantifier {
|
||||||
|
fn default() -> Self {
|
||||||
|
Quantifier::Unset
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToString for Quantifier {
|
||||||
|
fn to_string(&self) -> String {
|
||||||
|
match *self {
|
||||||
|
Quantifier::Const => "const",
|
||||||
|
Quantifier::Var => "var",
|
||||||
|
Quantifier::Unset => panic!("Found unset quantifier"),
|
||||||
|
}.to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
pub enum BaseType {
|
||||||
|
Int,
|
||||||
|
Real,
|
||||||
|
Never,
|
||||||
|
Unset,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for BaseType {
|
||||||
|
fn default() -> Self {
|
||||||
|
BaseType::Unset
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToString for BaseType {
|
||||||
|
fn to_string(&self) -> String {
|
||||||
|
// TODO: Use typedefs when possible. Might fit better on a high level node
|
||||||
|
match *self {
|
||||||
|
BaseType::Int => "integer",
|
||||||
|
BaseType::Real => "real",
|
||||||
|
BaseType::Never => panic!("Attempting to get string of never type"),
|
||||||
|
BaseType::Unset => panic!("Found unset basetype"),
|
||||||
|
}.to_string()
|
||||||
|
}
|
||||||
|
}
|
10
src/main.rs
10
src/main.rs
|
@ -5,11 +5,11 @@ use clap::Parser;
|
||||||
extern crate derive_builder;
|
extern crate derive_builder;
|
||||||
|
|
||||||
mod ast;
|
mod ast;
|
||||||
mod ast_builder;
|
//mod ast_builder;
|
||||||
mod params;
|
mod params;
|
||||||
|
|
||||||
use params::Params;
|
use params::Params;
|
||||||
use ast_builder::AstBuilder;
|
//use ast_builder::AstBuilder;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
|
@ -20,9 +20,9 @@ struct Args {
|
||||||
fn main() {
|
fn main() {
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
let params = Params::parse(&args.config);
|
let params = Params::parse(&args.config);
|
||||||
let mut builder = AstBuilder::from(params);
|
//let mut builder = AstBuilder::from(params);
|
||||||
|
|
||||||
builder.generate();
|
//builder.generate();
|
||||||
|
|
||||||
println!("{}", builder.to_string());
|
//println!("{}", builder.to_string());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue