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_______________________________________________________________ *)
17 type ('b, 'c) item = Term of 'b * 'c
22 type ('b, 'c) message = ('b, 'c) item list
24 type ('a, 'b, 'c) specs = {
25 pp_term: 'a -> 'b -> out_channel -> 'c -> unit;
26 pp_lenv: 'a -> out_channel -> 'b -> unit
29 (* Internal functions *******************************************************)
35 let pp_items och a st l items =
36 let indent = KT.make (l+l) ' ' in
37 let pp_item och = function
38 | Term (c, t) -> KP.fprintf och "%s%a\n" indent (st.pp_term a c) t
39 | LEnv c -> KP.fprintf och "%s%a" indent (st.pp_lenv a) c
40 | Warn s -> KP.fprintf och "%s%s\n" indent s
41 | Uri u -> KP.fprintf och "%s<%s>\n" indent (U.string_of_uri u)
43 let iter map och l = List.iter (map och) l in
44 KP.fprintf och "%a%!" (iter pp_item) items
46 (* Interface functions ******************************************************)
48 let log a st l items = pp_items std a st l items
50 let error a st items = pp_items err a st 0 items
52 let items1 s = [Warn s]
55 [Warn st; Term (c, t)]
57 let et_items1 sc c st t =
58 [Warn sc; LEnv c; Warn st; Term (c, t)]
60 let et_items2 sc1 c1 st1 t1 ?sc2 ?c2 st2 t2 =
61 let tl = match sc2, c2 with
62 | Some sc2, Some c2 -> et_items1 sc2 c2 st2 t2
63 | None, None -> t_items1 st2 c1 t2
66 et_items1 sc1 c1 st1 t1 @ tl
68 let et_items3 sc1 c1 st1 t1 ?sc2 ?c2 st2 t2 ?sc3 ?c3 st3 t3 =
69 let tl = match sc3, c3 with
70 | Some sc3, Some c3 -> et_items1 sc3 c3 st3 t3
71 | None, None -> t_items1 st3 c1 t3
74 et_items2 sc1 c1 st1 t1 ?sc2 ?c2 st2 t2 @ tl
77 pp_term = (fun _ _ _ _ -> ());
78 pp_lenv = (fun _ _ _ -> ());
81 let warn level str = log () specs level (items1 str)