Consider the grammar G: S → A | B, A → a | c, B → b | c, with non-terminals {S, A, B} and terminals {a, b, c}. S₁: LR(1) can parse all strings generated by G. S₂: LL(1) can parse all strings generated by G.
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: D. Neither 1 nor 2 S → (S)|SS|ε
Explanation
The string c has two derivations (S ⇒ A ⇒ c and S ⇒ B ⇒ c), so G is ambiguous. No ambiguous grammar is LL(1) or LR(1).
More Theory of Computation and Compilers questions
- The grammar S → (S) | SS | ε is not suitable for predictive parsing because the grammar is
- Two finite state machines are said to be equivalent if they :
- The finite state machine given in figure below recognizes :
- A pushdown automata behaves like a Turing machine when the number of auxiliary memory is :
- Pushdown automata can recognize language generated by_________.
- To obtain a string of n Terminals from a given Chomsky normal form grammar, the number of productions to be used is :