diff --git a/book.tex b/book.tex index 1db2d39..8bc4636 100644 --- a/book.tex +++ b/book.tex @@ -512,7 +512,7 @@ \section{Pattern Matching} \emph{construct} ASTs, however, the similarity is intentional: constructing and deconstructing ASTs uses similar syntax. % -While the pattern uses a restricted syntax, +While the pattern uses a restricted syntax, the body of the match clause may contain any Racket code whatsoever. @@ -584,9 +584,9 @@ \section{Recursion} [`(read) #t] [`(- ,e) (exp? e)] [`(+ ,e1 ,e2) - (and (exp? e1) (exp? e2))])) + (and (exp? e1) (exp? e2))])) (match sexp - [`(program ,e) (exp? e)] + [`(program ,e) (exp? e)] [else #f])) (R0? `(+ (read) (- 8))) @@ -598,7 +598,7 @@ \section{Recursion} \begin{lstlisting} - + @@ -659,7 +659,7 @@ \section{Interpreters} second example of structural recursion. The \texttt{interp-R0} function is defined in Figure~\ref{fig:interp-R0}. The body of the function is a match on the input program \texttt{p} and -then a call to the \lstinline{exp} helper function, which in turn has +then a call to the \lstinline{exp} helper function, which in turn has one match clause per grammar rule for $R_0$ expressions. The \lstinline{exp} function is naturally recursive: clauses for internal AST @@ -1268,7 +1268,7 @@ \section{The x86 Assembly Language} (\key{subq} \; \Arg\; \Arg) \mid (\key{movq} \; \Arg\; \Arg) \mid (\key{retq})\\ - &\mid& (\key{negq} \; \Arg) \mid + &\mid& (\key{negq} \; \Arg) \mid (\key{callq} \; \mathit{label}) \mid (\key{pushq}\;\Arg) \mid (\key{popq}\;\Arg) \\ @@ -4912,7 +4912,7 @@ \subsection{Print x86} stack in the prelude of \code{main}. In Figure~\ref{fig:print-x86-output-gc}, the instruction % -\lstinline{movq $0, (%r15)} +\lstinline{movq $0, (%r15)} % accomplishes this task. The garbage collector tests each root to see if it is null prior to dereferencing it. @@ -6691,11 +6691,12 @@ \subsection{Graphs} \subsection{Testing} The \key{interp-tests} function takes a compiler name (a string), a -description of the passes, an interpreter for the source language, a -test family name (a string), and a list of test numbers, and runs the -compiler passes and the interpreters to check whether the passes -correct. The description of the passes is a list with one entry per -pass. An entry is a list with three things: a string giving the name +typechecker (see the comment for check-passes), a description of the +passes, an interpreter for the source language, a test family name +(a string), and a list of test numbers, and runs the compiler passes +and the interpreters to check whether the passes correct. +The description of the passes is a list with one entry per pass. +An entry is a list with three things: a string giving the name of the pass, the function that implements the pass (a translator from AST to AST), and a function that implements the interpreter (a function from AST to result value) for the language of the output of @@ -6707,17 +6708,18 @@ \subsection{Testing} is a file with the same number except that it ends with \key{.in} that provides the input for the Scheme program. \begin{lstlisting} -(define (interp-tests name passes test-family test-nums) ... +(define (interp-tests name typechecker passes test-family test-nums) ... \end{lstlisting} -The compiler-tests function takes a compiler name (a string) a -description of the passes (see the comment for \key{interp-tests}) a -test family name (a string), and a list of test numbers (see the -comment for interp-tests), and runs the compiler to generate x86 (a -\key{.s} file) and then runs gcc to generate machine code. It runs -the machine code and checks that the output is 42. +The compiler-tests function takes a compiler name (a string), a +typechecker (see the comment for check-passes) a description of +the passes (ditto), a description of the passes (see the comment for +\key{interp-tests}), a test family name (a string), and a list of +test numbers (see the comment for interp-tests), and runs the compiler +to generate x86 (a \key{.s} file) and then runs gcc to generate +machine code. It runs the machine code and checks that the output is 42. \begin{lstlisting} -(define (compiler-tests name passes test-family test-nums) ...) +(define (compiler-tests name typechecker passes test-family test-nums) ...) \end{lstlisting} The compile-file function takes a description of the compiler passes