- Printf.printf " Intermediate representation summary\n";
- Printf.printf " Total entry items: %6u\n" items;
- Printf.printf " Declaration items: %6u\n" c.eabsts;
- Printf.printf " Definition items: %6u\n" c.eabbrs;
- Printf.printf " Total parameter items: %6u\n" pars;
- Printf.printf " Application items: %6u\n" c.pappls;
- Printf.printf " Abstraction items: %6u\n" c.pabsts;
- Printf.printf " Total term items: %6u\n" terms;
- Printf.printf " Sort items: %6u\n" c.tsorts;
- Printf.printf " Local reference items: %6u\n" c.tlrefs;
- Printf.printf " Global reference items: %6u\n" c.tgrefs;
- Printf.printf " Application items: %6u\n" c.tappls;
- Printf.printf " Abstraction items: %6u\n" c.tabsts;
- flush stdout; f ()
-
-let string_of_qid (id, path) =
- let path = String.concat "/" path in
- Filename.concat path id
-
+ L.warn (P.sprintf " Intermediate representation summary");
+ L.warn (P.sprintf " Total entry items: %6u" items);
+ L.warn (P.sprintf " Declaration items: %6u" c.eabsts);
+ L.warn (P.sprintf " Definition items: %6u" c.eabbrs);
+ L.warn (P.sprintf " Total parameter items: %6u" pars);
+ L.warn (P.sprintf " Application items: %6u" c.pappls);
+ L.warn (P.sprintf " Abstraction items: %6u" c.pabsts);
+ L.warn (P.sprintf " Total term items: %6u" terms);
+ L.warn (P.sprintf " Sort items: %6u" c.tsorts);
+ L.warn (P.sprintf " Local reference items: %6u" c.tlrefs);
+ L.warn (P.sprintf " Global reference items: %6u" c.tgrefs);
+ L.warn (P.sprintf " Application items: %6u" c.tappls);
+ L.warn (P.sprintf " Abstraction items: %6u" c.tabsts);
+ f ()
+
+let string_of_sort = function
+ | true -> "Type"
+ | false -> "Prop"
+
+let string_of_transparent = function
+ | true -> "="
+ | false -> "~"
+
+let pp_list pp opend sep closed frm l =
+ let rec aux frm = function
+ | [] -> ()
+ | [hd] -> pp frm hd
+ | hd :: tl -> F.fprintf frm "%a%s%a" pp hd sep aux tl
+ in
+ if l = [] then () else F.fprintf frm "%s%a%s" opend aux l closed
+
+let pp_rev_list pp opend sep closed frm l =
+ pp_list pp opend sep closed frm (List.rev l)
+
+let rec pp_args frm args = pp_list pp_term "(" "," ")" frm args
+
+and pp_term frm = function
+ | M.Sort s ->
+ F.fprintf frm "@[*%s@]" (string_of_sort s)
+ | M.LRef (l, i) ->
+ F.fprintf frm "@[%u@@#%u@]" l i
+ | M.GRef (l, uri, ts) ->
+ F.fprintf frm "@[%u@@$%s%a@]" l (U.string_of_uri uri) pp_args ts
+ | M.Appl (v, t) ->
+ F.fprintf frm "@[(%a).%a@]" pp_term v pp_term t
+ | M.Abst (id, w, t) ->
+ F.fprintf frm "@[[%s:%a].%a@]" id pp_term w pp_term t
+
+let pp_par frm (id, w) =
+ F.fprintf frm "%s:%a" id pp_term w
+
+let pp_pars = pp_rev_list pp_par "[" "," "]"
+
+let pp_body frm = function
+ | None -> ()
+ | Some (trans, t) ->
+ F.fprintf frm "%s%a" (string_of_transparent trans) pp_term t
+
+let pp_entry frm (l, pars, uri, u, body) =
+ F.fprintf frm "@[%u@@%s%a%a:%a@]@\n%!"
+ l (U.string_of_uri uri) pp_pars pars pp_body body pp_term u
+
+let pp_item f frm = function
+ | Some entry -> pp_entry frm entry; f ()
+ | None -> f ()