Ciências da computação dia 228

Linguagens formais --- Análise sintática ascendente

Análise sintática ascendente (shift-reduce)

S -> [L] | a
L -> L;S | S

entrada = [a;a]

|  Pilha |  Entrada |  Ação   |
|--------|----------|---------|
| $      | [a;a]$   | shift [ |
| $[     | a;a]$    | shift a |
| $[a    | ;a]$     | reduce a to S |
| $[S    | ;a]$     | reduce S to L |
| $[L    | ;a]$     | shift ; |
| $[L;   | a]$      | shift a |
| $[L;a  | ]$       | reduce a to S |
| $[L;S  | ]$       | reduce L;S to S |
| $[L    | ]$       | shift ] |
| $[L]   | $        | reduce [L] to S |
| $S     | $        | reduce S to L |
| $L     | $        | ACCEPT |