Question: Subject: Compiler Construction Question: Consider the following Semantic rules: Grammar: A Ba|c B b dCbd C a B q | & |A a C C

Subject: Compiler Construction

Subject: Compiler Construction Question: Consider the following Semantic rules: Grammar: A Ba|c

Question: Consider the following Semantic rules:

B b dCbd C a B q | & |A a C

C ACB S id = E; { gen( top.get(id.leceme) '=' E.addr); }

Grammar: A Ba|c B b dCbd C a B q | & |A a C C ACB S id = E; { gen( top.get(id.leceme) '=' E.addr); } | L = E ; { gen(L.array.base'[' L.addr"]''=' E.addr); } E El + E2 { E.addr = new Temp(); gen( E.addr'=' E1.addr' +' E.addr); } | id { E.addr = top.get(id.lereme); } IL { E.addr = new Temp(); gen(E.addr'=' Larray.base' L.addr']); } L id [ E] { L.array = top.get(id.lezeme); L. type L.array.type.elem; L.addr = new Temp 0); gen(L.addr'=' E.addr'*' L.type.width); } | L1 [E] { L.array = Lj.array; L.type = L1.type.elem; t = new Temp(); L.addr = = new Temp 0); gen(t'=' E.addr'*' L.type.width); gen(L.addr'=' L1.addr'+'t); } Now translate the following assignments: i) y = a[i][j] + b[c[k]][j] ii) y = c[k] + b [a [c[i]] + 2]

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!