Skip to content
Related Articles

Related Articles

Improve Article

GATE | GATE-CS-2003 | Question 56

  • Last Updated : 12 Sep, 2019

Consider the grammar shown below

S → i E t S S' | a
S' → e S | ε
E → b 

In the predictive parse table. M, of this grammar, the entries M[S’, e] and M[S’, $] respectively are
(A) {S’ → e S} and {S’ → e}
(B) {S’ → e S} and {}
(C) {S’ → ε} and {S’ → ε}
(D) {S’ → e S, S’→ ε} and {S’ → ε}

Answer: (D)

Explanation: Here representing the parsing table as M[ X , Y ], where X represents rows( Non terminals) and Y represents columns(terminals).

Here are the rules to fill the parsing table.

For each distinct production rule A->α, of the grammar, we need to apply the given rules:

Rule 1: if A –> α is a production, for each terminal ‘a’ in FIRST(α), add A–>α to M[ A , a ]

Rule 2 : if ‘ ε ‘ is in FIRST(α), add A –> α to M [ A , b ] for each ‘b’ in FOLLOW(A).

As Entries have been asked corresponding to Non-Terminal S’, hence we only need to consider its productions to get the answer.

For S’ → eS, according to rule 1, this production rule should be placed at the entry M[ S’, FIRST(eS) ], and from the given grammar, FIRST(eS) ={e}, hence S’->eS is placed in the parsing table at entry M[S’ , e].


For S’->ε, as FIRST(ε) = {ε}, hence rule 2 should be applied, therefore, this production rule should be placed in the parsing table at entry M[S’,FOLLOW(S’)], and FOLLOW(S’) = FOLLOW(S) = { e, $ }, hence R->ε is placed at entry M[ S’, e ] and M[ S’ , $ ].

Therefore Answer is option D.

Visit the Following links to Learn how to find First and Follow sets.

Quiz of this Question

Attention reader! Don’t stop learning now.  Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.

Learn all GATE CS concepts with Free Live Classes on our youtube channel.

My Personal Notes arrow_drop_up
Recommended Articles
Page :