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_______________________________________________________________ *)
15 type attr = Name of id * bool (* name, real? *)
16 | Apix of int (* additional position index *)
17 | Mark of int (* node marker *)
18 | Priv (* private global definition *)
20 type attrs = attr list (* attributes *)
22 type 'term bind = Abst of 'term (* declaration: domain *)
23 | Abbr of 'term (* definition: body *)
24 | Void (* exclusion *)
26 type 'term entity = attrs * uri * 'term bind (* attrs, name, binder *)
28 type uri_generator = string -> string
31 g: Hierarchy.graph; (* sort hierarchy parameter *)
32 delta: bool; (* global delta-expansion *)
33 rt: bool; (* reference typing *)
34 si: bool; (* sort inclusion *)
35 expand: bool (* always expand global definitions *)
38 (* helpers ******************************************************************)
40 let common f (a, u, _) = f a u
42 let rec name err f = function
43 | Name (n, r) :: _ -> f n r
44 | _ :: tl -> name err f tl
48 let rec aux f i a = function
50 | Name (n, r) :: tl -> aux (map f i n r) false a tl
51 | _ :: tl -> aux f i a tl
55 let rec get_name err f j = function
57 | Name (n, r) :: _ when j = 0 -> f n r
58 | Name _ :: tl -> get_name err f (pred j) tl
59 | _ :: tl -> get_name err f j tl
61 let rec get_names f = function
63 | Name _ as n :: tl ->
64 let f a ns = f a (n :: ns) in get_names f tl
66 let f a = f (e :: a) in get_names f tl
68 let rec apix err f = function
70 | _ :: tl -> apix err f tl
73 let rec mark err f = function
75 | _ :: tl -> mark err f tl
78 let rec priv err f = function
80 | _ :: tl -> priv err f tl
83 let resolve err f name a =
84 let rec aux i = function
85 | Name (n, true) :: _ when n = name -> f i
86 | _ :: tl -> aux (succ i) tl
91 let xlate f xlate_term = function
93 let f t = f (a, uri, Abst t) in xlate_term f t
95 let f t = f (a, uri, Abbr t) in xlate_term f t
99 let initial_status g expand si = {
100 g = g; delta = false; rt = false; si = si; expand = expand