GATE Computer ScienceVery hardGATE CS (PYQ pattern)
Backpatching scheme (each relation gives 'if r goto _' and 'goto _', no fall-through optimisation, instruction numbers from 100). How many instructions are generated for: while (a < b || c < d) while (e < f && g < h) x = x + 1; ?
- A. 10
- B. 12
- C. 8
- D. 11
Correct answer: D. 11
Outer test: 4 jumps; inner test: 4 jumps; assignment 1; inner loop's closing goto 1; outer loop's closing goto 1: 11.
More Compiler Design questions
- A basic block compiles to six three-address statements: t1 = a + b; t2 = c d; t3 = a + b; t4 = t1 t2; t5 = t3 − t4; x = t5. Value…
- After applying left factoring repeatedly (each time extracting the longest common prefix of alternatives that share a first symbol…
- Consider the grammar S → A B c, A → a A | ε, B → b B | A d | ε. How many terminals are in FOLLOW(A), and is the grammar LL(1)?
- For the grammar S → A B, A → a A | a, B → b, the augmented canonical LR(0) collection has how many states, and what is the strongest class…
- In the expression a = (b + c) (b + c) - d / (b + c), the numbers of operator (internal) nodes in the syntax tree for the right-hand side…
- A C lexer applies the longest-match (maximal munch) rule. The number of tokens in the statement x = a---bc++; is: