Printer: add some missing boxes

This commit is contained in:
Louis Gesbert 2023-04-15 15:43:03 +02:00
parent 404dc00db1
commit 8a2b50289e

View File

@ -431,12 +431,13 @@ let rec expr_aux :
Format.fprintf fmt "@[<hov 2>%a@ %a@ %a@]" operator op (lhs exprc) arg1
(rhs exprc) arg2
| EApp { f = EOp { op = (And | Or) as op; _ }, _; args = [arg1; arg2] } ->
Format.fprintf fmt "%a@ %a %a" (lhs exprc) arg1 operator op (rhs exprc) arg2
Format.fprintf fmt "@[<hv 0>%a@ %a %a@]" (lhs exprc) arg1 operator op
(rhs exprc) arg2
| EApp { f = EOp { op; _ }, _; args = [arg1; arg2] } ->
Format.fprintf fmt "@[<hv 0>%a@ %a %a@]" (lhs exprc) arg1 operator op
(rhs exprc) arg2
| EApp { f = EOp { op; _ }, _; args = [arg1] } ->
Format.fprintf fmt "%a %a" operator op (rhs exprc) arg1
Format.fprintf fmt "@[<hv 2>%a@ %a@]" operator op (rhs exprc) arg1
| EApp { f; args } ->
Format.fprintf fmt "@[<hv 2>%a@ %a@]" (lhs exprc) f
(Format.pp_print_list
@ -473,8 +474,8 @@ let rec expr_aux :
Format.fprintf fmt "@[<hov 2>%a@ %a@]" keyword "raise" except exn
| ELocation loc -> location fmt loc
| EDStructAccess { e; field; _ } ->
Format.fprintf fmt "%a%a%a%a%a" (lhs exprc) e punctuation "." punctuation
"\"" IdentName.format_t field punctuation "\""
Format.fprintf fmt "@[<hv 2>%a%a@,%a%a%a@]" (lhs exprc) e punctuation "."
punctuation "\"" IdentName.format_t field punctuation "\""
| EStruct { name; fields } ->
Format.fprintf fmt "@[<hv 0>@[<hv 2>%a@,@[<hv 0>%a@]@]@,%a%a@]" punctuation
"{"
@ -487,10 +488,11 @@ let rec expr_aux :
(StructField.Map.bindings fields)
punctuation "}_" StructName.format_t name
| EStructAccess { e; field; _ } ->
Format.fprintf fmt "%a%a%a%a%a" (lhs exprc) e punctuation "." punctuation
"\"" StructField.format_t field punctuation "\""
Format.fprintf fmt "@[<hv 2>%a%a@,%a%a%a@]" (lhs exprc) e punctuation "."
punctuation "\"" StructField.format_t field punctuation "\""
| EInj { e; cons; _ } ->
Format.fprintf fmt "%a@ %a" EnumConstructor.format_t cons (rhs exprc) e
Format.fprintf fmt "@[<hv 2>%a@ %a@]" EnumConstructor.format_t cons
(rhs exprc) e
| EMatch { e; cases; _ } ->
Format.fprintf fmt "@[<v 0>@[<hov 2>%a@ %a@]@ %a@ %a@]" keyword "match"
(lhs exprc) e keyword "with"