|
1 \documentclass[dvipsnames,14pt,t]{beamer} |
|
2 \usepackage{beamerthemeplainculight} |
|
3 \usepackage[T1]{fontenc} |
|
4 \usepackage[latin1]{inputenc} |
|
5 \usepackage{mathpartir} |
|
6 \usepackage[absolute,overlay]{textpos} |
|
7 \usepackage{ifthen} |
|
8 \usepackage{tikz} |
|
9 \usepackage{pgf} |
|
10 \usepackage{calc} |
|
11 \usepackage{ulem} |
|
12 \usepackage{courier} |
|
13 \usepackage{listings} |
|
14 \renewcommand{\uline}[1]{#1} |
|
15 \usetikzlibrary{arrows} |
|
16 \usetikzlibrary{automata} |
|
17 \usetikzlibrary{shapes} |
|
18 \usetikzlibrary{shadows} |
|
19 \usetikzlibrary{positioning} |
|
20 \usetikzlibrary{calc} |
|
21 \usetikzlibrary{plotmarks} |
|
22 \usepackage{graphicx} |
|
23 |
|
24 \definecolor{javared}{rgb}{0.6,0,0} % for strings |
|
25 \definecolor{javagreen}{rgb}{0.25,0.5,0.35} % comments |
|
26 \definecolor{javapurple}{rgb}{0.5,0,0.35} % keywords |
|
27 \definecolor{javadocblue}{rgb}{0.25,0.35,0.75} % javadoc |
|
28 |
|
29 \lstset{language=Java, |
|
30 basicstyle=\ttfamily, |
|
31 keywordstyle=\color{javapurple}\bfseries, |
|
32 stringstyle=\color{javagreen}, |
|
33 commentstyle=\color{javagreen}, |
|
34 morecomment=[s][\color{javadocblue}]{/**}{*/}, |
|
35 numbers=left, |
|
36 numberstyle=\tiny\color{black}, |
|
37 stepnumber=1, |
|
38 numbersep=10pt, |
|
39 tabsize=2, |
|
40 showspaces=false, |
|
41 showstringspaces=false} |
|
42 |
|
43 \lstdefinelanguage{scala}{ |
|
44 morekeywords={abstract,case,catch,class,def,% |
|
45 do,else,extends,false,final,finally,% |
|
46 for,if,implicit,import,match,mixin,% |
|
47 new,null,object,override,package,% |
|
48 private,protected,requires,return,sealed,% |
|
49 super,this,throw,trait,true,try,% |
|
50 type,val,var,while,with,yield}, |
|
51 otherkeywords={=>,<-,<\%,<:,>:,\#,@}, |
|
52 sensitive=true, |
|
53 morecomment=[l]{//}, |
|
54 morecomment=[n]{/*}{*/}, |
|
55 morestring=[b]", |
|
56 morestring=[b]', |
|
57 morestring=[b]""" |
|
58 } |
|
59 |
|
60 \lstset{language=Scala, |
|
61 basicstyle=\ttfamily, |
|
62 keywordstyle=\color{javapurple}\bfseries, |
|
63 stringstyle=\color{javagreen}, |
|
64 commentstyle=\color{javagreen}, |
|
65 morecomment=[s][\color{javadocblue}]{/**}{*/}, |
|
66 numbers=left, |
|
67 numberstyle=\tiny\color{black}, |
|
68 stepnumber=1, |
|
69 numbersep=10pt, |
|
70 tabsize=2, |
|
71 showspaces=false, |
|
72 showstringspaces=false} |
|
73 |
|
74 % beamer stuff |
|
75 \renewcommand{\slidecaption}{AFL 07, King's College London, 14.~November 2012} |
|
76 \newcommand{\bl}[1]{\textcolor{blue}{#1}} |
|
77 \newcommand{\dn}{\stackrel{\mbox{\scriptsize def}}{=}}% for definitions |
|
78 |
|
79 |
|
80 % The data files, written on the first run. |
|
81 \begin{filecontents}{re-python.data} |
|
82 1 0.029 |
|
83 5 0.029 |
|
84 10 0.029 |
|
85 15 0.032 |
|
86 16 0.042 |
|
87 17 0.042 |
|
88 18 0.055 |
|
89 19 0.084 |
|
90 20 0.136 |
|
91 21 0.248 |
|
92 22 0.464 |
|
93 23 0.899 |
|
94 24 1.773 |
|
95 25 3.505 |
|
96 26 6.993 |
|
97 27 14.503 |
|
98 28 29.307 |
|
99 #29 58.886 |
|
100 \end{filecontents} |
|
101 |
|
102 \begin{filecontents}{re-ruby.data} |
|
103 1 0.00006 |
|
104 2 0.00003 |
|
105 3 0.00001 |
|
106 4 0.00001 |
|
107 5 0.00001 |
|
108 6 0.00002 |
|
109 7 0.00002 |
|
110 8 0.00004 |
|
111 9 0.00007 |
|
112 10 0.00013 |
|
113 11 0.00026 |
|
114 12 0.00055 |
|
115 13 0.00106 |
|
116 14 0.00196 |
|
117 15 0.00378 |
|
118 16 0.00764 |
|
119 17 0.01606 |
|
120 18 0.03094 |
|
121 19 0.06508 |
|
122 20 0.12420 |
|
123 21 0.25393 |
|
124 22 0.51449 |
|
125 23 1.02174 |
|
126 24 2.05998 |
|
127 25 4.22514 |
|
128 26 8.42479 |
|
129 27 16.88678 |
|
130 28 34.79653 |
|
131 \end{filecontents} |
|
132 |
|
133 \begin{filecontents}{re1.data} |
|
134 1 0.00179 |
|
135 2 0.00011 |
|
136 3 0.00014 |
|
137 4 0.00026 |
|
138 5 0.00050 |
|
139 6 0.00095 |
|
140 7 0.00190 |
|
141 8 0.00287 |
|
142 9 0.00779 |
|
143 10 0.01399 |
|
144 11 0.01894 |
|
145 12 0.03666 |
|
146 13 0.07994 |
|
147 14 0.08944 |
|
148 15 0.02377 |
|
149 16 0.07392 |
|
150 17 0.22798 |
|
151 18 0.65310 |
|
152 19 2.11360 |
|
153 20 6.31606 |
|
154 21 21.46013 |
|
155 \end{filecontents} |
|
156 |
|
157 \begin{filecontents}{re2.data} |
|
158 1 0.00240 |
|
159 2 0.00013 |
|
160 3 0.00020 |
|
161 4 0.00030 |
|
162 5 0.00049 |
|
163 6 0.00083 |
|
164 7 0.00146 |
|
165 8 0.00228 |
|
166 9 0.00351 |
|
167 10 0.00640 |
|
168 11 0.01217 |
|
169 12 0.02565 |
|
170 13 0.01382 |
|
171 14 0.02423 |
|
172 15 0.05065 |
|
173 16 0.06522 |
|
174 17 0.02140 |
|
175 18 0.05176 |
|
176 19 0.18254 |
|
177 20 0.51898 |
|
178 21 1.39631 |
|
179 22 2.69501 |
|
180 23 8.07952 |
|
181 \end{filecontents} |
|
182 |
|
183 \begin{filecontents}{re-internal.data} |
|
184 1 0.00069 |
|
185 301 0.00700 |
|
186 601 0.00297 |
|
187 901 0.00470 |
|
188 1201 0.01301 |
|
189 1501 0.01175 |
|
190 1801 0.01761 |
|
191 2101 0.01787 |
|
192 2401 0.02717 |
|
193 2701 0.03932 |
|
194 3001 0.03470 |
|
195 3301 0.04349 |
|
196 3601 0.05411 |
|
197 3901 0.06181 |
|
198 4201 0.07119 |
|
199 4501 0.08578 |
|
200 \end{filecontents} |
|
201 |
|
202 \begin{filecontents}{re3.data} |
|
203 1 0.001605 |
|
204 501 0.131066 |
|
205 1001 0.057885 |
|
206 1501 0.136875 |
|
207 2001 0.176238 |
|
208 2501 0.254363 |
|
209 3001 0.37262 |
|
210 3501 0.500946 |
|
211 4001 0.638384 |
|
212 4501 0.816605 |
|
213 5001 1.00491 |
|
214 5501 1.232505 |
|
215 6001 1.525672 |
|
216 6501 1.757502 |
|
217 7001 2.092784 |
|
218 7501 2.429224 |
|
219 8001 2.803037 |
|
220 8501 3.463045 |
|
221 9001 3.609 |
|
222 9501 4.081504 |
|
223 10001 4.54569 |
|
224 \end{filecontents} |
|
225 \begin{document} |
|
226 |
|
227 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
228 \mode<presentation>{ |
|
229 \begin{frame}<1>[t] |
|
230 \frametitle{% |
|
231 \begin{tabular}{@ {}c@ {}} |
|
232 \\[-3mm] |
|
233 \LARGE Automata and \\[-2mm] |
|
234 \LARGE Formal Languages (7)\\[3mm] |
|
235 \end{tabular}} |
|
236 |
|
237 \normalsize |
|
238 \begin{center} |
|
239 \begin{tabular}{ll} |
|
240 Email: & christian.urban at kcl.ac.uk\\ |
|
241 Of$\!$fice: & S1.27 (1st floor Strand Building)\\ |
|
242 Slides: & KEATS (also home work is there)\\ |
|
243 \end{tabular} |
|
244 \end{center} |
|
245 |
|
246 |
|
247 \end{frame}} |
|
248 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
249 |
|
250 |
|
251 |
|
252 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
253 \mode<presentation>{ |
|
254 \begin{frame}[t] |
|
255 \frametitle{\begin{tabular}{c}\bl{$(a?\{n\})a\{n\}$}\end{tabular}} |
|
256 |
|
257 \mbox{}\\[-13mm] |
|
258 |
|
259 \begin{tikzpicture}[y=.2cm, x=.3cm] |
|
260 %axis |
|
261 \draw (0,0) -- coordinate (x axis mid) (30,0); |
|
262 \draw (0,0) -- coordinate (y axis mid) (0,30); |
|
263 %ticks |
|
264 \foreach \x in {0,5,...,30} |
|
265 \draw (\x,1pt) -- (\x,-3pt) |
|
266 node[anchor=north] {\x}; |
|
267 \foreach \y in {0,5,...,30} |
|
268 \draw (1pt,\y) -- (-3pt,\y) |
|
269 node[anchor=east] {\y}; |
|
270 %labels |
|
271 \node[below=0.6cm] at (x axis mid) {\bl{a}s}; |
|
272 \node[rotate=90, left=1.2cm] at (y axis mid) {secs}; |
|
273 |
|
274 %plots |
|
275 \draw[color=blue] plot[mark=*, mark options={fill=white}] |
|
276 file {re-python.data}; |
|
277 \draw[color=red] plot[mark=triangle*, mark options={fill=white} ] |
|
278 file {re1.data}; |
|
279 \draw[color=green] plot[mark=square*, mark options={fill=white} ] |
|
280 file {re2.data}; |
|
281 \draw[color=brown] plot[mark=pentagon*, mark options={fill=white} ] |
|
282 file {re-ruby.data}; |
|
283 |
|
284 %legend |
|
285 \begin{scope}[shift={(4,20)}] |
|
286 \draw[color=blue] (0,0) -- |
|
287 plot[mark=*, mark options={fill=white}] (0.25,0) -- (0.5,0) |
|
288 node[right]{\small Python}; |
|
289 \draw[yshift=-\baselineskip, color=brown] (0,0) -- |
|
290 plot[mark=pentagon*, mark options={fill=white}] (0.25,0) -- (0.5,0) |
|
291 node[right]{\small Ruby (Daniel Baldwin)}; |
|
292 \draw[yshift=\baselineskip, color=red] (0,0) -- |
|
293 plot[mark=triangle*, mark options={fill=white}] (0.25,0) -- (0.5,0) |
|
294 node[right]{\small Scala V1}; |
|
295 \draw[yshift=2\baselineskip, color=green] (0,0) -- |
|
296 plot[mark=square*, mark options={fill=white}] (0.25,0) -- (0.5,0) |
|
297 node[right]{\small Scala V2 with simplifications}; |
|
298 \end{scope} |
|
299 \end{tikzpicture} |
|
300 |
|
301 \end{frame}} |
|
302 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
303 |
|
304 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
305 \mode<presentation>{ |
|
306 \begin{frame}[t] |
|
307 |
|
308 \begin{tikzpicture}[y=.7cm, x=.0009cm] |
|
309 %axis |
|
310 \draw (0,0) -- coordinate (x axis mid) (10000,0); |
|
311 \draw (0,0) -- coordinate (y axis mid) (0,6); |
|
312 %ticks |
|
313 \foreach \x in {0,2000,...,10000} |
|
314 \draw (\x,1pt) -- (\x,-3pt) |
|
315 node[anchor=north] {\x}; |
|
316 \foreach \y in {0,1,...,6} |
|
317 \draw (1pt,\y) -- (-3pt,\y) |
|
318 node[anchor=east] {\y}; |
|
319 %labels |
|
320 \node[below=0.6cm] at (x axis mid) {\bl{a}s}; |
|
321 \node[rotate=90, left=1.2cm] at (y axis mid) {secs}; |
|
322 |
|
323 %plots |
|
324 \draw[color=blue] plot[mark=*, mark options={fill=white}] |
|
325 file {re-internal.data}; |
|
326 \only<1->{ |
|
327 \draw[color=red] plot[mark=triangle*, mark options={fill=white} ] |
|
328 file {re3.data};} |
|
329 |
|
330 %legend |
|
331 \begin{scope}[shift={(2000,4)}] |
|
332 \draw[color=blue] (0,0) -- |
|
333 plot[mark=*, mark options={fill=white}] (0.25,0) -- (0.5,0) |
|
334 node[right]{\small Scala Internal}; |
|
335 \only<1->{ |
|
336 \draw[yshift=\baselineskip, color=red] (0,0) -- |
|
337 plot[mark=triangle*, mark options={fill=white}] (0.25,0) -- (0.5,0) |
|
338 node[right]{\small Scala V3 with explicit $\_\{\_\}$};} |
|
339 \end{scope} |
|
340 \end{tikzpicture} |
|
341 |
|
342 \begin{center} |
|
343 \begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {\hspace{-10mm}}l@ {}} |
|
344 \\[-8mm] |
|
345 \bl{der c (r$_1$ $\cdot$ r$_2$)} & \bl{$\dn$} & \bl{if nullable r$_1$}\\ |
|
346 & & \bl{then ((der c r$_1$) $\cdot$ r$_2$) + (der c r$_2$)}\\ |
|
347 & & \bl{else (der c r$_1$) $\cdot$ r$_2$}\\ |
|
348 \bl{der c (r$\{n\}$)} & \bl{$\dn$} & \bl{if $n = 0$ then $\varnothing$}\\ |
|
349 & & \bl{else (der c r) $\cdot$ r$\{n - 1\}$} |
|
350 \end{tabular} |
|
351 \end{center} |
|
352 |
|
353 \end{frame}} |
|
354 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
355 |
|
356 |
|
357 |
|
358 \newcommand{\qq}{\mbox{\texttt{"}}} |
|
359 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
360 \mode<presentation>{ |
|
361 \begin{frame}[c] |
|
362 \frametitle{\begin{tabular}{c}CFGs\end{tabular}} |
|
363 |
|
364 A \alert{context-free} grammar (CFG) \bl{$G$} consists of: |
|
365 |
|
366 \begin{itemize} |
|
367 \item a finite set of nonterminal symbols (upper case) |
|
368 \item a finite terminal symbols or tokens (lower case) |
|
369 \item a start symbol (which must be a nonterminal) |
|
370 \item a set of rules |
|
371 \begin{center} |
|
372 \bl{$A \rightarrow \text{rhs}$} |
|
373 \end{center} |
|
374 |
|
375 where \bl{rhs} are sequences involving terminals and nonterminals (can also be empty).\medskip\pause |
|
376 |
|
377 We can also allow rules |
|
378 \begin{center} |
|
379 \bl{$A \rightarrow \text{rhs}_1 | \text{rhs}_2 | \ldots$} |
|
380 \end{center} |
|
381 \end{itemize} |
|
382 |
|
383 |
|
384 \end{frame}} |
|
385 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
386 |
|
387 |
|
388 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
389 \mode<presentation>{ |
|
390 \begin{frame}[c] |
|
391 \frametitle{\begin{tabular}{c}A CFG Derivation\end{tabular}} |
|
392 |
|
393 \begin{enumerate} |
|
394 \item Begin with a string with only the start symbol \bl{$S$}\bigskip |
|
395 \item Replace any non-terminal \bl{$X$} in the string by the |
|
396 right-hand side of some production \bl{$X \rightarrow \text{rhs}$}\bigskip |
|
397 \item Repeat 2 until there are no non-terminals |
|
398 \end{enumerate} |
|
399 |
|
400 \begin{center} |
|
401 \bl{$S \rightarrow \ldots \rightarrow \ldots \rightarrow \ldots \rightarrow \ldots $} |
|
402 \end{center} |
|
403 |
|
404 \end{frame}} |
|
405 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
406 |
|
407 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
408 \mode<presentation>{ |
|
409 \begin{frame}[c] |
|
410 \frametitle{\begin{tabular}{c}Language of a CFG\end{tabular}} |
|
411 |
|
412 Let \bl{$G$} be a context-free grammar with start symbol \bl{$S$}. |
|
413 Then the language \bl{$L(G)$} is: |
|
414 |
|
415 \begin{center} |
|
416 \bl{$\{c_1\ldots c_n \;|\; \forall i.\; c_i \in T \wedge S \rightarrow^* c_1\ldots c_n \}$} |
|
417 \end{center}\pause |
|
418 |
|
419 \begin{itemize} |
|
420 \item Terminals are so-called because there are no rules for replacing them |
|
421 \item Once generated, terminals are ``permanent'' |
|
422 \item Terminals ought to be tokens of the language (at least in this course) |
|
423 \end{itemize} |
|
424 |
|
425 \end{frame}} |
|
426 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
427 |
|
428 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
429 \mode<presentation>{ |
|
430 \begin{frame}[c] |
|
431 \frametitle{\begin{tabular}{c}Arithmetic Expressions\end{tabular}} |
|
432 |
|
433 \begin{center} |
|
434 \bl{\begin{tabular}{lcl} |
|
435 $E$ & $\rightarrow$ & $num\_token$ \\ |
|
436 $E$ & $\rightarrow$ & $E \cdot + \cdot E$ \\ |
|
437 $E$ & $\rightarrow$ & $E \cdot - \cdot E$ \\ |
|
438 $E$ & $\rightarrow$ & $E \cdot * \cdot E$ \\ |
|
439 $E$ & $\rightarrow$ & $( \cdot E \cdot )$ |
|
440 \end{tabular}} |
|
441 \end{center}\pause\bigskip |
|
442 |
|
443 A CFG is \alert{left-recursive} if it has a nonterminal \bl{$E$} such |
|
444 that \bl{$E \rightarrow^+ E\cdot \ldots$} |
|
445 |
|
446 \end{frame}} |
|
447 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
448 |
|
449 |
|
450 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
451 \mode<presentation>{ |
|
452 \begin{frame}[c] |
|
453 \frametitle{\begin{tabular}{c}Parse Trees\end{tabular}} |
|
454 |
|
455 \begin{center} |
|
456 \bl{\begin{tabular}{lcl} |
|
457 $E$ & $\rightarrow$ & $F \;|\; F \cdot * \cdot F$\\ |
|
458 $F$ & $\rightarrow$ & $T \;|\; T \cdot + \cdot T \;|\; T \cdot - \cdot T$\\ |
|
459 $T$ & $\rightarrow$ & $num\_token \;|\; ( \cdot E \cdot )$\\ |
|
460 \end{tabular}} |
|
461 \end{center} |
|
462 |
|
463 \begin{center} |
|
464 \begin{tikzpicture}[level distance=8mm, blue] |
|
465 \node {$E$} |
|
466 child {node {$F$} |
|
467 child {node {$T$} |
|
468 child {node {(\,$E$\,)} |
|
469 child {node{$F$ *{} $F$} |
|
470 child {node {$T$} child {node {2}}} |
|
471 child {node {$T$} child {node {3}}} |
|
472 } |
|
473 } |
|
474 } |
|
475 child {node {+}} |
|
476 child {node {$T$} |
|
477 child {node {(\,$E$\,)} |
|
478 child {node {$F$} |
|
479 child {node {$T$ +{} $T$} |
|
480 child {node {3}} |
|
481 child {node {4}} |
|
482 } |
|
483 }} |
|
484 }}; |
|
485 \end{tikzpicture} |
|
486 \end{center} |
|
487 |
|
488 \begin{textblock}{5}(1, 6.5) |
|
489 \bl{\texttt{(2*3)+(3+4)}} |
|
490 \end{textblock} |
|
491 |
|
492 \end{frame}} |
|
493 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
494 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
495 \mode<presentation>{ |
|
496 \begin{frame}[c] |
|
497 \frametitle{\begin{tabular}{c}Ambiguous Grammars\end{tabular}} |
|
498 |
|
499 A CFG is \alert{ambiguous} if there is a string that has at least parse trees. |
|
500 |
|
501 |
|
502 \begin{center} |
|
503 \bl{\begin{tabular}{lcl} |
|
504 $E$ & $\rightarrow$ & $num\_token$ \\ |
|
505 $E$ & $\rightarrow$ & $E \cdot + \cdot E$ \\ |
|
506 $E$ & $\rightarrow$ & $E \cdot - \cdot E$ \\ |
|
507 $E$ & $\rightarrow$ & $E \cdot * \cdot E$ \\ |
|
508 $E$ & $\rightarrow$ & $( \cdot E \cdot )$ |
|
509 \end{tabular}} |
|
510 \end{center} |
|
511 |
|
512 \bl{\texttt{1 + 2 * 3 + 4}} |
|
513 |
|
514 \end{frame}} |
|
515 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
516 |
|
517 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
518 \mode<presentation>{ |
|
519 \begin{frame}[c] |
|
520 \frametitle{\begin{tabular}{c}Dangling Else\end{tabular}} |
|
521 |
|
522 Another ambiguous grammar:\bigskip |
|
523 |
|
524 \begin{center} |
|
525 \bl{\begin{tabular}{lcl} |
|
526 $E$ & $\rightarrow$ & if $E$ then $E$\\ |
|
527 & $|$ & if $E$ then $E$ else $E$ \\ |
|
528 & $|$ & id |
|
529 \end{tabular}} |
|
530 \end{center}\bigskip |
|
531 |
|
532 \bl{\texttt{if a then if x then y else c}} |
|
533 |
|
534 \end{frame}} |
|
535 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
536 |
|
537 \end{document} |
|
538 |
|
539 %%% Local Variables: |
|
540 %%% mode: latex |
|
541 %%% TeX-master: t |
|
542 %%% End: |
|
543 |