2 ||M|| This file is part of HELM, an Hypertextual, Electronic
3 ||A|| Library of Mathematics, developed at the Computer Science
4 ||T|| Department, University of Bologna, Italy.
6 ||T|| HELM is free software; you can redistribute it and/or
7 ||A|| modify it under the terms of the GNU General Public License
8 \ / version 2 or (at your option) any later version.
9 \ / This software is distributed as is, NO WARRANTY.
10 V_______________________________________________________________ *)
16 type ('a, 'b) item = Term of 'a * 'b
21 type ('a, 'b) specs = {
22 pp_term : 'a -> F.formatter -> 'b -> unit;
23 pp_context: F.formatter -> 'a -> unit
28 (* Internal functions *******************************************************)
30 let std = F.std_formatter
32 let err = F.err_formatter
34 let pp_items frm st l items =
35 let pp_item frm = function
36 | Term (c, t) -> F.fprintf frm "@,%a" (st.pp_term c) t
37 | Context c -> F.fprintf frm "%a" st.pp_context c
38 | Warn s -> F.fprintf frm "@,%s" s
39 | String s -> F.fprintf frm "%s " s
41 let iter map frm l = List.iter (map frm) l in
42 if !level >= l then F.fprintf frm "%a" (iter pp_item) items
44 (* Interface functions ******************************************************)
48 begin F.fprintf std "@,@[<v 2>%s" " "; F.pp_print_if_newline std () end
50 let unbox l = if !level >= l then F.fprintf std "@]"
52 let flush l = if !level >= l then F.fprintf std "@]@."
54 let box_err () = F.fprintf err "@[<v>"
56 let flush_err () = F.fprintf err "@]@."
58 let log st l items = pp_items std st l items
60 let error st items = pp_items err st 0 items
62 let items1 s = [Warn s]
65 [Warn st; Term (c, t)]
67 let ct_items1 sc c st t =
68 [Warn sc; Context c; Warn st; Term (c, t)]
70 let ct_items2 sc c st1 t1 st2 t2 =
71 ct_items1 sc c st1 t1 @ [Warn st2; Term (c, t2)]
73 let ct_items3 sc c st1 t1 st2 t2 st3 t3 =
74 ct_items2 sc c st1 t1 st2 t2 @ [Warn st3; Term (c, t3)]
76 let warn msg = F.fprintf std "@,%s" msg