| stmt | → | if expr then stmt else stmt | 
| | | if expr then stmt | 
| stmt | → | if expr then stmt ifend | 
| ifend | → | else stmt | 
| | | ε | 
A → αΒ1|αΒ2 into A → αA' A' → Β1 | Β2
Input G, a grammar
- For each nonterminal A
- find the longest possible prefix α common to two or more of its alternatives
- if α ≠ ε
- replace all alternatives of the form A → αΒn with A → αA'
- Other productions (A → γ) remain.
- Add a rule A' → α Β1 | αΒ2 | ... | αΒn
- If A→ α was an alternative, add A' → ε
- GOTO step 2
| stmt | → | id (expr_list) | 
| expr_list | → | expr_list, expr | 
| | | expr |