GATE Computer ScienceVery hardGATE CS (PYQ pattern)
Construct the LL(1) table of S → A B c | B d; A → a A | ε; B → b B | A. Which option lists exactly the multiply-defined cells?
- A. M[S, a] and M[S, b] only
- B. M[S, a], M[S, b] and M[A, a]
- C. M[S, a], M[A, a] and M[B, a]
- D. M[S, a], M[S, b], M[A, a] and M[B, a]
Correct answer: B. M[S, a], M[S, b] and M[A, a]
A and B are nullable. FIRST(A B c) = {a, b, c}, FIRST(B d) = {a, b, d}: clash on a and b. FOLLOW(B) = {c, d}, and B → A makes FOLLOW(A) ⊇ FOLLOW(B); S → A B c adds FIRST(B c) = {a, b, c}, so FOLLOW(A) = {a, b, c, d}. Hence A → ε also lands in M[A, a] beside A → a A. M[B, a] holds only B → A (B → b B is under b), so it is not a conflict.
More Compiler Design questions
- An ε-NFA over {a, b} has states 0–4, start state 0 and accepting state 3, with moves δ(0, a) = {1}, δ(1, b) = {2}, δ(2, a) = {0, 3}, δ(3…
- For the code 1: i = 0; 2: s = 0; 3: L1: if i >= n goto L4; 4: t = a + i; 5: if t > m goto L2; 6: s = s + t; 7: goto L3; 8: L2: a = a - 1…
- An LR parser for S → ( L ) | x; L → S | L , S parses "( ( x , x ) , x , ( x ) )". How many reductions does it perform (accept not…
- Sethi–Ullman labelling: a leaf is 1 as a left child and 0 as a right child (a right operand may be a memory operand); an interior node is…
- Build the LL(1) table for E → T R; R → + T R | − T R | ε; T → F P; P → ^ T | ε; F → ( E ) | id (^ is right-associative exponent). How many…
- An LR parser for E → id | E [ E ] | ( E ) parses "id [ ( id [ id ] ) ]". What is the largest number of grammar symbols on its stack at any…