-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathprint.ml
28 lines (24 loc) · 822 Bytes
/
print.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
open Format
open Parser
open Print
open Core
let () = Arity.install ()
let margin = ref 80
let set_margin n = margin := n
let reformat content =
let p = Parse.Term.parse (`String { content; title = Some "user-supplied term" }) in
let tr = Parse.Term.final p in
pp_set_geometry std_formatter ~margin:!margin ~max_indent:(max (!margin - 12) (!margin / 2));
pp_open_hovbox std_formatter 0;
pp_term `None std_formatter tr;
pp_close_box std_formatter ();
pp_print_newline std_formatter ();
pp_print_newline std_formatter ()
module Terminal = Asai.Tty.Make (Core.Reporter.Code)
let run f =
Reporter.run ~emit:Terminal.display ~fatal:(fun d ->
Terminal.display d;
raise (Failure "Fatal error"))
@@ fun () ->
Builtins.run @@ fun () ->
Global.run ~init:Global.empty @@ fun () -> Scope.run f