LL(1) Grammar
L = Left-to-right scan
R = Right-to-left parse
CFG to LL(1)
Requirements for LL(1) Grammar
- Remove any ambiguity.
- Eliminate any left recursion.
- Eliminate any common left prefixes.
Eliminating Left Recursion
Convert:
into:
- Observe that must start with .
- Make followed by another non-terminal. (make it right-recursive)
- The other non-terminal may start with , or may be .
Eliminating Common Left Prefixes
Convert:
into:
- Notice all the possibilities of starts with .
- Make .
- Make possibilities that follow .