Computer Science, asked by fahadsbhai12, 9 months ago

Question 3: (4) Q=Perform all steps of LR(0) parsing on given grammar E->T E->E+T T->i T-> ( E ) And perform on input string (i+i).?

Answers

Answered by Anonymous
0

Answer:

First (E) = First (E + T) ∪ First (T)

First (T) = First (T * F) ∪ First (F)

First (F) = {id}

First (T) = {id}

First (E) = {id}

Follow (E) = First (+T) ∪ {$} = {+, $}

Follow (T) = First (*F) ∪ First (F)

= {*, +, $}

Follow (F) = {*, +, $}

I1 contains the final item which drives S → E• and follow (S) = {$}, so action {I1, $} = Accept

I2 contains the final item which drives E → T• and follow (E) = {+, $}, so action {I2, +} = R2, action {I2, $} = R2

I3 contains the final item which drives T → F• and follow (T) = {+, *, $}, so action {I3, +} = R4, action {I3, *} = R4, action {I3, $} = R4

I4 contains the final item which drives F → id• and follow (F) = {+, *, $}, so action {I4, +} = R5, action {I4, *} = R5, action {I4, $} = R5

I7 contains the final item which drives E → E + T• and follow (E) = {+, $}, so action {I7, +} = R1, action {I7, $} = R1

I8 contains the final item which drives T → T * F• and follow (T) = {+, *, $}, so action {I8, +} = R3, action {I8, *} = R3, action {I8, $} = R3.

Similar questions