Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Question: Consider the following Semantic rules:
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
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