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 type name = id * bool (* token, real? *)
18 type names = name list
20 type attr = Name of name (* name *)
21 | Apix of int (* additional position index *)
22 | Mark of int (* node marker *)
23 | Meta of string (* metaliguistic annotation *)
24 | Priv (* private global definition *)
26 type attrs = attr list (* attributes *)
28 type 'term bind = Abst of 'term (* declaration: domain *)
29 | Abbr of 'term (* definition: body *)
30 | Void (* exclusion *)
32 type 'term entity = attrs * uri * 'term bind (* attrs, name, binder *)
35 delta: bool; (* global delta-expansion *)
36 rt: bool; (* reference typing *)
37 si: bool; (* sort inclusion *)
38 expand: bool (* always expand global definitions *)
41 (* helpers ******************************************************************)
43 let common f (a, u, _) = f a u
45 let rec name err f = function
46 | Name (n, r) :: _ -> f n r
47 | _ :: tl -> name err f tl
51 let rec aux f i a = function
53 | Name (n, r) :: tl -> aux (map f i n r) false a tl
54 | _ :: tl -> aux f i a tl
58 let rec get_name err f j = function
60 | Name (n, r) :: _ when j = 0 -> f n r
61 | Name _ :: tl -> get_name err f (pred j) tl
62 | _ :: tl -> get_name err f j tl
64 let rec get_names f = function
66 | Name _ as n :: tl ->
67 let f a ns = f a (n :: ns) in get_names f tl
69 let f a = f (e :: a) in get_names f tl
72 let rec aux k = function
74 | Name _ :: tl -> aux (succ k) tl
79 let rec apix err f = function
81 | _ :: tl -> apix err f tl
84 let rec mark err f = function
86 | _ :: tl -> mark err f tl
89 let rec priv err f = function
91 | _ :: tl -> priv err f tl
94 let rec meta err f = function
96 | _ :: tl -> meta err f tl
99 let resolve err f name a =
100 let rec aux i = function
101 | Name (n, true) :: _ when n = name -> f i
102 | _ :: tl -> aux (succ i) tl
107 let rec rev_append_names ns = function
109 | Name n :: tl -> rev_append_names (n :: ns) tl
110 | _ :: tl -> rev_append_names ns tl
112 let xlate f xlate_term = function
114 let f t = f (a, uri, Abst t) in xlate_term f t
116 let f t = f (a, uri, Abbr t) in xlate_term f t
120 let initial_status () = {
121 delta = false; rt = false; si = !O.si; expand = !O.expand
124 let refresh_status st = {st with
125 si = !O.si; expand = !O.expand