GATE Computer ScienceHardGATE CS (PYQ pattern)
In S → A B; A → a | ε; B → A b | c, FOLLOW(A) does not contain $. Which of these productions, each added to the grammar on its own, put $ into FOLLOW(A)? I. B → ε. II. B → b A. III. A → b A. IV. B → A B.
- A. I and II only
- B. I only
- C. I, II and IV only
- D. II and III only
Correct answer: A. I and II only
$ ∈ FOLLOW(S) = FOLLOW(B). I: B nullable makes A end S → A B. II: A ends B, so FOLLOW(B) ⊆ FOLLOW(A). III only adds FOLLOW(A) to itself. IV: A is followed by B, which is still not nullable, so only FIRST(B) is added.
More Compiler Design questions
- For S → X Y Z; X → a X | ε; Y → b Y | X; Z → c | ε (augmented), in how many states is there a conflict in the SLR(1) table, and in how…
- In 1: i = 0; 2: c = 2; 3: L1: if i >= n goto L3; 4: d = c 3; 5: if i > k goto L2; 6: c = 2; 7: L2: e = d + 1; 8: f = a b; 9: i = i + 1…
- L1 is the set of strings over {a, b} whose third symbol from the right is a; its minimal DFA has 8 states. L2 = L1 ∩ {strings of even…
- For the augmented grammar S′ → S; S → ( L ) | x; L → S | L , S, how many states does the canonical LR(1) automaton have, and in how many…
- G: S → T | S ; T; T → a | ( S ). Removing the left recursion gives G′: S → T R; R → ; T R | ε; T → a | ( S ). Which statements are true?…
- The grammar A → B a | A a | c; B → B b | A b | d is transformed by the standard algorithm that removes (indirect and immediate) left…