|
@@ -2703,17 +2703,21 @@ arithmetic. For example, your partial evaluator should translate
|
|
|
To accomplish this, the \code{pe-exp} function should produce output
|
|
|
in the form of the $\itm{residual}$ non-terminal of the following
|
|
|
grammar. The idea is that when processing an addition expression, we
|
|
|
-can always produce either 1) an integer constant, 2) and addition
|
|
|
+can always produce either 1) an integer constant, 2) an addition
|
|
|
expression with an integer constant on the left-hand side but not the
|
|
|
right-hand side, or 3) or an addition expression in which neither
|
|
|
subexpression is a constant.
|
|
|
\[
|
|
|
\begin{array}{lcl}
|
|
|
-\itm{inert} &::=& \Var \mid \LP\key{read}\RP \mid \LP\key{-} \;\Var\RP
|
|
|
+ \itm{inert} &::=& \Var
|
|
|
+ \mid \LP\key{read}\RP
|
|
|
+ \mid \LP\key{-} \;\Var\RP
|
|
|
\mid \LP\key{-} \;\LP\key{read}\RP\RP
|
|
|
\mid \LP\key{+} \; \itm{inert} \; \itm{inert}\RP\\
|
|
|
- &\mid& \LP\key{let}~\LP\LS\Var~\itm{inert}\RS\RP~ \itm{residual} \RP \\
|
|
|
-\itm{residual} &::=& \Int \mid \LP\key{+}\; \Int\; \itm{inert}\RP \mid \itm{inert}
|
|
|
+ &\mid& \LP\key{let}~\LP\LS\Var~\itm{residual}\RS\RP~ \itm{residual} \RP \\
|
|
|
+ \itm{residual} &::=& \Int
|
|
|
+ \mid \LP\key{+}\; \Int\; \itm{inert}\RP
|
|
|
+ \mid \itm{inert}
|
|
|
\end{array}
|
|
|
\]
|
|
|
The \code{pe-add} and \code{pe-neg} functions may assume that their
|