AstBuilder: switch to global decls
All checks were successful
ci/woodpecker/push/build_rust Pipeline was successful
All checks were successful
ci/woodpecker/push/build_rust Pipeline was successful
This commit is contained in:
parent
4f6f81714d
commit
5c80987aa5
3 changed files with 17 additions and 6 deletions
|
@ -26,8 +26,8 @@ verify_config = true
|
|||
[statements.gen_global_decl]
|
||||
gen_boolean = 0.0
|
||||
gen_character = 0.0
|
||||
gen_integer = 0.0
|
||||
gen_real = 0.0
|
||||
gen_integer = 0.5
|
||||
gen_real = 0.5
|
||||
gen_tuple = 0.0
|
||||
|
||||
[statements.gen_if_statement]
|
||||
|
|
|
@ -59,15 +59,15 @@ impl AstBuilder {
|
|||
let typedef = self.gen_typedef();
|
||||
self.ast.push(typedef);
|
||||
} else {
|
||||
let decl = self.gen_decl();
|
||||
let decl = self.gen_global_decl();
|
||||
self.ast.push(decl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn gen_decl(&mut self) -> Stat {
|
||||
fn gen_global_decl(&mut self) -> Stat {
|
||||
let mut p: f64 = self.rng.gen();
|
||||
let ps = &self.params.statements.gen_decl;
|
||||
let ps = &self.params.statements.gen_global_decl;
|
||||
|
||||
let t: BaseType;
|
||||
let assn: Expr;
|
||||
|
|
|
@ -176,9 +176,20 @@ toml_struct!{
|
|||
|
||||
impl GenGlobalDecl {
|
||||
fn verify(&self) -> Result<(), String> {
|
||||
let sum_type = self.gen_boolean
|
||||
+ self.gen_character
|
||||
+ self.gen_integer
|
||||
+ self.gen_real
|
||||
+ self.gen_tuple;
|
||||
|
||||
|
||||
if (sum_type - 1.0).abs() > f64::EPSILON {
|
||||
Err(format!("statements.gen_global_decl probability sum for types is = {}", sum_type))
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
toml_struct!{
|
||||
struct GenIfStatement {
|
||||
|
|
Loading…
Reference in a new issue