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

📅  最后修改于: 2021-09-25 06:47:17             🧑  作者: 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 

这个问题的测验