author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Tue, 24 Sep 2013 01:12:36 +0100 | |
changeset 95 | dbe49327b6c5 |
parent 93 | 4794759139ea |
child 97 | 60a3ba90dd53 |
permissions | -rw-r--r-- |
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
1 |
\documentclass[dvipsnames,14pt,t,xelatex]{beamer} |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
2 |
\usepackage{beamerthemeplaincu} |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
3 |
\usepackage{fontenc,xltxtra,xunicode} |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
4 |
\defaultfontfeatures{Mapping=tex-text} |
0 | 5 |
\usepackage{mathpartir} |
6 |
\usepackage[absolute,overlay]{textpos} |
|
7 |
\usepackage{ifthen} |
|
8 |
\usepackage{tikz} |
|
9 |
\usepackage{pgf} |
|
10 |
\usepackage{calc} |
|
11 |
\usepackage{ulem} |
|
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
12 |
%%\usepackage{courier} |
0 | 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 |
\usepackage{graphicx} |
|
22 |
||
23 |
\definecolor{javared}{rgb}{0.6,0,0} % for strings |
|
24 |
\definecolor{javagreen}{rgb}{0.25,0.5,0.35} % comments |
|
25 |
\definecolor{javapurple}{rgb}{0.5,0,0.35} % keywords |
|
26 |
\definecolor{javadocblue}{rgb}{0.25,0.35,0.75} % javadoc |
|
27 |
||
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
28 |
\makeatletter |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
29 |
\lst@CCPutMacro\lst@ProcessOther {"2D}{\lst@ttfamily{-{}}{-{}}} |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
30 |
\@empty\z@\@empty |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
31 |
\makeatother |
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
32 |
|
0 | 33 |
\lstset{language=Java, |
34 |
basicstyle=\ttfamily, |
|
35 |
keywordstyle=\color{javapurple}\bfseries, |
|
36 |
stringstyle=\color{javagreen}, |
|
37 |
commentstyle=\color{javagreen}, |
|
38 |
morecomment=[s][\color{javadocblue}]{/**}{*/}, |
|
39 |
numbers=left, |
|
40 |
numberstyle=\tiny\color{black}, |
|
41 |
stepnumber=1, |
|
42 |
numbersep=10pt, |
|
43 |
tabsize=2, |
|
44 |
showspaces=false, |
|
45 |
showstringspaces=false} |
|
46 |
||
47 |
\lstdefinelanguage{scala}{ |
|
48 |
morekeywords={abstract,case,catch,class,def,% |
|
49 |
do,else,extends,false,final,finally,% |
|
50 |
for,if,implicit,import,match,mixin,% |
|
51 |
new,null,object,override,package,% |
|
52 |
private,protected,requires,return,sealed,% |
|
53 |
super,this,throw,trait,true,try,% |
|
54 |
type,val,var,while,with,yield}, |
|
55 |
otherkeywords={=>,<-,<\%,<:,>:,\#,@}, |
|
56 |
sensitive=true, |
|
57 |
morecomment=[l]{//}, |
|
58 |
morecomment=[n]{/*}{*/}, |
|
59 |
morestring=[b]", |
|
60 |
morestring=[b]', |
|
61 |
morestring=[b]""" |
|
62 |
} |
|
63 |
||
64 |
\lstset{language=Scala, |
|
65 |
basicstyle=\ttfamily, |
|
66 |
keywordstyle=\color{javapurple}\bfseries, |
|
67 |
stringstyle=\color{javagreen}, |
|
68 |
commentstyle=\color{javagreen}, |
|
69 |
morecomment=[s][\color{javadocblue}]{/**}{*/}, |
|
70 |
numbers=left, |
|
71 |
numberstyle=\tiny\color{black}, |
|
72 |
stepnumber=1, |
|
73 |
numbersep=10pt, |
|
74 |
tabsize=2, |
|
75 |
showspaces=false, |
|
76 |
showstringspaces=false} |
|
77 |
||
78 |
% beamer stuff |
|
1 | 79 |
\renewcommand{\slidecaption}{AFL 01, King's College London, 26.~September 2012} |
0 | 80 |
|
81 |
||
82 |
\begin{document} |
|
83 |
||
84 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
85 |
\mode<presentation>{ |
|
86 |
\begin{frame}<1>[t] |
|
87 |
\frametitle{% |
|
88 |
\begin{tabular}{@ {}c@ {}} |
|
1 | 89 |
\\[-3mm] |
90 |
\LARGE Automata and \\[-2mm] |
|
91 |
\LARGE Formal Languages (1)\\[-3mm] |
|
0 | 92 |
\end{tabular}} |
93 |
||
94 |
\begin{center} |
|
1 | 95 |
\includegraphics[scale=0.3]{pics/ante1.jpg}\hspace{5mm} |
96 |
\includegraphics[scale=0.31]{pics/ante2.jpg}\\ |
|
97 |
\footnotesize\textcolor{gray}{Antikythera automaton, 100 BC (Archimedes?)} |
|
0 | 98 |
\end{center} |
99 |
||
100 |
\normalsize |
|
101 |
\begin{center} |
|
102 |
\begin{tabular}{ll} |
|
103 |
Email: & christian.urban at kcl.ac.uk\\ |
|
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
104 |
Office: & S1.27 (1st floor Strand Building)\\ |
0 | 105 |
Slides: & KEATS |
106 |
\end{tabular} |
|
107 |
\end{center} |
|
108 |
||
109 |
||
110 |
\end{frame}} |
|
111 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
112 |
||
113 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
114 |
\mode<presentation>{ |
|
115 |
\begin{frame}[c] |
|
116 |
||
1 | 117 |
\begin{textblock}{1}(2,5) |
0 | 118 |
\begin{tabular}{c} |
1 | 119 |
\includegraphics[scale=0.15]{pics/servers.png}\\[-2mm] |
120 |
\small Server |
|
0 | 121 |
\end{tabular} |
122 |
\end{textblock} |
|
123 |
||
1 | 124 |
\begin{textblock}{1}(5.6,4) |
125 |
\begin{tikzpicture}[scale=1.1] |
|
126 |
\draw[white] (0,1) node (X) {}; |
|
127 |
\draw[white] (2,1) node (Y) {}; |
|
128 |
\draw[white] (0,0) node (X1) {}; |
|
129 |
\draw[white] (2,0) node (Y1) {}; |
|
130 |
\draw[white] (0,-1) node (X2) {}; |
|
131 |
\draw[white] (2,-1) node (Y2) {}; |
|
132 |
\draw[red, <-, line width = 2mm] (X) -- (Y); |
|
133 |
\node [inner sep=5pt,label=above:\textcolor{black}{GET request}] at ($ (X)!.5!(Y) $) {}; |
|
134 |
\draw[red, ->, line width = 2mm] (X1) -- (Y1); |
|
135 |
\node [inner sep=5pt,label=above:\textcolor{black}{webpage}] at ($ (X1)!.5!(Y1) $) {}; |
|
136 |
\draw[red, <-, line width = 2mm] (X2) -- (Y2); |
|
137 |
\node [inner sep=7pt,label=above:\textcolor{black}{POST data}] at ($ (X2)!.5!(Y2) $) {}; |
|
0 | 138 |
\end{tikzpicture} |
139 |
\end{textblock} |
|
140 |
||
141 |
||
1 | 142 |
\begin{textblock}{1}(9,5.5) |
0 | 143 |
\begin{tabular}{c} |
1 | 144 |
\includegraphics[scale=0.15]{pics/laptop.png}\\[-2mm] |
145 |
\small Browser |
|
0 | 146 |
\end{tabular} |
147 |
\end{textblock} |
|
148 |
||
1 | 149 |
\only<2>{ |
150 |
\begin{textblock}{10}(2,13.5) |
|
0 | 151 |
\begin{itemize} |
1 | 152 |
\item programming languages, compilers |
0 | 153 |
\end{itemize} |
1 | 154 |
\end{textblock}} |
0 | 155 |
|
156 |
||
157 |
\end{frame}} |
|
158 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
159 |
||
160 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
161 |
\mode<presentation>{ |
|
162 |
\begin{frame}[c] |
|
1 | 163 |
|
164 |
transforming strings into structured data\\[10mm] |
|
0 | 165 |
|
1 | 166 |
{\LARGE\bf Lexing}\medskip\\ |
167 |
\hspace{5mm}(recognising ``words'')\\[6mm] |
|
0 | 168 |
|
1 | 169 |
{\LARGE\bf Parsing}\medskip\\ |
170 |
\hspace{5mm}(recognising ``sentences'') |
|
171 |
||
0 | 172 |
\end{frame}} |
1 | 173 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
174 |
||
0 | 175 |
|
176 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
177 |
\mode<presentation>{ |
|
178 |
\begin{frame}[c] |
|
179 |
||
1 | 180 |
The subject is quite old: |
0 | 181 |
|
182 |
\begin{itemize} |
|
1 | 183 |
\item Turing Machines, 1936 |
184 |
\item first compiler for COBOL, 1957 (Grace Hopper) |
|
185 |
\item but surprisingly research papers are still published now |
|
0 | 186 |
\end{itemize} |
187 |
||
1 | 188 |
\begin{flushright} |
189 |
\includegraphics[scale=0.3]{pics/hopper.jpg}\\ |
|
190 |
\footnotesize\textcolor{gray}{Grace Hopper} |
|
191 |
\end{flushright} |
|
192 |
||
193 |
{\footnotesize\textcolor{gray}{(she made it to David Letterman's Tonight Show, \url{http://www.youtube.com/watch?v=aZOxtURhfEU})}} |
|
0 | 194 |
|
1 | 195 |
\end{frame}} |
196 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
197 |
||
198 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
199 |
\mode<presentation>{ |
|
200 |
\begin{frame}[c] |
|
201 |
\frametitle{\begin{tabular}{c}This Course\end{tabular}} |
|
0 | 202 |
|
1 | 203 |
\begin{itemize} |
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
204 |
\item the ultimate goal is to implement a small compiler (really small one)\bigskip |
1 | 205 |
\end{itemize} |
206 |
||
207 |
Let's start with: |
|
208 |
||
209 |
\begin{itemize} |
|
210 |
\item a web-crawler |
|
211 |
\item an email harvester |
|
212 |
\item a web-scraper |
|
213 |
\end{itemize} |
|
214 |
||
215 |
\end{frame}} |
|
216 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
0 | 217 |
|
2 | 218 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
219 |
\mode<presentation>{ |
|
3 | 220 |
\begin{frame}[t] |
13 | 221 |
\frametitle{\begin{tabular}{c}A Web-Crawler\end{tabular}} |
2 | 222 |
|
3 | 223 |
\mbox{}\\[10mm] |
224 |
||
2 | 225 |
\begin{enumerate} |
226 |
\item given an URL, read the corresponding webpage |
|
227 |
\item extract all links from it |
|
228 |
\item call the web-crawler again for all these links |
|
229 |
\end{enumerate} |
|
230 |
||
231 |
\end{frame}} |
|
232 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
233 |
||
234 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
235 |
\mode<presentation>{ |
|
3 | 236 |
\begin{frame}[t] |
13 | 237 |
\frametitle{\begin{tabular}{c}A Web-Crawler\end{tabular}} |
2 | 238 |
|
3 | 239 |
\mbox{}\\[10mm] |
240 |
||
241 |
||
2 | 242 |
\begin{enumerate} |
243 |
\item given an URL, read the corresponding webpage |
|
244 |
\item if not possible print, out a problem |
|
245 |
\item if possible, extract all links from it |
|
246 |
\item call the web-crawler again for all these links |
|
247 |
\end{enumerate}\bigskip\pause |
|
248 |
||
3 | 249 |
\small (we need a bound for the number of recursive calls) |
2 | 250 |
|
251 |
\small (the purpose is to check all links on my own webpage) |
|
252 |
\end{frame}} |
|
253 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
254 |
||
0 | 255 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
256 |
\mode<presentation>{ |
|
257 |
\begin{frame}[c] |
|
1 | 258 |
\frametitle{\begin{tabular}{c}Scala\end{tabular}} |
259 |
||
2 | 260 |
\footnotesize a simple Scala function for reading webpages\\[-3mm] |
0 | 261 |
|
1 | 262 |
{\lstset{language=Scala}\fontsize{8}{10}\selectfont |
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
263 |
\texttt{\lstinputlisting{../progs/app0.scala}}}\pause |
3 | 264 |
{\lstset{language=Scala}\fontsize{8}{10}\selectfont |
265 |
\texttt{\lstinline{get_page("""http://www.inf.kcl.ac.uk/staff/urbanc/""")}}}\pause\bigskip |
|
0 | 266 |
|
3 | 267 |
|
268 |
\footnotesize slightly more complicated for handling errors properly:\\[-3mm] |
|
2 | 269 |
|
1 | 270 |
\footnotesize |
271 |
{\lstset{language=Scala}\fontsize{8}{10}\selectfont |
|
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
272 |
\texttt{\lstinputlisting{../progs/app1.scala}}} |
1 | 273 |
|
0 | 274 |
|
275 |
\end{frame}} |
|
276 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
277 |
||
278 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
279 |
\mode<presentation>{ |
|
3 | 280 |
\begin{frame}[t] |
281 |
\frametitle{\begin{tabular}{c}A Regular Expression\end{tabular}} |
|
282 |
||
283 |
\begin{itemize} |
|
284 |
\item \ldots{} is a pattern or template for specifying strings |
|
285 |
\end{itemize}\bigskip |
|
286 |
||
287 |
\begin{center} |
|
288 |
\only<1>{{\lstset{language=Scala}\fontsize{18}{19}\selectfont\bf |
|
289 |
\texttt{"https?://[$\hat{\hspace{2mm}}$"]*"}}}% |
|
290 |
\only<2>{{\lstset{language=Scala}\fontsize{18}{19}\selectfont\bf |
|
291 |
\texttt{"""\textbackslash{}"https?://[$\hat{\hspace{2mm}}$\textbackslash{}"]*\textbackslash{}"""".r}}} |
|
292 |
\end{center}\bigskip\bigskip |
|
293 |
||
294 |
matches for example\\ |
|
295 |
\;{\lstset{language=Scala}\fontsize{12}{14}\selectfont\bf |
|
296 |
\texttt{"http://www.foobar.com"}}\\ |
|
297 |
\;{\lstset{language=Scala}\fontsize{12}{14}\selectfont\bf |
|
298 |
\texttt{"https://www.tls.org"}}\\ |
|
299 |
||
300 |
\end{frame}} |
|
301 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
302 |
||
303 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
304 |
\mode<presentation>{ |
|
0 | 305 |
\begin{frame}[c] |
306 |
||
3 | 307 |
{\lstset{language=Scala}\fontsize{18}{19}\selectfont\bf |
308 |
\texttt{rexp.findAllIn(string)}}\medskip |
|
309 |
||
310 |
returns a list of all (sub)strings that match the regular expression\bigskip\bigskip |
|
311 |
||
312 |
{\lstset{language=Scala}\fontsize{18}{19}\selectfont\bf |
|
313 |
\texttt{rexp.findFirstIn(string)}}\medskip |
|
314 |
||
315 |
returns either {\bf\texttt{None}} if no (sub)string matches |
|
316 |
or {\bf\texttt{Some(s)}} with the first (sub)string |
|
0 | 317 |
|
318 |
\end{frame}} |
|
319 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
320 |
||
321 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
322 |
\mode<presentation>{ |
|
323 |
\begin{frame}[c] |
|
324 |
||
3 | 325 |
{\lstset{language=Scala}\fontsize{8}{10}\selectfont |
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
326 |
\texttt{\lstinputlisting{../progs/app2.scala}}}\medskip |
0 | 327 |
|
3 | 328 |
{\lstset{language=Scala}\fontsize{8}{10}\selectfont |
329 |
\texttt{crawl(some\_start\_URL, 2)}}\ |
|
0 | 330 |
|
331 |
\end{frame}} |
|
332 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
333 |
||
334 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
335 |
\mode<presentation>{ |
|
3 | 336 |
\begin{frame}[c] |
0 | 337 |
|
3 | 338 |
\footnotesize |
339 |
a version that only ``crawls'' links in my domain: |
|
0 | 340 |
|
3 | 341 |
{\lstset{language=Scala}\fontsize{8}{10}\selectfont |
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
342 |
\texttt{\lstinputlisting{../progs/app3.scala}}} |
0 | 343 |
|
344 |
||
345 |
\end{frame}} |
|
346 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
347 |
||
348 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
349 |
\mode<presentation>{ |
|
350 |
\begin{frame}[c] |
|
3 | 351 |
|
352 |
\footnotesize |
|
353 |
a little email ``harvester'': |
|
354 |
||
355 |
{\lstset{language=Scala}\fontsize{8}{10}\selectfont |
|
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
356 |
\texttt{\lstinputlisting{../progs/app4.scala}}}\bigskip |
3 | 357 |
|
358 |
\tiny |
|
359 |
\textcolor{gray}{\url{http://net.tutsplus.com/tutorials/other/8-regular-expressions-you-should-know/}} |
|
360 |
||
361 |
\end{frame}} |
|
362 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
363 |
||
364 |
\newcommand{\bl}[1]{\textcolor{blue}{#1}} |
|
365 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
366 |
\mode<presentation>{ |
|
14 | 367 |
\begin{frame}[t] |
3 | 368 |
\frametitle{\begin{tabular}{c}Regular Expressions\end{tabular}} |
0 | 369 |
|
14 | 370 |
Their inductive definition:\medskip |
371 |
||
372 |
\begin{textblock}{6}(2,5) |
|
3 | 373 |
\begin{tabular}{@ {}rrl@ {\hspace{13mm}}l} |
374 |
\bl{r} & \bl{$::=$} & \bl{$\varnothing$} & null\\ |
|
5 | 375 |
& \bl{$\mid$} & \bl{$\epsilon$} & empty string / "" / []\\ |
3 | 376 |
& \bl{$\mid$} & \bl{c} & character\\ |
377 |
& \bl{$\mid$} & \bl{r$_1$ $\cdot$ r$_2$} & sequence\\ |
|
378 |
& \bl{$\mid$} & \bl{r$_1$ + r$_2$} & alternative / choice\\ |
|
379 |
& \bl{$\mid$} & \bl{r$^*$} & star (zero or more)\\ |
|
380 |
\end{tabular} |
|
381 |
\end{textblock} |
|
382 |
||
383 |
\end{frame}} |
|
384 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
385 |
||
386 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
387 |
\mode<presentation>{ |
|
388 |
\begin{frame}[t] |
|
389 |
\frametitle{\begin{tabular}{c}Regular Expressions\end{tabular}} |
|
390 |
||
14 | 391 |
\small |
392 |
In Scala: |
|
393 |
||
394 |
||
3 | 395 |
{\lstset{language=Scala}\fontsize{8}{10}\selectfont |
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
396 |
\texttt{\lstinputlisting{../progs/app51.scala}}} |
0 | 397 |
|
398 |
||
399 |
\end{frame}} |
|
400 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
401 |
||
3 | 402 |
\newcommand{\dn}{\stackrel{\mbox{\scriptsize def}}{=}}% for definitions |
0 | 403 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
404 |
\mode<presentation>{ |
|
405 |
\begin{frame}[c] |
|
3 | 406 |
\frametitle{\begin{tabular}{c}The Meaning of a\\[-2mm] Regular Expression\end{tabular}} |
0 | 407 |
|
4 | 408 |
\begin{textblock}{15}(1,4) |
3 | 409 |
\begin{tabular}{@ {}rcl} |
410 |
\bl{$L$($\varnothing$)} & \bl{$\dn$} & \bl{$\varnothing$}\\ |
|
411 |
\bl{$L$($\epsilon$)} & \bl{$\dn$} & \bl{$\{$""$\}$}\\ |
|
412 |
\bl{$L$(c)} & \bl{$\dn$} & \bl{$\{$"c"$\}$}\\ |
|
413 |
\bl{$L$(r$_1$ + r$_2$)} & \bl{$\dn$} & \bl{$L$(r$_1$) $\cup$ $L$(r$_2$)}\\ |
|
4 | 414 |
\bl{$L$(r$_1$ $\cdot$ r$_2$)} & \bl{$\dn$} & \bl{$\{$ s$_1$ @ s$_2$ $|$ s$_1$ $\in$ $L$(r$_1$) $\wedge$ s$_2$ $\in$ |
415 |
$L$(r$_2$) $\}$}\\ |
|
5 | 416 |
\bl{$L$(r$^*$)} & \bl{$\dn$} & \onslide<4->{\bl{$\bigcup_{n \ge 0}$ $L$(r)$^n$}}\\ |
4 | 417 |
\end{tabular}\bigskip |
3 | 418 |
|
4 | 419 |
\onslide<2->{ |
420 |
\hspace{5mm}\bl{$L$(r)$^0$ $\;\dn\;$ $\{$""$\}$}\\ |
|
5 | 421 |
\bl{$L$(r)$^{n+1}$ $\;\dn\;$ $L$(r) @ $L$(r)$^n$}\hspace{9mm}\onslide<3->{\small\textcolor{gray}{(append on sets)}\\ |
422 |
\small\hspace{5cm}\textcolor{gray}{$\{$ s$_1$ @ s$_2$ $|$ s$_1$ $\in$ $L$(r) $\wedge$ s$_2$ $\in$ |
|
423 |
$L$(r)$^n$ $\}$}} |
|
4 | 424 |
} |
425 |
\end{textblock} |
|
426 |
||
0 | 427 |
\end{frame}} |
428 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
429 |
||
5 | 430 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
431 |
\mode<presentation>{ |
|
432 |
\begin{frame}[c] |
|
8 | 433 |
\frametitle{\begin{tabular}{c}The Meaning of Matching\end{tabular}} |
5 | 434 |
|
435 |
\large |
|
436 |
a regular expression \bl{r} matches a string \bl{s} is defined as |
|
437 |
||
438 |
\begin{center} |
|
439 |
\bl{s $\in$ $L$(r)}\\ |
|
440 |
\end{center} |
|
441 |
||
442 |
\end{frame}} |
|
443 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
444 |
||
3 | 445 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
446 |
\mode<presentation>{ |
|
447 |
\begin{frame}[c] |
|
448 |
\frametitle{\begin{tabular}{c}This Course\end{tabular}} |
|
449 |
||
7 | 450 |
We will have a look at: |
3 | 451 |
|
452 |
\begin{itemize} |
|
7 | 453 |
\item regular expressions / regular expression matching |
3 | 454 |
\item automata |
455 |
\item the Myhill-Nerode theorem |
|
456 |
\item parsing |
|
457 |
\item grammars |
|
7 | 458 |
\item a small interpreter / web browser |
3 | 459 |
\end{itemize} |
460 |
||
461 |
\end{frame}} |
|
462 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
463 |
||
0 | 464 |
|
465 |
||
466 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
467 |
\mode<presentation>{ |
|
468 |
\begin{frame}[c] |
|
1 | 469 |
\frametitle{\begin{tabular}{c}Exam\end{tabular}} |
0 | 470 |
|
471 |
\begin{itemize} |
|
7 | 472 |
\item The question ``Is this relevant for the exam?'' is not appreciated!\bigskip\\ |
0 | 473 |
|
14 | 474 |
Whatever is in the homework sheets (and is not marked ``optional'') is relevant for the |
475 |
exam.\\ No code needs to be written in the exam. |
|
0 | 476 |
\end{itemize} |
477 |
||
478 |
\end{frame}} |
|
479 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
480 |
||
481 |
||
482 |
\end{document} |
|
483 |
||
484 |
%%% Local Variables: |
|
485 |
%%% mode: latex |
|
486 |
%%% TeX-master: t |
|
487 |
%%% End: |
|
488 |