GATE Computer ScienceHardGATE CS (PYQ pattern)
For S → A B | B C; A → a A | ε; B → b B | ε; C → c C | d, which statement is FALSE?
- A. FOLLOW(B) = {c, d, $}
- B. M[S, b] holds both S-productions
- C. FIRST(S) = {a, b, c, d, ε}
- D. M[S, $] holds both S-productions
Correct answer: D. M[S, $] holds both S-productions
A and B are nullable, C is not; M[C, c] and M[C, d] each hold one production. FIRST(A B) = {a, b, ε} and FIRST(B C) = {b, c, d}, so FIRST(S) = {a, b, c, d, ε} and both S-productions meet in M[S, b]. FOLLOW(B) = FOLLOW(S) ∪ FIRST(C) = {$, c, d}. But only S → A B is nullable, so M[S, $] holds just S → A B: that statement is false.
More Compiler Design questions
- 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…
- 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?…