Question 1
Lexical Analyzer
Syntax Analyzer (Parser)
Semantic Analyzer
Code Optimizer
The IIT Madras BS Compiler Design (Compiler Design) End Term paper sat on 13 Sept 2026, in the May 2026 term: 21 questions for 50 marks in 180 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.
Lexical Analyzer
Syntax Analyzer (Parser)
Semantic Analyzer
Code Optimizer
Correct answer
Syntax Analyzer (Parser)
Why does the Static Single Assignment (SSA) form simplify compiler optimization and dataflow analysis?
It gives each definition a unique SSA name so that every SSA name has exactly one static definition, simplifying def-use chains.
It converts non-deterministic context-free grammars into deterministic parsing tables.
It directly maps high-level syntax into binary machine code without an assembler.
It automatically executes hot code blocks dynamically at runtime.
Correct answer
It gives each definition a unique SSA name so that every SSA name has exactly one static definition, simplifying def-use chains.
Why do bottom-up LR parser generators (like Bison) handle left-recursive grammar rules efficiently, whereas predictive top-down LL(1) parsers cannot parse them directly?
LR parsers shift input symbols and reduce recognized handles rather than recursively expanding the leftmost nonterminal, so left recursion does not cause infinite recursive expansion.
LR parsers convert left recursion to right recursion at compile time.
Top-down parsers use state-splitting algorithms that eliminate shift actions.
LR parsers construct leftmost derivations.
Correct answer
LR parsers shift input symbols and reduce recognized handles rather than recursively expanding the leftmost nonterminal, so left recursion does not cause infinite recursive expansion.
It is an L-attributed definition because inherited attributes depend only on parent attributes and left-sibling attributes.
It contains a cyclic dependency preventing evaluation.
Correct answer
It is an L-attributed definition because inherited attributes depend only on parent attributes and left-sibling attributes.
Correct answer
The parser cannot perform any shift actions.
The lexer stops emitting token codes.
All variable data sizes default to 0 bytes.
Correct answer
The start of the surrounding function activation block.
Correct answer
It automatically renames the variable to avoid shadowing.
Correct answer
What is the defining structural invariant of Static Single Assignment (SSA) form?
Every source variable can only be modified at runtime once during execution.
Every SSA variable name has exactly one static definition in the intermediate representation.
No conditional jumps or loop structures are permitted in the control flow graph.
All variables are allocated exclusively to hardware registers.
Correct answer
Every SSA variable name has exactly one static definition in the intermediate representation.
Correct answer
A lexical analyzer uses standard Lex rules to tokenize an input stream. Code snippet
Input:
How many total tokens are produced by the lexical analyzer for this input?
Correct answer: 6
Correct answer: 8
?
Correct answer: 4
Consider the Boolean expression:
Correct answer: 104
Which of the following strings will be accepted by this DFA? (Select all that apply)
Correct answers
{ +, ), $ }
{ *, +, $ }
{ +, * }
{ ), $ }
Correct answer
{ +, ), $ }
t1 = ptr * 8 t2 = t1 + k
t1 = k * 8 t2 = ptr + t1
t1 = ptr + k
t1 = k + 8 t2 = ptr + t1
Correct answer
t1 = k * 8 t2 = ptr + t1
Consider the Three-Address Code block:
Which of the following is the correct set of instruction leaders for basic block partitioning?
Correct answer
Correct answer: 5
Consider the following program with nested declarations:
Which statements are TRUE regarding the variable bindings?
The two nested blocks share identical symbol table instances.
Correct answers
Consider the TAC basic blocks:
Which of the following statements are correct at the entry of basic block B2?
A variable is defined as live at a program point if its current value may be used along at least one future execution path before being redefined.
Correct answers
A variable is defined as live at a program point if its current value may be used along at least one future execution path before being redefined.