Tweak printing of if/then/else

This commit is contained in:
Louis Gesbert 2023-07-07 14:50:32 +02:00
parent 4ae949f7f8
commit 3cb8fc1499
4 changed files with 9 additions and 8 deletions

View File

@ -586,7 +586,8 @@ let rec expr_aux :
| EIfThenElse _ -> | EIfThenElse _ ->
let rec pr els fmt = function let rec pr els fmt = function
| EIfThenElse { cond; etrue; efalse }, _ -> | EIfThenElse { cond; etrue; efalse }, _ ->
Format.fprintf fmt "@[<hv 2>%a@ %a@]@ @[<hv 2>%a@ %a@]@ %a" keyword Format.fprintf fmt "@[<hv 2>@[<hv 2>%a@ %a@;<1 -2>%a@]@ %a@]@ %a"
keyword
(if els then "else if" else "if") (if els then "else if" else "if")
expr cond keyword "then" expr etrue (pr true) efalse expr cond keyword "then" expr etrue (pr true) efalse
| e -> Format.fprintf fmt "@[<hv 2>%a@ %a@]" keyword "else" (rhs exprc) e | e -> Format.fprintf fmt "@[<hv 2>%a@ %a@]" keyword "else" (rhs exprc) e

View File

@ -71,7 +71,8 @@ let scope S (x: integer|internal|output) =
to_rat ((2 - i) * (2 - i))) to_rat ((2 - i) * (2 - i)))
< let i : integer = i_2 in < let i : integer = i_2 in
to_rat ((2 - i) * (2 - i)) to_rat ((2 - i) * (2 - i))
then i_1 then
i_1
else i_2) else i_2)
42 42
[ 1; 2; 3 ]) [ 1; 2; 3 ])

View File

@ -34,8 +34,8 @@ let scope S
| ESome y_0 → | ESome y_0 →
let potential_max_1 : integer = y_0 in let potential_max_1 : integer = y_0 in
let potential_max_2 : integer = y_3 in let potential_max_2 : integer = y_3 in
if potential_max_1 < potential_max_2 if potential_max_1 < potential_max_2 then
then ESome potential_max_1 ESome potential_max_1
else ESome potential_max_2) else ESome potential_max_2)
ESome -1 ESome -1
y_2) y_2)
@ -83,8 +83,8 @@ let scope S
| ESome y_0 → | ESome y_0 →
let potential_max_1 : integer = y_0 in let potential_max_1 : integer = y_0 in
let potential_max_2 : integer = y_3 in let potential_max_2 : integer = y_3 in
if potential_max_1 < potential_max_2 if potential_max_1 < potential_max_2 then
then ESome potential_max_1 ESome potential_max_1
else ESome potential_max_2) else ESome potential_max_2)
ESome -1 ESome -1
y_2)) y_2))

View File

@ -171,8 +171,7 @@ let scope Foo
(match b with (match b with
| ENone _ → ENone _ | ENone _ → ENone _
| ESome b → | ESome b →
if b if b then
then
match match
(match (SubFoo1 { SubFoo1_in x_in = ESome 10; }).x with (match (SubFoo1 { SubFoo1_in x_in = ESome 10; }).x with
| ENone _ → ENone _ | ENone _ → ENone _