3

Trying to figure out removing left recursion in context free grammars. I'm used to certain forms, but this one has me a bit boggled.

S --> S {S} S | (A) | a
A --> {S} A | epsilon

I also have to design a decent parser, which I can do. However, figuring out this left recursion (especially on the first one) has me confused.

Josh Lee
  • 171,072
  • 38
  • 269
  • 275
Mercfh
  • 31
  • 1
  • 2

2 Answers2

0

There is an interesting Wikipedia article on left-recursion. It also has a section about removing left-recursion for non-context grammars.

http://en.wikipedia.org/wiki/Left_recursion

Alexander Rafferty
  • 6,134
  • 4
  • 33
  • 55
0

Try this:

S --> a [ { S } S ]
    | ( [ A ] ) [ {S} S ]


A --> { S } [ A ]
Scott Wisniewski
  • 24,561
  • 8
  • 60
  • 89