Question: ( 3 0 pt ) Consider a language where assignments can appear in the same context as expressions; the value of a = b =

(30pt) 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:
(a)(3pt) Show a parse tree for the string: id =id**(id =id+id**id.
(b)(10pt) For each production Alongrightarrow, compute FIRST() and FOLLOW(A) using the algorithm below;
FIRST () is computed by string_FIRST (). For each token added, indicate the pair (step, prod) used
to add it, where 0 step 3 is the step in the algorithm (marked as 0,1,2,3 below) and
0prod9 is the production involved; indicate (0,-) when step 0 is used for terminals.
(c)(5pt) For each production i,1i9, compute PREDICT(i).
(d)(2pt) Using the information computed above, show that this grammar is not LL(1).(See definition
on the slide 19 of the LR-parsing chapter.)
(e)(10pt) Modify this grammar to make it LL(1). Explain clearly your changes and prove it is LL(1).
 (30pt) Consider a language where assignments can appear in the same

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!