Therefore,
E T R
R + T {print (+)} R
R - T {print (-)} R
R ε
T num {print(num.val)}
transforms to
E T R
R + T M R
R - T N R
R ε
T num |
{print(num.val)}
|
M ε |
{print(+)}
|
N ε |
{print(-)}
|
Actions in the transformed scheme terminate productions, so they can be performed just before the right side is reduced during bottom-up parsing.
|