GATE Computer ScienceVery hardGATE CS (PYQ pattern)
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 LL(1). II. G is LR(0). III. G is SLR(1). IV. G is CLR(1) (canonical LR(1)).
- A. III and IV only
- B. I, II, III and IV
- C. I and IV only
- D. I, III and IV only
Correct answer: D. I, III and IV only
Computed from the automata: LL(1) yes, LR(0) no, SLR(1) yes, CLR(1) (canonical LR(1)) yes.
More Compiler Design questions
- 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 =…
- G: S → id | id [ E ] | id ( E ); E → id. G′ is obtained from G by left factoring S. Which statements are true? I. G is LL(1). II. G′ is…