4

How do you eliminate a left recursion of the following type. I can't seem to be able to apply the general rule on this particular one.

A -> A | a | b

By using the elimination rule you get:

A  -> aA' | bA'
A' -> A'  | epsilon

Which still has left recursion.

Does this say anything about the grammar being/not being LL(1)?

Thank you.

templatetypedef
  • 362,284
  • 104
  • 897
  • 1,065
Airwavezx
  • 323
  • 1
  • 9

1 Answers1

2

Notice that the rule

A → A

is, in a sense, entirely useless. It doesn't do anything to a derivation to apply this rule. As a result, we can safely remove it from the grammar without changing what the grammar produces. This leaves

A → a | b

which is LL(1).

templatetypedef
  • 362,284
  • 104
  • 897
  • 1,065