|
@@ -9028,7 +9028,7 @@ The main challenge to overcome is that the condition of an \key{if}
|
|
|
can be an arbitrary expression in \LangIfANF{}, whereas in \LangCIf{} the
|
|
|
condition must be a comparison.
|
|
|
|
|
|
-As a motivating example, consider the following program that has an
|
|
|
+As a motivating example, consider the following \LangIfANF{} program that has an
|
|
|
\key{if} expression nested in the condition of another \key{if}:%
|
|
|
\python{\footnote{Programmers rarely write nested \code{if}
|
|
|
expressions, but they do write nested expressions involving
|
|
@@ -9050,7 +9050,8 @@ As a motivating example, consider the following program that has an
|
|
|
\begin{lstlisting}
|
|
|
x = input_int()
|
|
|
y = input_int()
|
|
|
- print(y + 2 if (x == 0 if x < 1 else x == 2) else y + 10)
|
|
|
+ tmp_0 = y + 2 if (x == 0 if x < 1 else x == 2) else y + 10
|
|
|
+ print(tmp_0)
|
|
|
\end{lstlisting}
|
|
|
\fi}
|
|
|
\end{minipage}
|
|
@@ -9094,7 +9095,7 @@ For example, we want to generate the following code for the inner
|
|
|
\end{minipage}
|
|
|
\end{center}
|
|
|
One way to achieve this goal is to reorganize the code at the level of
|
|
|
-\LangIf{} or \LangIfANF{}, pushing the outer \key{if} inside the inner one, yielding
|
|
|
+\LangIfANF{}, pushing the outer \key{if} inside the inner one, yielding
|
|
|
the following code:
|
|
|
\begin{center}
|
|
|
\begin{minipage}{0.96\textwidth}
|
|
@@ -9115,9 +9116,10 @@ the following code:
|
|
|
\begin{lstlisting}
|
|
|
x = input_int()
|
|
|
y = input_int()
|
|
|
- print(((y + 2) if x == 0 else (y + 10)) \
|
|
|
- if (x < 1) \
|
|
|
- else ((y + 2) if (x == 2) else (y + 10)))
|
|
|
+ tmp_0 = ((y + 2) if x == 0 else (y + 10)) \
|
|
|
+ if (x < 1) \
|
|
|
+ else ((y + 2) if (x == 2) else (y + 10))
|
|
|
+ print(tmp_0)
|
|
|
\end{lstlisting}
|
|
|
\fi}
|
|
|
\end{minipage}
|
|
@@ -9138,8 +9140,8 @@ label the code for each branch and insert jumps in all the places that
|
|
|
need to execute the branch. In this way, jump instructions are edges
|
|
|
in the graph and the basic blocks are the nodes.
|
|
|
%
|
|
|
-Likewise, our language \LangCIf{} provides the ability to label a
|
|
|
-sequence of statements and to jump to a label via \code{goto}.
|
|
|
+Likewise, our intermediate language \LangCIf{} provides the ability to
|
|
|
+label a sequence of statements and to jump to a label via \code{goto}.
|
|
|
|
|
|
As a preview of what \code{explicate\_control} will do,
|
|
|
figure~\ref{fig:explicate-control-s1-38} shows the output of
|