Consider the following grammar: S → AaB | bC A → BC ∣ bA B → aB ∣ ε C→ a ∣ SA…

Consider the following grammar:

S  →  AaB | bC

A  →  BC  ∣  bA

B  →  aB  ∣  ε

C→    a ∣ SA

Let FIRST(X) and FOLLOW(X) denote the standard sets for non-terminal X.
Which one of the following options correctly gives FIRST and FOLLOW sets for all variables?

  1. A.

    FIRST(S) = { a,b }, FOLLOW(S) = { a, b, $ }, FIRST(A) = { a, b }, FOLLOW(A) = { a, b }, FIRST(B) = { a, ε }, FOLLOW(B) = { a,b, $ }, FIRST(C) = { a, b }, FOLLOW(C) = { a, b }

  2. B.

    FIRST(S) = { a,b }, FOLLOW(S) = { a, b, $ }, FIRST(A) = { a, b }, FOLLOW(A) = { a, b, $ }, FIRST(B) = { a, ε }, FOLLOW(B) = { a,b, $ }, FIRST(C) = { a, b }, FOLLOW(C) = { a, b, $ }

  3. C.

    FIRST(S) = { a,b }, FOLLOW(S) = { a, b, $ }, FIRST(A) = { a, b }, FOLLOW(A) = { a, b}, FIRST(B) = { a, ε }, FOLLOW(B) = { a,b, $ }, FIRST(C) = { a, b }, FOLLOW(C) = { a, b, $ }

  4. D.

    FIRST(S) = { a,b }, FOLLOW(S) = { a, b, $ }, FIRST(A) = { a, b }, FOLLOW(A) = { a, b, $ }, FIRST(B) = { a, ε }, FOLLOW(B) = { a,b, $ }, FIRST(C) = { a, b }, FOLLOW(C) = { b, $ }

Attempted by 102 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…