GATE Computer ScienceModerateGATE CS (PYQ pattern)
In the LL(1) table of S → A B C; A → a | ε; B → b | ε; C → c | ε, how many cells hold an ε-production, and how many cells of the $ column are filled?
- A. 6 ε-cells; 1 cell in the $ column
- B. 3 ε-cells; 4 cells in the $ column
- C. 6 ε-cells; 4 cells in the $ column
- D. 7 ε-cells; 3 cells in the $ column
Correct answer: C. 6 ε-cells; 4 cells in the $ column
FOLLOW(A) = {b, c, $}, FOLLOW(B) = {c, $}, FOLLOW(C) = {$}. A → ε fills 3 cells, B → ε 2, C → ε 1: 6. In the $ column, S → A B C (S is nullable and $ ∈ FOLLOW(S)) and all three ε-productions appear: 4 cells.
More Compiler Design questions
- Consider the grammar G with productions S → A B C; A → a | ε; B → b | ε; C → c | ε. Which of the following statements is/are true? I. G is…
- int x = 1; int g() { x = x + 1; return x; } int f(int n) { int x = n; if (n == 0) return g(); int r = f(n − 1); return r + g(); } What…
- The standard algorithm removes all left recursion from S → A a | b; A → A c | S d | e, taking the non-terminals in the order S, A…
- int i = 1; int A[0..2] = {5, 6, 7}; void f(x, y) { x = x + 1; y = 10; } The call f(i, A[i]) uses copy-in/copy-out (value-result), copying…
- For G: S → x S y | x y | S S, which statements are true? I. G is ambiguous. II. The canonical LR(1) table has more multiply-defined cells…
- A lexer uses longest match, breaking ties in favour of the rule listed first, with rules: KW = if | then; ID = [a-z][a-z0-9]; NUM =…