瀏覽代碼

Merge branch 'master' of https://github.com/IUCompilerCourse/Essentials-of-Compilation

Jeremy Siek 3 年之前
父節點
當前提交
c340550887
共有 1 個文件被更改,包括 19 次插入15 次删除
  1. 19 15
      book.tex

+ 19 - 15
book.tex

@@ -17111,7 +17111,7 @@ class InterpLdyn(InterpLlambda):
         if l.tag == r.tag:
           return self.tag(self.interp_cmp(cmp)(l.value, r.value))
         else:
-          raise Exception('interp Compare unexpected ' \
+          raise Exception('interp Compare unexpected '
                           + repr(l) + ' ' + repr(r))
       case Subscript(tup, index, Load()):
         t = self.interp_exp(tup, env)
@@ -17250,7 +17250,8 @@ class InterpLdyn(InterpLlambda):
         case Tagged(val, tag) if tag == expected_tag:
           return val
         case _:
-          raise Exception('expected Tagged value with ' + expected_tag + ', not ' + ' ' + repr(v))
+          raise Exception('expected Tagged value with '
+                          + expected_tag + ', not ' + ' ' + repr(v))
 
   def apply_fun(self, fun, args, e):
       f = self.untag(fun, 'function', e)
@@ -17295,7 +17296,7 @@ function for mapping types to tag codes.
 \end{align*}
 \fi}
 This stealing of 3 bits comes at some price: integers are now restricted
-to the range from $-2^{60}$ to $2^{60}$. The stealing does not adversely
+to the range from $-2^{60}$ to $2^{60}-1$. The stealing does not adversely
 affect tuples and procedures because those values are addresses, and
 our addresses are 8-byte aligned so the rightmost 3 bits are unused,
 they are always $000$. Thus, we do not lose information by overwriting
@@ -17334,8 +17335,10 @@ language in greater detail.
   \MID \key{TupleType}\LS\key{AnyType()}^+\RS \\
   &\MID& \key{FunctionType}\LP \key{AnyType()}^{*}\key{, }\key{AnyType()}\RP \\
 \Exp & ::= & \INJECT{\Exp}{\FType} \MID \PROJECT{\Exp}{\FType} \\
-     &\MID& \CALL{\VAR{\key{'any\_tuple\_load'}}}{\LS\Exp\key{, }\INT{n}\RS}\\
-     &\MID& \CALL{\VAR{\key{'any\_len'}}}{\LS\Exp\RS} 
+     &\MID& \CALL{\VAR{\key{'any\_tuple\_load'}}}{\LS\Exp\key{, }\Exp\RS}\\
+     &\MID& \CALL{\VAR{\key{'any\_len'}}}{\LS\Exp\RS} \\
+     &\MID& \CALL{\VAR{\key{'arity'}}}{\LS\Exp\RS}  \\
+     &\MID& \CALL{\VAR{\key{'make\_any'}}}{\LS\Exp\key{, }\INT{\Int}\RS} 
      %% &\MID& \CALL{\VAR{\key{'is\_int'}}}{\Exp} 
      %% \MID \CALL{\VAR{\key{'is\_bool'}}}{\Exp} \\
      %% &\MID& \CALL{\VAR{\key{'is\_none'}}}{\Exp} 
@@ -17623,7 +17626,7 @@ class InterpLany(InterpLlambda):
           case Tagged(val, tag) if self.type_to_tag(typ) == tag:
             return val
           case _:
-            raise Exception('interp project to ' + repr(typ) \
+            raise Exception('interp project to ' + repr(typ)
                             + '  unexpected ' + repr(v))
       case Call(Name('any_tuple_load'), [tup, index]):
         tv = self.interp_exp(tup, env)
@@ -17879,8 +17882,8 @@ $\Rightarrow$
 \end{tabular} 
 \fi}
 {\if\edition\pythonEd
-\begin{tabular}{lll}
-\begin{minipage}{0.22\textwidth}
+\hspace{-0.8em}\begin{tabular}{|lll|} \hline
+\begin{minipage}{0.23\textwidth}
 \begin{lstlisting}
 True
 \end{lstlisting}
@@ -17894,7 +17897,7 @@ Inject(True, BoolType())
 \end{lstlisting}
 \end{minipage}
 \\[2ex]\hline
-\begin{minipage}{0.22\textwidth}
+\begin{minipage}{0.23\textwidth}
 \begin{lstlisting}
 |$e_1$| + |$e_2$|
 \end{lstlisting}
@@ -17910,7 +17913,7 @@ Inject(Project(|$e'_1$|, IntType())
 \end{lstlisting}
 \end{minipage}
 \\[2ex]\hline
-\begin{minipage}{0.22\textwidth}
+\begin{minipage}{0.23\textwidth}
 \begin{lstlisting}
 lambda |$x_1 \ldots$|: |$e$|
 \end{lstlisting}
@@ -17925,7 +17928,7 @@ Inject(Lambda([(|$x_1$|,AnyType),|$\ldots$|], |$e'$|)
 \end{lstlisting}
 \end{minipage}
 \\[2ex]\hline
-\begin{minipage}{0.22\textwidth}
+\begin{minipage}{0.23\textwidth}
 \begin{lstlisting}
 |$e_0$|(|$e_1 \ldots e_n$|)
 \end{lstlisting}
@@ -17940,7 +17943,7 @@ Call(Project(|$e'_0$|, FunctionType([AnyType(),|$\ldots$|],
 \end{lstlisting}
 \end{minipage}
 \\[2ex]\hline
-\begin{minipage}{0.22\textwidth}
+\begin{minipage}{0.23\textwidth}
 \begin{lstlisting}
 |$e_1$|[|$e_2$|]
 \end{lstlisting}
@@ -17954,7 +17957,7 @@ Call(Name('any_tuple_load'),
      [|$e_1'$|, Project(|$e_2'$|, IntType())])
 \end{lstlisting}
 \end{minipage}
-%% \begin{minipage}{0.22\textwidth}
+%% \begin{minipage}{0.23\textwidth}
 %% \begin{lstlisting}
 %% |$e_2$| if |$e_1$| else |$e_3$|
 %% \end{lstlisting}
@@ -17968,7 +17971,7 @@ Call(Name('any_tuple_load'),
 %% \end{lstlisting}
 %% \end{minipage}
 %% \\[2ex]\hline
-%% \begin{minipage}{0.22\textwidth}
+%% \begin{minipage}{0.23\textwidth}
 %% \begin{lstlisting}
 %% (eq? |$e_1$| |$e_2$|)
 %% \end{lstlisting}
@@ -17982,7 +17985,7 @@ Call(Name('any_tuple_load'),
 %% \end{lstlisting}
 %% \end{minipage}
 %% \\[2ex]\hline
-%% \begin{minipage}{0.22\textwidth}
+%% \begin{minipage}{0.23\textwidth}
 %% \begin{lstlisting}
 %% (not |$e_1$|)
 %% \end{lstlisting}
@@ -17997,6 +18000,7 @@ Call(Name('any_tuple_load'),
 %% \end{lstlisting}
 %% \end{minipage}
 %% \\[2ex]\hline
+\\\hline
 \end{tabular} 
 \fi}
   \end{tcolorbox}