GATE Computer ScienceModerateGATE CSE
Three-address code (at most one operator per instruction, the last instruction assigning to x) is generated for x = a*b + c*(d − e) − f/g. How many instructions are generated?
- A. 6
- B. 5
- C. 7
- D. 4
Correct answer: A. 6
The expression has six operators (*, −, *, +, /, −), and each gets one instruction, with the last storing directly into x.
More Compiler Design questions
- With ^ right-associative and higher than which is higher than + and − (both left-associative), what is the postfix form of a − b c ^ d ^ e…
- Consider this three-address code: 1: i = 0; 2: s = 0; 3: if i >= n goto 9; 4: t = a[i]; 5: if t < 0 goto 7; 6: s = s + t; 7: i = i + 1; 8…
- Using E → E + T | T; T → T F | F; F → id, how many reductions does a bottom-up parser perform for the input id + id id?
- In the grammar S → A B c | d; A → B B | a; B → b | ε; C → A C | ε, how many non-terminals are nullable?
- For the grammar S → A B; A → a A | b | ε; B → a B | b A | ε, how many cells of the LL(1) parsing table contain more than one production?
- For S → L = R | R; L → R | id; R → L, how many states of the LR(0) automaton contain a conflict that SLR(1) fails to resolve?