|
@@ -3096,6 +3096,16 @@ print(tmp_1)
|
|
|
\end{transformation}
|
|
|
\fi}
|
|
|
|
|
|
+\newcommand{\LvarMonadASTPython}{
|
|
|
+\begin{array}{rcl}
|
|
|
+\Atm &::=& \INT{\Int} \MID \VAR{\Var} \\
|
|
|
+\Exp{} &::=& \Atm \MID \READ{} \\
|
|
|
+ &\MID& \UNIOP{\itm{unaryop}}{\Atm} \MID \BINOP{\Atm}{\itm{binaryop}}{\Atm} \\
|
|
|
+\Stmt{} &::=& \PRINT{\Atm} \MID \EXPR{\Exp} \\
|
|
|
+ &\MID& \ASSIGN{\VAR{\Var}}{\Exp}
|
|
|
+\end{array}
|
|
|
+}
|
|
|
+
|
|
|
\begin{figure}[tp]
|
|
|
\centering
|
|
|
\fbox{
|
|
@@ -3113,16 +3123,13 @@ print(tmp_1)
|
|
|
\fi}
|
|
|
{\if\edition\pythonEd
|
|
|
\[
|
|
|
+\begin{array}{l}
|
|
|
+ \LvarMonadASTPython \\
|
|
|
\begin{array}{rcl}
|
|
|
-\Atm &::=& \INT{\Int} \MID \VAR{\Var} \\
|
|
|
-\Exp{} &::=& \Atm \MID \READ{} \\
|
|
|
- &\MID& \NEG{\Atm} \MID \ADD{\Atm}{\Atm} \\
|
|
|
-\Stmt{} &::=& \PRINT{\Atm} \MID \EXPR{\Exp} \\
|
|
|
- &\MID& \ASSIGN{\VAR{\Var}}{\Exp}\\
|
|
|
\LangVarANFM{} &::=& \PROGRAM{}{\Stmt^{*}}
|
|
|
\end{array}
|
|
|
+\end{array}
|
|
|
\]
|
|
|
-
|
|
|
\fi}
|
|
|
\end{minipage}
|
|
|
}
|
|
@@ -7644,20 +7651,16 @@ temporary variable because that would interfere with the generation of
|
|
|
high-quality output in the \code{explicate\_control} pass.
|
|
|
|
|
|
|
|
|
-\newcommand{\LifASTMonadPython}{
|
|
|
+\newcommand{\LifMonadASTPython}{
|
|
|
\begin{array}{rcl}
|
|
|
%% \itm{binaryop} &::=& \code{Add()} \MID \code{Sub()} \\
|
|
|
%% \itm{cmp} &::= & \code{Eq()} \MID \code{NotEq()} \MID \code{Lt()} \MID \code{LtE()} \MID \code{Gt()} \MID \code{GtE()} \\
|
|
|
%% \itm{unaryop} &::=& \code{USub()} \MID \code{Not()} \\
|
|
|
%% \itm{bool} &::=& \code{True} \MID \code{False} \\
|
|
|
-\Atm &::=& \INT{\Int} \MID \VAR{\Var} \MID \BOOL{\itm{bool}}\\
|
|
|
-\Exp &::=& \Atm \MID \READ{} \\
|
|
|
- &\MID& \BINOP{\Atm}{\itm{binaryop}}{\Atm} \MID \UNIOP{\itm{unaryop}}{\Atm} \\
|
|
|
- &\MID& \CMP{\Atm}{\itm{cmp}}{\Atm} \MID \IF{\Exp}{\Exp}{\Exp} \\
|
|
|
- &\MID& \LET{\Var}{\Exp}{\Exp}\\
|
|
|
-\Stmt{} &::=& \PRINT{\Atm} \MID \EXPR{\Exp} \\
|
|
|
- &\MID& \ASSIGN{\VAR{\Var}}{\Exp} \MID \IFSTMT{\Exp}{\Stmt^{*}}{\Stmt^{*}}\\
|
|
|
-\LangIfANF &::=& \PROGRAM{\code{()}}{\Stmt^{*}}
|
|
|
+\Atm &::=& \BOOL{\itm{bool}}\\
|
|
|
+\Exp &::=& \CMP{\Atm}{\itm{cmp}}{\Atm} \MID \IF{\Exp}{\Exp}{\Exp} \\
|
|
|
+ &\MID& \BEGIN{\Stmt^{*}}{\Exp}\\
|
|
|
+\Stmt{} &::=& \IFSTMT{\Exp}{\Stmt^{*}}{\Stmt^{*}}
|
|
|
\end{array}
|
|
|
}
|
|
|
|
|
@@ -7681,10 +7684,11 @@ Atm &::=& \gray{ \INT{\Int} \MID \VAR{\Var} } \MID \BOOL{\itm{bool}}\\
|
|
|
{\if\edition\pythonEd
|
|
|
\[
|
|
|
\begin{array}{l}
|
|
|
- \LifASTMonadPython \\
|
|
|
- % \begin{array}{rcl}
|
|
|
- % \LangIfANF &::=& \PROGRAM{\code{()}}{\Stmt^{*}}
|
|
|
- % \end{array}
|
|
|
+ \gray{\LvarMonadASTPython} \\ \hline
|
|
|
+ \LifMonadASTPython \\
|
|
|
+ \begin{array}{rcl}
|
|
|
+ \LangIfANF &::=& \PROGRAM{\code{()}}{\Stmt^{*}}
|
|
|
+ \end{array}
|
|
|
\end{array}
|
|
|
\]
|
|
|
\fi}
|
|
@@ -10385,6 +10389,13 @@ statement.
|
|
|
Figure~\ref{fig:Rwhile-anf-syntax} defines the output language
|
|
|
\LangLoopANF{} of this pass.
|
|
|
|
|
|
+
|
|
|
+\newcommand{\LwhileMonadASTPython}{
|
|
|
+\begin{array}{rcl}
|
|
|
+\Stmt{} &::=& \WHILESTMT{\Exp}{\Stmt^{+}}
|
|
|
+\end{array}
|
|
|
+}
|
|
|
+
|
|
|
\begin{figure}[tp]
|
|
|
\centering
|
|
|
\fbox{
|
|
@@ -10406,17 +10417,25 @@ Figure~\ref{fig:Rwhile-anf-syntax} defines the output language
|
|
|
\fi}
|
|
|
{\if\edition\pythonEd
|
|
|
\[
|
|
|
-\begin{array}{rcl}
|
|
|
-\Atm &::=& \INT{\Int} \MID \VAR{\Var} \MID \BOOL{\itm{bool}}\\
|
|
|
-\Exp &::=& \Atm \MID \READ{} \\
|
|
|
- &\MID& \BINOP{\Atm}{\itm{binaryop}}{\Atm} \MID \UNIOP{\itm{unaryop}}{\Atm} \\
|
|
|
- &\MID& \CMP{\Atm}{\itm{cmp}}{\Atm} \MID \IF{\Exp}{\Exp}{\Exp} \\
|
|
|
-% &\MID& \LET{\Var}{\Exp}{\Exp}\\ % Why?
|
|
|
-\Stmt{} &::=& \PRINT{\Atm} \MID \EXPR{\Exp} \\
|
|
|
- &\MID& \ASSIGN{\VAR{\Var}}{\Exp} \MID \IFSTMT{\Exp}{\Stmt^{+}}{\Stmt^{+}}\\
|
|
|
- &\MID& \WHILESTMT{\Exp}{\Stmt^{+}} \\
|
|
|
-\LangLoopANF &::=& \PROGRAM{\code{()}}{\Stmt^{*}}
|
|
|
+\begin{array}{l}
|
|
|
+ \gray{\LvarMonadASTPython} \\ \hline
|
|
|
+ \gray{\LifMonadASTPython} \\ \hline
|
|
|
+ \LwhileMonadASTPython \\
|
|
|
+ \begin{array}{rcl}
|
|
|
+ \LangLoopANF &::=& \PROGRAM{\code{()}}{\Stmt^{*}}
|
|
|
+ \end{array}
|
|
|
\end{array}
|
|
|
+%% \begin{array}{rcl}
|
|
|
+%% \Atm &::=& \INT{\Int} \MID \VAR{\Var} \MID \BOOL{\itm{bool}}\\
|
|
|
+%% \Exp &::=& \Atm \MID \READ{} \\
|
|
|
+%% &\MID& \BINOP{\Atm}{\itm{binaryop}}{\Atm} \MID \UNIOP{\itm{unaryop}}{\Atm} \\
|
|
|
+%% &\MID& \CMP{\Atm}{\itm{cmp}}{\Atm} \MID \IF{\Exp}{\Exp}{\Exp} \\
|
|
|
+%% % &\MID& \LET{\Var}{\Exp}{\Exp}\\ % Why?
|
|
|
+%% \Stmt{} &::=& \PRINT{\Atm} \MID \EXPR{\Exp} \\
|
|
|
+%% &\MID& \ASSIGN{\VAR{\Var}}{\Exp} \MID \IFSTMT{\Exp}{\Stmt^{+}}{\Stmt^{+}}\\
|
|
|
+%% &\MID& \WHILESTMT{\Exp}{\Stmt^{+}} \\
|
|
|
+%% \LangLoopANF &::=& \PROGRAM{\code{()}}{\Stmt^{*}}
|
|
|
+%% \end{array}
|
|
|
\]
|
|
|
\fi}
|
|
|
\end{minipage}
|
|
@@ -11707,6 +11726,17 @@ Figure~\ref{fig:Lvec-anf-syntax}
|
|
|
shows the grammar for the output language \LangAllocANF{} of this
|
|
|
pass, which is \LangAlloc{} in monadic normal form.
|
|
|
|
|
|
+\newcommand{\LtupMonadASTPython}{
|
|
|
+\begin{array}{rcl}
|
|
|
+\Exp &::=& \GET{\Atm}{\Atm} \\
|
|
|
+ &\MID& \LEN{\Exp}\\
|
|
|
+ &\MID& \ALLOCATE{\Int}{\Type}
|
|
|
+ \MID \GLOBALVALUE{\Var}\RP\\
|
|
|
+\Stmt{} &::=& \ASSIGN{\PUT{\Atm}{\Atm}}{\Exp} \\
|
|
|
+ &\MID& \COLLECT{\Int}
|
|
|
+\end{array}
|
|
|
+}
|
|
|
+
|
|
|
\begin{figure}[tp]
|
|
|
\centering
|
|
|
\fbox{
|
|
@@ -11731,33 +11761,42 @@ pass, which is \LangAlloc{} in monadic normal form.
|
|
|
\fi}
|
|
|
{\if\edition\pythonEd
|
|
|
\[
|
|
|
-\begin{array}{lcl}
|
|
|
-\itm{binaryop} &::=& \code{Add()} \MID \code{Sub()} \\
|
|
|
-\itm{boolop} &::=& \code{And()} \MID \code{Or()} \\
|
|
|
-\itm{cmp} &::= & \code{Eq()} \MID \code{NotEq()} \MID \code{Lt()} \MID \code{LtE()} \MID \code{Gt()} \MID \code{GtE()} \MID \code{Is()} \\
|
|
|
-\itm{unaryop} &::=& \code{USub()} \MID \code{Not()} \\
|
|
|
-\itm{bool} &::=& \code{True} \MID \code{False} \\
|
|
|
-\Atm &::=& \INT{\Int} \MID \VAR{\Var} \MID \BOOL{\itm{bool}} \\
|
|
|
-\Exp &::=& \Atm \MID \READ{} \MID \\
|
|
|
- &\MID& \BINOP{\Atm}{\itm{binaryop}}{\Atm}
|
|
|
- \MID \UNIOP{\itm{unaryop}}{\Atm}\\
|
|
|
- &\MID& \CMP{\Atm}{\itm{cmp}}{\Atm} \\
|
|
|
-% \MID \BOOLOP{\itm{boolop}}{\Exp}{\Exp} \\ % removed by RCO
|
|
|
- &\MID& \IF{\Exp}{\Exp}{\Exp} \\
|
|
|
- &\MID& \GET{\Atm}{\Atm} \\
|
|
|
- &\MID& \LEN{\Exp}\\
|
|
|
- &\MID& \ALLOCATE{\Int}{\Type}
|
|
|
- \MID \GLOBALVALUE{\Var}\RP\\
|
|
|
- &\MID& \BEGIN{\Stmt^{*}}{\Atm} \\ % can use this in place of \LET;
|
|
|
- % why have \LET?
|
|
|
-\Stmt{} &::=& \PRINT{\Atm} \MID \EXPR{\Exp} \\
|
|
|
- &\MID& \ASSIGN{\VAR{\Var}}{\Exp} \\
|
|
|
- &\MID& \ASSIGN{\PUT{\Atm}{\Atm}}{\Exp} \\
|
|
|
- &\MID& \IFSTMT{\Exp}{\Stmt^{+}}{\Stmt^{+}}\\
|
|
|
- &\MID& \WHILESTMT{\Exp}{\Stmt^{+}}
|
|
|
- \MID \COLLECT{\Int} \\
|
|
|
-\LangAllocANFM{} &::=& \PROGRAM{\code{'()}}{\Stmt^{*}}
|
|
|
+\begin{array}{l}
|
|
|
+ \gray{\LvarMonadASTPython} \\ \hline
|
|
|
+ \gray{\LifMonadASTPython} \\ \hline
|
|
|
+ \gray{\LwhileMonadASTPython} \\ \hline
|
|
|
+ \LtupMonadASTPython \\
|
|
|
+ \begin{array}{rcl}
|
|
|
+ \LangAllocANFM{} &::=& \PROGRAM{\code{'()}}{\Stmt^{*}}
|
|
|
+ \end{array}
|
|
|
\end{array}
|
|
|
+%% \begin{array}{lcl}
|
|
|
+%% \itm{binaryop} &::=& \code{Add()} \MID \code{Sub()} \\
|
|
|
+%% \itm{boolop} &::=& \code{And()} \MID \code{Or()} \\
|
|
|
+%% \itm{cmp} &::= & \code{Eq()} \MID \code{NotEq()} \MID \code{Lt()} \MID \code{LtE()} \MID \code{Gt()} \MID \code{GtE()} \MID \code{Is()} \\
|
|
|
+%% \itm{unaryop} &::=& \code{USub()} \MID \code{Not()} \\
|
|
|
+%% \itm{bool} &::=& \code{True} \MID \code{False} \\
|
|
|
+%% \Atm &::=& \INT{\Int} \MID \VAR{\Var} \MID \BOOL{\itm{bool}} \\
|
|
|
+%% \Exp &::=& \Atm \MID \READ{} \MID \\
|
|
|
+%% &\MID& \BINOP{\Atm}{\itm{binaryop}}{\Atm}
|
|
|
+%% \MID \UNIOP{\itm{unaryop}}{\Atm}\\
|
|
|
+%% &\MID& \CMP{\Atm}{\itm{cmp}}{\Atm} \\
|
|
|
+%% % \MID \BOOLOP{\itm{boolop}}{\Exp}{\Exp} \\ % removed by RCO
|
|
|
+%% &\MID& \IF{\Exp}{\Exp}{\Exp} \\
|
|
|
+%% &\MID& \GET{\Atm}{\Atm} \\
|
|
|
+%% &\MID& \LEN{\Exp}\\
|
|
|
+%% &\MID& \ALLOCATE{\Int}{\Type}
|
|
|
+%% \MID \GLOBALVALUE{\Var}\RP\\
|
|
|
+%% &\MID& \BEGIN{\Stmt^{*}}{\Atm} \\ % can use this in place of \LET;
|
|
|
+%% % why have \LET?
|
|
|
+%% \Stmt{} &::=& \PRINT{\Atm} \MID \EXPR{\Exp} \\
|
|
|
+%% &\MID& \ASSIGN{\VAR{\Var}}{\Exp} \\
|
|
|
+%% &\MID& \ASSIGN{\PUT{\Atm}{\Atm}}{\Exp} \\
|
|
|
+%% &\MID& \IFSTMT{\Exp}{\Stmt^{+}}{\Stmt^{+}}\\
|
|
|
+%% &\MID& \WHILESTMT{\Exp}{\Stmt^{+}}
|
|
|
+%% \MID \COLLECT{\Int} \\
|
|
|
+%% \LangAllocANFM{} &::=& \PROGRAM{\code{'()}}{\Stmt^{*}}
|
|
|
+%% \end{array}
|
|
|
\]
|
|
|
\fi}
|
|
|
\end{minipage}
|