Commit d1f1c69f authored by Andrei Paskevich's avatar Andrei Paskevich

pretty-print mixfix operators correctly

parent 3441ae2b
......@@ -92,7 +92,10 @@ let print_th fmt th =
let print_ts fmt ts =
fprintf fmt "%s" (id_unique tprinter ts.ts_name)
let print_ls fmt ls = match extract_op ls with
let print_ls fmt ls =
if ls.ls_name.id_string = "mixfix []" then fprintf fmt "([])" else
if ls.ls_name.id_string = "mixfix [<-]" then fprintf fmt "([<-])" else
match extract_op ls with
| Some s -> fprintf fmt "(%s)" (escape_op s)
| None -> fprintf fmt "%s" (id_unique iprinter ls.ls_name)
......@@ -200,14 +203,20 @@ and print_app pri ls fmt tl = match extract_op ls, tl with
| _, [] ->
print_ls fmt ls
| Some s, [t1] when tight_op s ->
fprintf fmt (protect_on (pri > 6) "%s%a")
s (print_lterm 6) t1
fprintf fmt (protect_on (pri > 7) "%s%a")
s (print_lterm 7) t1
| Some s, [t1] ->
fprintf fmt (protect_on (pri > 4) "%s %a")
s (print_lterm 5) t1
| Some s, [t1;t2] ->
fprintf fmt (protect_on (pri > 4) "%a %s@ %a")
(print_lterm 5) t1 s (print_lterm 5) t2
| _, [t1;t2] when ls.ls_name.id_string = "mixfix []" ->
fprintf fmt (protect_on (pri > 6) "%a[%a]")
(print_lterm 6) t1 print_term t2
| _, [t1;t2;t3] when ls.ls_name.id_string = "mixfix [<-]" ->
fprintf fmt (protect_on (pri > 6) "%a[%a <- %a]")
(print_lterm 6) t1 (print_lterm 5) t2 (print_lterm 5) t3
| _, tl ->
fprintf fmt (protect_on (pri > 5) "%a@ %a")
print_ls ls (print_list space (print_lterm 6)) tl
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment