X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Flambda-delta%2Flib%2Flog.ml;h=9c2ecefa2721f90b8365651527a0314c93951a5e;hb=c5e6ccfa6049bd5a0b941ec6d00cf452db0e8af9;hp=b33f6726b9b148d54bb15474eb23cf14853f3240;hpb=f23388dbd51574725a11b0ab5373f09838a32ab5;p=helm.git diff --git a/helm/software/lambda-delta/lib/log.ml b/helm/software/lambda-delta/lib/log.ml index b33f6726b..9c2ecefa2 100644 --- a/helm/software/lambda-delta/lib/log.ml +++ b/helm/software/lambda-delta/lib/log.ml @@ -17,6 +17,7 @@ type ('a, 'b) item = Term of 'a * 'b | Context of 'a | Warn of string | String of string + | Loc type ('a, 'b) specs = { pp_term : 'a -> F.formatter -> 'b -> unit; @@ -25,39 +26,34 @@ type ('a, 'b) specs = { let level = ref 0 +let loc = ref 0 + (* Internal functions *******************************************************) let std = F.std_formatter let err = F.err_formatter -let init = - let started = ref false in - fun () -> - if !started then () else - begin P.printf "\n"; started := true end - let pp_items frm st l items = let pp_item frm = function - | Term (c, t) -> F.fprintf frm "%a@,%a" st.pp_context c (st.pp_term c) t + | Term (c, t) -> F.fprintf frm "@,%a" (st.pp_term c) t | Context c -> F.fprintf frm "%a" st.pp_context c | Warn s -> F.fprintf frm "@,%s" s | String s -> F.fprintf frm "%s " s + | Loc -> F.fprintf frm " (line %u)" !loc in let iter map frm l = List.iter (map frm) l in if !level >= l then F.fprintf frm "%a" (iter pp_item) items (* Interface functions ******************************************************) -(* -let warn msg = - init (); P.printf " %s\n" msg; flush stdout -*) -let box () = F.fprintf std "@,@[%s" " "; F.pp_print_if_newline std () +let box l = + if !level >= l then + begin F.fprintf std "@,@[%s" " "; F.pp_print_if_newline std () end -let unbox () = F.fprintf std "@]" +let unbox l = if !level >= l then F.fprintf std "@]" -let flush () = F.fprintf std "@]@." +let flush l = if !level >= l then F.fprintf std "@]@." let box_err () = F.fprintf err "@[" @@ -69,10 +65,16 @@ let error st items = pp_items err st 0 items let items1 s = [Warn s] -let ct_items1 s c t = - [Warn s; Term (c, t)] +let t_items1 st c t = + [Warn st; Term (c, t)] + +let ct_items1 sc c st t = + [Warn sc; Context c; Warn st; Term (c, t)] + +let ct_items2 sc c st1 t1 st2 t2 = + ct_items1 sc c st1 t1 @ [Warn st2; Term (c, t2)] -let ct_items2 s1 c1 t1 s2 c2 t2 = - [Warn s1; Term (c1, t1); Warn s2; Term (c2, t2)] +let ct_items3 sc c st1 t1 st2 t2 st3 t3 = + ct_items2 sc c st1 t1 st2 t2 @ [Warn st3; Term (c, t3)] let warn msg = F.fprintf std "@,%s" msg