Question: 5 . ( 1 5 pt ) Consider the following grammar, G: 1 . P - > S $$ 2 . S - > if

5.(15pt) Consider the following grammar, G:
1. P -> S $$
2. S -> if (e) then M O
3. S -> other
4. M -> if (e) then M else M
5. M -> other
6. O -> else T
7. O ->\epsi
8. T -> if (e) then T
9. T -> other
(a)(5pt) Compute the sets first(X) and follow(X), for all non-terminals X, and the sets
predict(p) for all production rules p.
(b)(5pt) Prove that G an LL(1) grammar.
(c)(5pt) We said that there is no top-down grammar for if..then..else statements. Does G
contradict this? Prove your answer.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!