Reputation: 69
I know that every LL(1) is also an LR(1). But what about the relationship between LL(1) and LR(0), can a LL(1) be a LR(0) as well?
Upvotes: 5
Views: 3288
Reputation: 241671
You ask two questions, one in the title and the other in the body of the post. Neither specify whether you are asking about languages or grammars, but the basic answers are the same:
Are all LL(1) languages LR(0)?
No. A language which contains both a string and a proper prefix of that string cannot be LR(0). But many LL(1) languages have that form.
Are some LL(1) languages LR(0)?
Sure.
(The unasked question) Are any LR(0) languages not LL(1).
Yes. For example, the language {ambnc | m≥n≥0}
is LR(0), but it has no LL(1) grammar.
Upvotes: 8