(20%) Consider the production and semantic rules for incremental translation (Ta
ID: 3909623 • Letter: #
Question
(20%) Consider the production and semantic rules for incremental translation (Table 1). P is the start symbol. Function Temp0 returns a new name for each call. S ? ?d» E ; { gen( tog.get(id.lezerre) 'z' Eaddr); } 2. L id LE (L.array top.get(id.lereme), IL-E: genl L.addr.base 't L.addr 'T '-E.addr); E-, El + ?? { E.addr-new Temp(); ?.type L.arTuy.type.elem; ?.addr-new Tempo; gen(?.addr? ?.addr's' L.type.undth); } gen(E.addr addr'Ea.addr);) { E.addr = top.get(id.lereme); } {E.addr = new Tanp(); E Larray-L1.array ?.type= L1 type.elem; tnew Temp ?.addr= new Temp(); gen(t E.addr L.type.undth); } gen(L.addrLaddr; id IL gen(E.addr' L.array.base 't L.addr T);) Translate the following statement into the corresponding three-address code. c a[i] bljl; 1l a is an integer array. b is a char array.Explanation / Answer
(Ans-) Given statement is:
c=a[i] + b[j];
Following is the 3-address code generation:-
T1= addr(a)
T2= i*4
T3= T1[T2]
T4= addr(b)
T5= j*4
T6= T4[T5]
T7= T4 + T6
c= T7
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.