Question
QUESTION 4: A: Consider syntax of Switch-Case statement of JAVA programming language and create an equivalent L-attributed SDD for chosen grammar. B: Consider an unambiguous
QUESTION 4: A: Consider syntax of Switch-Case statement of JAVA programming language and create an equivalent L-attributed SDD for chosen grammar. B: Consider an unambiguous expression grammar that accepts parenthesis, +, , , and unary minus (-) operators; Create SDD that generates directed acyclic graph (DAG) or syntax tree. C: Consider the grammar in PART (B) and rewrite SDD to generate Three-Address Code that accepts the following input string: x = a + b c ( d e ) D: 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 ]
YOU HAVE TO SOLVE ONLY PAR D
YOU HAVE TO SOLVE ONLY PAR D
YOU HAVE TO SOLVE ONLY PAR D
I WILL UPVOTE IF THE ANSWER IS CORRECT
D: Consider the following Semantic rules: S + id = E; {gen( top.get(id.lexeme) '=' E.addr); } | L=E; { gen(L.array.base 'l' L.addr '''=' E.addr); } E + E + E { E.addr = new Temp(); gen(E.addr'=' El addr'+ Ey addr); } id { E.addr = top.get(id.lereme); } IL { E.addr = new Temp(); gen(E.addr '=' Larray.base 'l Laddr '1'); } + id [E] {L.array = top.get(id. lexemne); L.type = L.array.type.elem; L.addr = new Temp(); gen(L.addr'=' E.addr'*' L.type. width); } | L[E] {L.array = L aray; L.type = Lj.type.elem; t = new Temp 0); L.addr = = new Temp(); gen(t'= E.addr 's' L.type.width); gen(L.addr'=' Laddr'+'t); } - . . : . D: Consider the following Semantic rules: S + id = E; {gen( top.get(id.lexeme) '=' E.addr); } | L=E; { gen(L.array.base 'l' L.addr '''=' E.addr); } E + E + E { E.addr = new Temp(); gen(E.addr'=' El addr'+ Ey addr); } id { E.addr = top.get(id.lereme); } IL { E.addr = new Temp(); gen(E.addr '=' Larray.base 'l Laddr '1'); } + id [E] {L.array = top.get(id. lexemne); L.type = L.array.type.elem; L.addr = new Temp(); gen(L.addr'=' E.addr'*' L.type. width); } | L[E] {L.array = L aray; L.type = Lj.type.elem; t = new Temp 0); L.addr = = new Temp(); gen(t'= E.addr 's' L.type.width); gen(L.addr'=' Laddr'+'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