src/Pure/General/name_space.ML
changeset 16848 1c8a5bb7c688
parent 16444 80c8f742c6fc
child 17163 f1455d56e5b5
equal deleted inserted replaced
16847:8fc160b12e73 16848:1c8a5bb7c688
    53     naming -> naming
    53     naming -> naming
    54   type 'a table = T * 'a Symtab.table
    54   type 'a table = T * 'a Symtab.table
    55   val empty_table: 'a table
    55   val empty_table: 'a table
    56   val extend_table: naming -> 'a table * (bstring * 'a) list -> 'a table
    56   val extend_table: naming -> 'a table * (bstring * 'a) list -> 'a table
    57   val merge_tables: ('a * 'a -> bool) -> 'a table * 'a table -> 'a table
    57   val merge_tables: ('a * 'a -> bool) -> 'a table * 'a table -> 'a table
       
    58   val dest_table: 'a table -> (string * 'a) list
    58   val extern_table: 'a table -> (xstring * 'a) list
    59   val extern_table: 'a table -> (xstring * 'a) list
    59 end;
    60 end;
    60 
    61 
    61 structure NameSpace: NAME_SPACE =
    62 structure NameSpace: NAME_SPACE =
    62 struct
    63 struct
   255   in (fold (declare naming o #1) entries space, Symtab.extend (tab, entries)) end;
   256   in (fold (declare naming o #1) entries space, Symtab.extend (tab, entries)) end;
   256 
   257 
   257 fun merge_tables eq ((space1, tab1), (space2, tab2)) =
   258 fun merge_tables eq ((space1, tab1), (space2, tab2)) =
   258   (merge (space1, space2), (Symtab.merge eq (tab1, tab2)));
   259   (merge (space1, space2), (Symtab.merge eq (tab1, tab2)));
   259 
   260 
   260 fun extern_table (space, tab) =
   261 fun ext_table (space, tab) =
   261   Library.sort_wrt #1 (map (apfst (extern space)) (Symtab.dest tab));
   262   Symtab.fold (fn (name, x) => cons ((name, extern space name), x)) tab []
       
   263   |> Library.sort_wrt (#2 o #1);
       
   264 
       
   265 fun dest_table tab = map (apfst #1) (ext_table tab);
       
   266 fun extern_table tab = map (apfst #2) (ext_table tab);
   262 
   267 
   263 end;
   268 end;
   264 
   269 
   265 structure BasicNameSpace: BASIC_NAME_SPACE = NameSpace;
   270 structure BasicNameSpace: BASIC_NAME_SPACE = NameSpace;
   266 open BasicNameSpace;
   271 open BasicNameSpace;