Sfoglia il codice sorgente

copy edit ch 2 for python

Jeremy G. Siek 2 anni fa
parent
commit
6aa5ec8833
2 ha cambiato i file con 22 aggiunte e 21 eliminazioni
  1. 20 19
      book.tex
  2. 2 2
      defs.tex

+ 20 - 19
book.tex

@@ -1807,7 +1807,7 @@ instructor solution for the \LangVar{} compiler is approximately
 
 
 The \LangVar{} language extends the \LangInt{} language with
 The \LangVar{} language extends the \LangInt{} language with
 variables.  The concrete syntax of the \LangVar{} language is defined
 variables.  The concrete syntax of the \LangVar{} language is defined
-by the grammar presented in figure~\ref{fig:Lvar-concrete-syntax} and
+by the grammar presented in figure~\ref{fig:Lvar-concrete-syntax}, and
 the abstract syntax is presented in figure~\ref{fig:Lvar-syntax}.  The
 the abstract syntax is presented in figure~\ref{fig:Lvar-syntax}.  The
 nonterminal \Var{} may be any \racket{Racket}\python{Python}
 nonterminal \Var{} may be any \racket{Racket}\python{Python}
 identifier.  As in \LangInt{}, \READOP{} is a nullary operator,
 identifier.  As in \LangInt{}, \READOP{} is a nullary operator,
@@ -1923,10 +1923,10 @@ evaluates the body \code{(+ 10 x)}, producing $42$.
 %
 %
 {\if\edition\pythonEd\pythonColor
 {\if\edition\pythonEd\pythonColor
 %
 %
-The \LangVar{} language includes assignment statements, which define a
+The \LangVar{} language includes an assignment statement, which defines a
 variable for use in later statements and initializes the variable with
 variable for use in later statements and initializes the variable with
 the value of an expression.  The abstract syntax for assignment is
 the value of an expression.  The abstract syntax for assignment is
-defined in Figure~\ref{fig:Lvar-syntax}.  The concrete syntax for
+defined in figure~\ref{fig:Lvar-syntax}.  The concrete syntax for
 assignment is \index{subject}{Assign@\texttt{Assign}}
 assignment is \index{subject}{Assign@\texttt{Assign}}
 \begin{lstlisting}
 \begin{lstlisting}
 |$\itm{var}$| = |$\itm{exp}$|
 |$\itm{var}$| = |$\itm{exp}$|
@@ -2064,7 +2064,7 @@ method overriding to interpret \LangInt{} and \LangVar{} using
 %
 %
 \racket{the
 \racket{the
   \href{https://docs.racket-lang.org/guide/classes.html}{\code{class}}
   \href{https://docs.racket-lang.org/guide/classes.html}{\code{class}}
-  \index{subject}{class} feature of Racket.}
+  \index{subject}{class} feature of Racket.}%
 %
 %
 \python{a Python \code{class} definition.}
 \python{a Python \code{class} definition.}
 %
 %
@@ -2136,7 +2136,7 @@ def InterpLvar(InterpLint):
 \end{minipage}
 \end{minipage}
 \fi}
 \fi}
 \end{center}
 \end{center}
-Getting back to the troublesome example, repeated here:
+We return to the troublesome example, repeated here:
 {\if\edition\racketEd  
 {\if\edition\racketEd  
 \begin{lstlisting}
 \begin{lstlisting}
 (Let 'y (Int 10) (Prim '- (Var 'y)))
 (Let 'y (Int 10) (Prim '- (Var 'y)))
@@ -2148,9 +2148,9 @@ y = 10
 print(-y)
 print(-y)
 \end{lstlisting}
 \end{lstlisting}
 \fi}
 \fi}
-\noindent We can invoke the \code{interp\_exp} method for \LangVar{}
+\noindent We can invoke the \code{interp\_exp} method for \LangVar{}%
 \racket{on this expression,}
 \racket{on this expression,}
-\python{on the \code{-y} expression,}%
+\python{on the \code{-y} expression,}
 %
 %
 which we call \code{e0}, by creating an object of the \LangVar{} class
 which we call \code{e0}, by creating an object of the \LangVar{} class
 and calling the \code{interp\_exp} method
 and calling the \code{interp\_exp} method
@@ -3390,7 +3390,7 @@ variables with their initializing expressions.
 
 
 {\if\edition\racketEd
 {\if\edition\racketEd
 %
 %
-Returning to the example program with the expression \code{(+ 42 (-
+In the example program with the expression \code{(+ 42 (-
   10))}, the subexpression \code{(- 10)} should be processed using the
   10))}, the subexpression \code{(- 10)} should be processed using the
 \code{rco\_atom} function because it is an argument of the \code{+}
 \code{rco\_atom} function because it is an argument of the \code{+}
 operator and therefore needs to become atomic.  The output of
 operator and therefore needs to become atomic.  The output of
@@ -3411,7 +3411,7 @@ tmp.1
 %
 %
 Returning to the example program with the expression \code{42 + -10},
 Returning to the example program with the expression \code{42 + -10},
 the subexpression \code{-10} should be processed using the
 the subexpression \code{-10} should be processed using the
-\code{rco\_exp} function with \code{True} as the second argument
+\code{rco\_exp} function with \code{True} as the second argument,
 because \code{-10} is an argument of the \code{+} operator and
 because \code{-10} is an argument of the \code{+} operator and
 therefore needs to become atomic.  The output of \code{rco\_exp}
 therefore needs to become atomic.  The output of \code{rco\_exp}
 applied to \code{-10} is as follows.
 applied to \code{-10} is as follows.
@@ -3517,8 +3517,8 @@ programs, place \lstinline{(debug-level 1)} before the call to
 {\if\edition\pythonEd\pythonColor
 {\if\edition\pythonEd\pythonColor
   Implement the \code{remove\_complex\_operands} pass in
   Implement the \code{remove\_complex\_operands} pass in
   \code{compiler.py}, creating auxiliary functions for each
   \code{compiler.py}, creating auxiliary functions for each
-  nonterminal in the grammar, i.e., \code{rco\_exp}
-  and \code{rco\_stmt}. We recommend you use the function
+  nonterminal in the grammar, that is, \code{rco\_exp}
+  and \code{rco\_stmt}. We recommend that you use the function
   \code{utils.generate\_name()} to generate fresh names from a stub string.
   \code{utils.generate\_name()} to generate fresh names from a stub string.
 \fi}  
 \fi}  
 \end{exercise}
 \end{exercise}
@@ -3835,7 +3835,7 @@ recursively and then append the resulting instructions.
 We recommend that you use the function \code{utils.label\_name()} to
 We recommend that you use the function \code{utils.label\_name()} to
 transform strings into labels, for example, in
 transform strings into labels, for example, in
 the target of the \code{callq} instruction. This practice makes your
 the target of the \code{callq} instruction. This practice makes your
-compiler portable across Linus and Mac OS X, which requires an underscore
+compiler portable across Linux and Mac OS X, which requires an underscore
 prefixed to all labels.
 prefixed to all labels.
 \fi}
 \fi}
 \begin{exercise}
 \begin{exercise}
@@ -3855,7 +3855,7 @@ list of \code{passes} and then run the script to test your compiler.
 Implement the \key{select\_instructions} pass in
 Implement the \key{select\_instructions} pass in
 \code{compiler.py}. Create three new example programs that are
 \code{compiler.py}. Create three new example programs that are
 designed to exercise all the interesting cases in this pass.
 designed to exercise all the interesting cases in this pass.
-Run the \code{run-tests.py} script to to check
+Run the \code{run-tests.py} script to check
 whether the output programs produce the same result as the input
 whether the output programs produce the same result as the input
 programs.
 programs.
 \fi}
 \fi}
@@ -3958,7 +3958,7 @@ list of \code{passes} and then run the script to test your compiler.
 \end{lstlisting}
 \end{lstlisting}
 \fi}
 \fi}
 {\if\edition\pythonEd\pythonColor
 {\if\edition\pythonEd\pythonColor
-Run the \code{run-tests.py} script to to check
+Run the \code{run-tests.py} script to check
 whether the output programs produce the same result as the input
 whether the output programs produce the same result as the input
 programs.
 programs.
 \fi}
 \fi}
@@ -4038,7 +4038,7 @@ list of \code{passes} and then run the script to test your compiler.
 \end{lstlisting}
 \end{lstlisting}
 \fi}
 \fi}
 {\if\edition\pythonEd\pythonColor
 {\if\edition\pythonEd\pythonColor
-Run the \code{run-tests.py} script to to check
+Run the \code{run-tests.py} script to check
 whether the output programs produce the same result as the input
 whether the output programs produce the same result as the input
 programs.
 programs.
 \fi}
 \fi}
@@ -4062,8 +4062,9 @@ all labels (for example, changing \key{main} to \key{\_main}).
   returns \code{'macosx}, \code{'unix}, or \code{'windows}.}
   returns \code{'macosx}, \code{'unix}, or \code{'windows}.}
 %
 %
 \python{The Python \code{platform} library includes a \code{system()}
 \python{The Python \code{platform} library includes a \code{system()}
-  function that returns \code{'Linux'}, \code{'Windows'}, or
-  \code{'Darwin'} (for Mac).}
+  function that returns \code{\textquotesingle Linux\textquotesingle},
+  \code{\textquotesingle Windows\textquotesingle}, or
+  \code{\textquotesingle Darwin\textquotesingle} (for Mac).}
 
 
 \begin{exercise}\normalfont\normalsize
 \begin{exercise}\normalfont\normalsize
 %
 %
@@ -4088,7 +4089,7 @@ the provided \key{runtime.c} file to \key{runtime.o} using
 \fi}
 \fi}
 {\if\edition\pythonEd\pythonColor
 {\if\edition\pythonEd\pythonColor
 %
 %
-Run the \code{run-tests.py} script to to check whether the output
+Run the \code{run-tests.py} script to check whether the output
 programs produce the same result as the input programs. That script
 programs produce the same result as the input programs. That script
 translates the x86 AST that you produce into a string by invoking the
 translates the x86 AST that you produce into a string by invoking the
 \code{repr} method that is implemented by the x86 AST classes in
 \code{repr} method that is implemented by the x86 AST classes in
@@ -6656,7 +6657,7 @@ Run the script to test the register allocator.
 \fi}
 \fi}
 %
 %
 {\if\edition\pythonEd\pythonColor      
 {\if\edition\pythonEd\pythonColor      
-Run the \code{run-tests.py} script to to check whether the
+Run the \code{run-tests.py} script to check whether the
 output programs produce the same result as the input programs.
 output programs produce the same result as the input programs.
 \fi}
 \fi}
 \end{exercise}
 \end{exercise}

+ 2 - 2
defs.tex

@@ -116,9 +116,9 @@
 \newcommand{\Var}{\itm{var}}
 \newcommand{\Var}{\itm{var}}
 \newcommand{\Op}{\itm{op}}
 \newcommand{\Op}{\itm{op}}
 \newcommand{\key}[1]{\texttt{#1}}
 \newcommand{\key}[1]{\texttt{#1}}
-\newcommand{\skey}[1]{\texttt{'#1'}}
+\newcommand{\skey}[1]{\texttt{\textquotesingle #1\textquotesingle}}
 \newcommand{\code}[1]{\texttt{#1}}
 \newcommand{\code}[1]{\texttt{#1}}
-\newcommand{\scode}[1]{\texttt{'#1'}}
+\newcommand{\scode}[1]{\texttt{\textquotesingle #1\textquotesingle}}
 
 
 \newcommand{\LP}{\key{(}}
 \newcommand{\LP}{\key{(}}
 \newcommand{\RP}{\key{)}}
 \newcommand{\RP}{\key{)}}