The Symbol Table
After finishing the scanner, you are ready to add symbol table and the symbol table routines to your project. As a result your scanner should now return a symbol table address with each identifier as well as a string table address with each string.
You may use an array and linear search. This will make things easy.
To manipulate your tables you need to write a method/function to install a name (string) in your symbol(string) table and also to return the address of a name.
When your scanner discovers an identifier, it is necessary to first search the symbol table for table for that identifier. If the identifier is found, the scanner returns the token iden along with the address in the symbol table. If the identifier is not found, it is first installed in the table and the address returned.
With strings, simply install the string and return the address.
Thus you really need to write two basic functions :
1.
INSTALL
2. RETRIEVE
Again, using a linear search will make it simple. (A hashed table would be more common, however)
The symbol table may be an array of objects . FOR NOW-- there will be only one field--NAME-- but as you build your compiler this will change.