Question: Consider a language where assignments can appear in the same context as expressions; the value of a = b = c equals the value of

Consider a language where assignments can appear in the same context as expressions; the value of a = b = c equals the value of c. The following grammar, G, generates such expressions that includes assignments in addition to additions and multiplications:
2
3
0. program
1. exp
2. exp
3. term tail
4. term tail
5. term
6. factor tail
7. factor tail
8. factor
9. factor
-> exp $$
-> id=exp
-> term term tail ->+ term term tail ->\epsi
-> factor factor tail ->* factor factor tail ->\epsi
->(exp)
-> id
(a) Showaparsetreeforthestring: id = id *(id = id + id * id)$$.
(b) For each production A ->\alpha , compute first(\alpha ) and follow(A) using the algorithm below; first(\alpha ) is computed by string FIRST(\alpha ). For each token added, indicate the pair (step, prod) used toaddit,where0<=step<=3isthestepinthealgorithm(markedas 0,1,2,3 below)and 0<= prod <=9 is
(c)(5pt) For each production i,1<= i <=9, compute predict(i).
(d) Using the information computed above, show that this grammar is not LL(1)
(e) Modify this grammar to make it LL(1). Explain clearly your changes and prove it is LL(1).

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!