diff --git a/src/haz3lmenhir/AST.re b/src/haz3lmenhir/AST.re index ea2520ab9..e35d7187d 100644 --- a/src/haz3lmenhir/AST.re +++ b/src/haz3lmenhir/AST.re @@ -218,19 +218,19 @@ let arb_exp_sized: QCheck.arbitrary(exp) = ), ), // Need to make ExpToSegment add parens for tuples for menhir - // Gen.join( - // Gen.map( - // (sizes: array(int)) => { - // let exps = Array.map((size: int) => self(size), sizes); - // let flattened = Gen.flatten_a(exps); - // Gen.map( - // (exps: array(exp)) => TupleExp(Array.to_list(exps)), - // flattened, - // ); - // }, - // list_sizes, - // ), - // ), + Gen.join( + Gen.map( + (sizes: array(int)) => { + let exps = Array.map((size: int) => self(size), sizes); + let flattened = Gen.flatten_a(exps); + Gen.map( + (exps: array(exp)) => TupleExp(Array.to_list(exps)), + flattened, + ); + }, + list_sizes, + ), + ), ]); } }), diff --git a/test/Test_Menhir.re b/test/Test_Menhir.re index c5746e068..2da8481ad 100644 --- a/test/Test_Menhir.re +++ b/test/Test_Menhir.re @@ -253,6 +253,22 @@ let qcheck_menhir_maketerm_equivalent_test = exp => { let core_exp = Conversion.Exp.of_menhir_ast(exp); + // TODO Maybe only do this when necessary. + // TODO Check with Matthew if I'm using this correctly + // Add parens around tuples + let core_exp = + Exp.map_term( + ~f_exp= + (cont, e) => + switch (e.term) { + | Tuple(es) => + Parens(Tuple(es |> List.map(cont)) |> Exp.fresh) + |> Exp.fresh + | _ => cont(e) + }, + core_exp, + ); + let segment = ExpToSegment.exp_to_segment( ~settings= @@ -264,6 +280,7 @@ let qcheck_menhir_maketerm_equivalent_test = ); let serialized = Printer.of_segment(~holes=Some("?"), segment); + print_endline("Serialized: " ++ serialized); let make_term_parsed = make_term_parse(serialized); let menhir_parsed = Haz3lmenhir.Conversion.Exp.of_menhir_ast(