Question: Subject: Compiler Construction Note: Kindly do not write the answer on a paper as I want to copy and paste it so I do not

Subject: Compiler Construction

Note: Kindly do not write the answer on a paper as I want to copy and paste it so I do not need to write that again thank you

Question:

Consider the following Semantic rules:

Subject: Compiler Construction Note: Kindly do not write the answer on a

Now translate the following assignments:

i) y = a [ i ] [ j ] + b [ c [ k ] ] [ j ]

ii) y = c [ k ] + b [ a [ c [ i ] ] + 2 ]

Rubrics for each part in Question 4

Understanding 0.5

mark Method / Problem Solving 1 mark

Correct Answer 1 mark

S id = E; { gen( top.get(id.leceme) '=' E.addr); } | L = E; { gen(L.array.base'l L.addr')' '=' E.addr); } E + E + E { E.addr = new Temp(); gen(E.addr'=' E .addr' +' E2.addr); } | id { E.addr = top.get(id.leceme); } IL { E.addr = new Temp(); gen(E.addr'=' Larray.base'l L.addr ']); } L + id [E] { L.array = top.get(id.leceme); L.type = L.array.type.elem; L.addr = new Temp 0); gen(L.addr'=' E.addr '*' L.type.width); } | L [E] {L.array = Lj.array L.type = Li.type.elem; t = new Temp 0); L.addr = new Temp 0); gent'=' E.addr'*' L.type width); gen(L.addr'=' L1.addr'+'t); } S id = E; { gen( top.get(id.leceme) '=' E.addr); } | L = E; { gen(L.array.base'l L.addr')' '=' E.addr); } E + E + E { E.addr = new Temp(); gen(E.addr'=' E .addr' +' E2.addr); } | id { E.addr = top.get(id.leceme); } IL { E.addr = new Temp(); gen(E.addr'=' Larray.base'l L.addr ']); } L + id [E] { L.array = top.get(id.leceme); L.type = L.array.type.elem; L.addr = new Temp 0); gen(L.addr'=' E.addr '*' L.type.width); } | L [E] {L.array = Lj.array L.type = Li.type.elem; t = new Temp 0); L.addr = new Temp 0); gent'=' E.addr'*' L.type width); gen(L.addr'=' L1.addr'+'t); }

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!