]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/lambda-delta/src/basic_ag/bagOutput.ml
Matitaweb: layout change in the matitaweb inteface, in order to allow better
[helm.git] / helm / software / lambda-delta / src / basic_ag / bagOutput.ml
index 0bfc13ee64c3b4de9274a62f450cf583e9fc2369..feebca464a05bf92fbd2af4d78381dd639511e7a 100644 (file)
@@ -9,14 +9,17 @@
      \ /   This software is distributed as is, NO WARRANTY.              
       V_______________________________________________________________ *)
 
-module P = Printf
-module F = Format
-module U = NUri
-module L = Log
-module O = Options
-module Y = Entity
-module H = Hierarchy
-module B = Bag
+module P  = Printf
+module F  = Format
+module U  = NUri
+module L  = Log
+module G  = Options
+module E  = Entity
+module J  = Marks
+module H  = Hierarchy
+module XD = XmlCrg
+module Z  = Bag
+module ZD = BagCrg
 
 type counters = {
    eabsts: int;
@@ -36,41 +39,41 @@ let initial_counters = {
 }
 
 let rec count_term_binder f c = function
-   | B.Abst w ->
+   | Z.Abst w ->
       let c = {c with tabsts = succ c.tabsts} in
       count_term f c w
-   | B.Abbr v -> 
+   | Z.Abbr v -> 
       let c = {c with tabbrs = succ c.tabbrs} in
       count_term f c v
-   | B.Void   -> f c
+   | Z.Void   -> f c
 
 and count_term f c = function
-   | B.Sort _            -> 
+   | Z.Sort _            -> 
       f {c with tsorts = succ c.tsorts}
-   | B.LRef _            -> 
+   | Z.LRef _            -> 
       f {c with tlrefs = succ c.tlrefs}
-   | B.GRef _            -> 
+   | Z.GRef _            -> 
       f {c with tgrefs = succ c.tgrefs}
-   | B.Cast (v, t)       -> 
+   | Z.Cast (v, t)       -> 
       let c = {c with tcasts = succ c.tcasts} in
       let f c = count_term f c t in
       count_term f c v
-   | B.Appl (v, t)       -> 
+   | Z.Appl (v, t)       -> 
       let c = {c with tappls = succ c.tappls} in
       let f c = count_term f c t in
       count_term f c v
-   | B.Bind (_, _, b, t) -> 
+   | Z.Bind (_, _, b, t) -> 
       let f c = count_term_binder f c b in
       count_term f c t
 
 let count_entity f c = function
-   | _, _, Y.Abst w -> 
+   | _, _, E.Abst (_, w) -> 
       let c = {c with eabsts = succ c.eabsts} in
       count_term f c w
-   | _, _, Y.Abbr v -> 
+   | _, _, E.Abbr v      -> 
       let c = {c with eabbrs = succ c.eabbrs} in
       count_term f c v
-   | _, _, Y.Void   -> assert false
+   | _, _, E.Void        -> assert false
 
 let print_counters f c =
    let terms =
@@ -78,7 +81,7 @@ let print_counters f c =
       c.tabbrs
    in
    let items = c.eabsts + c.eabbrs in
-   let locations = B.locations () in
+   let locations = J.locations () in
    L.warn (P.sprintf "  Kernel representation summary (basic_ag)");
    L.warn (P.sprintf "    Total entry items:        %7u" items);
    L.warn (P.sprintf "      Declaration items:      %7u" c.eabsts);
@@ -94,52 +97,63 @@ let print_counters f c =
    L.warn (P.sprintf "    Total binder locations:   %7u" locations);   
    f ()
 
-let res l id =
-   if !O.indexes then P.sprintf "#%u" l else id
+let name err frm a =
+   let f n = function 
+      | true  -> F.fprintf frm "%s" n
+      | false -> F.fprintf frm "-%s" n
+   in      
+   E.name err f a
+
+let res a l frm =
+   let err () = F.fprintf frm "@[#%u@]" l in
+   if !G.indexes then err () else name err frm a
 
 let rec pp_term c frm = function
-   | B.Sort h                 -> 
+   | Z.Sort h                 -> 
       let err () = F.fprintf frm "@[*%u@]" h in
       let f s = F.fprintf frm "@[%s@]" s in
       H.string_of_sort err f h 
-   | B.LRef i                 -> 
-      let f = function
-         | Some (id, _) -> F.fprintf frm "@[%s@]" id
-         | None         -> F.fprintf frm "@[#%u@]" i
-      in
-      if !O.indexes then f None else B.get f c i
-   | B.GRef s                    -> F.fprintf frm "@[$%s@]" (U.string_of_uri s)
-   | B.Cast (u, t)               ->
+   | Z.LRef i                 -> 
+      let err () = F.fprintf frm "@[#%u@]" i in
+      let f a _ = name err frm a in
+      if !G.indexes then err () else Z.get err f c i
+   | Z.GRef s                    -> F.fprintf frm "@[$%s@]" (U.string_of_uri s)
+   | Z.Cast (u, t)               ->
       F.fprintf frm "@[{%a}.%a@]" (pp_term c) u (pp_term c) t
-   | B.Appl (v, t)               ->
+   | Z.Appl (v, t)               ->
       F.fprintf frm "@[(%a).%a@]" (pp_term c) v (pp_term c) t
-   | B.Bind (l, id, B.Abst w, t) ->
+   | Z.Bind (a, l, Z.Abst w, t) ->
       let f cc =
-         F.fprintf frm "@[[%s:%a].%a@]" (res l id) (pp_term c) w (pp_term cc) t
+         F.fprintf frm "@[[%t:%a].%a@]" (res a l) (pp_term c) w (pp_term cc) t
       in
-      B.push "output abst" f c l id (B.Abst w)
-   | B.Bind (l, id, B.Abbr v, t) ->
+      Z.push "output abst" f c a l (Z.Abst w)
+   | Z.Bind (a, l, Z.Abbr v, t) ->
       let f cc = 
-         F.fprintf frm "@[[%s=%a].%a@]" (res l id) (pp_term c) v (pp_term cc) t
+         F.fprintf frm "@[[%t=%a].%a@]" (res a l) (pp_term c) v (pp_term cc) t
       in
-      B.push "output abbr" f c l id (B.Abbr v)
-   | B.Bind (l, id, B.Void, t)   ->
-      let f cc = F.fprintf frm "@[[%s].%a@]" (res l id) (pp_term cc) t in
-      B.push "output void" f c l id B.Void
+      Z.push "output abbr" f c a l (Z.Abbr v)
+   | Z.Bind (a, l, Z.Void, t)   ->
+      let f cc = F.fprintf frm "@[[%t].%a@]" (res a l) (pp_term cc) t in
+      Z.push "output void" f c a l Z.Void
 
 let pp_lenv frm c =
    let pp_entry frm = function
-      | l, id, B.Abst w -> 
-         F.fprintf frm "@,@[%s : %a@]" (res l id) (pp_term c) w
-      | l, id, B.Abbr v -> 
-         F.fprintf frm "@,@[%s = %a@]" (res l id) (pp_term c) v
-      | l, id, B.Void   -> 
-         F.fprintf frm "@,%s" (res l id)
+      | a, l, Z.Abst w -> 
+         F.fprintf frm "@,@[%t : %a@]" (res a l) (pp_term c) w
+      | a, l, Z.Abbr v -> 
+         F.fprintf frm "@,@[%t = %a@]" (res a l) (pp_term c) v
+      | a, l, Z.Void   -> 
+         F.fprintf frm "@,%t" (res a l)
    in
    let iter map frm l = List.iter (map frm) l in
    let f es = F.fprintf frm "%a" (iter pp_entry) (List.rev es) in
-   B.contents f c
+   Z.contents f c
 
 let specs = {
    L.pp_term = pp_term; L.pp_lenv = pp_lenv
 }
+
+(* term xml printing ********************************************************)
+
+let export_term =
+   ZD.crg_of_bag XD.export_term