Simple precedence parser: Difference between revisions

Content deleted Content added
top: No footnotes
Example: replace <pre> with table
Line 44:
 
{| class="wikitable"
! | ||E|| E' || T || T' || F || + ||*||(||)||num || $
|-
! E
Line 80:
|}
 
{{aligned table|cols=4|row1header=Y|class=wikitable|style=font-family:monospace
<pre>
| STACK | PRECEDENCE | INPUT | ACTION
 
| $ | | 2 * ( 1 + 3 )$ | SHIFT
| $ ⋖ 2 | | * ( 1 + 3 )$ | REDUCE (F -> num)
| $ ⋖ F | | * ( 1 + 3 )$ | REDUCE (T -> F)
| $ ⋖ T | | * ( 1 + 3 )$ | SHIFT
| $ ⋖ T ≐ * | | ( 1 + 3 )$ | SHIFT
| $ ⋖ T ≐ * ⋖ ( | | 1 + 3 )$ | SHIFT
| $ ⋖ T ≐ * ⋖ ( ⋖ 1 | | + 3 )$ | REDUCE 4× (F -> num) (T -> F) (T' -> T) (E ->T ')
| $ ⋖ T ≐ * ⋖ ( ⋖ E | | + 3 )$ | SHIFT
| $ ⋖ T ≐ * ⋖ ( ⋖ E ≐ + | | 3 )$ | SHIFT
| $ ⋖ T ≐ * ⋖ ( ⋖ E ≐ + < 3 | | )$ | REDUCE 3× (F -> num) (T -> F) (T' -> T)
| $ ⋖ T ≐ * ⋖ ( ⋖ E ≐ + ≐ T | | )$ | REDUCE 2× (E -> E + T) (E' -> E)
| $ ⋖ T ≐ * ⋖ ( ≐ E' | | )$ | SHIFT
| $ ⋖ T ≐ * ⋖ ( ≐ E' ≐ ) | | $ | REDUCE (F -> ( E' ))
| $ ⋖ T ≐ * ≐ F | | $ | REDUCE (T -> T * F)
| $ ⋖ T | | $ | REDUCE 2× (T' -> T) (E -> T')
| $ ⋖ E | | $ | ACCEPT
}}
</pre>
 
==References==