InterviewSolution
Saved Bookmarks
| 1. |
Consider the grammar rule. E -> E1 − E2 for arithmetic expressions. If E1 and E2 do not have any common sub expression, in order to get the shortest possible code.(a) E1 should be evaluated first(b) E2 should be evaluated first(c) Evaluation of E1 and E2 should necessarily be interleaved(d) Order of evaluation of E1 and E2 is of no consequenceI have been asked this question in an online interview.My question is from L-Attributed Definition topic in portion Syntax Directed Definition and Translations of Compiler |
|
Answer» CORRECT option is (b) E2 should be evaluated first The explanation: E1 is to be KEPT in accumulator & accumulator is REQUIRED for OPERATIONS to EVALUATE E2. |
|