Chapter 2: Introduction to compilers

. Information required about the program variables during compilation

- Class of variable: keyword, identifier etc.

- Type of variable: integer, float, array, function etc.

- Amount of storage required

- Address in the memory

- Scope information

. Location to store this information

- Attributes with the variable (has obvious problems)

- At a central repository and every phase refers to the repository whenever information is required

. Normally the second approach is preferred

- Use a data structure called symbol table

For the lexicons, additional information with its name may be needed. Information about whether it is a keyword/identifier, its data type, value, scope, etc might be needed to be known during the latter phases of compilation. However, all this information is not available in a straight away. This information has to be found and stored somewhere. We store it in a data structure called Symbol Table. Thus each phase of the compiler can access data from the symbol table & write data to it. The method of retrieval of data is that with each lexicon a symbol table entry is associated. A pointer to this symbol in the table can be used to retrieve more information about the lexicon