-1

Anyone would give me an processed example of LR(1) grammar which is not LR(0) Grammar? I was just trying to find out why LR(1) parser is more efficient and powerful, and tried an example of grammar and found it non LR(0) ,there was conflict in parsing table,then tried LR(1) also no use... A very simple example of grammar ,(augmented)

S->A
A->aBed | aEef
B->m
E->m

Needed details analysis. Anyone would explain with examples? Getting confused here.

RahulCoffee
  • 56
  • 11
  • 1
    Possible duplicate of [Examples of LL(1), LR(1), LR(0), LALR(1) grammars?](http://stackoverflow.com/questions/6480634/examples-of-ll1-lr1-lr0-lalr1-grammars) – Harald Jun 05 '16 at 08:22
  • This seems to belong to [CS.SE](http://cs.stackexchange.com/). – Zulan Jun 05 '16 at 08:22

1 Answers1

0

For example:

S -> Aa | Bb
A->c
B->c

In order to decide if a c is an A or a B, you need to know the following symbol.

In real life, you most commonly need LR(1) for epsilon productions:

OPTIONAL_A ->  ε | A

MULTI_A ->  ε | MULTI_A A

... where ε matches only the empty string. In order to reduce an epsilon production, you always need to see past it.

Matt Timmermans
  • 53,709
  • 3
  • 46
  • 87