GATE Computer ScienceVery hardGATE CS (PYQ pattern)
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? I. G is LR(0). II. G′ is LL(1). III. G′ is LR(0).
- A. II only
- B. I, II and III
- C. I and II only
- D. II and III only
Correct answer: C. I and II only
I: every complete item of G (T → a·, T → (S)·, S → T·, S → S;T·) is alone in its state, and the accept item S′ → S· shares its state only with the shift of ; (accept acts on $ alone): G is LR(0). II: R → ; T R and R → ε are told apart by ; versus FOLLOW(R) = {$, )}. III: the state after T in G′ contains R → · together with R → ·; T R, a shift-reduce clash without lookahead.
More Compiler Design questions
- The grammar A → B a | A a | c; B → B b | A b | d is transformed by the standard algorithm that removes (indirect and immediate) left…
- SDD: D → T L { L.inh = T.type }; T → int { T.type = integer }; L → L1 , id { L1.inh = L.inh; addType(id.entry, L.inh) }; L → id {…
- Which of the following are true? I. Every LL(1) grammar is LR(1). II. Every LL(1) grammar is LALR(1). III. Every LALR(1) grammar is LR(1)…
- Available-expressions analysis (expressions compared textually, so a b and b a differ; assigning an operand kills an expression) is run on…
- Nested procedures: main (depth 1) contains A (depth 2); A contains B (depth 3); B contains C (depth 4). C also calls itself recursively…
- void p(int x, int y) { x = x + 1; y = y + x; } is called as p(a, a) with a = 2. What is a after the call when the parameters are passed by…