5. Consider the following syntax-directed translation scheme. (1) P→ P:MS (2) PS (3) S begin Pend (4) S→ while M E do M2

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

5. Consider the following syntax-directed translation scheme. (1) P→ P:MS (2) PS (3) S begin Pend (4) S→ while M E do M2

Post by answerhappygod »

5 Consider The Following Syntax Directed Translation Scheme 1 P P Ms 2 Ps 3 S Begin Pend 4 S While M E Do M2 1
5 Consider The Following Syntax Directed Translation Scheme 1 P P Ms 2 Ps 3 S Begin Pend 4 S While M E Do M2 1 (82.94 KiB) Viewed 31 times
5 Consider The Following Syntax Directed Translation Scheme 1 P P Ms 2 Ps 3 S Begin Pend 4 S While M E Do M2 2
5 Consider The Following Syntax Directed Translation Scheme 1 P P Ms 2 Ps 3 S Begin Pend 4 S While M E Do M2 2 (40.23 KiB) Viewed 31 times
5. Consider the following syntax-directed translation scheme. (1) P→ P:MS (2) PS (3) S begin Pend (4) S→ while M E do M2 Si { backpatch (P1 . nextlist, M. quad) P. nextlist := S. nextlist {P. nextlist := S. nextlist } { S. nextlist :=Pnextlist } (5) SL:=E (6) N → (7) M → (8) E E relop E2 (9) E E, arith-op E2 (10) E (E) (11) Enum (12) EL { backpatch (Si . nextlist, M . quad); backpatch (E. truelist, M. quad); S. nextlist := E. falselist; emit ("goto' M . quad) } { S. nextlist := null; if L . offset = null then emit (L . place := E. place) else emit (L . place '' L . offset '=' E. place) } {N. nextlist := makelist (nextquad); emit ('goto-') } {M. quad := nextquad } { E. truelist := makelist (nextquad); E. falselist := makelist (nextquad + 1); emit (if Ei place relop E2 · place 'goto -); emit ("goto -') } { E. place := newtemp; emit (E. place := Ei place arith-op E, . place) } { E. place := Ej . place } {E. place := num. lexval } { if L . offset = null then E.place := L .place else begin E place := newtemp: emit (E. place :=' L . place [' L . offset 1) end {L. place := newtemp; L. offset := newtemp; emit (L. place='c (Elist . array)); emit (L. offset :=' Elist. place *** width (Elist. array)) } {L. place := id. place; L. offset := null } { t = newtemp; t2 := newtemp: m:= Elisti . ndim + 1; emit (t1 :=' Elist, place "*" limit (Elist, array, m)); emit (t2 ":='t'+'E. place); Elist array := Elist1 . array; Elist place := t2: Elist . ndim :=m} { Elist array := id. place; Elist. place := E. place: Elist . ndim := 1) (13) L → Elist] (14) Lid (15) Elist → Elisti , E (16) Elist →id [E

Show the intermediate code which is generated for the program below. I := 1; while I <= N do begin J: = 1; while J <= N do begin C[I, J] := A (I, J] + B [I, J]; J := J + 1 end; I := I + 1 end Arrays A, B and C are dimensioned at (1..100, 1..100). Each element should be considered as a 4-byte integer. Note that you are asked only to give the code and need not give the attributed parse tree unless it is helpful to you in computing the solution.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply