215 views edited | 215 views
0
Getting 4 but given ans is 2
0

how did u gate 4,....

1. one for s row a column

2. s row b column..

2...

0
only (S,a) and (S,b) will have 2 entries. So 2 is ryt.
0
Got it but 2 entries would be under (A,a) and (A,b)
0
Under (S,a) entry : S$\rightarrow$aAbB, S$\rightarrow$ϵ

Under (S,b) entry : S$\rightarrow$bAaB, S$\rightarrow$ϵ

Under (A,a) and (A,b) : A$\rightarrow$S
0

no ..under (A,a) and(A,b)...we would get...A->S   First of S(a,b)

similarly   under (B,a) and (B,b)....B->S

+1 vote

$First (S) = First(A) = First(B)= {\{a, b, \epsilon}\} \\ Follow (S)= {\{a, b, \$} \}Follow (A)= {\{a, b} \}Follow (B)= {\{a, b, \$} \}$

LL(1) Parse Table:

 $a$ $b$ SS\rightarrow aAbBS\rightarrow \epsilonS\rightarrow bAaBS\rightarrow \epsilonS\rightarrow \epsilonAA\rightarrow SA\rightarrow SBB\rightarrow SB\rightarrow SB\rightarrow S$2 multiple entries Hence 2 is the correct answer by Boss (16.3k points) edited 0 will you please write its first and follow table? 0 Done 0 now, why not there is entry for A--->ϵ under T[A,a], T[A,b] similarly, why not there is entry for B--->ϵ under T[B,a], T[B,b] , T[B,$]
0
Because there is no such production for A and B present in grammar
0
but indirectly A is driving epsilon
+1
Yes, it is driving but we didn't add it into the table, we add only those entries present in grammar.

See LL(1) is a predictive parser, on the basis of current input symbol it decides which grammar production it will select.

Suppose at any instant when next input symbol is 'a' which is in first of A then production A->S is selected by parser

LL(1) table contains only productions present in grammar
0
thanks !

+1 vote