refactor(compiler): minor factorization of formatting functions inside the To_ocaml module

This commit is contained in:
EmileRolley 2021-07-08 17:00:24 +02:00
parent 731513a003
commit ac47d1ff1a

View File

@ -42,13 +42,13 @@ let format_op_kind (fmt : Format.formatter) (k : Dcalc.Ast.op_kind) =
(match k with KInt -> "!" | KRat -> "&" | KMoney -> "$" | KDate -> "@" | KDuration -> "^") (match k with KInt -> "!" | KRat -> "&" | KMoney -> "$" | KDate -> "@" | KDuration -> "^")
let format_log_entry (fmt : Format.formatter) (entry : Dcalc.Ast.log_entry) : unit = let format_log_entry (fmt : Format.formatter) (entry : Dcalc.Ast.log_entry) : unit =
match entry with Format.fprintf fmt "%s"
| VarDef _ -> Format.fprintf fmt ":=" (match entry with
| BeginCall -> Format.fprintf fmt "" | VarDef _ -> ":="
| EndCall -> Format.fprintf fmt "%s" "" | BeginCall -> ""
| PosRecordIfTrueBool -> Format.fprintf fmt "" | EndCall -> ""
| PosRecordIfTrueBool -> "")
(* TODO: to factorize. *)
let format_binop (fmt : Format.formatter) (op : Dcalc.Ast.binop Pos.marked) : unit = let format_binop (fmt : Format.formatter) (op : Dcalc.Ast.binop Pos.marked) : unit =
match Pos.unmark op with match Pos.unmark op with
| Add k -> Format.fprintf fmt "+%a" format_op_kind k | Add k -> Format.fprintf fmt "+%a" format_op_kind k