Ver Fonte

4.1 and 4.2

Jeremy Siek há 3 anos atrás
pai
commit
b82ab87822
2 ficheiros alterados com 18 adições e 18 exclusões
  1. 16 16
      book.tex
  2. 2 2
      defs.tex

+ 16 - 16
book.tex

@@ -6553,12 +6553,11 @@ checking and define a type checker for \LangIf{}
   language \LangCVar{} into \LangCIf{} (Section~\ref{sec:Cif}) and
   \LangXInt{} into \LangXIf{} (Section~\ref{sec:x86-if}).}
 %
-The remaining sections of this chapter discuss how the addition of
-Booleans and conditional control flow to the language requires changes
-to the existing compiler passes and the addition of new ones. In
-particular, we introduce the \code{shrink} pass to translates some
-operators into others, thereby reducing the number of operators that
-need to be handled in later passes.
+The remaining sections of this chapter discuss how Booleans and
+conditional control flow require changes to the existing compiler
+passes and the addition of new ones. We introduce the \code{shrink}
+pass to translates some operators into others, thereby reducing the
+number of operators that need to be handled in later passes.
 %
 The main event of this chapter is the \code{explicate\_control} pass
 that is responsible for translating \code{if}'s into conditional
@@ -6590,7 +6589,7 @@ respectively. The \LangIf{} language includes all of
   rule for all of them. This means that the grammar no longer checks
   whether the arity of an operators matches the number of
   arguments. That responsibility is moved to the type checker for
-  \LangIf{}, which we introduce in Section~\ref{sec:type-check-Lif}.}
+  \LangIf{} (Section~\ref{sec:type-check-Lif}).}
 
 
 \newcommand{\LifGrammarRacket}{
@@ -6615,6 +6614,7 @@ respectively. The \LangIf{} language includes all of
 }
 \newcommand{\LintOpAST}{
   \begin{array}{rcl}
+    \Type &::=& \key{Integer} \\
     \itm{op} &::= & \code{read} \MID \code{+} \MID \code{-}\\
     \Exp{} &::=& \INT{\Int} \MID \PRIM{\itm{op}}{\Exp\ldots}    
   \end{array}
@@ -6926,10 +6926,11 @@ for the below expression {\if\edition\racketEd
    not (10 + -(12 + 20))
 \end{lstlisting}
 \fi}
-The subexpression
-\racket{\code{(+ 10 (- (+ 12 20)))}}\python{\code{(10 + -(12 + 20))}}
-has type \INTTY{} but the type checker enforces the rule that the argument of
-\code{not} must be an expression of type \BOOLTY{}.
+\noindent The subexpression
+\racket{\code{(+ 10 (- (+ 12 20)))}}
+\python{\code{(10 + -(12 + 20))}}
+has type \INTTY{} but the type checker enforces the rule that the
+argument of \code{not} must be an expression of type \BOOLTY{}.
 
 We implement type checking using classes and methods because they
 provide the open recursion needed to reuse code as we extend the type
@@ -6948,8 +6949,7 @@ of the support code.
 %
 Each type checker is a structurally recursive function over the AST.
 Given an input expression \code{e}, the type checker either signals an
-error or returns \racket{an expression and} its type (\INTTY{} or
-\BOOLTY{}).
+error or returns \racket{an expression and} its type.
 %
 \racket{It returns an expression because there are situations in which
   we want to change or update the expression.}
@@ -7205,13 +7205,13 @@ class TypeCheckLif(TypeCheckLvar):
 \label{fig:type-check-Lif}
 \end{figure}
 
-We shift our focus to Figure~\ref{fig:type-check-Lif}, the type
-checker for \LangIf{}.
+The type checker for \LangIf{} is defined in
+Figure~\ref{fig:type-check-Lif}.
 %
 The type of a Boolean constant is \BOOLTY{}.
 %
 \racket{The \code{operator-types} function adds dictionary entries for
-  the other new operators.}
+  the new operators.}
 %
 \python{Logical not requires its argument to be a \BOOLTY{} and
   produces a \BOOLTY{}. Similarly for logical and and logical or. }

+ 2 - 2
defs.tex

@@ -147,8 +147,8 @@
 \newcommand{\CIF}[3]{\LP\key{if}~#1~#2~#3\RP}
 \newcommand{\AND}[2]{\key{(Prim}~\code{'and}~\code{(}#1~#2\code{))}}
 \newcommand{\OR}[2]{\key{(Prim}~\code{'or}~\code{(}#1~#2\code{))}}
-\newcommand{\CAND}[2]{\CBINOP{\key{'and}}{#1}{#2}}
-\newcommand{\COR}[2]{\CBINOP{\key{'or}}{#1}{#2}}
+\newcommand{\CAND}[2]{\CBINOP{\key{and}}{#1}{#2}}
+\newcommand{\COR}[2]{\CBINOP{\key{or}}{#1}{#2}}
 \newcommand{\INTTY}{{\key{Integer}}}
 \newcommand{\INTTYPE}{{\key{Integer}}}
 \newcommand{\BOOLTY}{{\key{Boolean}}}