LL(1) Grammar

L = Left-to-right scan

R = Right-to-left parse

CFG to LL(1)

Requirements for LL(1) Grammar

  1. Remove any ambiguity.
  2. Eliminate any left recursion.
  3. Eliminate any common left prefixes.

Eliminating Left Recursion

Convert:

into:

  1. Observe that must start with .
  2. Make followed by another non-terminal. (make it right-recursive)
  3. The other non-terminal may start with , or may be .

Eliminating Common Left Prefixes

Convert:

into:

  1. Notice all the possibilities of starts with .
  2. Make .
  3. Make possibilities that follow .