1. NADAR SARAWATHI COLLEGE OF ARTS
AND SCIENCE,THENI.
DEPARTMENT OF COMPUTER SCIENCE
DATA STRUCTURE OF SYMBOL TABLE
BY:
B.POORANI
I-MSC(CS)
2. Symbol tables
A data structure used by a compiler to keep track of semantic of
names.
•Determine whether the variable is defined already or not.
•Determine the scope
Search : access the information associated with given name.
Insert: add a name into the table.
Delete : remove a name when its scope is closed.
3. Block structured languages
Two basic operation : set and reset
The set operation is invoked when the beginning of a block is recognized
during compilation.
The reset operation ,is applied when the end of a block is encountered.
4. Four structure
a. Unordered symbol table
b. Ordered symbol table
c. Tree structured symbol table
d. Hash symbol table
5. Unordered list:
1. For a very small set of variable.
2. Coding is easy , but performance is bad for large number of variables.
Ordered linear list:
1. Use binary search on arrays,
2. Insertion and deletion are expensive.
3. Coding is relatively easy.
6. Binary search tree:
1. O(log n) time per operation (search ,insert or delete)for n variables.
2. Coding is relatively different.
Hash table:
1. Most commonly used.
2. Very efficient provided the memory space is adequately larger than the
number of variable.
3. Coding is not too difficult.
7.
8. Content in a symbol table
•Possible entries in a symbol table:
Name : a string
Attribute:
Reserved word
Variable name
Type name
Procedure name
Constant name