GATE / CS ARCHIVE

GATE CSE 2010 / QUESTION 13

Compiler variable attributes

Compiler Design · Semantic Analysis & Type Checking · Full GATE CSE 2010 paper

GATE 2010, Q13 1 mark · MCQ
Report issue

Semantic Analysis & Type Checking

Question 13, GATE 2010: Which compiler data structure manages information about variables and their attributes?
Options: (A) Abstract syntax tree; (B) Symbol table; (C) Semantic stack; (D) Parse table.
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

A symbol table stores identifier entries and attributes such as type, scope, storage location and parameter information. An abstract syntax tree represents program structure, a parse table guides parsing, and a semantic stack supports intermediate parser actions. Therefore the data structure asked for is the symbol table, B.

For example, a declaration “int count” can create a symbol-table entry recording the name count, integer type and scope. Later uses look up that entry for type checking and storage access. The syntax tree may refer to the entry but is not itself the lookup structure; a parse table instead maps parser states/lookahead to parsing actions.

Original paper, page 3