Hash table This is an example of the use of a hash table in the compiler. I extract this file from my language project (som v.4.1). The hash table is separated from the attributes (htab[], symtab[]). This design saves space and is more flexible, htab is big but narrow (2003 x 1), symtab is small but wide (1000 x 5). An entry into the hash table will never be deleted. This fact makes symbols in the table unique. The symbol has no duplicate. The string of the symbol name is stored in a separate array (nmstr). The uniqueness of symbols means that there is no duplicate string in this array. The function "hash" is the hash function. It just sum all the ascii code representation of the name string (modulo by the table size). The main function to insert a symbol into the table is "install". It works by linear probing. The main "while loop" will search for a key in the table or an empty slot. By linear probe, the scan will look for the next empty slot one-by-one, wrapping around the end of table. If there is no empty slot the pointer will return to the starting point. "install" returns the value slot of the hash table. You don't have to worry about other functions in this file. Good luck P. Chongstitvatana 24 Oct 2008