Question

I'm trying to prove that LL(3) is not a subset of LR(2).

Intuitively it's easy, but I can't point my intuition into finding such a grammar.

Could you please give me a hand? Thanks for any help

Was it helpful?

Solution

Theorem: If a grammar is LL(3) but not LR(2), then the grammar has ε-productions.

Proof: A grammar is LL(3) if it always is possible to identify the handle in a right sentential form after reading three characters past the beginning of the handle.

A grammar is LR(2) if it always is possible to identify the handle in a right sentential form after reading two characters past the end of the handle.

If a grammar is LL(3) but not LR(2), then reading three characters past the beginning of the handle must sometimes provide more information than reading two characters past the end of the handle. That can only happen if the handle is empty.

OTHER TIPS

Well, apparently the trick is to use ε-productions.

The following grammar would work:

S->aa|Aaaa

A->ε
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top