[cprint] code reduction
This commit is contained in:
parent
f121f55432
commit
52092b1480
@ -241,30 +241,23 @@ let cp_main_fn fmt (prog, sts) =
|
|||||||
cp_array vl
|
cp_array vl
|
||||||
in
|
in
|
||||||
let rec cp_inputs fmt (f, l) =
|
let rec cp_inputs fmt (f, l) =
|
||||||
match f, l with
|
match l with
|
||||||
| _, [] -> ()
|
| [] -> ()
|
||||||
| true, h :: t ->
|
| h :: t ->
|
||||||
Format.fprintf fmt ", %s%a"
|
(if f
|
||||||
(Utils.name_of_var h)
|
then Format.fprintf fmt ", %s%a"
|
||||||
cp_inputs (true, t)
|
else Format.fprintf fmt "%s%a")
|
||||||
| false, h :: t ->
|
|
||||||
Format.fprintf fmt "%s%a"
|
|
||||||
(Utils.name_of_var h)
|
(Utils.name_of_var h)
|
||||||
cp_inputs (true, t)
|
cp_inputs (true, t)
|
||||||
in
|
in
|
||||||
let cp_scanf fmt vl =
|
let cp_scanf fmt vl =
|
||||||
let rec cp_scanf_str fmt (b, vl) =
|
let rec cp_scanf_str fmt (b, vl) =
|
||||||
match b, vl with
|
match vl with
|
||||||
| _, [] -> ()
|
| [] -> ()
|
||||||
| true, h :: t ->
|
| h :: t ->
|
||||||
Format.fprintf fmt " %s%a"
|
(if b
|
||||||
(match h with
|
then Format.fprintf fmt " %s%a"
|
||||||
| IVar _ -> "%d"
|
else Format.fprintf fmt "%s%a")
|
||||||
| BVar _ -> "%c"
|
|
||||||
| RVar _ -> "%lf")
|
|
||||||
cp_scanf_str (true, t)
|
|
||||||
| false, h :: t ->
|
|
||||||
Format.fprintf fmt "%s%a"
|
|
||||||
(match h with
|
(match h with
|
||||||
| IVar _ -> "%d"
|
| IVar _ -> "%d"
|
||||||
| BVar _ -> "%c"
|
| BVar _ -> "%c"
|
||||||
@ -286,17 +279,12 @@ let cp_main_fn fmt (prog, sts) =
|
|||||||
in
|
in
|
||||||
let cp_printf fmt vl =
|
let cp_printf fmt vl =
|
||||||
let rec cp_printf_str fmt (b, vl) =
|
let rec cp_printf_str fmt (b, vl) =
|
||||||
match b, vl with
|
match vl with
|
||||||
| _, [] -> ()
|
| [] -> ()
|
||||||
| true, h :: t ->
|
| h :: t ->
|
||||||
Format.fprintf fmt " %s%a"
|
(if b
|
||||||
(match h with
|
then Format.fprintf fmt " %s%a"
|
||||||
| IVar _ -> "%d"
|
else Format.fprintf fmt "%s%a")
|
||||||
| BVar _ -> "%c"
|
|
||||||
| RVar _ -> "%f")
|
|
||||||
cp_printf_str (true, t)
|
|
||||||
| false, h :: t ->
|
|
||||||
Format.fprintf fmt "%s%a"
|
|
||||||
(match h with
|
(match h with
|
||||||
| IVar _ -> "%d"
|
| IVar _ -> "%d"
|
||||||
| BVar _ -> "%c"
|
| BVar _ -> "%c"
|
||||||
|
Loading…
Reference in New Issue
Block a user