QUESTION 3 Consider the following attributed translation grammar for Decaf expression and the table for comparison codes

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

QUESTION 3 Consider the following attributed translation grammar for Decaf expression and the table for comparison codes

Post by answerhappygod »

Question 3 Consider The Following Attributed Translation Grammar For Decaf Expression And The Table For Comparison Codes 1
Question 3 Consider The Following Attributed Translation Grammar For Decaf Expression And The Table For Comparison Codes 1 (115.35 KiB) Viewed 36 times
QUESTION 3 Consider the following attributed translation grammar for Decaf expression and the table for comparison codes: Stmt AssignStmt WhileStmt IfStmt ElsePart BoolExpribll Exprp AssignExprp Rvalue, Elistp.q Termp Tlistp,q Factorp Factorp Factorp Factorp Comparison VA ↑↑ VAL AssignStmt | WhileStmt | IfStmt | CompoundStmt | ; AssignExpr, ; while (LBL) bll (BoolExprb12) Stmt (JMP) Lb11 (LBL) Lb12 if (BoolExprib11) Stmt {JMP } Lb12 {LBL} Lb11 Else Part (LBL) Lb12 else Stmt | e Expr, compare. Expr (TST)p.q.7-e, Lb11 AssignExprp | identifier, Term, Elistą, p + Term (ADD) p,r,s Elists,q I Term (SUB) p,r,s Elists, q Factor, Tlistą, p * Factor: {MUL}p,r,s Tlists, q Factor. (DIV)p,r,s Tlists,q | ε (Exprp ) Factor, (Neg)q..p nump identifier, Code (the c value in the grammar) 1 ашашин 2 Rvalue, Expra {MOV}q..p 3 4 5 Logical Complement != >= Lb11 newlab () Lb12 newlab () Lb11 newlab () s ← alloc() salloc() q p salloc() s ← alloc() q ← p palloc() Code for Complement 6 INW550 4 3 2 1 a) Construct an attributed derivation tree for the following Decaf control statement: f * 12 - 5 <= 14 (10 Marks)
b) Convert the following segment of Decaf program into a sequence of atoms: while ( f <= 14 ) { } f = f + n; (5 Marks)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply