| E | → | E + E |
| | | E * E | |
| | | ( E ) | |
| | | id |
| E | → | E+T |
| | | T | |
| T | → | T*F |
| | | F | |
| F | → | ( E) |
| | | id |
| S | → | aSbS |
| | | bSaS | |
| | | ε |
| stmt | → | if expr then stmt |
| | | if expr then stmt else stmt | |
| | | other |
if E1 then if E1 then
if E2 then if E2 then
S1 S1
else else
S2 S2
| stmt | → | matched_stmt |
| | | open_stmt | |
| matched_stmt | → | if expr then matched_stmt else unmatched_stmt |
| | | other | |
| open_stmt | → | if expr then stmt |
| | | if expr then matched_stmt else open_stmt |
| S | → | aS |
| | | SB | |
| | | d | |
| B | → | Bb |
| | | c |