GATE Computer ScienceVery hardGATE CSE
Three-address code: 1: x = 0; 2: if a > b goto 8; 3: x = x + 1; 4: if x > 5 goto 7; 5: y = y * 2; 6: goto 2; 7: y = y + 1; 8: if y < 100 goto 2; 9: print y; 10: halt. The program is partitioned into basic blocks and a control-flow graph is built (an edge is added for each jump target and for each fall-through; duplicate edges are counted once; the entry and exit pseudo-nodes are ignored). How many edges does the CFG have?
- A. 9
- B. 8
- C. 10
- D. 11
Correct answer: A. 9
Blocks start at instructions 1, 2, 3, 5, 7, 8, 9; counting conditional (two successors), unconditional and fall-through edges gives 9.
More Compiler Design questions
- Grammar: S → L = R | R; L → R | id; R → L, augmented with S' → S. How many distinct LR(1) items (production, dot position, lookahead) does…
- Grammar: S → a S b | S S | ε. How many distinct strings of length exactly 10 belong to the language it generates?
- Backpatching with no fall-through optimisation, numbering from 100, translates while (a < b && c < d || e < f) { if (x < y) p = 1; else q…
- For the augmented grammar S′ → S; S → a S a | b S b | c, how many states does the canonical LR(1) automaton have, and how many does the…
- For the grammar G: S → A b | B c; A → a A | ε; B → a B | ε, the LL(1) predictive table is built. Which statement is correct?
- For G: S → a A | b B; A → c A d | ε; B → c B d d | ε, which statements are true? I. G is LL(1). II. G is LR(0). III. The canonical LR(1)…