author | wenzelm |
Mon, 29 Oct 2007 16:13:44 +0100 | |
changeset 25225 | e638164593bf |
parent 25072 | 03f57b516e12 |
child 26440 | feeb83f9657f |
permissions | -rw-r--r-- |
6118 | 1 |
(* Title: Pure/General/name_space.ML |
5012 | 2 |
ID: $Id$ |
3 |
Author: Markus Wenzel, TU Muenchen |
|
4 |
||
16137 | 5 |
Generic name spaces with declared and hidden entries. Unknown names |
16341
e573e5167eda
added type NameSpace.table with basic operations;
wenzelm
parents:
16262
diff
changeset
|
6 |
are considered global; no support for absolute addressing. |
16137 | 7 |
*) |
8 |
||
9 |
type bstring = string; (*names to be bound / internalized*) |
|
10 |
type xstring = string; (*externalized names / to be printed*) |
|
5012 | 11 |
|
16137 | 12 |
signature BASIC_NAME_SPACE = |
13 |
sig |
|
14 |
val long_names: bool ref |
|
15 |
val short_names: bool ref |
|
16 |
val unique_names: bool ref |
|
17 |
end; |
|
5012 | 18 |
|
19 |
signature NAME_SPACE = |
|
20 |
sig |
|
16137 | 21 |
include BASIC_NAME_SPACE |
9120 | 22 |
val hidden: string -> string |
25225 | 23 |
val is_hidden: string -> bool |
16137 | 24 |
val separator: string (*single char*) |
25 |
val is_qualified: string -> bool |
|
21858
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents:
20530
diff
changeset
|
26 |
val implode: string list -> string |
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents:
20530
diff
changeset
|
27 |
val explode: string -> string list |
16137 | 28 |
val append: string -> string -> string |
29 |
val qualified: string -> string -> string |
|
5012 | 30 |
val base: string -> string |
20530
448594cbd82b
renamed NameSpace.drop_base to NameSpace.qualifier;
wenzelm
parents:
19367
diff
changeset
|
31 |
val qualifier: string -> string |
11829 | 32 |
val map_base: (string -> string) -> string -> string |
5012 | 33 |
type T |
34 |
val empty: T |
|
16137 | 35 |
val intern: T -> xstring -> string |
36 |
val extern: T -> string -> xstring |
|
37 |
val hide: bool -> string -> T -> T |
|
5012 | 38 |
val merge: T * T -> T |
16137 | 39 |
type naming |
40 |
val path_of: naming -> string |
|
25072
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
41 |
val external_names: naming -> string -> string list |
16137 | 42 |
val full: naming -> bstring -> string |
43 |
val declare: naming -> string -> T -> T |
|
44 |
val default_naming: naming |
|
45 |
val add_path: string -> naming -> naming |
|
19015 | 46 |
val no_base_names: naming -> naming |
16137 | 47 |
val qualified_names: naming -> naming |
19055 | 48 |
val sticky_prefix: string -> naming -> naming |
24361 | 49 |
type 'a table = T * 'a Symtab.table |
16341
e573e5167eda
added type NameSpace.table with basic operations;
wenzelm
parents:
16262
diff
changeset
|
50 |
val empty_table: 'a table |
23086 | 51 |
val extend_table: naming -> (bstring * 'a) list -> 'a table -> 'a table |
16341
e573e5167eda
added type NameSpace.table with basic operations;
wenzelm
parents:
16262
diff
changeset
|
52 |
val merge_tables: ('a * 'a -> bool) -> 'a table * 'a table -> 'a table |
16848 | 53 |
val dest_table: 'a table -> (string * 'a) list |
16341
e573e5167eda
added type NameSpace.table with basic operations;
wenzelm
parents:
16262
diff
changeset
|
54 |
val extern_table: 'a table -> (xstring * 'a) list |
5012 | 55 |
end; |
56 |
||
57 |
structure NameSpace: NAME_SPACE = |
|
58 |
struct |
|
59 |
||
60 |
(** long identifiers **) |
|
61 |
||
16137 | 62 |
fun hidden name = "??." ^ name; |
63 |
val is_hidden = String.isPrefix "??." |
|
64 |
||
5012 | 65 |
val separator = "."; |
19305 | 66 |
val is_qualified = exists_string (fn s => s = separator); |
5012 | 67 |
|
21858
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents:
20530
diff
changeset
|
68 |
val implode_name = space_implode separator; |
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents:
20530
diff
changeset
|
69 |
val explode_name = space_explode separator; |
5012 | 70 |
|
16137 | 71 |
fun append name1 "" = name1 |
72 |
| append "" name2 = name2 |
|
73 |
| append name1 name2 = name1 ^ separator ^ name2; |
|
74 |
||
75 |
fun qualified path name = |
|
76 |
if path = "" orelse name = "" then name |
|
77 |
else path ^ separator ^ name; |
|
11829 | 78 |
|
16137 | 79 |
fun base "" = "" |
21858
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents:
20530
diff
changeset
|
80 |
| base name = List.last (explode_name name); |
11829 | 81 |
|
20530
448594cbd82b
renamed NameSpace.drop_base to NameSpace.qualifier;
wenzelm
parents:
19367
diff
changeset
|
82 |
fun qualifier "" = "" |
21858
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents:
20530
diff
changeset
|
83 |
| qualifier name = implode_name (#1 (split_last (explode_name name))); |
5012 | 84 |
|
16137 | 85 |
fun map_base _ "" = "" |
86 |
| map_base f name = |
|
21858
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents:
20530
diff
changeset
|
87 |
let val names = explode_name name |
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents:
20530
diff
changeset
|
88 |
in implode_name (nth_map (length names - 1) f names) end; |
16137 | 89 |
|
19015 | 90 |
|
25072
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
91 |
(* standard accesses *) |
19015 | 92 |
|
93 |
infixr 6 @@; |
|
94 |
fun ([] @@ yss) = [] |
|
95 |
| ((xs :: xss) @@ yss) = map (fn ys => xs @ ys) yss @ (xss @@ yss); |
|
96 |
||
97 |
fun suffixes_prefixes list = |
|
5012 | 98 |
let |
19015 | 99 |
val (xs, ws) = chop (length list - 1) list; |
100 |
val sfxs = suffixes xs @@ [ws]; |
|
101 |
val pfxs = prefixes1 xs @@ [ws]; |
|
25072
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
102 |
in (sfxs @ pfxs, sfxs) end; |
19015 | 103 |
|
104 |
fun suffixes_prefixes_split i k list = |
|
105 |
let |
|
106 |
val (((xs, ys), zs), ws) = list |> chop i ||>> chop k ||>> chop (length list - (i + k + 1)); |
|
107 |
val sfxs = |
|
108 |
[ys] @@ suffixes zs @@ [ws] @ |
|
109 |
suffixes1 xs @@ [ys @ zs @ ws]; |
|
110 |
val pfxs = |
|
111 |
prefixes1 xs @@ [ys @ ws] @ |
|
112 |
[xs @ ys] @@ prefixes1 zs @@ [ws]; |
|
25072
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
113 |
in (sfxs @ pfxs, sfxs) end; |
13332 | 114 |
|
5012 | 115 |
|
116 |
||
117 |
(** name spaces **) |
|
118 |
||
119 |
(* datatype T *) |
|
120 |
||
121 |
datatype T = |
|
25072
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
122 |
NameSpace of |
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
123 |
((string list * string list) * stamp) Symtab.table * (*internals, hidden internals*) |
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
124 |
(string list * stamp) Symtab.table; (*externals*) |
5012 | 125 |
|
25072
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
126 |
val empty = NameSpace (Symtab.empty, Symtab.empty); |
5012 | 127 |
|
25072
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
128 |
fun lookup (NameSpace (tab, _)) xname = |
17412 | 129 |
(case Symtab.lookup tab xname of |
16137 | 130 |
NONE => (xname, true) |
19030
78d43fe9ac65
low-level tuning of merge: maintain identity of accesses;
wenzelm
parents:
19015
diff
changeset
|
131 |
| SOME (([], []), _) => (xname, true) |
78d43fe9ac65
low-level tuning of merge: maintain identity of accesses;
wenzelm
parents:
19015
diff
changeset
|
132 |
| SOME (([name], _), _) => (name, true) |
78d43fe9ac65
low-level tuning of merge: maintain identity of accesses;
wenzelm
parents:
19015
diff
changeset
|
133 |
| SOME ((name :: _, _), _) => (name, false) |
78d43fe9ac65
low-level tuning of merge: maintain identity of accesses;
wenzelm
parents:
19015
diff
changeset
|
134 |
| SOME (([], name' :: _), _) => (hidden name', true)); |
8728 | 135 |
|
25072
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
136 |
fun get_accesses (NameSpace (_, tab)) name = |
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
137 |
(case Symtab.lookup tab name of |
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
138 |
NONE => [name] |
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
139 |
| SOME (xnames, _) => xnames); |
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
140 |
|
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
141 |
fun put_accesses name xnames (NameSpace (tab, xtab)) = |
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
142 |
NameSpace (tab, Symtab.update (name, (xnames, stamp ())) xtab); |
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
143 |
|
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
144 |
fun valid_accesses (NameSpace (tab, _)) name = Symtab.fold (fn (xname, ((names, _), _)) => |
16444 | 145 |
if not (null names) andalso hd names = name then cons xname else I) tab []; |
8728 | 146 |
|
147 |
||
16137 | 148 |
(* intern and extern *) |
149 |
||
150 |
fun intern space xname = #1 (lookup space xname); |
|
151 |
||
152 |
val long_names = ref false; |
|
153 |
val short_names = ref false; |
|
154 |
val unique_names = ref true; |
|
155 |
||
156 |
fun extern space name = |
|
157 |
let |
|
158 |
fun valid unique xname = |
|
159 |
let val (name', uniq) = lookup space xname |
|
160 |
in name = name' andalso (uniq orelse (not unique)) end; |
|
8728 | 161 |
|
16137 | 162 |
fun ex [] = if valid false name then name else hidden name |
163 |
| ex (nm :: nms) = if valid (! unique_names) nm then nm else ex nms; |
|
164 |
in |
|
165 |
if ! long_names then name |
|
166 |
else if ! short_names then base name |
|
25072
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
167 |
else ex (get_accesses space name) |
16137 | 168 |
end; |
169 |
||
5012 | 170 |
|
16137 | 171 |
(* basic operations *) |
172 |
||
25072
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
173 |
local |
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
174 |
|
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
175 |
fun map_space f xname (NameSpace (tab, xtab)) = |
23086 | 176 |
NameSpace (Symtab.map_default (xname, (([], []), stamp ())) |
25072
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
177 |
(fn (entry, _) => (f entry, stamp ())) tab, xtab); |
16137 | 178 |
|
179 |
fun del (name: string) = remove (op =) name; |
|
180 |
fun add name names = name :: del name names; |
|
181 |
||
25072
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
182 |
in |
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
183 |
|
16137 | 184 |
val del_name = map_space o apfst o del; |
185 |
val add_name = map_space o apfst o add; |
|
186 |
val add_name' = map_space o apsnd o add; |
|
8728 | 187 |
|
25072
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
188 |
end; |
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
189 |
|
8728 | 190 |
|
191 |
(* hide *) |
|
5012 | 192 |
|
16137 | 193 |
fun hide fully name space = |
8728 | 194 |
if not (is_qualified name) then |
195 |
error ("Attempt to hide global name " ^ quote name) |
|
196 |
else if is_hidden name then |
|
197 |
error ("Attempt to hide hidden name " ^ quote name) |
|
16137 | 198 |
else |
199 |
let val names = valid_accesses space name in |
|
200 |
space |
|
201 |
|> add_name' name name |
|
202 |
|> fold (del_name name) (if fully then names else names inter_string [base name]) |
|
203 |
end; |
|
5012 | 204 |
|
205 |
||
16137 | 206 |
(* merge *) |
5012 | 207 |
|
25072
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
208 |
(* FIXME non-canonical merge order!? *) |
6845 | 209 |
|
25072
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
210 |
fun merge (NameSpace (tab1, xtab1), NameSpace (tab2, xtab2)) = |
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
211 |
let |
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
212 |
val tab' = (tab1, tab2) |> Symtab.join |
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
213 |
(K (fn (((names1, names1'), stamp1), ((names2, names2'), stamp2)) => |
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
214 |
if stamp1 = stamp2 then raise Symtab.SAME |
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
215 |
else |
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
216 |
((Library.merge (op =) (names2, names1), |
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
217 |
Library.merge (op =) (names2', names1')), stamp ()))); |
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
218 |
val xtab' = (xtab1, xtab2) |> Symtab.join |
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
219 |
(K (fn ((xnames1, stamp1), (xnames2, stamp2)) => |
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
220 |
if stamp1 = stamp2 then raise Symtab.SAME |
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
221 |
else (Library.merge (op =) (xnames2, xnames1), stamp ()))); |
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
222 |
in NameSpace (tab', xtab') end; |
5012 | 223 |
|
16137 | 224 |
|
225 |
(** naming contexts **) |
|
226 |
||
227 |
(* datatype naming *) |
|
228 |
||
229 |
datatype naming = Naming of |
|
25072
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
230 |
string * (*path*) |
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
231 |
((string -> string -> string) * (*qualify*) |
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
232 |
(string list -> string list list * string list list)); (*accesses*) |
16137 | 233 |
|
234 |
fun path_of (Naming (path, _)) = path; |
|
25072
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
235 |
fun accesses (Naming (_, (_, accs))) = accs; |
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
236 |
|
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
237 |
fun external_names naming = map implode_name o #2 o accesses naming o explode_name; |
16137 | 238 |
|
239 |
||
240 |
(* declarations *) |
|
241 |
||
242 |
fun full (Naming (path, (qualify, _))) = qualify path; |
|
243 |
||
25072
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
244 |
fun declare naming name space = |
16137 | 245 |
if is_hidden name then |
246 |
error ("Attempt to declare hidden name " ^ quote name) |
|
247 |
else |
|
21962 | 248 |
let |
249 |
val names = explode_name name; |
|
23668 | 250 |
val _ = (null names orelse exists (fn s => s = "") names |
251 |
orelse exists_string (fn s => s = "\"") name) andalso |
|
21962 | 252 |
error ("Bad name declaration " ^ quote name); |
25072
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
253 |
val (accs, accs') = pairself (map implode_name) (accesses naming names); |
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
254 |
in space |> fold (add_name name) accs |> put_accesses name accs' end; |
16137 | 255 |
|
256 |
||
257 |
(* manipulate namings *) |
|
258 |
||
259 |
fun reject_qualified name = |
|
260 |
if is_qualified name then |
|
261 |
error ("Attempt to declare qualified name " ^ quote name) |
|
262 |
else name; |
|
263 |
||
264 |
val default_naming = |
|
265 |
Naming ("", (fn path => qualified path o reject_qualified, suffixes_prefixes)); |
|
266 |
||
267 |
fun add_path elems (Naming (path, policy)) = |
|
268 |
if elems = "//" then Naming ("", (qualified, #2 policy)) |
|
269 |
else if elems = "/" then Naming ("", policy) |
|
20530
448594cbd82b
renamed NameSpace.drop_base to NameSpace.qualifier;
wenzelm
parents:
19367
diff
changeset
|
270 |
else if elems = ".." then Naming (qualifier path, policy) |
16137 | 271 |
else Naming (append path elems, policy); |
272 |
||
273 |
fun no_base_names (Naming (path, (qualify, accs))) = |
|
25072
03f57b516e12
store external accesses within name space (as produced by naming policy);
wenzelm
parents:
24361
diff
changeset
|
274 |
Naming (path, (qualify, pairself (filter_out (fn [_] => true | _ => false)) o accs)); |
16137 | 275 |
|
19015 | 276 |
fun qualified_names (Naming (path, (_, accs))) = Naming (path, (qualified, accs)); |
277 |
||
19055 | 278 |
fun sticky_prefix prfx (Naming (path, (qualify, _))) = |
279 |
Naming (append path prfx, |
|
21858
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents:
20530
diff
changeset
|
280 |
(qualify, suffixes_prefixes_split (length (explode_name path)) (length (explode_name prfx)))); |
19015 | 281 |
|
16137 | 282 |
|
16341
e573e5167eda
added type NameSpace.table with basic operations;
wenzelm
parents:
16262
diff
changeset
|
283 |
|
e573e5167eda
added type NameSpace.table with basic operations;
wenzelm
parents:
16262
diff
changeset
|
284 |
(** name spaces coupled with symbol tables **) |
e573e5167eda
added type NameSpace.table with basic operations;
wenzelm
parents:
16262
diff
changeset
|
285 |
|
e573e5167eda
added type NameSpace.table with basic operations;
wenzelm
parents:
16262
diff
changeset
|
286 |
type 'a table = T * 'a Symtab.table; |
e573e5167eda
added type NameSpace.table with basic operations;
wenzelm
parents:
16262
diff
changeset
|
287 |
|
e573e5167eda
added type NameSpace.table with basic operations;
wenzelm
parents:
16262
diff
changeset
|
288 |
val empty_table = (empty, Symtab.empty); |
e573e5167eda
added type NameSpace.table with basic operations;
wenzelm
parents:
16262
diff
changeset
|
289 |
|
23086 | 290 |
fun extend_table naming bentries (space, tab) = |
16341
e573e5167eda
added type NameSpace.table with basic operations;
wenzelm
parents:
16262
diff
changeset
|
291 |
let val entries = map (apfst (full naming)) bentries |
e573e5167eda
added type NameSpace.table with basic operations;
wenzelm
parents:
16262
diff
changeset
|
292 |
in (fold (declare naming o #1) entries space, Symtab.extend (tab, entries)) end; |
e573e5167eda
added type NameSpace.table with basic operations;
wenzelm
parents:
16262
diff
changeset
|
293 |
|
e573e5167eda
added type NameSpace.table with basic operations;
wenzelm
parents:
16262
diff
changeset
|
294 |
fun merge_tables eq ((space1, tab1), (space2, tab2)) = |
19367 | 295 |
(merge (space1, space2), Symtab.merge eq (tab1, tab2)); |
16341
e573e5167eda
added type NameSpace.table with basic operations;
wenzelm
parents:
16262
diff
changeset
|
296 |
|
16848 | 297 |
fun ext_table (space, tab) = |
298 |
Symtab.fold (fn (name, x) => cons ((name, extern space name), x)) tab [] |
|
299 |
|> Library.sort_wrt (#2 o #1); |
|
300 |
||
301 |
fun dest_table tab = map (apfst #1) (ext_table tab); |
|
302 |
fun extern_table tab = map (apfst #2) (ext_table tab); |
|
16341
e573e5167eda
added type NameSpace.table with basic operations;
wenzelm
parents:
16262
diff
changeset
|
303 |
|
21858
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents:
20530
diff
changeset
|
304 |
|
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents:
20530
diff
changeset
|
305 |
(*final declarations of this structure!*) |
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents:
20530
diff
changeset
|
306 |
val implode = implode_name; |
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents:
20530
diff
changeset
|
307 |
val explode = explode_name; |
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents:
20530
diff
changeset
|
308 |
|
5012 | 309 |
end; |
5175 | 310 |
|
16137 | 311 |
structure BasicNameSpace: BASIC_NAME_SPACE = NameSpace; |
312 |
open BasicNameSpace; |