GATE | GATE-CS-2007 | Question 85

Consider the following two statements:

P: Every regular grammar is LL(1)
Q: Every regular set has a LR(1) grammar

Which of the following is TRUE?
(A) Both P and Q are true
(B) P is true and Q is false
(C) P is false and Q is true
(D) Both P and Q are false


Answer: (C)

Explanation:

A regular grammar can also be ambiguous also
For example, consider the following grammar,                             
S → aA/a
A → aA/ε
In above grammar, string 'a' has two leftmost
derivations. 
(1)   S → aA                      (2)   S → a
      S->a (using A->ε)
And LL(1) parses only unambiguous grammar,
so statement P is False.
Statement Q is true is for every regular set, we can have a regular
grammar which is unambiguous so it can be parse by LR parser. 

So option C is correct choice 


Quiz of this Question



My Personal Notes arrow_drop_up


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.