E → E + T | T T → T * F | F F → (E) | id Parse id1 * id2
Right Sentential Form | Handle | Input | Production | Action |
---|---|---|---|---|
$ | id1 * id2 $ | Shift | ||
$id1 | id1 | * id2 $ | F → id | Reduce |
$F | F | * id2 $ | T → F | Reduce |
$T | * id2$ | Shift | ||
$T * | id2$ | Shift | ||
$T * id2 | id2 | $ | F → id | Reduce |
$T * F | T * F | $ | T → T * F | Reduce |
$T | T | $ | E → T | Reduce |
$E | $ | Accept |
STACK INPUT $αβγ yz$ Reduce B → γ $αβB yz$ Shift $αβBy z$ Reduce A → βBy $αA z$
STACK INPUT $αγ xyz$ Reduce B → γ $αB xyz$ Shift $αBx yz$ Shift $αBxy z$ Reduce A → y $αBxA z$
stmt → if expr then stmt | if expr then stmt else stmt | other STACK INPUT $α if expr then stmt else...$
stmt → id ( parameter_list) | expr := expr parameter_list → parameter_list, parameter | parameter parameter → id expr → id (expr_list) | id expr_list → expr_list, expr | expr