Page 1 of 1

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

Posted: Fri Jul 08, 2022 6:17 am
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 37 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)