GATE Computer ScienceVery hardGATE CS (PYQ pattern)
For 1: a = 0; 2: if p > 0 goto L2; 3: L1: a = a + 1; 4: if a < m goto L1; 5: goto L3; 6: L2: b = 1; 7: if q > 0 goto L1; 8: L3: return a, consider the block B that starts at L1 (statements 3–4). What is its dominance frontier DF(B)?
- A. {the L3 block}
- B. {the L1 block}
- C. {the L1 block, the L3 block}
- D. {the L2 block, the L3 block}
Correct answer: C. {the L1 block, the L3 block}
L1 is entered from the entry block and from L2, so its idom is the entry block. B has a self-loop (4 → L1): B is a predecessor of B and does not strictly dominate it, so B ∈ DF(B). B also reaches L3 through {5}, and L3 is entered from L2 too, so B does not dominate L3: L3 ∈ DF(B). {5} is dominated by B, so it is not in the frontier.
More Compiler Design questions
- For E → id | E [ E ] | ( E ) (augmented with S′ → E), how many more states does the canonical LR(1) automaton have than the LALR(1)…
- For the grammar E → E + T | T; T → T F | F; F → ( E ) | id, the LALR(1) parser is obtained by merging LR(1) states with identical cores…
- How many distinct LR(0) items does the grammar S → X Y Z; X → a X | ε; Y → b Y | X; Z → c | ε have (do not augment it; an ε-production…
- Which of the following is/are true? I. Every S-attributed definition is L-attributed. II. Every L-attributed definition can be evaluated…
- For S → S ( S ) | ε (augmented), count the reduce entries ( column included, accept excluded) in the SLR(1) and in the LALR(1) ACTION…
- A table-driven LL(1) parser for S → ( S ) S | ε parses "( ) ( )". Each pop of a non-terminal (expanding it) and each match of a terminal…