Getting 4 but given ans is 2

The Gateway to Computer Science Excellence

0 votes

+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$ | $ | |

$S$ |
$S\rightarrow aAbB$ $S\rightarrow \epsilon$ |
$S\rightarrow bAaB$ $S\rightarrow \epsilon$ |
$S\rightarrow \epsilon$ |

$A$ | $A\rightarrow S$ | $A\rightarrow S$ | |

$B$ | $B\rightarrow S$ | $B\rightarrow S$ | $B\rightarrow S$ |

2 multiple entries

**Hence 2 is the correct answer**

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,$]

similarly, why not there is entry for B--->ϵ under T[B,a], T[B,b] , T[B,$]

+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

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

52,345 questions

60,497 answers

201,858 comments

95,315 users