Professional Documents
Culture Documents
Syntax
Analyzer
Symbol
Table
Semantic
Analyzer
Code
Generator
SYMBOL TABLE
A compiler needs to collect and use information about the names appearing in
the source program. This information is entered into a data structure called a
symbol table.
The symbol table is built up during the lexical and syntactic analysis.
The information collected about a name includes: 1- The string of characters by which it is denoted.
2- It's type (e.g. integer, real, string).
3- It's form (e.g. a simple variable, a structure).
4- It's location in memory.
5- Other attributes depending on the language.
information).
Each time a name is encountered, the symbol table is searched to
see whether that name has been seen previously.
If new, it is entered into the table.
Information about that name is entered into the table
during
STORING CHARACTERS
Method 1: A fixed size space within each entry large
enough to hold the largest possible name. Most names will
be much shorter than this so there will be a lot of wasted
storage
Method 2: Store all symbols in one large separate array.
Each symbol is terminated with an end of symbol mark
(EOS). Each symbol table record contains a pointer to the
first character of the symbol.
12345-
Look UP
Find symbol in the symbol table (and get its attributes)
SYMBOL TABLE
ORGANIZATION