|
@@ -514,19 +514,19 @@ definition for integer constants.
|
|
|
(struct Int (value))
|
|
|
\end{lstlisting}
|
|
|
An integer node includes just one thing: the integer value.
|
|
|
-To create a AST node for the integer $8$, we write \code{(Int 8)}.
|
|
|
+To create an AST node for the integer $8$, we write \code{(Int 8)}.
|
|
|
\begin{lstlisting}
|
|
|
(define eight (Int 8))
|
|
|
\end{lstlisting}
|
|
|
We say that the value created by \code{(Int 8)} is an
|
|
|
\emph{instance} of the \code{Int} structure.
|
|
|
|
|
|
-The following is the \code{struct} definition for primitives operations.
|
|
|
+The following is the \code{struct} definition for primitive operations.
|
|
|
\begin{lstlisting}
|
|
|
(struct Prim (op args))
|
|
|
\end{lstlisting}
|
|
|
A primitive operation node includes an operator symbol \code{op}
|
|
|
-and a list of children \code{args}. For example, to create
|
|
|
+and a list of child \code{args}. For example, to create
|
|
|
an AST that negates the number $8$, we write \code{(Prim '- (list eight))}.
|
|
|
\begin{lstlisting}
|
|
|
(define neg-eight (Prim '- (list eight)))
|
|
@@ -599,7 +599,7 @@ left-hand-side.
|
|
|
A name such as $\Exp$ that is defined by the grammar rules is a
|
|
|
\emph{non-terminal}. \index{non-terminal}
|
|
|
%
|
|
|
-The name $\Int$ is a also a non-terminal, but instead of defining it
|
|
|
+The name $\Int$ is also a non-terminal, but instead of defining it
|
|
|
with a grammar rule, we define it with the following explanation. We
|
|
|
make the simplifying design decision that all of the languages in this
|
|
|
book only handle machine-representable integers. On most modern
|
|
@@ -844,7 +844,7 @@ it is defined using a sequence of match clauses that correspond to a
|
|
|
grammar, and the body of each clause makes a recursive call on each
|
|
|
child node.\footnote{This principle of structuring code according to
|
|
|
the data definition is advocated in the book \emph{How to Design
|
|
|
- Programs} \url{http://www.ccs.neu.edu/home/matthias/HtDP2e/}.}.
|
|
|
+ Programs} \url{https://htdp.org/2020-8-1/Book/index.html}.}.
|
|
|
Below we also define a second function, named \code{Rint?}, that
|
|
|
determines whether an AST is an \LangInt{} program. In general we can
|
|
|
expect to write one recursive function to handle each non-terminal in
|