语法→ aSa | bS | c是 (A) LL(1)而非LR(1) (B) LR(1)但不是LR(1) (C) LL(1)和LR(1) (D) 既不是LL(1)也不是LR(1) 答复: (C) 说明:
null
First(aSa) = a First(bS) = b First(c) = c All are mutually disjoint i.e no common terminal between them, the given grammar is LL(1). As the grammar is LL(1) so it will also be LR(1) as LR parsers are more powerful then LL(1) parsers. and all LL(1) grammar are also LR(1) So option C is correct.
以下是更多细节。
如果可以通过只查看输入字符串中的下一个标记来选择下一个产品,则语法为LL(1)。
Formally, grammar G is LL(1) if and only if For all productions A → α1 | α2 | ... | αn, First(αi) ∩ First(αj) = ∅, 1 ≤ i,j ≤ n, i ≠ j. For every non-terminal A such that First(A) contains ε, First(A) ∩ Follow(A) = ∅
资料来源: https://s3-ap-southeast-1.amazonaws.com/erbuc/files/4147_870334aa-9922-4f78-9c2c-713e7a7f0d53.pdf
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END