The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+13 votes
1.3k views

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
asked in Compiler Design by Veteran (99.8k points)
edited by | 1.3k views

3 Answers

+25 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!

answered by Loyal (9.6k points)
edited by
0
what is semantic stack??
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
+15 votes
B. It uses array to implement.
answered by Boss (19.7k points)
+1
The symbol table is actually a array implementation.
+1
It is Symbol Table only. Mostly implemented as Hash tables.
0
We use hash table instead of array in symbol table bcz in array we cant exceed the size of array .
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??
+4
@rajan obviously Hash table. as time complexity f searching inserting is O(1) using hash table.
+3 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.

answered by Loyal (7.8k 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

38,115 questions
45,622 answers
132,338 comments
49,308 users