GATE CS 2021 Set 1 | Question 41

Compiler Design › Parser · MCQ · 2 marks · Answer: A

  1. Question 41Compiler Designmcq2 marks
    Consider the following context-free grammar where the set of terminals is .
    S -> d a T | R f
    T -> a S | b a T | e
    R -> c a T R | e        (e denotes epsilon)
    The following is a partially-filled LL(1) parsing table; the numbered cells (1), (2), (3), (4) are to be filled (blank denotes an empty cell):
          a            b         c          d            f       $
    S                          (1)       S->daT       (2)
    T   T->aS     T->baT      (3)                    T->e      (4)
    R                         R->caTR               R->e
    Which one of the following choices represents the correct combination for the numbered cells in the parsing table ("blank" denotes that the corresponding cell is empty)?
    • A.
      (1) S->Rf (2) S->Rf (3) T->e (4) T->e
      ✓
    • B.
      (1) blank (2) S->Rf (3) T->e (4) T->e
    • C.
      (1) S->Rf (2) blank (3) blank (4) T->e
    • D.
      (1) blank (2) S->Rf (3) blank (4) blank

    Answer: A

    Solution

    Computing FIRST and FOLLOW sets: is nullable with , so is entered under both and (cells 1 and 2). is nullable, and FOLLOW contains and , so is entered in cells 3 and 4. This matches option (A).

More GATE PYQ on Parser

All GATE CS Compiler Design PYQ →

Attempt GATE CS 2021 Set 1 in real GATE exam mode

Full paper with a timer, the GATE interface and a topic-wise analysis — free.

Create free account →