CSC 4101 Chapter : Homework 3 Solutions
Document Summary
Homework 3 solutions: instead of creating a new ident object for every occurrence of, say, the symbol "x, the idea is to ensure that every time the symbol "x is used, the same ident object gets returned. I. e. , for every symobol name a unique ident object should be created. This can be done by creating a hash table that maps symbol names (strings) into ident objects. When a symbol is seen for the first time, an ident object is created and is inserted into this hash table. The next time the same symbol is seen, the ident object is retrieved from the hash table. Instead of creating a new ident object for every occurrence of a symbol, the parser would make the appropriate calls on that hash table to ensure that every symbol is represented by a unique. The same idea is used in java for making string comparison more efficient.