StreakPeaked· Practice

ExamsGATETechnical

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 → ε, ε 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 → ε, ε 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.

Correct answer: If there is any input right end marker, it will be added to Follow(S), where S is the start symbol.

Solution

The correct option is true because the Follow set of a non-terminal includes the end-of-input marker to indicate that the parsing can successfully complete when reaching the start symbol, allowing the parser to recognize the end of the input.

Related GATE Technical questions

⚔️ Practice GATE Technical free + battle 1v1 →