# MadeEasy Test Series: Compiler Design - Parsing

297 views edited
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 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 !

## Related questions

1 vote
1
511 views
Why ε is not shown in First(S). First(s) does contain ε . And please help me figure out which grammar is this? According to me it is NOT LL(1) (since it is left factored), NOT LR(0) (Since the Item 0 has a R-R conflict), NOT SLR(1) (The item 0 has a RR conflict since Follow(X) = Follow(Y) = {a,b} correct me If i'm wrong
1 vote