Introduction


Try to perform the elimination of left recursion, the input grammar should have no cycles or ϵ-productions.

Supported grammars

  • A -> A c | A a d | b d | ϵ
    (All tokens must be separated by space characters)
  • A -> A c
       | A a d
       | b d
       | ϵ
  • S -> A a | b
    A -> A c | S d | ϵ
  • (Copy ϵ to input if needed)

Examples

  • S -> S S + | S S * | a
  • S -> 0 S 1 | 0 1
  • S -> + S S | * S S | a
  • S -> S ( S ) S | ϵ
  • S -> S + S | S S | ( S ) | S * | a
  • S -> ( L ) | a L -> L , S | S
  • S -> a S b S | b S a S | ϵ
  • bexpr -> bexpr or bterm | bterm
    bterm -> bterm and bfactor | bfactor
    bfactor -> not bfactor | ( bexpr ) | true | false