|
@@ -679,15 +679,15 @@ our compiler will translate it into the program
|
|
|
\end{lstlisting}
|
|
|
|
|
|
Figure~\ref{fig:pe-arith} gives the code for a simple partial
|
|
|
-evaluator for the $R_0$ language. The output of the partial
|
|
|
-evaluator is an $R_0$ program, which we build up using a
|
|
|
-combination of quasiquotes and commas. (Though no quasiquote is
|
|
|
-necessary for integers.) In Figure~\ref{fig:pe-arith}, the normal
|
|
|
-structural recursion is captured in the main \texttt{pe-arith}
|
|
|
-function whereas the code for partially evaluating negation and
|
|
|
-addition is factored out the into two separate helper functions:
|
|
|
-\texttt{pe-neg} and \texttt{pe-add}. The input to these helper
|
|
|
-functions is the output of partially evaluating the children nodes.
|
|
|
+evaluator for the $R_0$ language. The output of the partial evaluator
|
|
|
+is an $R_0$ program, which we build up using a combination of
|
|
|
+quasiquotes and commas. (Though no quasiquote is necessary for
|
|
|
+integers.) In Figure~\ref{fig:pe-arith}, the normal structural
|
|
|
+recursion is captured in the main \texttt{pe-arith} function whereas
|
|
|
+the code for partially evaluating negation and addition is factored
|
|
|
+into two separate helper functions: \texttt{pe-neg} and
|
|
|
+\texttt{pe-add}. The input to these helper functions is the output of
|
|
|
+partially evaluating the children nodes.
|
|
|
|
|
|
\begin{figure}[tbp]
|
|
|
\begin{lstlisting}
|
|
@@ -721,7 +721,7 @@ input program. That is, we can test whether it satisfies Diagram
|
|
|
evaluator on several examples and tests the output program. The
|
|
|
\texttt{assert} function is defined in Appendix~\ref{appendix:utilities}.
|
|
|
\begin{lstlisting}
|
|
|
-(define (test-pe pe p)
|
|
|
+(define (test-pe p)
|
|
|
(assert "testing pe-arith"
|
|
|
(equal? (interp-R0 p) (interp-R0 (pe-arith p)))))
|
|
|
|