The Gateway to Computer Science Excellence
+15 votes

Which data structure in a compiler is used for managing information about variables and their attributes?

  1. Abstract syntax tree
  2. Symbol table
  3. Semantic stack
  4. Parse table
in Compiler Design by Veteran (105k points)
edited by | 2k views

3 Answers

+28 votes
Best answer

$(B)$ Symbol table is  the answer.

It can be implemented by using an array, hash table, tree and even some time with the help of the Iinked list!

by Loyal (9.9k points)
edited by
what is semantic stack??
To make the stack directly accessible to the semantic routines. Using this approach, the action routines take their parameters from the top of the stack rather than receiving them explicitly when they are called. Similarly, any semantic record produced by an action routine is pushed onto the stack after the parameters are called  Semantic Stack
+15 votes
B. It uses array to implement.
by Boss (19.9k points)
The symbol table is actually a array implementation.
It is Symbol Table only. Mostly implemented as Hash tables.
We use hash table instead of array in symbol table bcz in array we cant exceed the size of array .
can any one tell me if they ask symbol table is easily implemented by and options are 1. hash table 2. array what will be the answer??
@rajan obviously Hash table. as time complexity f searching inserting is O(1) using hash table.
+9 votes

Symbol table is an important data structure created and maintained by compilers in order to store information about the occurrence of various entities such as variable names, function names, objects, classes, interfaces, etc. Symbol table is used by both the analysis and the synthesis parts of a compiler.

If a compiler is to handle a small amount of data, then the symbol table can be implemented as an unordered list, which is easy to code, but it is only suitable for small tables only. A symbol table can be implemented in one of the following ways:

  • Linear (sorted or unsorted) list
  • Binary Search Tree
  • Hash table

Among all, symbol tables are mostly implemented as hash tables, where the source code symbol itself is treated as a key for the hash function and the return value is the information about the symbol.

by Loyal (7.9k points)
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,370 answers
105,272 users