The GATE Grind

GATE 2025 CS (CS1) – Question 46

Compiler Design · Parsing and Syntax Analysis · 2 marks · Multiple select

Which of the following statement(s) is/are TRUE while computing First and Follow during top down parsing by a compiler?

  1. For a production $A \rightarrow \epsilon$, $\epsilon$ will be added to $First(A)$.
  2. If there is any input right end marker, it will be added to $First(S)$, where $S$ is the start symbol.
  3. For a production $A \rightarrow \epsilon$, $\epsilon$ will be added to $Follow(A)$.
  4. If there is any input right end marker, it will be added to $Follow(S)$, where $S$ is the start symbol.

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (A) For a production $A \rightarrow \epsilon$, $\epsilon$ will be added to $First(A)$.; (D) If there is any input right end marker, it will be added to $Follow(S)$, where $S$ is the start symbol.

Explanation

A→ε puts ε in First(A). The end marker $ is placed in Follow(S) for the start symbol. ε is never in a Follow set, and $ is not added to First.