# 05.20.2022 - Adding symbol table

Not much for today, just adding some unit tests and implement a symbol table during the compilation process. The way it works is pretty much like the Constant Table that was mentioned yesterday.

If we have a let statement like in the following example, after the compilation process, the STORE_NAME opcode will be generated with the address of the a symbol.

(let a 10)

STORE_NAME 1  ; Symbol a


The Constants table would look like this:

value index
50 1

And the Symbols table would look like this:

value index
a 1

For now, I’m reusing the ConstantTable class from yesterday, renamed it to LookupTable, so both Constants and Symbols table shared the same behavior: If a value is looked up and not found, it will automatically insert to the table and return the address. But maybe I’ll need to revise this, as it may not make any sense to load a symbol before it’s being created, like in this following code:

(let a (* 10 x))


(print