Answered step by step
Verified Expert Solution
Link Copied!

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:

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Apache Cassandra Development

Authors: Vivek Mishra

1st Edition

1484201426, 9781484201428

More Books

Students also viewed these Databases questions

Question

2. Place a value on the outcomes.

Answered: 1 week ago

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago