AstBuilder: produce ints and floats

This commit is contained in:
Akemi Izuko 2023-11-16 21:27:59 -07:00
parent dfabbaf6f5
commit dc52b4fa3c
Signed by: akemi
GPG key ID: 8DE0764E1809E9FC
2 changed files with 12 additions and 3 deletions

View file

@ -15,8 +15,8 @@
[statements.gen_decl] [statements.gen_decl]
gen_boolean = 0.0 gen_boolean = 0.0
gen_character = 0.0 gen_character = 0.0
gen_integer = 0.0 gen_integer = 0.5
gen_real = 0.0 gen_real = 0.5
gen_tuple = 0.0 gen_tuple = 0.0
qual_const = 0.0 qual_const = 0.0
qual_var = 0.0 qual_var = 0.0

View file

@ -53,7 +53,16 @@ impl AstBuilder {
} }
fn gen_decl(&mut self) -> Box<dyn Statement> { fn gen_decl(&mut self) -> Box<dyn Statement> {
let t = BaseType::Real; let p: f64 = self.rng.gen();
let ps = &self.params.statements.gen_decl;
let t = if p < ps.gen_integer {
BaseType::Int
} else {
BaseType::Real
};
let v = self.gen_variable_quantified(t, Quantifier::Const); let v = self.gen_variable_quantified(t, Quantifier::Const);
Box::new( Box::new(