GATE Computer ScienceModerateGATE CS (PYQ pattern)
For the grammar S → C C; C → c C | d (augmented with S′), the canonical LR(1) automaton is built and then the states with identical LR(0) cores are merged to get LALR(1). The LALR state whose only item is the complete item C → d · is the merge of how many canonical LR(1) states?
- A. 3
- B. 5
- C. 2
- D. 4
Correct answer: C. 2
There are 2 LR(1) states with this core (they differ only in their lookahead sets), and LALR merges them into one.
More Compiler Design questions
- Using the backpatching scheme (each relation gives 'if r goto ' then 'goto ', no fall-through optimisation, numbering from 100), the code…
- For the nested-loop code 1: s = 0; 2: i = 0; 3: L1: if i >= n goto L5; 4: j = 0; 5: L2: if j >= i goto L4; 6: s = s + j; 7: j = j + 1; 8…
- For the grammar E → T E'; E' → + T E' | ε; T → F T'; T' → F T' | ε; F → ( E ) | id, what is FOLLOW(T)?
- Which of the following about iterative data-flow analyses is/are true? I. Live-variable analysis is a backward problem whose meet operator…
- For the code 1: x = 0; 2: y = 1; 3: L1: if x > n goto L4; 4: if y > m goto L2; 5: y = y + x; 6: goto L3; 7: L2: x = x + 2; 8: L3: x = x +…
- For the grammar S → A B; A → a | ε; B → A b | c, what is FOLLOW(A)?