📜  门| GATE-CS-2007 |第85章

📅  最后修改于: 2021-06-28 21:44:10             🧑  作者: Mango

请考虑以下两个语句:

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

以下内容哪些是对的?
(A) P和Q均为真
(B) P为真Q为假
(C) P为假而Q为真
(D) P和Q均为假答案: (C)
解释:

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 

这个问题的测验