Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

show the following grammar S-> SA|A , A->a is SLR(1) but not LL(1) Solution Firs

ID: 3637128 • Letter: S

Question

show the following grammar S-> SA|A , A->a is SLR(1) but not LL(1)

Explanation / Answer

First i will proof that it is not LL(1). Given grammar is S-> SA|A A->a for any grammar in LL(1) both starting Variable in left and right should not be same.so change the form to: S->AS' S'->AS'|e (epsilon) A->a Now we determine the first of S and S'. first(S)={a} first(S')={a} to be a grammar in LL(1) no two varible should have the same first. but here we are getting both as {a}. So it proves that the grammar is not LL(1). For SLR(1) We have to transfer the given grammar as: S->AS' S'->AS'|e(epsilon) S''->S' S'->AS'|e(epsilon) A->a now we have to form the state transition diagram.I can't draw here. from that diagram it is seen that there is no repetation of states.Which proves that it is SLR(1) grammar.