equal
deleted
inserted
replaced
23 val rep_sg: sg -> |
23 val rep_sg: sg -> |
24 {self: sg_ref, |
24 {self: sg_ref, |
25 tsig: Type.type_sig, |
25 tsig: Type.type_sig, |
26 const_tab: typ Symtab.table, |
26 const_tab: typ Symtab.table, |
27 syn: Syntax.syntax, |
27 syn: Syntax.syntax, |
28 path: string list, |
28 path: string list option, |
29 spaces: (string * NameSpace.T) list, |
29 spaces: (string * NameSpace.T) list, |
30 data: data} |
30 data: data} |
31 val name_of: sg -> string |
31 val name_of: sg -> string |
32 val stamp_names_of: sg -> string list |
32 val stamp_names_of: sg -> string list |
33 val exists_stamp: string -> sg -> bool |
33 val exists_stamp: string -> sg -> bool |
176 stamps: string ref list} * (*unique theory indentifier*) |
176 stamps: string ref list} * (*unique theory indentifier*) |
177 {self: sg_ref, (*mutable self reference*) |
177 {self: sg_ref, (*mutable self reference*) |
178 tsig: Type.type_sig, (*order-sorted signature of types*) |
178 tsig: Type.type_sig, (*order-sorted signature of types*) |
179 const_tab: typ Symtab.table, (*type schemes of constants*) |
179 const_tab: typ Symtab.table, (*type schemes of constants*) |
180 syn: Syntax.syntax, (*syntax for parsing and printing*) |
180 syn: Syntax.syntax, (*syntax for parsing and printing*) |
181 path: string list, (*current name space entry prefix*) |
181 path: string list option, (*current name space entry prefix*) |
182 spaces: (string * NameSpace.T) list, (*name spaces for consts, types etc.*) |
182 spaces: (string * NameSpace.T) list, (*name spaces for consts, types etc.*) |
183 data: data} (*anytype data*) |
183 data: data} (*anytype data*) |
184 and data = |
184 and data = |
185 Data of |
185 Data of |
186 (Object.kind * (*kind (for authorization)*) |
186 (Object.kind * (*kind (for authorization)*) |
439 fun change_space f spaces kind x = overwrite (spaces, (kind, f (space_of spaces kind, x))); |
439 fun change_space f spaces kind x = overwrite (spaces, (kind, f (space_of spaces kind, x))); |
440 fun add_names x = change_space NameSpace.extend x; |
440 fun add_names x = change_space NameSpace.extend x; |
441 fun hide_names x = change_space NameSpace.hide x; |
441 fun hide_names x = change_space NameSpace.hide x; |
442 |
442 |
443 (*make full names*) |
443 (*make full names*) |
444 fun full path name = |
444 fun full _ "" = error "Attempt to declare empty name \"\"" |
445 if name = "" then error "Attempt to declare empty name \"\"" |
445 | full None name = name |
446 else if NameSpace.is_qualified name then |
446 | full (Some path) name = |
447 error ("Attempt to declare qualified name " ^ quote name) |
447 if NameSpace.is_qualified name then |
448 else NameSpace.pack (path @ [name]); |
448 error ("Attempt to declare qualified name " ^ quote name) |
|
449 else NameSpace.pack (path @ [name]); |
449 |
450 |
450 (*base name*) |
451 (*base name*) |
451 val base_name = NameSpace.base; |
452 val base_name = NameSpace.base; |
452 |
453 |
453 |
454 |
505 fun intern_const sg = intrn (spaces_of sg) constK; |
506 fun intern_const sg = intrn (spaces_of sg) constK; |
506 |
507 |
507 val intern_tycons = intrn_tycons o spaces_of; |
508 val intern_tycons = intrn_tycons o spaces_of; |
508 |
509 |
509 val full_name = full o #path o rep_sg; |
510 val full_name = full o #path o rep_sg; |
510 fun full_name_path sg elems name = |
511 |
511 full (#path (rep_sg sg) @ NameSpace.unpack elems) name; |
512 fun full_name_path sg elems = |
|
513 full (Some (if_none (#path (rep_sg sg)) [] @ NameSpace.unpack elems)); |
|
514 |
512 end; |
515 end; |
513 |
516 |
514 |
517 |
515 |
518 |
516 (** pretty printing of terms, types etc. **) |
519 (** pretty printing of terms, types etc. **) |
968 (* add to path *) |
971 (* add to path *) |
969 |
972 |
970 fun ext_path (syn, tsig, ctab, (path, spaces), data) elems = |
973 fun ext_path (syn, tsig, ctab, (path, spaces), data) elems = |
971 let |
974 let |
972 val path' = |
975 val path' = |
973 if elems = ".." andalso not (null path) then fst (split_last path) |
976 if elems = "//" then None |
974 else if elems = "/" then [] |
977 else if elems = "/" then Some [] |
975 else path @ NameSpace.unpack elems; |
978 else if elems = ".." andalso is_some path andalso path <> Some [] then |
|
979 Some (fst (split_last (the path))) |
|
980 else Some (if_none path [] @ NameSpace.unpack elems); |
976 in |
981 in |
977 (syn, tsig, ctab, (path', spaces), data) |
982 (syn, tsig, ctab, (path', spaces), data) |
978 end; |
983 end; |
979 |
984 |
980 |
985 |
1105 val const_tab = Symtab.merge (op =) (const_tab1, const_tab2) |
1110 val const_tab = Symtab.merge (op =) (const_tab1, const_tab2) |
1106 handle Symtab.DUPS cs => |
1111 handle Symtab.DUPS cs => |
1107 raise TERM ("Incompatible types for constant(s) " ^ commas_quote cs, []); |
1112 raise TERM ("Incompatible types for constant(s) " ^ commas_quote cs, []); |
1108 val syn = Syntax.merge_syntaxes syn1 syn2; |
1113 val syn = Syntax.merge_syntaxes syn1 syn2; |
1109 |
1114 |
1110 val path = []; |
1115 val path = Some []; |
1111 val kinds = distinct (map fst (spaces1 @ spaces2)); |
1116 val kinds = distinct (map fst (spaces1 @ spaces2)); |
1112 val spaces = |
1117 val spaces = |
1113 kinds ~~ |
1118 kinds ~~ |
1114 ListPair.map NameSpace.merge |
1119 ListPair.map NameSpace.merge |
1115 (map (space_of spaces1) kinds, map (space_of spaces2) kinds); |
1120 (map (space_of spaces1) kinds, map (space_of spaces2) kinds); |
1124 |
1129 |
1125 |
1130 |
1126 (** partial Pure signature **) |
1131 (** partial Pure signature **) |
1127 |
1132 |
1128 val dummy_sg = make_sign (ref "", SgRef None, Type.tsig0, |
1133 val dummy_sg = make_sign (ref "", SgRef None, Type.tsig0, |
1129 Symtab.empty, Syntax.pure_syn, [], [], empty_data, []); |
1134 Symtab.empty, Syntax.pure_syn, Some [], [], empty_data, []); |
1130 |
1135 |
1131 val pre_pure = |
1136 val pre_pure = |
1132 create_sign (SgRef (Some (ref dummy_sg))) [] "#" |
1137 create_sign (SgRef (Some (ref dummy_sg))) [] "#" |
1133 (Syntax.pure_syn, Type.tsig0, Symtab.empty, ([], []), empty_data); |
1138 (Syntax.pure_syn, Type.tsig0, Symtab.empty, (Some [], []), empty_data); |
1134 |
1139 |
1135 |
1140 |
1136 end; |
1141 end; |