Question 1
+2 marksOne or more correct optionsSelect all that apply.
- A
- B
- C
- D
- E
The IIT Madras BS Compiler Design (Compiler Design) Quiz 2 paper sat on 16 Aug 2026, in the May 2026 term: 16 questions for 47 marks in 120 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.
Correct answers
A lexical analyzer uses the following rules.
The keyword rule has higher priority than the identifier rule. Input
Which of the following gives the correct number of Keyword, Identifier, and Number tokens?
(3,1,0)
(2,2,0)
(3,2,0)
(2,1,1)
Correct answer
(3,2,0)
Convert the following infix expression to postfix notation:
Which one of the following is the correct postfix expression?
Correct answer
A parser generator performs the following steps:
1. Construct the canonical LR(1) collection of item sets. 2. Merge all states having the same LR(0) core. 3. Construct the ACTION and GOTO tables from the merged automaton.
Which parsing technique is obtained after these steps?
LR(0)
Canonical LR(1)
LALR(1)
SLR(1)
Correct answer
LALR(1)
Consider the grammar
The initial state is
Which of the following is GOTO(I0, b) ?
Correct answer
Consider the grammar:
A shift-reduce parser is parsing the input:
The parser has already performed the following actions:
What should be the next action?
Accept
Correct answer
Consider the production
The semantic rules are
Which of the following is the minimum valid attribute evaluation sequence?
Correct answer
Consider the following overloaded functions.
The compiler evaluates the following function calls.
Which one of the following function calls requires integer promotion before overload resolution selects the best match?
Correct answer
Correct answer: 10
Consider the following operator grammar:
An operator-precedence parser is used to parse the expression
Correct answer: 5
Consider the grammar
and the following recursive descent parser.
Correct answers
A context-free grammar contains the productions
Which language is generated?
Correct answer
Consider the following statements about SLR(1), Canonical LR(1), and LALR(1) parsers.
1. Every SLR(1) grammar is also an LALR(1) grammar. 2. Every LALR(1) grammar is also an LR(1) grammar. 3. Every LR(1) grammar is also an LALR(1) grammar. Which of the following is correct?
Only 1 and 2
Only 2 and 3
Only 1 and 3
1, 2 and 3
Correct answer
Only 1 and 2
Consider the grammar.
Which of the following correctly gives FIRST(S) and FOLLOW(X)?
FIRST(S) = {p, q, r, s} FOLLOW(X) = {r, s, $}
FIRST(S) = {p, q, r, s, ε} FOLLOW(X) = {r, s}
FIRST(S) = {p, q, s} FOLLOW(X) = {$}
FIRST(S) = {p, q, r, s} FOLLOW(X) = {r, s}
Correct answer
FIRST(S) = {p, q, r, s} FOLLOW(X) = {r, s}
For the expression
which of the following statements are correct? (Select all that apply.)
Correct answers
Consider the SDD.
Which of the following statements are correct?
This SDD requires inherited attributes for expression evaluation.
The attribute evaluation naturally proceeds from the leaves toward the root.
Correct answers
The attribute evaluation naturally proceeds from the leaves toward the root.