There are two important theorems about LR(k) grammars and DCFL. Mentioned here.
- A language has an LR(1) grammar iff it is DCFL.
- A language has an LR(0) grammar iff it is DCFL and has prefix property.
I have counter example for 2nd theorem, plz see if it is valid counterexample. (Ofcourse its not valid and I am wrong, But what wrong I am doing here ?)
DCFL without prefix property: $\{b(ab)^n \mid n\geq0\}$
2nd theorem says it should not have $LR(0)$ grammar, but here it is-
$ S \rightarrow Sab \\S \rightarrow b$
PS: This is my first question here, sorry if I violated any protocol.
@ArjunSuresh sir, I got ur point, U mean when we add "$" as end marker to the grammar then this ensures prefix property, right ? But doing so. it will change the language itself.
– user3699192 Feb 01 '17 at 07:09