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_______________________________________________________________ *)
16 (* Internal functions *******************************************************)
18 let map_fold_left f map1 map2 a l =
19 let f a = C.list_fold_left f map2 a l in
22 let map_args f t v = f (B.Appl (v, t))
24 let map_pars f t (id, w) = f (B.Bind (id, B.Abst w, t))
26 let rec xlate_term f = function
28 let f h = f (B.Sort h) in
29 if s then f 0 else f 1
31 f (B.LRef (l - succ i))
32 | M.GRef (_, uri, vs) ->
33 let f vs = map_fold_left f C.id map_args (B.GRef uri) vs in
34 C.list_map f xlate_term vs
36 let f v t = f (B.Appl (v, t)) in
37 let f v = xlate_term (f v) t in
39 | M.Abst (id, w, t) ->
40 let f w t = f (B.Bind (id, B.Abst w, t)) in
41 let f w = xlate_term (f w) t in
44 let xlate_pars f (id, w) =
45 let f w = f (id, w) in
48 let xlate_entry f = function
49 | e, pars, uri, u, None ->
50 let f u = f (e, uri, B.Abst u) in
51 let f pars = map_fold_left f xlate_term map_pars u pars in
52 C.list_map f xlate_pars pars
53 | e, pars, uri, u, Some (_, t) ->
54 let f u t = f (e, uri, B.Abbr (B.Cast (u, t))) in
55 let f pars u = map_fold_left (f u) xlate_term map_pars t pars in
56 let f pars = map_fold_left (f pars) xlate_term map_pars u pars in
57 C.list_map f xlate_pars pars
59 let xlate_item f = function
61 | Some e -> let f e = f (Some e) in xlate_entry f e
63 (* Interface functions ******************************************************)
65 let brg_of_meta = xlate_item