Representation of Names in Symbol Table:
There are two types of name representations
Fixed Length Name
Variable Length Name
Fixed Length Name:
- A fixed space for each name is allocated in symbol table
- In this type of storage, if name is too small then there is wastage of space
- The name can be referred by pointer to symbol table entry
Example:
Name
|
Attribute
| ||
S
|
U
|
M
| |
A
| |||
B
| |||
M
|
A
|
X
|
- In the above example, SUM, A, B, MAX are the variables
Variable Length Name:
- The name can be stored with the help of starting index and length of each name
Example: the above example can be modified as shown in the table
Name
|
Attributes
| |
Starting index
|
Length
| |
0
|
4
| |
4
|
2
| |
6
|
2
| |
8
|
4
|
0
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
10
|
11
|
S
|
U
|
M
|
$
|
A
|
$
|
B
|
$
|
M
|
A
|
X
|
$
|
Need for Symbol Table
Symbol table are used,
- To store or retrieve the information about an identifier quickly at compile time as well as at run time environment
- To achieve compile time efficiency
- To verify that used identifier have been declared
0 comments:
Post a Comment