Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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:
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started