Skip to content

Commit

Permalink
fix racket version
Browse files Browse the repository at this point in the history
  • Loading branch information
jsiek committed Sep 19, 2024
1 parent 8710658 commit 9935155
Showing 1 changed file with 61 additions and 19 deletions.
80 changes: 61 additions & 19 deletions book.tex
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

\def\racketEd{0}
\def\pythonEd{1}
\def\edition{1}
\def\edition{0}

% material that is specific to the Racket edition of the book
\newcommand{\racket}[1]{{\if\edition\racketEd{#1}\fi}}
Expand Down Expand Up @@ -2488,8 +2488,7 @@ \section{The \LangXInt{} Assembly Language}
\MID \key{r11} \MID \key{r12} \MID \key{r13}
\MID \key{r14} \MID \key{r15}}

\newcommand{\GrammarXInt}{
\if\edition\racketEd
\newcommand{\GrammarXIntRacket}{
\begin{array}{rcl}
\Reg &::=& \allregisters{} \\
\Arg &::=& \key{\$}\Int \MID \key{\%}\Reg \MID \Int\key{(}\key{\%}\Reg\key{)}\\
Expand All @@ -2502,8 +2501,9 @@ \section{The \LangXInt{} Assembly Language}
\key{jmp}\,\itm{label} \MID \\
&& \itm{label}\key{:}\; \Instr
\end{array}
\fi
\if\edition\pythonEd\pythonColor
}

\newcommand{\GrammarXIntPython}{
% no jmp and label in the python version
\begin{array}{rcl}
\Reg &::=& \allregisters{} \\
Expand All @@ -2514,15 +2514,14 @@ \section{The \LangXInt{} Assembly Language}
&& \key{pushq}\;\Arg \MID \key{popq}\;\Arg \MID
\key{callq} \; \mathit{label} \MID \key{retq}
\end{array}
\fi
}

\begin{figure}[tp]
\begin{tcolorbox}[colback=white]
{\if\edition\racketEd
\[
\begin{array}{l}
\GrammarXInt \\
\GrammarXIntRacket \\
\begin{array}{lcl}
\LangXIntM{} &::= & \key{.globl main}\\
& & \key{main:} \; \Instr\ldots
Expand Down Expand Up @@ -8667,8 +8666,7 @@ \section{The \LangXIf{} Language}
\end{array}
\]

\newcommand{\GrammarXIf}{
\if\edition\racketEd
\newcommand{\GrammarXIfRacket}{
\begin{array}{lcl}
\itm{bytereg} &::=& \key{ah} \MID \key{al} \MID \key{bh} \MID \key{bl}
\MID \key{ch} \MID \key{cl} \MID \key{dh} \MID \key{dl} \\
Expand All @@ -8680,8 +8678,9 @@ \section{The \LangXIf{} Language}
\MID \key{movzbq}~\Arg\key{,}~\Arg \\
&\MID& \key{j}cc~\itm{label} \\
\end{array}
\fi
\if\edition\pythonEd\pythonColor
}

\newcommand{\GrammarXIfPython}{
\begin{array}{lcl}
\itm{bytereg} &::=& \key{ah} \MID \key{al} \MID \key{bh} \MID \key{bl}
\MID \key{ch} \MID \key{cl} \MID \key{dh} \MID \key{dl} \\
Expand All @@ -8694,22 +8693,35 @@ \section{The \LangXIf{} Language}
&\MID& \key{jmp}\,\itm{label} \MID \key{j}cc~\itm{label}
\MID \itm{label}\key{:}\; \Instr
\end{array}
\fi
}


\begin{figure}[tp]
\begin{tcolorbox}[colback=white]
\begin{tcolorbox}[colback=white]
{\if\edition\racketEd
\[
\begin{array}{l}
\gray{\GrammarXInt} \\ \hline
\GrammarXIf \\
\gray{\GrammarXIntRacket} \\ \hline
\GrammarXIfRacket \\
\begin{array}{lcl}
\LangXIfM{} &::= & \key{.globl main} \\
& & \key{main:} \; \Instr\ldots
\end{array}
\end{array}
\]
}
{\if\edition\pythonEd
\[
\begin{array}{l}
\gray{\GrammarXIntPython} \\ \hline
\GrammarXIfPython \\
\begin{array}{lcl}
\LangXIfM{} &::= & \key{.globl main} \\
& & \key{main:} \; \Instr\ldots
\end{array}
\end{array}
\]
\fi}
\end{tcolorbox}
\caption{The concrete syntax of \LangXIf{} (extends \LangXInt{} of figure~\ref{fig:x86-int-concrete}).}
\label{fig:x86-1-concrete}
Expand Down Expand Up @@ -13518,17 +13530,32 @@ \section{Select Instructions and the \LangXGlobal{} Language}

\begin{figure}[tp]
\begin{tcolorbox}[colback=white]
{\if\edition\racketEd
\[
\begin{array}{l}
\gray{\GrammarXInt} \\ \hline
\gray{\GrammarXIf} \\ \hline
\gray{\GrammarXIntRacket} \\ \hline
\gray{\GrammarXIfRacket} \\ \hline
\GrammarXGlobal \\
\begin{array}{lcl}
\LangXGlobalM{} &::= & \key{.globl main} \\
& & \key{main:} \; \Instr^{*}
\end{array}
\end{array}
\]
\fi}
{\if\edition\pythonEd\pythonColor
\[
\begin{array}{l}
\gray{\GrammarXIntPython} \\ \hline
\gray{\GrammarXIfPython} \\ \hline
\GrammarXGlobal \\
\begin{array}{lcl}
\LangXGlobalM{} &::= & \key{.globl main} \\
& & \key{main:} \; \Instr^{*}
\end{array}
\end{array}
\]
\fi}
\end{tcolorbox}
\caption{The concrete syntax of \LangXGlobal{} (extends \LangXIf{} shown in figure~\ref{fig:x86-1-concrete}).}
\label{fig:x86-2-concrete}
Expand Down Expand Up @@ -16090,17 +16117,32 @@ \section{Select Instructions and the \LangXIndCall{} Language}
\begin{figure}[tp]
\begin{tcolorbox}[colback=white]
\small
{\if\edition\racketEd
\[
\begin{array}{l}
\gray{\GrammarXInt} \\ \hline
\gray{\GrammarXIf} \\ \hline
\gray{\GrammarXIntRacket} \\ \hline
\gray{\GrammarXIfRacket} \\ \hline
\gray{\GrammarXGlobal} \\ \hline
\GrammarXIndCall \\
\begin{array}{lcl}
\LangXIndCallM{} &::= & \Def^{*}
\end{array}
\end{array}
\]
\fi}
{\if\edition\pythonEd
\[
\begin{array}{l}
\gray{\GrammarXIntPython} \\ \hline
\gray{\GrammarXIfPython} \\ \hline
\gray{\GrammarXGlobal} \\ \hline
\GrammarXIndCall \\
\begin{array}{lcl}
\LangXIndCallM{} &::= & \Def^{*}
\end{array}
\end{array}
\]
\fi}
\end{tcolorbox}

\caption{The concrete syntax of \LangXIndCall{} (extends \LangXGlobal{} of figure~\ref{fig:x86-2-concrete}).}
Expand Down

0 comments on commit 9935155

Please sign in to comment.