Skip to content

Commit

Permalink
Improve pretty-printing of infixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kakadu committed Dec 11, 2020
1 parent bc52979 commit 73016b2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions bench/demo_infix.ml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ let rewrite_infix s =
else
let num c = Char.code c - Char.code '0' in
let c = Char.chr (num s.[i] * 10 + num s.[i+1]) in
(* Printf.printf "Got char '%c'\n" c; *)
Buffer.add_char b c;
loop (i+2)
in
Expand All @@ -44,7 +43,11 @@ class my_pp_e pp_decl fself = object
method! c_Call ppf e f args =
match f,args with
| (Var s, [l; r]) when looks_like_infix s ->
super#c_Call ppf e (Var (rewrite_infix s)) args (* CHANGE 1 *)
Format.fprintf ppf "@[<h>%a@ %s@ %a@]"
fself l
(rewrite_infix s)
fself r (* CHANGE 1 *)

| _ -> super#c_Call ppf e f args
end

Expand Down

0 comments on commit 73016b2

Please sign in to comment.