GATE / CS ARCHIVE

GATE CSE 2006 / QUESTION 58

Predictive parsing table with epsilon production

Compiler Design · Parsing & Syntax Analysis · Full GATE CSE 2006 paper

GATE 2006, Q58 2 marks · MCQ
Report issue

Parsing & Syntax Analysis

Question 58, GATE 2006: For grammar S→FR, R→*S|ε, F→id, what are predictive-table entries M[S,id] and M[R,$], respectively?
Options:
(A) {S→FR}, {R→ε}
(B) {S→FR}, empty
(C) {S→FR}, {R→*S}
(D) {F→id}, {R→ε}
Question 58, GATE 2006: For grammar S→FR, R→*S|ε, F→id, what are predictive-table entries M[S,id] and M[R,$], respectively?
Options:
(A) {S→FR}, {R→ε}
(B) {S→FR}, empty
(C) {S→FR}, {R→*S}
(D) {F→id}, {R→ε}
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step through it (2 parts)

1. For S→FR, R→*S|ε, F→id, FIRST(FR)={id}; hence M[S,id]={S→FR}. Since S is the start symbol and R occurs at the end of S→FR, $ belongs to FOLLOW(R).

2. Therefore M[R,$]={R→ε}. Option A.

3. Teaching check: An LL(1) table uses FIRST of a nonempty production; ε productions use FOLLOW of their left-hand side. Since id begins FR, the S/id cell receives S→FR. Since R can end the start-symbol derivation, end marker $ belongs to FOLLOW(R).

Original paper, page 8