Skip to content

Commit 8465012

Browse files
committed
fix examples in 5.7
1 parent 3a503ea commit 8465012

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

book.tex

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9028,7 +9028,7 @@ \section{Explicate Control}
90289028
can be an arbitrary expression in \LangIfANF{}, whereas in \LangCIf{} the
90299029
condition must be a comparison.
90309030

9031-
As a motivating example, consider the following program that has an
9031+
As a motivating example, consider the following \LangIfANF{} program that has an
90329032
\key{if} expression nested in the condition of another \key{if}:%
90339033
\python{\footnote{Programmers rarely write nested \code{if}
90349034
expressions, but they do write nested expressions involving
@@ -9050,7 +9050,8 @@ \section{Explicate Control}
90509050
\begin{lstlisting}
90519051
x = input_int()
90529052
y = input_int()
9053-
print(y + 2 if (x == 0 if x < 1 else x == 2) else y + 10)
9053+
tmp_0 = y + 2 if (x == 0 if x < 1 else x == 2) else y + 10
9054+
print(tmp_0)
90549055
\end{lstlisting}
90559056
\fi}
90569057
\end{minipage}
@@ -9094,7 +9095,7 @@ \section{Explicate Control}
90949095
\end{minipage}
90959096
\end{center}
90969097
One way to achieve this goal is to reorganize the code at the level of
9097-
\LangIf{} or \LangIfANF{}, pushing the outer \key{if} inside the inner one, yielding
9098+
\LangIfANF{}, pushing the outer \key{if} inside the inner one, yielding
90989099
the following code:
90999100
\begin{center}
91009101
\begin{minipage}{0.96\textwidth}
@@ -9115,9 +9116,10 @@ \section{Explicate Control}
91159116
\begin{lstlisting}
91169117
x = input_int()
91179118
y = input_int()
9118-
print(((y + 2) if x == 0 else (y + 10)) \
9119-
if (x < 1) \
9120-
else ((y + 2) if (x == 2) else (y + 10)))
9119+
tmp_0 = ((y + 2) if x == 0 else (y + 10)) \
9120+
if (x < 1) \
9121+
else ((y + 2) if (x == 2) else (y + 10))
9122+
print(tmp_0)
91219123
\end{lstlisting}
91229124
\fi}
91239125
\end{minipage}
@@ -9138,8 +9140,8 @@ \section{Explicate Control}
91389140
need to execute the branch. In this way, jump instructions are edges
91399141
in the graph and the basic blocks are the nodes.
91409142
%
9141-
Likewise, our language \LangCIf{} provides the ability to label a
9142-
sequence of statements and to jump to a label via \code{goto}.
9143+
Likewise, our intermediate language \LangCIf{} provides the ability to
9144+
label a sequence of statements and to jump to a label via \code{goto}.
91439145

91449146
As a preview of what \code{explicate\_control} will do,
91459147
figure~\ref{fig:explicate-control-s1-38} shows the output of

0 commit comments

Comments
 (0)