Browse Source

defining syntax for R_4 and R_5 (functions and lambdas)

Jeremy Siek 9 years ago
parent
commit
708379914b
2 changed files with 44 additions and 5 deletions
  1. 42 5
      book.tex
  2. 2 0
      defs.tex

+ 42 - 5
book.tex

@@ -2956,6 +2956,8 @@ the element at index $0$ of the 1-tuple.
         44)))
 \end{lstlisting}
 
+\marginpar{\scriptsize To do: interpreter for $R_3$ \\ --Jeremy}
+
 \begin{figure}[tbp]
 \centering
 \fbox{
@@ -2975,11 +2977,9 @@ the element at index $0$ of the 1-tuple.
 \label{fig:r3-syntax}
 \end{figure}
 
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\chapter{Garbage Collection}
-\label{ch:gc}
+\[
+  \Type ::= \ldots \mid (\key{Vector}\;\Type^{+}) 
+\]
 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -2987,10 +2987,47 @@ the element at index $0$ of the 1-tuple.
 \label{ch:functions}
 
 
+\begin{figure}[tbp]
+\centering
+\fbox{
+\begin{minipage}{0.96\textwidth}
+\[
+\begin{array}{lcl}
+  \Type &::=& \ldots \mid (\Type^{*} \; \key{->}\; \Type) \\
+  \Exp &::=& \ldots \mid (\Exp \; \Exp^{*}) \\
+  \Def &::=& (\key{define}\; (\Var \; [\Var \key{:} \Type]^{*} \key{:} \Type \; \Exp)) \\
+  R_4 &::=& (\key{program} \; \Def^{*} \; \Exp)
+\end{array}
+\]
+\end{minipage}
+}
+\caption{The $R_4$ language, an extension of $R_3$
+  (Figure~\ref{fig:r3-syntax}).}
+\label{fig:r4-syntax}
+\end{figure}
+
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \chapter{Lexically Scoped Functions}
 \label{ch:lambdas}
 
+\begin{figure}[tbp]
+\centering
+\fbox{
+\begin{minipage}{0.96\textwidth}
+\[
+\begin{array}{lcl}
+  \Exp &::=& \ldots \mid (\key{lambda:}\; ([\Var \key{:} \Type]^{*} \key{:} \Type \; \Exp)) \\
+  R_5 &::=& (\key{program} \; \Def^{*} \; \Exp)
+\end{array}
+\]
+\end{minipage}
+}
+\caption{The $R_5$ language, an extension of $R_4$
+  (Figure~\ref{fig:r4-syntax}).}
+\label{fig:r5-syntax}
+\end{figure}
+
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %\chapter{Mutable Data}

+ 2 - 0
defs.tex

@@ -3,6 +3,8 @@
 \newcommand{\itm}[1]{\ensuremath{\mathit{#1}}}
 \newcommand{\Stmt}{\itm{stmt}}
 \newcommand{\Exp}{\itm{exp}}
+\newcommand{\Def}{\itm{def}}
+\newcommand{\Type}{\itm{type}}
 \newcommand{\Instr}{\itm{instr}}
 \newcommand{\Prog}{\itm{prog}}
 \newcommand{\Arg}{\itm{arg}}