Javatpoint Logo
Javatpoint Logo

Data structure for symbol table

  • A compiler contains two type of symbol table: global symbol table and scope symbol table.
  • Global symbol table can be accessed by all the procedures and scope symbol table.

The scope of a name and symbol table is arranged in the hierarchy structure as shown below:

The above grammar can be represented in a hierarchical data structure of symbol tables:

Data structure for symbol table

The global symbol table contains one global variable and two procedure names. The name mentioned in the sum_num table is not available for sum_id and its child tables.

Data structure hierarchy of symbol table is stored in the semantic analyzer. If you want to search the name in the symbol table then you can search it using the following algorithm:

  • First a symbol is searched in the current symbol table.
  • If the name is found then search is completed else the name will be searched in the symbol table of parent until,
  • The name is found or global symbol is searched.





Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA