GATE Computer ScienceModerateNIELIT Scientist B
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: goto 3; 9: print s. Into how many basic blocks is it partitioned?
- A. 5
- B. 7
- C. 6
- D. 4
Correct answer: C. 6
The leaders are statements 1, 3, 4, 6, 7 and 9 (first statement, jump targets, and statements after jumps), giving 6 blocks.
More Compiler Design questions
- 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?
- For E → T E′; E′ → + T E′ | ε; T → F T′; T′ → F T′ | ε; F → ( E ) | id, what is the sum of the sizes of the FOLLOW sets of E, E′, T, T′…
- How many LR(0) items does the grammar S → a S b | S S | ε | c d have (the ε-production contributes one item; do not count the augmented…