Which of the following statement(s) is/are TRUE while computing and during top down parsing by a compiler?
GATE CSE 2025Compiler Design › Grammars & ParsingVerified
GATE CSE 2025 PYQ: Which of the following statement(s) is/are TRUE while computing First \operatorname{First} First and…
- AFor a production will be added to .Correct answer
- BIf there is any input right end marker, it will be added to , where is the start symbol.
- CFor a production will be added to Follow .
- DIf there is any input right end marker, it will be added to , where is the start symbol.Correct answer
Answer
(A, D) For a production A → ϵ , ϵ A \rightarrow \epsilon, \epsilon A → ϵ , ϵ will be added to First ( A ) \operatorname{First}(A) First ( A ) .; If there is any input right end marker, it will be added to Follow ( S ) \operatorname{Follow}(S) Follow ( S ) , where S \text{S} S is the start symbol.
Approach
Use the standard definitions of FIRST and FOLLOW: FIRST(A) contains terminals that can begin strings derived from A and also contains ε if A derives ε. FOLLOW(A) contains terminals and the end-of-input marker that can appear immediately after A in some sentential form. ε is never added to any FOLLOW set.
The correct statements are A and D. A holds because ε is placed in FIRST(A) when A → ε. D holds because the end-of-input marker is placed in FOLLOW(S) for the start symbol S. B and C are false because the end marker does not go into FIRST and ε does not go into FOLLOW.
Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.