diff -r e8ac05fe2630 -r fa2589ec0fae slides/slides09.tex --- a/slides/slides09.tex Tue Nov 17 15:03:08 2015 +0000 +++ b/slides/slides09.tex Tue Nov 17 19:12:51 2015 +0000 @@ -3,6 +3,7 @@ \usepackage{../langs} \usepackage{../data} \usepackage{../graphics} +\usepackage{../grammar} \usepackage{soul} \tikzset{onslide/.code args={<#1>#2}{% @@ -17,7 +18,7 @@ \newcommand<>\btHL[1][]{% \only#2{\begin{btHighlight}[#1]\bgroup\aftergroup\bt@HL@endenv}% } -\def\bt@HL@endenv{% +\def\bt@HL@endenv{%b jm \end{btHighlight}% \egroup } @@ -30,6 +31,7 @@ } \makeatother +\lstset{morekeywords={def,if,then,else,write,read},keywordstyle=\color{codepurple}\bfseries} % beamer stuff \renewcommand{\slidecaption}{AFL 09, King's College London} @@ -65,7 +67,6 @@ \footnotesize \begin{textblock}{13}(0.9,3) -\lstset{emph={def,if,then,else},emphstyle=\color{codepurple}} \begin{lstlisting}[basicstyle=\ttfamily, numbers=none] def fib(n) = if n == 0 then 0 else if n == 1 then 1 @@ -85,30 +86,29 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\mode{ \begin{frame}[c] - -\begin{center} -\bl{\begin{tabular}{@{}lcl@{}} -\textit{Exp} & $\rightarrow$ & \textit{Var} $|$ \textit{Num}\\ - & $|$ & \textit{Exp} \texttt{+} \textit{Exp} $|$ ... $|$ ( \textit{Exp} )\\ - & $|$ & \texttt{if}\; \textit{BExp} \;\texttt{then}\; \textit{Exp} \;\texttt{else}\; \textit{Exp}\\ - & $|$ & \texttt{write}\;\textit{Exp}\\ - & $|$ & \textit{Exp}\;\texttt{;}\;\textit{Exp}\\ - & $|$ & \textit{FunName} \texttt{(}\textit{Exp},...,\textit{Exp}\texttt{)}\medskip\\ -\textit{BExp} & $\rightarrow$ & \ldots\medskip\\ -\textit{Decl} & $\rightarrow$ & \textit{Def} \;\texttt{;}\; \textit{Decl}\\ - & $|$ & \textit{Exp}\medskip\\ -\textit{Def} & -$\rightarrow$ & \texttt{def} \textit{FunName}\texttt{(}\textit{x}$_1$,..., \textit{x}$_n$\texttt{)} \texttt{=} \textit{Exp}\\ -\end{tabular}} -\end{center} +\frametitle{Fun Grammar} +\bl{ +\begin{plstx}[rhs style=] +: \meta{Exp} ::= \meta{Var} | \meta{Num}{\hspace{3cm}} + | \meta{Exp} + \meta{Exp} | ... | (\meta{ExP}) + | \code{if} \meta{BExp} \code{then} \meta{Exp} \code{else} \meta{Exp} + | \code{write} \meta{Exp} {\hspace{3cm}} + | \meta{Exp} ; \meta{Exp} + | \textit{FunName} (\meta{Exp}, ..., \meta{Exp})\\ +: \meta{BExp} ::= ...\\ +: \meta{Decl} ::= \meta{Def} ; \meta{Decl} + | \meta{Exp}\\ +: \meta{Def} ::= \code{def} \textit{FunName} ($\hspace{0.4mm}x_1$, ..., $x_2$)\\ +\end{plstx}} -\end{frame}} + +\end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}[c, fragile] \frametitle{Abstract Syntax Tree}