Consider the following grammar 𝐺, with 𝑆 as the start symbol. The grammar 𝐺…

PYQ GATE 2024

Consider the following grammar 𝐺, with 𝑆 as the start symbol. The grammar 𝐺 has three incomplete productions denoted by (1), (2), and (3).

Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  𝑆 β†’ π‘‘π‘Žπ‘‡ | (1)

                          𝑇 β†’ π‘Žπ‘† | 𝑏𝑇 | (2)

Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  𝑅 β†’ (3) | πœ–

The set of terminals is {π‘Ž, 𝑏, 𝑐, 𝑑, 𝑓}. The FIRST and FOLLOW sets of the different non-terminals are as follows.

Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β FIRST(𝑆) = {𝑐, 𝑑, 𝑓}, FIRST(𝑇) = {π‘Ž, 𝑏, πœ–}, FIRST(𝑅) = {𝑐, πœ–}

Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  FOLLOW(𝑆) = FOLLOW(𝑇) = {𝑐, 𝑓, $}, FOLLOW(𝑅) = {𝑓}

Which one of the following options CORRECTLY fills in the incomplete productions?

  1. A.

    (1) 𝑆 β†’ 𝑅𝑓 (2) 𝑇 β†’ πœ– (3) 𝑅 β†’ 𝑐𝑇𝑅

  2. B.

    (1) 𝑆 β†’ 𝑓𝑅 (2) 𝑇 β†’ πœ– (3) 𝑅 β†’ 𝑐𝑇𝑅

  3. C.

    (1) 𝑆 β†’ 𝑓𝑅 (2) 𝑇 β†’ 𝑐𝑇 (3) 𝑅 → 𝑐𝑅

  4. D.

    (1) 𝑆 β†’ 𝑅𝑓 (2) 𝑇 β†’ 𝑐𝑇 (3) 𝑅 → 𝑐𝑅

Attempted by 230 students.

Sign up free to check your answer

Sign up free

Explore the full course: Compiler Design

Loading lesson…