# HG changeset patch # User paulson # Date 819624894 -3600 # Node ID cef540a0a10e22dacc1c10ecdb12a749ec616b1f # Parent 036e072b215a182f1c53a6f326d8f780a9dbd946 Removed obsolete alist_of and st_of_alist. Is now simply a structure instead of a functor. diff -r 036e072b215a -r cef540a0a10e src/Pure/symtab.ML --- a/src/Pure/symtab.ML Fri Dec 22 10:30:06 1995 +0100 +++ b/src/Pure/symtab.ML Fri Dec 22 10:34:54 1995 +0100 @@ -18,9 +18,7 @@ val update: (string * 'a) * 'a table -> 'a table val update_new: (string * 'a) * 'a table -> 'a table val map: ('a -> 'b) -> 'a table -> 'b table - val alist_of: 'a table -> (string * 'a) list (*obsolete*) val balance: 'a table -> 'a table - val st_of_alist: (string * 'a) list * 'a table -> 'a table (*obsolete*) val st_of_declist: (string list * 'a) list * 'a table -> 'a table val make: (string * 'a) list -> 'a table val dest: 'a table -> (string * 'a) list @@ -32,7 +30,7 @@ val dest_multi: 'a list table -> (string * 'a) list end; -functor SymtabFun(): SYMTAB = +structure Symtab: SYMTAB = struct (*symbol table errors, such as from update_new*) @@ -76,8 +74,7 @@ else Branch (key, entry, left, right) in upd symtab end; -(*Like update but fails if key is already defined in table. - Allows st_of_alist, etc. to detect multiple definitions*) +(*Like update but fails if key is already defined in table.*) fun update_new ((key: string, entry: 'a), symtab : 'a table) : 'a table = let fun upd Tip = Branch (key, entry, Tip, Tip) @@ -89,15 +86,13 @@ (*conversion of symbol table to sorted association list*) -fun alist_of (symtab : 'a table) : (string * 'a) list = +fun dest (symtab : 'a table) : (string * 'a) list = let fun ali (symtab, cont) = case symtab of Tip => cont | Branch (key, entry, left, right) => ali(left, (key, entry) :: ali(right, cont)) in ali (symtab, []) end; -val dest = alist_of; - (*Make a balanced tree of the first n members of the sorted alist (sal). Utility for the function balance.*) @@ -112,14 +107,10 @@ fun balance symtab = - let val sal = alist_of symtab + let val sal = dest symtab in bal_of (sal, length sal) end; -(*Addition of association list to a symbol table*) -fun st_of_alist (al, symtab) = - foldr update_new (al, symtab); - (*A "declaration" associates the same entry with a list of keys; does not allow overwriting of an entry*) fun decl_update_new ((keys : string list, entry: 'a), symtab) @@ -139,7 +130,7 @@ fun make alst = (case gen_duplicates eq_fst alst of - [] => balance (st_of_alist (alst, Tip)) + [] => balance (foldr update_new (alst, Tip)) | dups => raise DUPS (map fst dups)); fun extend eq (tab, alst) =