X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Flambda-delta%2Flib%2Flog.ml;h=03e7b5b958a2b44dcca9a1571b7e12e948a60383;hb=4c157ac5c58f34fffc98289c2d2e71032d584a83;hp=4cea12cda89eef2d4e0c5d45bae5ebd9b9c8797b;hpb=d38cea7e4865091412e1414f5594dd7c124de47e;p=helm.git diff --git a/helm/software/lambda-delta/lib/log.ml b/helm/software/lambda-delta/lib/log.ml index 4cea12cda..03e7b5b95 100644 --- a/helm/software/lambda-delta/lib/log.ml +++ b/helm/software/lambda-delta/lib/log.ml @@ -14,19 +14,27 @@ module F = Format module C = Cps type ('a, 'b) item = Term of 'a * 'b - | Context of 'a + | LEnv of 'a | Warn of string | String of string + | Loc + +type ('a, 'b) message = ('a, 'b) item list type ('a, 'b) specs = { - pp_term : 'a -> F.formatter -> 'b -> unit; - pp_context: F.formatter -> 'a -> unit + pp_term: 'a -> F.formatter -> 'b -> unit; + pp_lenv: F.formatter -> 'a -> unit } let level = ref 0 +let loc = ref "unknown location" + (* Internal functions *******************************************************) +let clear () = + level := 0; loc := "unknown location" + let std = F.std_formatter let err = F.err_formatter @@ -34,9 +42,10 @@ let err = F.err_formatter let pp_items frm st l items = let pp_item frm = function | Term (c, t) -> F.fprintf frm "@,%a" (st.pp_term c) t - | Context c -> F.fprintf frm "%a" st.pp_context c + | LEnv c -> F.fprintf frm "%a" st.pp_lenv c | Warn s -> F.fprintf frm "@,%s" s | String s -> F.fprintf frm "%s " s + | Loc -> F.fprintf frm " <%s>" !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 @@ -64,13 +73,23 @@ let items1 s = [Warn s] 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 et_items1 sc c st t = + [Warn sc; LEnv 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_items3 sc c st1 t1 st2 t2 st3 t3 = - ct_items2 sc c st1 t1 st2 t2 @ [Warn st3; Term (c, t3)] +let et_items2 sc1 c1 st1 t1 ?sc2 ?c2 st2 t2 = + let tl = match sc2, c2 with + | Some sc2, Some c2 -> et_items1 sc2 c2 st2 t2 + | None, None -> t_items1 st2 c1 t2 + | _ -> assert false + in + et_items1 sc1 c1 st1 t1 @ tl + +let et_items3 sc1 c1 st1 t1 ?sc2 ?c2 st2 t2 ?sc3 ?c3 st3 t3 = + let tl = match sc3, c3 with + | Some sc3, Some c3 -> et_items1 sc3 c3 st3 t3 + | None, None -> t_items1 st3 c1 t3 + | _ -> assert false + in + et_items2 sc1 c1 st1 t1 ?sc2 ?c2 st2 t2 @ tl let warn msg = F.fprintf std "@,%s" msg