in Compiler Design edited by
14,052 views
28 votes
28 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 edited by
14.1k views

5 Answers

40 votes
40 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!

edited by

2 Comments

what is semantic stack??
0
0
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 removed.is called  Semantic Stack
1
1
22 votes
22 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.

2 Comments

Perfect all points are cleared
0
0
This should be the best answer , all points covered!
0
0
15 votes
15 votes
B. It uses array to implement.

4 Comments

We use hash table instead of array in symbol table bcz in array we cant exceed the size of array .
0
0
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??
0
0
@rajan obviously Hash table. as time complexity f searching inserting is O(1) using hash table.
4
4
0 votes
0 votes
Ans = Symbol table
Which is used for managing information about variables and their attributes.
Answer:

Related questions