Skip to content

Commit

Permalink
More expression generation
Browse files Browse the repository at this point in the history
  • Loading branch information
7h3kk1d committed Dec 20, 2024
1 parent f5595e7 commit 618a4d9
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/haz3lmenhir/AST.re
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ let rec gen_exp_sized = (n: int): QCheck.Gen.t(exp) =>
arb_str_exp,
arb_float,
arb_var,
map(x => Bool(x), bool),
always(~print=show_exp, EmptyHole),
always(~print=show_exp, TupleExp([])),
always(~print=show_exp, ListExp([])),
Expand Down Expand Up @@ -338,7 +339,6 @@ let rec gen_exp_sized = (n: int): QCheck.Gen.t(exp) =>
Gen.(
let e = self(n - 1 / 2);
let case = n => {
print_endline("Case size" ++ string_of_int(n));
let p = gen_pat_sized(n / 2);
let e = self(n / 2);
tup2(p, e);
Expand All @@ -348,9 +348,6 @@ let rec gen_exp_sized = (n: int): QCheck.Gen.t(exp) =>
sized_arr(n - 1 / 2)
>>= (
sizes => {
print_endline(
"Case sizes" ++ [%derive.show: array(int)](sizes),
);
let cases: QCheck.Gen.t(array((pat, exp))) =
flatten_a(Array.map(case, sizes));
cases;
Expand All @@ -359,18 +356,21 @@ let rec gen_exp_sized = (n: int): QCheck.Gen.t(exp) =>
tup2(e, cases)
>|= (
((e, cases)) => {
print_endline(
"Cases: " ++ [%derive.show: array((pat, exp))](cases),
);
CaseExp(e, Array.to_list(cases));
}
)
),
Gen.map2(
(e1, e2) => ApExp(e1, e2),
self((n - 1) / 2),
self((n - 1) / 2),
),
Gen.map2(
(p, e) => FixF(p, e),
gen_pat_sized((n - 1) / 2),
self((n - 1) / 2),
),
/*
| CaseExp(exp, list((pat, exp)))
| ApExp(exp, exp)
| FixF(pat, exp)
| Bool(bool)
| Cast(exp, typ, typ)
| FailedCast(exp, typ, typ)
| EmptyHole
Expand Down

0 comments on commit 618a4d9

Please sign in to comment.