uiz Space

May 2026 term · Compiler Design · BSCS4032

Compiler Design Quiz 2: 16 August 2026 (May 2026 term)

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.

Questions
16
Marks
47
Duration
120 min
MSQ
4
MCQ
10
Numerical
2

Updated

Official paper: Compiler Design 14 Aug 26 · No negative marking.

Question 1

+2 marksOne or more correct options

Select all that apply.

  1. A
  2. B
  3. C
  4. D
  5. E
Show answer

Correct answers

  • A
  • B
  • C

Question 2

+3 marksOne correct option

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?

  1. A

    (3,1,0)

  2. B

    (2,2,0)

  3. C

    (3,2,0)

  4. D

    (2,1,1)

Show answer

Correct answer

  • C

    (3,2,0)

Question 3

+3 marksOne correct option

Convert the following infix expression to postfix notation:

Which one of the following is the correct postfix expression?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • A

Question 4

+3 marksOne correct option

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?

  1. A

    LR(0)

  2. B

    Canonical LR(1)

  3. C

    LALR(1)

  4. D

    SLR(1)

Show answer

Correct answer

  • C

    LALR(1)

Question 5

+3 marksOne correct option

Consider the grammar

The initial state is

Which of the following is GOTO(I0, b) ?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • A

Question 6

+3 marksOne correct option

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?

  1. A
  2. B
  3. C
  4. D

    Accept

Show answer

Correct answer

  • B

Question 7

+3 marksOne correct option

Consider the production

The semantic rules are

Which of the following is the minimum valid attribute evaluation sequence?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • A

Question 8

+3 marksOne correct option

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?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B

Question 9

+3 marksNumerical answer
Show answer

Correct answer: 10

Question 10

+3 marksNumerical answer

Consider the following operator grammar:

An operator-precedence parser is used to parse the expression

Show answer

Correct answer: 5

Question 11

+4 marksOne or more correct options

Consider the grammar

and the following recursive descent parser.

Select all that apply.

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answers

  • A
  • D

Question 12

+2 marksOne correct option

A context-free grammar contains the productions

Which language is generated?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B

Question 13

+2 marksOne correct option

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?

  1. A

    Only 1 and 2

  2. B

    Only 2 and 3

  3. C

    Only 1 and 3

  4. D

    1, 2 and 3

Show answer

Correct answer

  • A

    Only 1 and 2

Question 14

+4 marksOne correct option

Consider the grammar.

Which of the following correctly gives FIRST(S) and FOLLOW(X)?

  1. A

    FIRST(S) = {p, q, r, s} FOLLOW(X) = {r, s, $}

  2. B

    FIRST(S) = {p, q, r, s, ε} FOLLOW(X) = {r, s}

  3. C

    FIRST(S) = {p, q, s} FOLLOW(X) = {$}

  4. D

    FIRST(S) = {p, q, r, s} FOLLOW(X) = {r, s}

Show answer

Correct answer

  • D

    FIRST(S) = {p, q, r, s} FOLLOW(X) = {r, s}

Question 15

+3 marksOne or more correct options

For the expression

which of the following statements are correct? (Select all that apply.)

Select all that apply.

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answers

  • A
  • C

Question 16

+3 marksOne or more correct options

Consider the SDD.

Which of the following statements are correct?

Select all that apply.

  1. A
  2. B
  3. C

    This SDD requires inherited attributes for expression evaluation.

  4. D
  5. E

    The attribute evaluation naturally proceeds from the leaves toward the root.

Show answer

Correct answers

  • A
  • B
  • E

    The attribute evaluation naturally proceeds from the leaves toward the root.