GATE Computer ScienceEasyGATE CS (PYQ pattern)
For the grammar S → a A | A b; A → c | ε, what is FOLLOW(A)?
- A. {$, b}
- B. {b}
- C. {$}
- D. {$, a, b}
Correct answer: A. {$, b}
From S → a A, FOLLOW(A) gets FOLLOW(S) = {$}; from S → A b it gets b. So FOLLOW(A) = {b, $}.
More Compiler Design questions
- For S′ → S; S → A A A; A → a A | b, how many states of the canonical LR(1) automaton contain the complete item A → b · ?
- int f(int k) { if (k <= 0) return 0; return g(k - 1) + 1; } int g(int k) { if (k <= 1) return 1; return f(k - 2) + f(k - 1); } During the…
- After applying left factoring repeatedly (each time extracting the longest common prefix of alternatives that share a first symbol…
- A DAG is built for r = (p − q) (p − q) + (q − p) (p − q) − (p − q), with commutative and − not commutative. How many interior (operator)…
- 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)…
- Using the backpatching scheme (each relation gives 'if r goto ' then 'goto ', no fall-through optimisation, numbering from 100), the code…