slides/slides06.tex
changeset 295 19f23c4c2167
parent 215 828303e8e4af
child 365 9b71dead1219
equal deleted inserted replaced
294:c29853b672fb 295:19f23c4c2167
     1 \documentclass[dvipsnames,14pt,t]{beamer}
     1 \documentclass[dvipsnames,14pt,t]{beamer}
     2 \usepackage{beamerthemeplaincu}
     2 \usepackage{../slides}
     3 \usepackage[absolute,overlay]{textpos}
     3 \usepackage{../graphics}
     4 \usepackage{ifthen}
       
     5 \usepackage{tikz}
       
     6 \usepackage{pgf}
       
     7 \usepackage{calc} 
       
     8 \usepackage{ulem}
       
     9 \usepackage{courier}
       
    10 \usepackage{listings}
       
    11 \renewcommand{\uline}[1]{#1}
       
    12 \usetikzlibrary{arrows}
       
    13 \usetikzlibrary{automata}
       
    14 \usetikzlibrary{shapes}
       
    15 \usetikzlibrary{shadows}
       
    16 \usetikzlibrary{positioning}
       
    17 \usetikzlibrary{calc}
       
    18 \usetikzlibrary{plotmarks}
       
    19 \usepackage{graphicx} 
       
    20 \usepackage{../langs}
     4 \usepackage{../langs}
    21 \usepackage{../data}
     5 \usepackage{../data}
    22 
     6 \usepackage{../grammar}
    23 
     7 
    24 \makeatletter
     8 \hfuzz=220pt 
    25 \lst@CCPutMacro\lst@ProcessOther {"2D}{\lst@ttfamily{-{}}{-{}}}
     9 
    26 \@empty\z@\@empty
    10 \pgfplotsset{compat=1.11}
    27 \makeatother
    11 
    28 
    12 \newcommand{\bl}[1]{\textcolor{blue}{#1}}  
    29 
    13 
    30 % beamer stuff 
    14 % beamer stuff 
    31 \renewcommand{\slidecaption}{AFL 06, King's College London, 30.~October 2013}
    15 \renewcommand{\slidecaption}{AFL 06, King's College London}
    32 \newcommand{\bl}[1]{\textcolor{blue}{#1}}       
       
    33 \newcommand{\dn}{\stackrel{\mbox{\scriptsize def}}{=}}% for definitions
       
    34 
    16 
    35 \begin{document}
    17 \begin{document}
    36 
    18 
       
    19 
       
    20 
    37 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    21 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    38 \mode<presentation>{
    22 \begin{frame}[t]
    39 \begin{frame}<1>[t]
       
    40 \frametitle{%
    23 \frametitle{%
    41   \begin{tabular}{@ {}c@ {}}
    24   \begin{tabular}{@ {}c@ {}}
    42   \\[-3mm]
    25   \\[-3mm]
    43   \LARGE Automata and \\[-2mm] 
    26   \LARGE Automata and \\[-2mm] 
    44   \LARGE Formal Languages (6)\\[3mm] 
    27   \LARGE Formal Languages (6)\\[3mm] 
    51   Office: & S1.27 (1st floor Strand Building)\\
    34   Office: & S1.27 (1st floor Strand Building)\\
    52   Slides: & KEATS (also home work is there)\\
    35   Slides: & KEATS (also home work is there)\\
    53   \end{tabular}
    36   \end{tabular}
    54   \end{center}
    37   \end{center}
    55 
    38 
    56 
    39 \end{frame}
    57 \end{frame}}
    40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
    58  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
    41 
    59 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    42 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    60 \mode<presentation>{
    43 \begin{frame}[c]
    61 \begin{frame}[c]
    44 \frametitle{Regular Languages}
    62 \frametitle{\begin{tabular}{c}Regular Languages\end{tabular}}
    45 
    63 
    46 While regular expressions are very useful for lexing, there is
    64 While regular expressions are very useful for lexing, 
    47 no regular expression that can recognise the language
    65 there is no regular expression that can recognise the language \bl{$a^nb^n$}.\bigskip
    48 \bl{$a^nb^n$}.\bigskip
    66 
    49 
    67 \begin{center}
    50 \begin{center}
    68 \bl{$(((()()))())$} \;\;vs.\;\; \bl{$(((()()))()))$}
    51 \bl{$(((()()))())$} \;\;vs.\;\; \bl{$(((()()))()))$}
    69 \end{center}
    52 \end{center}\bigskip\bigskip
    70 
    53 
    71 
    54 \small
    72 \end{frame}}
    55 \noindent So we cannot find out with regular expressions
    73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
    56 whether parentheses are matched or unmatched.
    74 
    57 
    75 
    58 \end{frame}
    76 \newcommand{\qq}{\mbox{\texttt{"}}}
    59 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
    77 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    60 
    78 \mode<presentation>{
    61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    79 \begin{frame}[c]
    62 \begin{frame}[c]
    80 \frametitle{\begin{tabular}{c}Grammars\end{tabular}}
    63 \frametitle{Hierarchy of Languages}
       
    64 
       
    65 \begin{center}
       
    66 \begin{tikzpicture}
       
    67 [rect/.style={draw=black!50, 
       
    68               top color=white,
       
    69               bottom color=black!20, 
       
    70               rectangle, 
       
    71               very thick, 
       
    72               rounded corners}]
       
    73 
       
    74 \draw (0,0) node [rect, text depth=39mm, text width=68mm] {all languages};
       
    75 \draw (0,-0.4) node [rect, text depth=28.5mm, text width=64mm] {decidable languages};
       
    76 \draw (0,-0.85) node [rect, text depth=17mm] {context sensitive languages};
       
    77 \draw (0,-1.14) node [rect, text depth=9mm, text width=50mm] {context-free languages};
       
    78 \draw (0,-1.4) node [rect] {regular languages};
       
    79 \end{tikzpicture}
       
    80 
       
    81 \end{center}
       
    82 
       
    83 \end{frame}
       
    84 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
       
    85 
       
    86 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
    87 \begin{frame}[c]
       
    88 \frametitle{Grammars}
    81 
    89 
    82 A (context-free) grammar \bl{$G$} consists of
    90 A (context-free) grammar \bl{$G$} consists of
    83 
    91 
    84 \begin{itemize}
    92 \begin{itemize}
    85 \item a finite set of nonterminal symbols (upper case)
    93 \item a finite set of nonterminal symbols (upper case)
    97 \begin{center}
   105 \begin{center}
    98 \bl{$A \rightarrow \text{rhs}_1 | \text{rhs}_2 | \ldots$}
   106 \bl{$A \rightarrow \text{rhs}_1 | \text{rhs}_2 | \ldots$}
    99 \end{center}
   107 \end{center}
   100 \end{itemize}
   108 \end{itemize}
   101 
   109 
   102 
   110 \end{frame}
   103 \end{frame}}
   111 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   112 
   105 
   113 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   106 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   114 \begin{frame}[c]
   107 \mode<presentation>{
   115 \frametitle{Palindromes}
   108 \begin{frame}[c]
   116 
   109 \frametitle{\begin{tabular}{c}Palindromes\end{tabular}}
   117 A grammar for palindromes over the alphabet~\bl{$\{a,b\}$}:
   110 
   118 
   111 \begin{center}
   119 \begin{center}
   112 \bl{\begin{tabular}{lcl}
   120 \bl{\begin{tabular}{lcl}
   113 $S$ & $\rightarrow$ &  $\epsilon$ \\
   121 $S$ & $\rightarrow$ &  $\epsilon$ \\
   114 $S$ & $\rightarrow$ &  $a\cdot S\cdot a$ \\
   122 $S$ & $\rightarrow$ &  $a\cdot S\cdot a$ \\
   120 
   128 
   121 \begin{center}
   129 \begin{center}
   122 \bl{\begin{tabular}{lcl}
   130 \bl{\begin{tabular}{lcl}
   123 $S$ & $\rightarrow$ &  $\epsilon \;|\; a\cdot S\cdot a \;|\;b\cdot S\cdot b$ \\
   131 $S$ & $\rightarrow$ &  $\epsilon \;|\; a\cdot S\cdot a \;|\;b\cdot S\cdot b$ \\
   124 \end{tabular}}
   132 \end{tabular}}
   125 \end{center}
   133 \end{center}\pause\bigskip
   126 
   134 
   127 
   135 \small
   128 \end{frame}}
   136 Can you find the grammar rules for matched parentheses?
   129 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   137 
   130 
   138 \end{frame}
   131 
   139 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   132 
   140 
   133 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   141 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   134 \mode<presentation>{
   142 \begin{frame}[c]
   135 \begin{frame}[c]
   143 \frametitle{Arithmetic Expressions}
   136 \frametitle{\begin{tabular}{c}Arithmetic Expressions\end{tabular}}
       
   137 
   144 
   138 \begin{center}
   145 \begin{center}
   139 \bl{\begin{tabular}{lcl}
   146 \bl{\begin{tabular}{lcl}
   140 $E$ & $\rightarrow$ &  $num\_token$ \\
   147 $E$ & $\rightarrow$ &  $num\_token$ \\
   141 $E$ & $\rightarrow$ &  $E \cdot + \cdot E$ \\
   148 $E$ & $\rightarrow$ &  $E \cdot + \cdot E$ \\
   145 \end{tabular}}
   152 \end{tabular}}
   146 \end{center}\pause
   153 \end{center}\pause
   147 
   154 
   148 \bl{\texttt{1 + 2 * 3 + 4}}
   155 \bl{\texttt{1 + 2 * 3 + 4}}
   149 
   156 
   150 \end{frame}}
   157 \end{frame}
   151 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   158 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   152 
   159 
   153 
   160 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   154 
   161 \begin{frame}[c]
   155 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   162 \frametitle{A CFG Derivation}
   156 \mode<presentation>{
       
   157 \begin{frame}[c]
       
   158 \frametitle{\begin{tabular}{c}A CFG Derivation\end{tabular}}
       
   159 
   163 
   160 \begin{enumerate}
   164 \begin{enumerate}
   161 \item Begin with a string containing only the start symbol, say \bl{$S$}\bigskip
   165 \item Begin with a string containing only the start symbol, say \bl{$S$}\bigskip
   162 \item Replace any nonterminal \bl{$X$} in the string by the
   166 \item Replace any nonterminal \bl{$X$} in the string by the
   163 right-hand side of some production \bl{$X \rightarrow \text{rhs}$}\bigskip
   167 right-hand side of some production \bl{$X \rightarrow \text{rhs}$}\bigskip
   166 
   170 
   167 \begin{center}
   171 \begin{center}
   168 \bl{$S \rightarrow \ldots \rightarrow \ldots  \rightarrow \ldots  \rightarrow \ldots $}
   172 \bl{$S \rightarrow \ldots \rightarrow \ldots  \rightarrow \ldots  \rightarrow \ldots $}
   169 \end{center}
   173 \end{center}
   170 
   174 
   171 \end{frame}}
   175 \end{frame}
   172 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
   176 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
   173   
   177   
   174 
   178 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   175 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   179 \begin{frame}[c]
   176 \mode<presentation>{
   180 \frametitle{Example Derivation}
   177 \begin{frame}[c]
       
   178 \frametitle{\begin{tabular}{c}Example Derivation\end{tabular}}
       
   179 
   181 
   180 \begin{center}
   182 \begin{center}
   181 \bl{\begin{tabular}{lcl}
   183 \bl{\begin{tabular}{lcl}
   182 $S$ & $\rightarrow$ &  $\epsilon \;|\; a\cdot S\cdot a \;|\;b\cdot S\cdot b$ \\
   184 $S$ & $\rightarrow$ &  $\epsilon \;|\; a\cdot S\cdot a \;|\;b\cdot S\cdot b$ \\
   183 \end{tabular}}
   185 \end{tabular}}
   184 \end{center}\bigskip
   186 \end{center}\bigskip
   185 
       
   186 
   187 
   187 \begin{center}
   188 \begin{center}
   188 \begin{tabular}{lcl}
   189 \begin{tabular}{lcl}
   189 \bl{$S$} & \bl{$\rightarrow$} & \bl{$aSa$}\\
   190 \bl{$S$} & \bl{$\rightarrow$} & \bl{$aSa$}\\
   190               & \bl{$\rightarrow$} & \bl{$abSba$}\\
   191               & \bl{$\rightarrow$} & \bl{$abSba$}\\
   193 
   194 
   194  
   195  
   195 \end{tabular}
   196 \end{tabular}
   196 \end{center}
   197 \end{center}
   197 
   198 
   198 \end{frame}}
   199 \end{frame}
   199 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   200 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   200 
   201 
   201 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   202 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   202 \mode<presentation>{
   203 \begin{frame}[c]
   203 \begin{frame}[c]
   204 \frametitle{Example Derivation}
   204 \frametitle{\begin{tabular}{c}Example Derivation\end{tabular}}
       
   205 
   205 
   206 \begin{center}
   206 \begin{center}
   207 \bl{\begin{tabular}{lcl}
   207 \bl{\begin{tabular}{lcl}
   208 $E$ & $\rightarrow$ &  $num\_token$ \\
   208 $E$ & $\rightarrow$ &  $num\_token$ \\
   209 $E$ & $\rightarrow$ &  $E \cdot + \cdot E$ \\
   209 $E$ & $\rightarrow$ &  $E \cdot + \cdot E$ \\
   229               & \bl{$\rightarrow^+$} & \bl{$1+2*3+4$}\\
   229               & \bl{$\rightarrow^+$} & \bl{$1+2*3+4$}\\
   230 \end{tabular}
   230 \end{tabular}
   231 \end{tabular}
   231 \end{tabular}
   232 \end{center}
   232 \end{center}
   233 
   233 
   234 \end{frame}}
   234 \end{frame}
   235 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   235 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   236 
   236 
   237 
   237 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   238 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   238 \begin{frame}[c]
   239 \mode<presentation>{
   239 \frametitle{Language of a CFG}
   240 \begin{frame}[c]
       
   241 \frametitle{\begin{tabular}{c}Language of a CFG\end{tabular}}
       
   242 
   240 
   243 Let \bl{$G$} be a context-free grammar with start symbol \bl{$S$}. 
   241 Let \bl{$G$} be a context-free grammar with start symbol \bl{$S$}. 
   244 Then the language \bl{$L(G)$} is:
   242 Then the language \bl{$L(G)$} is:
   245 
   243 
   246 \begin{center}
   244 \begin{center}
   252 \item Once generated, terminals are ``permanent''.
   250 \item Once generated, terminals are ``permanent''.
   253 \item Terminals ought to be tokens of the language\\
   251 \item Terminals ought to be tokens of the language\\
   254 (but can also be strings).
   252 (but can also be strings).
   255 \end{itemize}
   253 \end{itemize}
   256 
   254 
   257 \end{frame}}
   255 \end{frame}
   258 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   256 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   259 
   257 
   260 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   258 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   261 \mode<presentation>{
   259 \begin{frame}[c]
   262 \begin{frame}[c]
   260 \frametitle{Parse Trees}
   263 \frametitle{\begin{tabular}{c}Parse Trees\end{tabular}}
       
   264 
   261 
   265 \begin{center}
   262 \begin{center}
   266 \bl{\begin{tabular}{lcl}
   263 \bl{\begin{tabular}{lcl}
   267 $E$ & $\rightarrow$ &  $F \;|\; F \cdot * \cdot F$\\
   264 $E$ & $\rightarrow$ &  $F \;|\; F \cdot * \cdot F$\\
   268 $F$ & $\rightarrow$ & $T \;|\; T \cdot + \cdot T \;|\; T \cdot - \cdot T$\\
   265 $F$ & $\rightarrow$ & $T \;|\; T \cdot + \cdot T \;|\; T \cdot - \cdot T$\\
   297 
   294 
   298 \begin{textblock}{5}(1, 6.5)
   295 \begin{textblock}{5}(1, 6.5)
   299 \bl{\texttt{(2*3)+(3+4)}}
   296 \bl{\texttt{(2*3)+(3+4)}}
   300 \end{textblock}
   297 \end{textblock}
   301 
   298 
   302 \end{frame}}
   299 \end{frame}
   303 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   300 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   304 
   301 
   305 
   302 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   306 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   303 \begin{frame}[c]
   307 \mode<presentation>{
   304 \frametitle{Arithmetic Expressions}
   308 \begin{frame}[c]
       
   309 \frametitle{\begin{tabular}{c}Arithmetic Expressions\end{tabular}}
       
   310 
   305 
   311 \begin{center}
   306 \begin{center}
   312 \bl{\begin{tabular}{lcl}
   307 \bl{\begin{tabular}{lcl}
   313 $E$ & $\rightarrow$ &  $num\_token$ \\
   308 $E$ & $\rightarrow$ &  $num\_token$ \\
   314 $E$ & $\rightarrow$ &  $E \cdot + \cdot E$ \\
   309 $E$ & $\rightarrow$ &  $E \cdot + \cdot E$ \\
   319 \end{center}\pause\bigskip
   314 \end{center}\pause\bigskip
   320 
   315 
   321 A CFG is \alert{left-recursive} if it has a nonterminal \bl{$E$} such
   316 A CFG is \alert{left-recursive} if it has a nonterminal \bl{$E$} such
   322 that \bl{$E \rightarrow^+ E\cdot \ldots$}
   317 that \bl{$E \rightarrow^+ E\cdot \ldots$}
   323 
   318 
   324 \end{frame}}
   319 \end{frame}
   325 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   320 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   326 
   321 
   327 
   322 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   328 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   323 \begin{frame}[c]
   329 \mode<presentation>{
   324 \frametitle{Ambiguous Grammars}
   330 \begin{frame}[c]
   325 
   331 \frametitle{\begin{tabular}{c}Ambiguous Grammars\end{tabular}}
   326 A grammar is \alert{ambiguous} if there is a string that has
   332 
   327 at least two different parse trees.
   333 A grammar is \alert{ambiguous} if there is a string that has at least two different parse trees.
       
   334 
   328 
   335 
   329 
   336 \begin{center}
   330 \begin{center}
   337 \bl{\begin{tabular}{lcl}
   331 \bl{\begin{tabular}{lcl}
   338 $E$ & $\rightarrow$ &  $num\_token$ \\
   332 $E$ & $\rightarrow$ &  $num\_token$ \\
   343 \end{tabular}}
   337 \end{tabular}}
   344 \end{center}
   338 \end{center}
   345 
   339 
   346 \bl{\texttt{1 + 2 * 3 + 4}}
   340 \bl{\texttt{1 + 2 * 3 + 4}}
   347 
   341 
   348 \end{frame}}
   342 \end{frame}
   349 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   343 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   350 
   344 
   351 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   345 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   352 \mode<presentation>{
   346 \begin{frame}[c]
   353 \begin{frame}[c]
   347 \frametitle{Dangling Else}
   354 \frametitle{\begin{tabular}{c}Dangling Else\end{tabular}}
       
   355 
   348 
   356 Another ambiguous grammar:\bigskip
   349 Another ambiguous grammar:\bigskip
   357 
   350 
   358 \begin{center}
   351 \begin{center}
   359 \bl{\begin{tabular}{lcl}
   352 \bl{\begin{tabular}{lcl}
   363 \end{tabular}}
   356 \end{tabular}}
   364 \end{center}\bigskip
   357 \end{center}\bigskip
   365 
   358 
   366 \bl{\texttt{if a then if x then y else c}}
   359 \bl{\texttt{if a then if x then y else c}}
   367 
   360 
   368 \end{frame}}
   361 \end{frame}
   369 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
   362 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
   370 
   363 
   371 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   364 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   372 \mode<presentation>{
   365 \begin{frame}[c]
   373 \begin{frame}[c]
   366 \frametitle{Parser Combinators}
   374 \frametitle{\begin{tabular}{c}Parser Combinators\end{tabular}}
       
   375 
   367 
   376 Parser combinators: \bigskip
   368 Parser combinators: \bigskip
   377 
   369 
   378 \begin{minipage}{1.1\textwidth}
   370 \begin{minipage}{1.1\textwidth}
   379 \begin{center}
   371 \begin{center}
   381 $\underbrace{\text{set of (parsed input, unparsed input)}}_{\text{output}}$
   373 $\underbrace{\text{set of (parsed input, unparsed input)}}_{\text{output}}$
   382 \end{center}
   374 \end{center}
   383 \end{minipage}\bigskip
   375 \end{minipage}\bigskip
   384 
   376 
   385 \begin{itemize}
   377 \begin{itemize}
       
   378 \item atomic parsers
   386 \item sequencing
   379 \item sequencing
   387 \item alternative
   380 \item alternative
   388 \item semantic action
   381 \item semantic action
   389 \end{itemize}
   382 \end{itemize}
   390 
   383 
   391 \end{frame}}
   384 \end{frame}
   392 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   385 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   393 
   386 
   394 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   387 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   395 \mode<presentation>{
   388 \begin{frame}[c]
       
   389 
       
   390 Atomic parsers, for example, number tokens
       
   391 
       
   392 \begin{center}
       
   393 \bl{$\texttt{Num(123)}::rest \;\Rightarrow\; \{(\texttt{Num(123)}, rest)\}$} 
       
   394 \end{center}\bigskip
       
   395 
       
   396 \begin{itemize}
       
   397 \item you consume one or more token from the\\ 
       
   398   input (stream)
       
   399 \item also works for characters and strings
       
   400 \end{itemize}
       
   401 \end{frame}
       
   402 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
       
   403 
       
   404 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   396 \begin{frame}[c]
   405 \begin{frame}[c]
   397 
   406 
   398 Alternative parser (code \bl{$p\;||\;q$})\bigskip
   407 Alternative parser (code \bl{$p\;||\;q$})\bigskip
   399 
   408 
   400 \begin{itemize}
   409 \begin{itemize}
   401 \item apply \bl{$p$} and also \bl{$q$}; then combine the outputs
   410 \item apply \bl{$p$} and also \bl{$q$}; then combine 
       
   411   the outputs
   402 \end{itemize}
   412 \end{itemize}
   403 
   413 
   404 \begin{center}
   414 \begin{center}
   405 \large \bl{$p(\text{input}) \cup q(\text{input})$}
   415 \large \bl{$p(\text{input}) \cup q(\text{input})$}
   406 \end{center}
   416 \end{center}
   407 
   417 
   408 
   418 \end{frame}
   409 \end{frame}}
       
   410 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   419 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   411 
   420 
   412 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   421 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   413 \mode<presentation>{
   422 \mode<presentation>{
   414 \begin{frame}[c]
   423 \begin{frame}[c]
   416 Sequence parser (code \bl{$p\sim q$})\bigskip
   425 Sequence parser (code \bl{$p\sim q$})\bigskip
   417 
   426 
   418 \begin{itemize}
   427 \begin{itemize}
   419 \item apply first \bl{$p$} producing a set of pairs
   428 \item apply first \bl{$p$} producing a set of pairs
   420 \item then apply \bl{$q$} to the unparsed parts
   429 \item then apply \bl{$q$} to the unparsed parts
   421 \item then combine the results:\\ \mbox{}\;\;((output$_1$, output$_2$), unparsed part)
   430 \item then combine the results:\medskip 
       
   431 \begin{center}
       
   432 ((output$_1$, output$_2$), unparsed part)
       
   433 \end{center}
   422 \end{itemize}
   434 \end{itemize}
   423 
   435 
   424 \begin{center}
   436 \begin{center}
   425 \begin{tabular}{l}
   437 \begin{tabular}{l}
   426 \large \bl{$\{((o_1, o_2), u_2) \;|\;$}\\[2mm] 
   438 \large \bl{$\{((o_1, o_2), u_2) \;|\;$}\\[2mm] 
   515 
   527 
   516 \end{frame}}
   528 \end{frame}}
   517 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
   529 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
   518 
   530 
   519 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   531 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   520 \mode<presentation>{
   532 \begin{frame}[c]
   521 \begin{frame}[c]
   533 \frametitle{Input Types of Parsers}
   522 \frametitle{\begin{tabular}{c}Input Types of Parsers\end{tabular}}
   534 
   523 
   535 \begin{itemize}
   524 \begin{itemize}
   536 \item input: \alert{token list}
   525 \item input: \alert{string}
   537 \item output: set of (output\_type, \alert{token list})
   526 \item output: set of (output\_type, \alert{string})
       
   527 \end{itemize}\bigskip\pause
   538 \end{itemize}\bigskip\pause
   528 
   539 
   529 actually it can be any input type as long as it is a kind of sequence
   540 actually it can be any input type as long as it is a kind of
   530 (for example a string)
   541 sequence (for example a string)
   531 
   542 
   532 \end{frame}}
   543 \end{frame}
   533 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
   544 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
   534 
   545 
   535 
   546 
   536 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   547 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   537 \mode<presentation>{
   548 \begin{frame}[c]
   538 \begin{frame}[c]
   549 \frametitle{Scannerless Parsers}
   539 \frametitle{\begin{tabular}{c}Scannerless Parsers\end{tabular}}
       
   540 
   550 
   541 \begin{itemize}
   551 \begin{itemize}
   542 \item input: \alert{string}
   552 \item input: \alert{string}
   543 \item output: set of (output\_type, \alert{string})
   553 \item output: set of (output\_type, \alert{string})
   544 \end{itemize}\bigskip
   554 \end{itemize}\bigskip
   545 
   555 
   546 but lexers are better when whitespaces or comments need to be filtered out;
   556 but lexers are better when whitespaces or comments need to be
   547 then input is a sequence of tokens
   557 filtered out; then input is a sequence of tokens
   548 
   558 
   549 \end{frame}}
   559 \end{frame}
   550 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
   560 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
   551 
   561 
   552 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   562 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   553 \mode<presentation>{
   563 \begin{frame}[c]
   554 \begin{frame}[c]
   564 \frametitle{Successful Parses}
   555 \frametitle{\begin{tabular}{c}Successful Parses\end{tabular}}
       
   556 
   565 
   557 \begin{itemize}
   566 \begin{itemize}
   558 \item input: string
   567 \item input: string
   559 \item output: \alert{set of} (output\_type, string)
   568 \item output: \alert{set of} (output\_type, string)
   560 \end{itemize}\bigskip
   569 \end{itemize}\bigskip
   561 
   570 
   562 a parse is successful whenever the input has been
   571 a parse is successful whenever the input has been fully
   563 fully ``consumed'' (that is the second component is empty)
   572 ``consumed'' (that is the second component is empty)
   564 
   573 
   565 
   574 \end{frame}
   566 \end{frame}}
       
   567 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
   575 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
   568 
   576 
   569 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   577 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   570 \mode<presentation>{
       
   571 \begin{frame}[c]
   578 \begin{frame}[c]
   572 \frametitle{Abstract Parser Class}
   579 \frametitle{Abstract Parser Class}
   573 
   580 
   574 \mbox{\lstset{language=Scala}\fontsize{10}{12}\selectfont
   581 \small
   575 \texttt{\lstinputlisting{../progs/app7.scala}}}
   582 \lstinputlisting[language=Scala,xleftmargin=1mm]{../progs/app7.scala}
   576 \end{frame}}
   583 \end{frame}
   577 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
   584 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
   578 
   585 
   579 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   586 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   580 \mode<presentation>{
   587 \begin{frame}[c]
   581 \begin{frame}[c]
   588 
   582 {\lstset{language=Scala}\fontsize{10}{12}\selectfont
   589 \small
   583 \texttt{\lstinputlisting{../progs/app8.scala}}}
   590 \fontsize{10}{12}\selectfont
   584 \end{frame}}
   591 \lstinputlisting[language=Scala,xleftmargin=1mm]{../progs/app8.scala}
       
   592 \end{frame}
   585 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
   593 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
   586 
   594 
   587 
   595 
   588 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   596 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   589 \mode<presentation>{
   597 \begin{frame}[c]
   590 \begin{frame}[c]
   598 \frametitle{Two Grammars}
   591 \frametitle{\begin{tabular}{c}Two Grammars\end{tabular}}
       
   592 
   599 
   593 Which languages are recognised by the following two grammars?
   600 Which languages are recognised by the following two grammars?
   594 
   601 
   595 \begin{center}
   602 \begin{center}
   596 \bl{\begin{tabular}{lcl}
   603 \bl{\begin{tabular}{lcl}
   604 $U$ & $\rightarrow$ &  $1 \cdot U$\\
   611 $U$ & $\rightarrow$ &  $1 \cdot U$\\
   605         & $|$ & $\epsilon$
   612         & $|$ & $\epsilon$
   606 \end{tabular}}
   613 \end{tabular}}
   607 \end{center}
   614 \end{center}
   608 
   615 
   609 \end{frame}}
   616 \end{frame}
   610 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   617 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   611 
   618 
   612 
   619 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   613 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   614 \mode<presentation>{
       
   615 \begin{frame}[t]
   620 \begin{frame}[t]
   616 \frametitle{\begin{tabular}{c}Ambiguous Grammars\end{tabular}}
   621 \frametitle{Ambiguous Grammars}
   617 
   622 
   618 \mbox{}\\[-25mm]\mbox{}
   623 \begin{center}
   619 
   624 \begin{tikzpicture}
   620 \begin{center}
   625 \begin{axis}[xlabel={\pcode{1}s},ylabel={time in secs},
   621 \begin{tikzpicture}[y=.2cm, x=.009cm]
   626     enlargelimits=false,
   622  	%axis
   627     xtick={0,100,...,1000},
   623 	\draw (0,0) -- coordinate (x axis mid) (1000,0);
   628     xmax=1050,
   624     	\draw (0,0) -- coordinate (y axis mid) (0,30);
   629     ymax=33,
   625     	%ticks
   630     ytick={0,5,...,30},
   626     	\foreach \x in {0, 20, 100, 200,...,1000}
   631     scaled ticks=false,
   627      		\draw (\x,1pt) -- (\x,-3pt)
   632     axis lines=left,
   628 			node[anchor=north] {\small \x};
   633     width=11cm,
   629     	\foreach \y in {0,5,...,30}
   634     height=7cm, 
   630      		\draw (1pt,\y) -- (-3pt,\y) 
   635     legend entries={unambiguous,ambiguous},  
   631      			node[anchor=east] {\small\y}; 
   636     legend pos=north east,
   632 	%labels      
   637     legend cell align=left,
   633 	\node[below=0.6cm] at (x axis mid) {\bl{1}s};
   638     x tick label style={font=\small,/pgf/number format/1000 sep={}}]
   634 	\node[rotate=90, left=1.2cm] at (y axis mid) {secs};
   639 \addplot[blue,mark=*, mark options={fill=white}] 
   635 
   640   table {s-grammar1.data};
   636 	%plots
   641 \only<2>{
   637 	\draw[color=blue] plot[mark=*, mark options={fill=white}] 
   642   \addplot[red,mark=triangle*, mark options={fill=white}] 
   638 		file {s-grammar1.data};
   643   table {s-grammar2.data};}  
   639          \only<2->{\draw[color=red] plot[mark=triangle*, mark options={fill=white} ] 
   644 \end{axis}
   640                   file {s-grammar2.data};}
       
   641 	%legend
       
   642 	\begin{scope}[shift={(400,20)}] 
       
   643 	\draw[color=blue] (0,0) -- 
       
   644 		plot[mark=*, mark options={fill=white}] (0.25,0) -- (0.5,0) 
       
   645 		node[right]{\small unambiguous};
       
   646 	\only<2->{\draw[yshift=\baselineskip, color=red] (0,0) -- 
       
   647                 plot[mark=triangle*, mark options={fill=white}] (0.25,0) -- (0.5,0)
       
   648                 node[right]{\small ambiguous};}  
       
   649 	\end{scope}
       
   650 \end{tikzpicture}
   645 \end{tikzpicture}
   651 \end{center}
   646 \end{center}
   652 
   647 
   653 \end{frame}}
   648 \end{frame}
   654 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   649 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   655 
   650 
   656 
   651 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   657 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   652 \begin{frame}
   658 \mode<presentation>{
   653 \frametitle{While-Language}
   659 \begin{frame}[c]
   654 \mbox{}\\[-23mm]\mbox{}
   660 \frametitle{\begin{tabular}{c}While-Language\end{tabular}}
   655 
   661 
   656 \bl{\begin{plstx}[rhs style=,one per line]
   662 
   657 : \meta{Stmt} ::= skip
   663 \begin{center}
   658          | \meta{Id} := \meta{AExp}
   664 \bl{\begin{tabular}{@{}lcl@{}}
   659          | if \meta{BExp} then \meta{Block} else \meta{Block}
   665 $Stmt$ & $\rightarrow$ &  $\text{skip}$\\
   660          | while \meta{BExp} do \meta{Block}\\
   666               & $|$ & $Id := AExp$\\
   661 : \meta{Stmts} ::= \meta{Stmt} ; \meta{Stmts}
   667               & $|$ & $\text{if}\; B\!Exp \;\text{then}\; Block \;\text{else}\; Block$\\
   662           | \meta{Stmt}\\
   668               & $|$ & $\text{while}\; B\!Exp \;\text{do}\; Block$\medskip\\
   663 : \meta{Block} ::= \{ \meta{Stmts} \}
   669 $Stmts$ & $\rightarrow$ &  $Stmt \;\text{;}\; Stmts$\\
   664           | \meta{Stmt}\\
   670               & $|$ & $Stmt$\medskip\\
   665 : \meta{AExp} ::= \ldots\\
   671 $Block$ & $\rightarrow$ &  $\{ Stmts \}$\\
   666 : \meta{BExp} ::= \ldots\\
   672                 & $|$ & $Stmt$\medskip\\
   667 \end{plstx}}
   673 $AExp$ & $\rightarrow$ & \ldots\\
   668 
   674 $BExp$ & $\rightarrow$ & \ldots\\
   669 \end{frame}
   675 \end{tabular}}
   670 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   676 \end{center}
   671 
   677 
   672 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   678 
   673 \begin{frame}[c]
   679 \end{frame}}
   674 \frametitle{An Interpreter}
   680 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
       
   681 
       
   682 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   683 \mode<presentation>{
       
   684 \begin{frame}[c]
       
   685 \frametitle{\begin{tabular}{c}An Interpreter\end{tabular}}
       
   686 
   675 
   687 \begin{center}
   676 \begin{center}
   688 \bl{\begin{tabular}{l}
   677 \bl{\begin{tabular}{l}
   689 $\{$\\
   678 $\{$\\
   690 \;\;$x := 5 \text{;}$\\
   679 \;\;$x := 5 \text{;}$\\
   695 \end{tabular}}
   684 \end{tabular}}
   696 \end{center}
   685 \end{center}
   697 
   686 
   698 \begin{itemize}
   687 \begin{itemize}
   699 \item the interpreter has to record the value of \bl{$x$} before assigning a value to \bl{$y$}\pause
   688 \item the interpreter has to record the value of \bl{$x$} before assigning a value to \bl{$y$}\pause
   700 \item \bl{\text{eval}(stmt, env)}
   689 \item \bl{\texttt{eval(stmt, env)}}
   701 \end{itemize}
   690 \end{itemize}
   702 
   691 
   703 
   692 \end{frame}
   704 \end{frame}}
   693 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   705 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
       
   706 
       
   707 
       
   708   
       
   709 
   694 
   710 
   695 
   711 \end{document}
   696 \end{document}
   712 
   697 
   713 %%% Local Variables:  
   698 %%% Local Variables: