Эх сурвалжийг харах

for explicate control, make sure input language is the monadic one

Jeremy G. Siek 6 сар өмнө
parent
commit
c835b037a0
1 өөрчлөгдсөн 15 нэмэгдсэн , 15 устгасан
  1. 15 15
      book.tex

+ 15 - 15
book.tex

@@ -3616,7 +3616,7 @@ output programs produce the same result as the input programs.
 \section{Explicate Control}
 \section{Explicate Control}
 \label{sec:explicate-control-Lvar}
 \label{sec:explicate-control-Lvar}
 
 
-The \code{explicate\_control} pass compiles \LangVar{} programs into \LangCVar{}
+The \code{explicate\_control} pass compiles \LangVarANF{} programs into \LangCVar{}
 programs that make the order of execution explicit in their
 programs that make the order of execution explicit in their
 syntax. For now this amounts to flattening \key{let} constructs into a
 syntax. For now this amounts to flattening \key{let} constructs into a
 sequence of assignment statements. For example, consider the following
 sequence of assignment statements. For example, consider the following
@@ -3702,11 +3702,11 @@ function should be applied to expressions in tail position, whereas the
 \code{explicate\_assign} should be applied to expressions that occur on
 \code{explicate\_assign} should be applied to expressions that occur on
 the right-hand side of a \key{let}.
 the right-hand side of a \key{let}.
 %
 %
-The \code{explicate\_tail} function takes an \Exp{} in \LangVar{} as
+The \code{explicate\_tail} function takes an \Exp{} in \LangVarANF{} as
 input and produces a \Tail{} in \LangCVar{} (see
 input and produces a \Tail{} in \LangCVar{} (see
 figure~\ref{fig:c0-syntax}).
 figure~\ref{fig:c0-syntax}).
 %
 %
-The \code{explicate\_assign} function takes an \Exp{} in \LangVar{},
+The \code{explicate\_assign} function takes an \Exp{} in \LangVarANF{},
 the variable to which it is to be assigned, and a \Tail{} in
 the variable to which it is to be assigned, and a \Tail{} in
 \LangCVar{} for the code that comes after the assignment.  The
 \LangCVar{} for the code that comes after the assignment.  The
 \code{explicate\_assign} function returns a $\Tail$ in \LangCVar{}.
 \code{explicate\_assign} function returns a $\Tail$ in \LangCVar{}.
@@ -3725,7 +3725,7 @@ generated code.
 \begin{exercise}\normalfont\normalsize
 \begin{exercise}\normalfont\normalsize
 %
 %
 Implement the \code{explicate\_control} function in
 Implement the \code{explicate\_control} function in
-\code{compiler.rkt}.  Create three new \LangInt{} programs that
+\code{compiler.rkt}.  Create three new \LangVar{} programs that
 exercise the code in \code{explicate\_control}.
 exercise the code in \code{explicate\_control}.
 %
 %
 In the \code{run-tests.rkt} script, add the following entry to the
 In the \code{run-tests.rkt} script, add the following entry to the
@@ -9041,10 +9041,10 @@ list of \code{passes} and then run the script to test your compiler.
   make the order of evaluation explicit in the syntax of the program.
   make the order of evaluation explicit in the syntax of the program.
   With the addition of \key{if}, this becomes more interesting.}
   With the addition of \key{if}, this becomes more interesting.}
 %
 %
-The \code{explicate\_control} pass translates from \LangIf{} to \LangCIf{}.
+The \code{explicate\_control} pass translates from \LangIfANF{} to \LangCIf{}.
 %
 %
 The main challenge to overcome is that the condition of an \key{if}
 The main challenge to overcome is that the condition of an \key{if}
-can be an arbitrary expression in \LangIf{}, whereas in \LangCIf{} the
+can be an arbitrary expression in \LangIfANF{}, whereas in \LangCIf{} the
 condition must be a comparison.
 condition must be a comparison.
 
 
 As a motivating example, consider the following program that has an
 As a motivating example, consider the following program that has an
@@ -9113,7 +9113,7 @@ For example, we want to generate the following code for the inner
 \end{minipage}
 \end{minipage}
 \end{center}
 \end{center}
 One way to achieve this goal is to reorganize the code at the level of
 One way to achieve this goal is to reorganize the code at the level of
-\LangIf{}, pushing the outer \key{if} inside the inner one, yielding
+\LangIf{} or \LangIfANF{}, pushing the outer \key{if} inside the inner one, yielding
 the following code:
 the following code:
 \begin{center}
 \begin{center}
 \begin{minipage}{0.96\textwidth}
 \begin{minipage}{0.96\textwidth}
@@ -9263,7 +9263,7 @@ block_3:
 \end{tabular} 
 \end{tabular} 
 \fi}
 \fi}
 \end{tcolorbox}
 \end{tcolorbox}
-\caption{Translation from \LangIf{} to \LangCIf{}
+\caption{Translation from \LangIfANF{} to \LangCIf{}
   via the \code{explicate\_control}.}
   via the \code{explicate\_control}.}
 \label{fig:explicate-control-s1-38}
 \label{fig:explicate-control-s1-38}
 \end{figure}
 \end{figure}
@@ -9272,15 +9272,15 @@ block_3:
 {\if\edition\racketEd        
 {\if\edition\racketEd        
 %
 %
 Recall that in section~\ref{sec:explicate-control-Lvar} we implement
 Recall that in section~\ref{sec:explicate-control-Lvar} we implement
-\code{explicate\_control} for \LangVar{} using two recursive
+\code{explicate\_control} for \LangVarANF{} using two recursive
 functions, \code{explicate\_tail} and \code{explicate\_assign}.  The
 functions, \code{explicate\_tail} and \code{explicate\_assign}.  The
 former function translates expressions in tail position, whereas the
 former function translates expressions in tail position, whereas the
 latter function translates expressions on the right-hand side of a
 latter function translates expressions on the right-hand side of a
-\key{let}. With the addition of \key{if} expression to \LangIf{} we
+\key{let}. With the addition of \key{if} expression to \LangIfANF{} we
 have a new kind of position to deal with: the predicate position of
 have a new kind of position to deal with: the predicate position of
 the \key{if}. We need another function, \code{explicate\_pred}, that
 the \key{if}. We need another function, \code{explicate\_pred}, that
 decides how to compile an \key{if} by analyzing its condition.  So,
 decides how to compile an \key{if} by analyzing its condition.  So,
-\code{explicate\_pred} takes an \LangIf{} expression and two
+\code{explicate\_pred} takes an \LangIfANF{} expression and two
 \LangCIf{} tails for the \emph{then} branch and \emph{else} branch
 \LangCIf{} tails for the \emph{then} branch and \emph{else} branch
 and outputs a tail.  In the following paragraphs we discuss specific
 and outputs a tail.  In the following paragraphs we discuss specific
 cases in the \code{explicate\_tail}, \code{explicate\_assign}, and
 cases in the \code{explicate\_tail}, \code{explicate\_assign}, and
@@ -11920,10 +11920,10 @@ $\Rightarrow$
 {\if\edition\racketEd
 {\if\edition\racketEd
 
 
 Recall that in the \code{explicate\_control} pass we define one helper
 Recall that in the \code{explicate\_control} pass we define one helper
-function for each kind of position in the program.  For the \LangVar{}
+function for each kind of position in the program.  For the \LangVarANF{}
 language of integers and variables, we needed assignment and tail
 language of integers and variables, we needed assignment and tail
-positions. The \code{if} expressions of \LangIf{} introduced predicate
-positions. For \LangLoop{}, the \code{begin} expression introduces yet
+positions. The \code{if} expressions of \LangIfANF{} introduced predicate
+positions. For \LangLoopANF{}, the \code{begin} expression introduces yet
 another kind of position: effect position. Except for the last
 another kind of position: effect position. Except for the last
 subexpression, the subexpressions inside a \code{begin} are evaluated
 subexpression, the subexpressions inside a \code{begin} are evaluated
 only for their effect. Their result values are discarded. We can
 only for their effect. Their result values are discarded. We can
@@ -16036,7 +16036,7 @@ in tail position \code{Apply} becomes \code{TailCall}.}
 We recommend defining a new auxiliary function for processing function
 We recommend defining a new auxiliary function for processing function
 definitions.  This code is similar to the case for \code{Program} in
 definitions.  This code is similar to the case for \code{Program} in
 \LangVec{}.  The top-level \code{explicate\_control} function that
 \LangVec{}.  The top-level \code{explicate\_control} function that
-handles the \code{ProgramDefs} form of \LangFun{} can apply this
+handles the \code{ProgramDefs} form of \LangFunANF{} can apply this
 new function to all function definitions.
 new function to all function definitions.
 
 
 {\if\edition\pythonEd\pythonColor
 {\if\edition\pythonEd\pythonColor