author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Sat, 24 Sep 2016 08:31:04 +0100 | |
changeset 428 | a47c4227a0c6 |
parent 334 | fd89a63e9db3 |
child 437 | fe387fcbf2ee |
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} |
252
e8ef8f38ca84
added style files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
2 |
\usepackage{../slides} |
e8ef8f38ca84
added style files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
3 |
\usepackage{../graphics} |
215
828303e8e4af
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
98
diff
changeset
|
4 |
\usepackage{../langs} |
828303e8e4af
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
98
diff
changeset
|
5 |
\usepackage{../data} |
0 | 6 |
|
252
e8ef8f38ca84
added style files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
7 |
\hfuzz=220pt |
e8ef8f38ca84
added style files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
8 |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
9 |
%\setmonofont[Scale=.88]{Consolas} |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
10 |
%\newfontfamily{\consolas}{Consolas} |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
11 |
|
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
12 |
\lstset{language=Scala, |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
13 |
style=mystyle, |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
14 |
numbersep=0pt, |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
15 |
numbers=none, |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
16 |
xleftmargin=0mm} |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
17 |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
18 |
\newcommand{\bl}[1]{\textcolor{blue}{#1}} |
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
19 |
|
0 | 20 |
% beamer stuff |
428
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
21 |
\renewcommand{\slidecaption}{CFL 01, King's College London} |
0 | 22 |
|
23 |
||
24 |
\begin{document} |
|
25 |
||
26 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
27 |
\begin{frame}[t] |
0 | 28 |
\frametitle{% |
29 |
\begin{tabular}{@ {}c@ {}} |
|
1 | 30 |
\\[-3mm] |
428
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
31 |
\LARGE Compilers and \\[-1mm] |
1 | 32 |
\LARGE Formal Languages (1)\\[-3mm] |
0 | 33 |
\end{tabular}} |
34 |
||
35 |
\begin{center} |
|
1 | 36 |
\includegraphics[scale=0.3]{pics/ante1.jpg}\hspace{5mm} |
37 |
\includegraphics[scale=0.31]{pics/ante2.jpg}\\ |
|
38 |
\footnotesize\textcolor{gray}{Antikythera automaton, 100 BC (Archimedes?)} |
|
0 | 39 |
\end{center} |
40 |
||
41 |
\normalsize |
|
42 |
\begin{center} |
|
43 |
\begin{tabular}{ll} |
|
44 |
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
|
45 |
Office: & S1.27 (1st floor Strand Building)\\ |
0 | 46 |
Slides: & KEATS |
47 |
\end{tabular} |
|
48 |
\end{center} |
|
49 |
||
50 |
||
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
51 |
\end{frame} |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
52 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
0 | 53 |
|
54 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
55 |
\begin{frame}[c] |
|
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
56 |
\frametitle{The Goal of this Course} |
0 | 57 |
|
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
58 |
\begin{center} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
59 |
\begin{tikzpicture}[scale=1, |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
60 |
node/.style={ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
61 |
rectangle,rounded corners=3mm, |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
62 |
very thick,draw=black!50,minimum height=18mm, minimum width=20mm, |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
63 |
top color=white,bottom color=black!20}] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
64 |
|
334
fd89a63e9db3
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
332
diff
changeset
|
65 |
\node at (3.05, 1.8) {\Large\bf Write A Compiler}; |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
66 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
67 |
\node (0) at (-2.3,0) {}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
68 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
69 |
\node (A) at (0,0) [node] {}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
70 |
\node [below right] at (A.north west) {lexer}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
71 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
72 |
\node (B) at (3,0) [node] {}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
73 |
\node [below right=1mm] at (B.north west) {\mbox{}\hspace{-1mm}parser}; |
0 | 74 |
|
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
75 |
\node (C) at (6,0) [node] {}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
76 |
\node [below right] at (C.north west) {\mbox{}\hspace{-1mm}code gen}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
77 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
78 |
\node (1) at (8.4,0) {}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
79 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
80 |
\draw [->,line width=4mm] (0) -- (A); |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
81 |
\draw [->,line width=4mm] (A) -- (B); |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
82 |
\draw [->,line width=4mm] (B) -- (C); |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
83 |
\draw [->,line width=4mm] (C) -- (1); |
0 | 84 |
\end{tikzpicture} |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
85 |
\end{center} |
0 | 86 |
|
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
87 |
\only<2,3>{ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
88 |
\begin{textblock}{1}(1,2) |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
89 |
\begin{bubble}[9.8cm] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
90 |
\normalsize |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
91 |
lexer input: a string\smallskip\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
92 |
\hspace{5mm}\code{"read(n);"}\medskip\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
93 |
lexer output: a sequence of tokens\smallskip\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
94 |
\hspace{5mm}\code{key(read); lpar; id(n); rpar; semi} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
95 |
\end{bubble} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
96 |
\end{textblock}} |
0 | 97 |
|
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
98 |
\only<3>{ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
99 |
\begin{textblock}{1}(6,7.8) |
0 | 100 |
\begin{tabular}{c} |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
101 |
\includegraphics[scale=0.2]{../pics/rosetta.jpg}\\[-2mm] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
102 |
\footnotesize lexing $\Rightarrow$ recognising words (Stone of Rosetta) |
0 | 103 |
\end{tabular} |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
104 |
\end{textblock}} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
105 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
106 |
\only<4>{ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
107 |
\begin{textblock}{1}(1,1.5) |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
108 |
\begin{bubble}[8.5cm] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
109 |
\normalsize |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
110 |
parser input: a sequence of token\smallskip\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
111 |
parser output: an abstract syntax tree\smallskip\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
112 |
\footnotesize |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
113 |
\hspace{2cm}\begin{tikzpicture} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
114 |
\node {\code{read}} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
115 |
child {node {\code{lpar}}} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
116 |
child {node {\code{n}}} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
117 |
child {node {\code{rpar}}}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
118 |
\end{tikzpicture} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
119 |
\end{bubble} |
1 | 120 |
\end{textblock}} |
0 | 121 |
|
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
122 |
\only<5,6>{ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
123 |
\begin{textblock}{1}(1,1.5) |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
124 |
\begin{bubble}[4cm] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
125 |
\normalsize |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
126 |
code generator:\smallskip\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
127 |
\hspace{5mm}\code{istore 2}\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
128 |
\hspace{5mm}\code{iload 2}\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
129 |
\hspace{5mm}\code{ldc 10}\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
130 |
\hspace{5mm}\code{isub}\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
131 |
\hspace{5mm}\code{ifeq Label2}\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
132 |
\hspace{5mm}\code{iload 2}\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
133 |
\hspace{5mm}\code{...}\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
134 |
\end{bubble} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
135 |
\end{textblock}} |
1 | 136 |
|
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
137 |
\only<6>{ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
138 |
\begin{textblock}{6}(8.4,7) |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
139 |
\begin{bubble}[5cm] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
140 |
\mbox{\begin{tikzpicture}[scale=0.58,rounded corners=0mm] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
141 |
\begin{axis}[axis x line=bottom, axis y line=left, ylabel=secs, |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
142 |
xlabel=n, |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
143 |
enlargelimits=0.05, |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
144 |
ybar interval=0.7, legend style=small] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
145 |
\addplot file {interpreted2.data}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
146 |
\addplot file {compiled2.data}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
147 |
%\legend{interpreted, compiled} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
148 |
\end{axis} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
149 |
\end{tikzpicture}} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
150 |
\end{bubble} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
151 |
\end{textblock}} |
1 | 152 |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
153 |
\end{frame} |
1 | 154 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
155 |
||
0 | 156 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
157 |
\begin{frame}[c] |
|
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
158 |
\frametitle{The subject is quite old} |
0 | 159 |
|
160 |
\begin{itemize} |
|
1 | 161 |
\item Turing Machines, 1936 |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
162 |
\item Regular Expressions, 1956\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
163 |
\item The first compiler for COBOL, 1957\\ (Grace Hopper) |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
164 |
\item But surprisingly research papers are still published nowadays |
0 | 165 |
\end{itemize} |
166 |
||
1 | 167 |
\begin{flushright} |
168 |
\includegraphics[scale=0.3]{pics/hopper.jpg}\\ |
|
169 |
\footnotesize\textcolor{gray}{Grace Hopper} |
|
170 |
\end{flushright} |
|
171 |
||
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
172 |
\mbox{}\\[-10mm] |
1 | 173 |
{\footnotesize\textcolor{gray}{(she made it to David Letterman's Tonight Show, \url{http://www.youtube.com/watch?v=aZOxtURhfEU})}} |
0 | 174 |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
175 |
\end{frame} |
1 | 176 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
177 |
||
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
178 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
179 |
\begin{frame}[c] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
180 |
\frametitle{Why Bother?} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
181 |
|
428
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
182 |
\begin{columns}[t] |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
183 |
\begin{column}{.5\textwidth} |
428
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
184 |
Ruby, Python, Java\medskip\\ |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
185 |
\begin{tikzpicture}\footnotesize |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
186 |
\begin{axis}[ |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
187 |
xlabel={$n$}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
188 |
x label style={at={(1.05,0.0)}}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
189 |
ylabel={time in secs}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
190 |
enlargelimits=false, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
191 |
xtick={0,5,...,30}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
192 |
xmax=33, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
193 |
ymax=35, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
194 |
ytick={0,5,...,30}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
195 |
scaled ticks=false, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
196 |
axis lines=left, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
197 |
width=5.5cm, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
198 |
height=4cm, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
199 |
legend entries={Python,Ruby}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
200 |
legend pos=north west, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
201 |
legend cell align=left] |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
202 |
\addplot[blue,mark=*] table {re-python.data}; |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
203 |
\addplot[brown,mark=triangle*] table {re-ruby.data}; |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
204 |
\end{axis} |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
205 |
\end{tikzpicture} |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
206 |
\begin{tikzpicture}\footnotesize |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
207 |
\begin{axis}[ |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
208 |
xlabel={$n$}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
209 |
x label style={at={(1.05,0.0)}}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
210 |
ylabel={time in secs}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
211 |
enlargelimits=false, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
212 |
xtick={0,5,...,30}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
213 |
xmax=33, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
214 |
ymax=35, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
215 |
ytick={0,5,...,30}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
216 |
scaled ticks=false, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
217 |
axis lines=left, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
218 |
width=5.5cm, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
219 |
height=4cm, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
220 |
legend entries={Java}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
221 |
legend pos=north west, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
222 |
legend cell align=left] |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
223 |
\addplot[cyan,mark=*, mark options={fill=white}] table {re-java.data}; |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
224 |
\end{axis} |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
225 |
\end{tikzpicture} |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
226 |
|
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
227 |
\end{column} |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
228 |
\begin{column}{.5\textwidth} |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
229 |
Us (after next lecture)\medskip\\ |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
230 |
\begin{tikzpicture}\footnotesize |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
231 |
\begin{axis}[ |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
232 |
xlabel={$n$}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
233 |
x label style={at={(1.07,0.0)}}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
234 |
ylabel={time in secs}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
235 |
enlargelimits=false, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
236 |
xtick={0,4000,...,12000}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
237 |
xmax=13000, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
238 |
ymax=35, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
239 |
ytick={0,5,...,30}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
240 |
scaled ticks=false, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
241 |
axis lines=left, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
242 |
width=5.5cm, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
243 |
height=4cm] |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
244 |
\addplot[green,mark=square*,mark options={fill=white}] table {re2b.data}; |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
245 |
\addplot[black,mark=square*,mark options={fill=white}] table {re3.data}; |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
246 |
\end{axis} |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
247 |
\end{tikzpicture} |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
248 |
\begin{tikzpicture}\footnotesize |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
249 |
\begin{axis}[ |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
250 |
xlabel={$n$}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
251 |
x label style={at={(1.07,0.0)}}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
252 |
ylabel={time in secs}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
253 |
enlargelimits=false, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
254 |
ymax=35, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
255 |
ytick={0,5,...,30}, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
256 |
scaled ticks=false, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
257 |
axis lines=left, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
258 |
width=5.5cm, |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
259 |
height=4cm] |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
260 |
\addplot[black,mark=square*,mark options={fill=white}] table {re3a.data}; |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
261 |
\end{axis} |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
262 |
\end{tikzpicture} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
263 |
\end{column} |
428
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
264 |
\end{columns}\bigskip |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
265 |
|
428
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
266 |
\small\centering |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
267 |
matching \texttt{[a?]\{n\}[a]\{n\}} and \texttt{[a*]*b} |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
268 |
against $\underbrace{\texttt{a}...\texttt{a}}_n$ |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
269 |
\end{frame} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
270 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
271 |
|
428
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
272 |
|
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
273 |
|
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
274 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
275 |
\begin{frame}[c] |
327
9470cd124667
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
255
diff
changeset
|
276 |
\frametitle{Lectures 1 - 5} |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
277 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
278 |
transforming strings into structured data\\[10mm] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
279 |
|
331
a2c18456c6b7
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
330
diff
changeset
|
280 |
\alert<2>{\LARGE\bf Lexing} \onslide<2>{\hfill{}based on regular expressions}\medskip\\ |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
281 |
\hspace{5mm}(recognising ``words'')\\[6mm] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
282 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
283 |
{\LARGE\bf Parsing}\medskip\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
284 |
\hspace{5mm}(recognising ``sentences'') |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
285 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
286 |
\begin{textblock}{1}(10,9.1) |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
287 |
\begin{tabular}{c} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
288 |
\includegraphics[scale=0.1]{../pics/rosetta.jpg}\\[-2mm] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
289 |
\footnotesize Stone of Rosetta |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
290 |
\end{tabular} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
291 |
\end{textblock} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
292 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
293 |
\end{frame} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
294 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
295 |
|
1 | 296 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
297 |
\begin{frame}[t] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
298 |
\frametitle{Familiar Regular Expr.} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
299 |
\small |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
300 |
\begin{center} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
301 |
\texttt{[a-z0-9\_.-]+ @ [a-z0-9.-]+ . [a-z.]\{2,6\}} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
302 |
\end{center}\smallskip |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
303 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
304 |
\begin{center} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
305 |
\begin{tabular}{@{}lp{8.5cm}@{}} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
306 |
\pcode{re*} & matches 0 or more times\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
307 |
\pcode{re+} & matches 1 or more times\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
308 |
\pcode{re?} & matches 0 or 1 times\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
309 |
\pcode{re\{n\}} & matches exactly \pcode{n} number of times\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
310 |
\pcode{re\{n,m\}} & matches at least \pcode{n} and at most {\tt m} times\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
311 |
\pcode{[...]} & matches any single character inside the brackets\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
312 |
\pcode{[^...]} & matches any single character not inside the |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
313 |
brackets\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
314 |
\pcode{a-zA-Z} & character ranges\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
315 |
\pcode{\\d} & matches digits; equivalent to \pcode{[0-9]}\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
316 |
\pcode{.} & matches every character except newline\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
317 |
\pcode{(re)} & groups regular expressions and remembers |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
318 |
the matched text |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
319 |
\end{tabular} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
320 |
\end{center} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
321 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
322 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
323 |
\end{frame} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
324 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
325 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
326 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1 | 327 |
\begin{frame}[c] |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
328 |
\frametitle{Today} |
0 | 329 |
|
1 | 330 |
\begin{itemize} |
332
4755ad4b457b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
331
diff
changeset
|
331 |
\item While the ultimate goal is to implement a small compiler |
4755ad4b457b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
331
diff
changeset
|
332 |
(a really small one for the JVM)\ldots\bigskip |
1 | 333 |
\end{itemize} |
334 |
||
335 |
Let's start with: |
|
336 |
||
337 |
\begin{itemize} |
|
338 |
\item a web-crawler |
|
339 |
\item an email harvester |
|
332
4755ad4b457b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
331
diff
changeset
|
340 |
\item \textcolor{gray}{(a web-scraper)} |
1 | 341 |
\end{itemize} |
342 |
||
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
343 |
\end{frame} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
344 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
0 | 345 |
|
2 | 346 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
3 | 347 |
\begin{frame}[t] |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
348 |
\frametitle{A Web-Crawler} |
2 | 349 |
|
3 | 350 |
\mbox{}\\[10mm] |
351 |
||
2 | 352 |
\begin{enumerate} |
353 |
\item given an URL, read the corresponding webpage |
|
354 |
\item extract all links from it |
|
355 |
\item call the web-crawler again for all these links |
|
356 |
\end{enumerate} |
|
357 |
||
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
358 |
\end{frame} |
2 | 359 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
360 |
||
361 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
362 |
\mode<presentation>{ |
|
3 | 363 |
\begin{frame}[t] |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
364 |
\frametitle{A Web-Crawler} |
2 | 365 |
|
3 | 366 |
\mbox{}\\[10mm] |
367 |
||
368 |
||
2 | 369 |
\begin{enumerate} |
370 |
\item given an URL, read the corresponding webpage |
|
371 |
\item if not possible print, out a problem |
|
372 |
\item if possible, extract all links from it |
|
373 |
\item call the web-crawler again for all these links |
|
374 |
\end{enumerate}\bigskip\pause |
|
375 |
||
3 | 376 |
\small (we need a bound for the number of recursive calls) |
2 | 377 |
|
378 |
\small (the purpose is to check all links on my own webpage) |
|
379 |
\end{frame}} |
|
380 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
381 |
||
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
382 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
383 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
384 |
\begin{frame}[c] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
385 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
386 |
\begin{textblock}{1}(2,5) |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
387 |
\begin{tabular}{c} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
388 |
\includegraphics[scale=0.15]{pics/servers.png}\\[-2mm] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
389 |
\small Server |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
390 |
\end{tabular} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
391 |
\end{textblock} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
392 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
393 |
\begin{textblock}{1}(5.6,4) |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
394 |
\begin{tikzpicture}[scale=1.1] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
395 |
\draw[white] (0,1) node (X) {}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
396 |
\draw[white] (2,1) node (Y) {}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
397 |
\draw[white] (0,0) node (X1) {}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
398 |
\draw[white] (2,0) node (Y1) {}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
399 |
\draw[white] (0,-1) node (X2) {}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
400 |
\draw[white] (2,-1) node (Y2) {}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
401 |
\draw[red, <-, line width = 2mm] (X) -- (Y); |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
402 |
\node [inner sep=5pt,label=above:\textcolor{black}{GET request}] at ($ (X)!.5!(Y) $) {}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
403 |
\draw[red, ->, line width = 2mm] (X1) -- (Y1); |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
404 |
\node [inner sep=5pt,label=above:\textcolor{black}{webpage}] at ($ (X1)!.5!(Y1) $) {}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
405 |
\draw[red, <-, line width = 2mm] (X2) -- (Y2); |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
406 |
\node [inner sep=7pt,label=above:\textcolor{black}{POST data}] at ($ (X2)!.5!(Y2) $) {}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
407 |
\end{tikzpicture} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
408 |
\end{textblock} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
409 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
410 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
411 |
\begin{textblock}{1}(9,5.5) |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
412 |
\begin{tabular}{c} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
413 |
\includegraphics[scale=0.15]{pics/laptop.png}\\[-2mm] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
414 |
\small Browser |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
415 |
\end{tabular} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
416 |
\end{textblock} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
417 |
\end{frame} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
418 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
419 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
420 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
421 |
|
0 | 422 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
423 |
\begin{frame}[c] |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
424 |
\frametitle{Scala} |
1 | 425 |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
426 |
\small A simple Scala function for reading webpages: |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
427 |
\smallskip |
0 | 428 |
|
98
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
429 |
\footnotesize |
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
430 |
\lstinputlisting{../progs/app0.scala} |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
431 |
\medskip\pause |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
432 |
|
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
433 |
\lstinline{get_page("""http://www.inf.kcl.ac.uk/staff/urbanc/""")} |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
434 |
\bigskip\medskip\pause |
0 | 435 |
|
3 | 436 |
|
428
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
437 |
\small A slightly more complicated version for handling errors: |
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
438 |
\smallskip |
2 | 439 |
|
98
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
440 |
\footnotesize |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
441 |
\lstinputlisting{../progs/app1.scala} |
1 | 442 |
|
0 | 443 |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
444 |
\end{frame} |
0 | 445 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
446 |
||
447 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
98
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
448 |
\begin{frame}[c] |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
449 |
\frametitle{Why Scala?} |
98
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
450 |
|
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
451 |
\begin{textblock}{6}(1,3) |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
452 |
\begin{tabular}{l} |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
453 |
\mbox{}\hspace{-1mm}\includegraphics[scale=0.36]{pics/twitter.png}\\[-1mm] |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
454 |
\includegraphics[scale=0.30]{pics/linked.png}\\ |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
455 |
\includegraphics[scale=0.30]{pics/guardian.jpg}\\[-3mm] |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
456 |
\mbox{}\hspace{-2mm}\includegraphics[scale=0.38]{pics/morgan.png}\\[-3mm] |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
457 |
\includegraphics[scale=0.30]{pics/suisse.png}\\ |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
458 |
\includegraphics[scale=0.20]{pics/edf.png}\\[-1mm] |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
459 |
\includegraphics[scale=0.08]{pics/novell.png}\\[-1mm] |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
460 |
\includegraphics[scale=0.30]{pics/foursquare.png}\\ |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
461 |
\includegraphics[scale=0.30]{pics/hsbc.png}\\ |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
462 |
{\large\bf ...} |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
463 |
\end{tabular} |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
464 |
\end{textblock} |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
465 |
|
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
466 |
\only<2->{ |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
467 |
\begin{textblock}{6}(6,3) |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
468 |
\includegraphics[scale=0.35]{pics/jobgraph.png}\\ |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
469 |
\end{textblock}} |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
470 |
|
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
471 |
\only<3->{ |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
472 |
\begin{textblock}{6}(7.3,9.2) |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
473 |
\begin{tabular}{l} |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
474 |
\footnotesize 2013: 1$\%$\\[-2mm] |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
475 |
\footnotesize 2014: 3$\%$\\[-2mm] |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
476 |
\footnotesize 2015: 9$\%$\\[-2mm] |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
477 |
\footnotesize 2016: 27$\%$\\[-2mm] |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
478 |
\footnotesize 2017: 81$\%$\\[-2mm] |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
479 |
\footnotesize 2018: 243$\%$ \raisebox{-1mm}{\includegraphics[scale=0.02]{pics/smiley.jpg}} |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
480 |
\end{tabular} |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
481 |
\end{textblock}} |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
482 |
|
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
483 |
\only<3->{ |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
484 |
\begin{textblock}{6}(6,9.5) |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
485 |
\footnotesize 5 yrs $\begin{cases}\mbox{}\\[1.4cm]\end{cases}$ |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
486 |
\end{textblock}} |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
487 |
|
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
488 |
\only<4->{ |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
489 |
\begin{textblock}{11}(5,14.1) |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
490 |
\textcolor{gray}{ |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
491 |
\footnotesize {\bf in London today:} 1 Scala job for every 30 Java jobs;\\[-2mm] |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
492 |
Scala programmers seem to get up to 20\% better salary} |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
493 |
\end{textblock}} |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
494 |
|
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
495 |
|
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
496 |
\only<5->{ |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
497 |
\begin{textblock}{1}(3,6) |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
498 |
\begin{bubble}[8.5cm] |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
499 |
\normalsize |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
500 |
Scala is a functional and object-oriented programming |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
501 |
language; compiles to the JVM; does not need null-pointer |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
502 |
exceptions; a course on Coursera\\ |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
503 |
\mbox{}\hfill\url{http://www.scala-lang.org} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
504 |
\end{bubble} |
98
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
505 |
\end{textblock}} |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
506 |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
507 |
\end{frame} |
98
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
508 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
509 |
|
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
510 |
|
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
511 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
3 | 512 |
\begin{frame}[t] |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
513 |
\frametitle{A Regular Expression} |
3 | 514 |
|
515 |
\begin{itemize} |
|
516 |
\item \ldots{} is a pattern or template for specifying strings |
|
517 |
\end{itemize}\bigskip |
|
518 |
||
519 |
\begin{center} |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
520 |
\only<1>{\scode{"https?://[^"]*"}}% |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
521 |
\only<2>{\scode{""""https?://[^"]*"""".r}} |
3 | 522 |
\end{center}\bigskip\bigskip |
523 |
||
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
524 |
matches for example\smallskip\\ |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
525 |
\hspace{2mm}\code{"http://www.foobar.com"}\\ |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
526 |
\hspace{2mm}\code{"https://www.tls.org"}\\ |
3 | 527 |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
528 |
\end{frame} |
3 | 529 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
530 |
||
531 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
532 |
\begin{frame}[t] |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
533 |
\frametitle{Finding Operations} |
0 | 534 |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
535 |
{\bf\code{rexp.findAllIn(string)}}\medskip |
3 | 536 |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
537 |
returns a list of all (sub)strings that match the |
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
538 |
regular expression |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
539 |
\bigskip\bigskip |
0 | 540 |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
541 |
|
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
542 |
{\bf\code{rexp.findFirstIn(string)}}\medskip |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
543 |
|
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
544 |
returns either |
0 | 545 |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
546 |
\begin{itemize} |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
547 |
\item \code{None} if no (sub)string matches or |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
548 |
\item \code{Some(s)} with the first (sub)string |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
549 |
\end{itemize} |
0 | 550 |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
551 |
\end{frame} |
0 | 552 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
553 |
||
554 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
3 | 555 |
\begin{frame}[c] |
0 | 556 |
|
3 | 557 |
\footnotesize |
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
558 |
\lstinputlisting{../progs/app2.scala} |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
559 |
|
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
560 |
\end{frame} |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
561 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
0 | 562 |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
563 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
564 |
\begin{frame}[c] |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
565 |
|
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
566 |
\small |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
567 |
A version that only crawls links in ``my'' domain: |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
568 |
|
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
569 |
\footnotesize |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
570 |
\lstinputlisting{../progs/app3.scala} |
0 | 571 |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
572 |
\end{frame} |
0 | 573 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
574 |
||
575 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
576 |
\begin{frame}[c] |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
577 |
\lstset{xleftmargin=-4mm} |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
578 |
\small |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
579 |
A little email harvester: |
3 | 580 |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
581 |
\footnotesize |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
582 |
\lstinputlisting{../progs/app4.scala}\bigskip |
3 | 583 |
|
584 |
\tiny |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
585 |
\url{http://net.tutsplus.com/tutorials/other/8-regular-expressions-you-should-know/} |
3 | 586 |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
587 |
\end{frame} |
3 | 588 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
589 |
||
590 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
14 | 591 |
\begin{frame}[t] |
3 | 592 |
\frametitle{\begin{tabular}{c}Regular Expressions\end{tabular}} |
0 | 593 |
|
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
594 |
Their inductive definition: |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
595 |
|
14 | 596 |
|
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
597 |
\begin{textblock}{6}(2,7.5) |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
598 |
\begin{tabular}{@ {}rrl@ {\hspace{13mm}}l} |
428
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
599 |
\bl{$r$} & \bl{$::=$} & \bl{$\ZERO$} & null\\ |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
600 |
& \bl{$\mid$} & \bl{$\ONE$} & empty string / \pcode{""} / $[]$\\ |
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
601 |
& \bl{$\mid$} & \bl{$c$} & character\\ |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
602 |
& \bl{$\mid$} & \bl{$r_1 + r_2$} & alternative / choice\\ |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
603 |
& \bl{$\mid$} & \bl{$r_1 \cdot r_2$} & sequence\\ |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
604 |
& \bl{$\mid$} & \bl{$r^*$} & star (zero or more)\\ |
3 | 605 |
\end{tabular} |
606 |
\end{textblock} |
|
607 |
||
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
608 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
609 |
\only<2->{\footnotesize |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
610 |
\begin{textblock}{9}(2,0.5) |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
611 |
\begin{bubble}[9.8cm] |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
612 |
\lstinputlisting{../progs/app01.scala} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
613 |
\end{bubble} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
614 |
\end{textblock}} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
615 |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
616 |
\end{frame} |
3 | 617 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
618 |
||
619 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
620 |
\begin{frame}[t] |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
621 |
\frametitle{Regular Expressions} |
3 | 622 |
|
14 | 623 |
\small |
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
624 |
In Scala:\bigskip |
14 | 625 |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
626 |
\footnotesize |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
627 |
\lstinputlisting{../progs/app51.scala} |
0 | 628 |
|
629 |
||
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
630 |
\end{frame} |
0 | 631 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
632 |
||
633 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
634 |
\begin{frame}[t] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
635 |
\frametitle{Strings} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
636 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
637 |
\ldots are lists of characters. For example \code{"hello"} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
638 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
639 |
\begin{center} |
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
640 |
\bl{$[h, e, l, l, o]$} or just \bl{$hello$} |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
641 |
\end{center} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
642 |
|
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
643 |
the empty string: \bl{$[]$} or \bl{\pcode{""}}\bigskip\\ |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
644 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
645 |
the concatenation of two strings: |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
646 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
647 |
\begin{center} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
648 |
\bl{$s_1 \,@\, s_2$} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
649 |
\end{center} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
650 |
|
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
651 |
\bl{\textit{foo $@$ bar = foobar}, \textit{baz $@\, []$ = baz}} |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
652 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
653 |
\end{frame} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
654 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
655 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
656 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
657 |
\begin{frame}[c] |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
658 |
\frametitle{Languages, Strings} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
659 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
660 |
\begin{itemize} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
661 |
\item \alert{\bf Strings} are lists of characters, for example |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
662 |
\begin{center} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
663 |
\bl{$[]$},\;\bl{$abc$} \hspace{2cm}(Pattern match: \bl{$c\!::\!s$}) |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
664 |
\end{center}\bigskip |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
665 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
666 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
667 |
\item A \alert{\bf language} is a set of strings, for example\medskip |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
668 |
\begin{center} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
669 |
\bl{$\{[], hello, \textit{foobar}, a, abc\}$} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
670 |
\end{center}\bigskip |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
671 |
|
332
4755ad4b457b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
331
diff
changeset
|
672 |
\item \alert{\bf Concatenation} of strings and languages |
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
673 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
674 |
\begin{center} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
675 |
\begin{tabular}{rcl} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
676 |
\bl{$\textit{foo}\;@\;bar$} & \bl{$=$} & \bl{$\textit{foobar}$}\medskip\\ |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
677 |
\bl{$A\;@\;B$} & \bl{$\dn$} & \bl{$\{ s_1\,@\,s_2 \;\mid\; s_1 \in A \wedge s_2 \in B\}$} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
678 |
\end{tabular} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
679 |
\end{center} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
680 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
681 |
%\item The \alert{\bf meaning} of a regular expression is a set of |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
682 |
% strings, or language. |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
683 |
\end{itemize} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
684 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
685 |
\end{frame} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
686 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
687 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
688 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
689 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
0 | 690 |
\mode<presentation>{ |
691 |
\begin{frame}[c] |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
692 |
\frametitle{\begin{tabular}{c}The Meaning of a\\[-2mm] |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
693 |
Regular Expression\end{tabular}} |
0 | 694 |
|
4 | 695 |
\begin{textblock}{15}(1,4) |
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
696 |
\begin{tabular}{rcl} |
428
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
697 |
\bl{$L(\ZERO)$} & \bl{$\dn$} & \bl{$\{\}$}\\ |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
698 |
\bl{$L(\ONE)$} & \bl{$\dn$} & \bl{$\{[]\}$}\\ |
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
699 |
\bl{$L(c)$} & \bl{$\dn$} & \bl{$\{[c]\}$}\\ |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
700 |
\bl{$L(r_1 + r_2)$} & \bl{$\dn$} & \bl{$L(r_1) \cup L(r_2)$}\\ |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
701 |
\bl{$L(r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{$\{ s_1 \,@\, s_2 \;|\; s_1 \in L(r_1) \wedge s_2 \in L(r_2) \}$}\\ |
428
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
702 |
\bl{$L(r^*)$} & \bl{$\dn$} & \onslide<4->{\bl{$\bigcup_{0 \le n} L(r)^n$}}\\ |
4 | 703 |
\end{tabular}\bigskip |
3 | 704 |
|
4 | 705 |
\onslide<2->{ |
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
706 |
\hspace{5mm}\bl{$L(r)^0 \;\dn\; \{[]\}$}\\ |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
707 |
\bl{$L(r)^{n+1} \;\dn\; L(r) \,@\, L(r)^n$}\hspace{9mm}\onslide<3->{\small\textcolor{gray}{(append on sets)}\\ |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
708 |
\small\hspace{5cm}\textcolor{gray}{$\{ s_1 @ s_2 \;|\; s_1\in L(r) \wedge s_2 \in L(r)^n \}$}} |
4 | 709 |
} |
710 |
\end{textblock} |
|
711 |
||
0 | 712 |
\end{frame}} |
713 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
714 |
||
5 | 715 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
716 |
\begin{frame}[c] |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
717 |
\frametitle{The Meaning of Matching} |
5 | 718 |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
719 |
\begin{bubble}[10cm] |
5 | 720 |
\large |
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
721 |
A regular expression \bl{$r$} matches a string \bl{$s$} |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
722 |
provided |
5 | 723 |
|
724 |
\begin{center} |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
725 |
\bl{$s \in L(r)$}\\ |
5 | 726 |
\end{center} |
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
727 |
\end{bubble}\bigskip\bigskip |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
728 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
729 |
\ldots and the point of the next lecture is |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
730 |
to decide this problem as fast as possible (unlike Python, |
428
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
731 |
Ruby, Java) |
5 | 732 |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
733 |
\end{frame} |
5 | 734 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
735 |
||
0 | 736 |
|
737 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
738 |
\begin{frame}[c] |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
739 |
\frametitle{Written Exam} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
740 |
|
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
741 |
\begin{itemize} |
428
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
742 |
\item Accounts for 80\%.\bigskip |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
743 |
|
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
744 |
\item You will understand the question ``\textit{Is this relevant for |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
745 |
the exam?}'' is very demotivating for the lecturer!\bigskip\\ |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
746 |
|
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
747 |
\item Deal: Whatever is in the homework (and is not marked |
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
748 |
``\textit{optional}'') is relevant for the exam.\bigskip |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
749 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
750 |
\item Each lecture has also a handout. There are also handouts about |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
751 |
notation and Scala. |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
752 |
\end{itemize} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
753 |
|
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
754 |
\end{frame} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
755 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
756 |
|
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
757 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
758 |
\begin{frame}[t] |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
759 |
\frametitle{Coursework} |
0 | 760 |
|
761 |
\begin{itemize} |
|
428
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
762 |
\item Accounts for 20\%. Two strands. Choose \alert{\bf one}!\bigskip |
0 | 763 |
\end{itemize} |
764 |
||
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
765 |
\begin{columns}[t] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
766 |
\begin{column}{.5\textwidth} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
767 |
\underline{\bf Strand 1}\medskip |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
768 |
\begin{itemize} |
428
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
769 |
\item four programming tasks: |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
770 |
\begin{itemize} |
428
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
771 |
\item matcher (4\%, 20.10.) |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
772 |
\item lexer (5\%, 03.11.) |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
773 |
\item parser (5\%, 24.11.) |
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
774 |
\item compiler (6\%, 13.12.) |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
775 |
\end{itemize} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
776 |
\end{itemize} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
777 |
\end{column} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
778 |
|
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
779 |
\hspace{-45pt}\vrule{}\hspace{10pt} |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
780 |
\begin{column}{.5\textwidth} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
781 |
\underline{\bf Strand 2}\smallskip\begin{itemize} |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
782 |
\item one task: prove the correctness of a regular expression matcher in |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
783 |
the Isabelle theorem prover |
428
a47c4227a0c6
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
334
diff
changeset
|
784 |
\item 20\%, submission 13.12. |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
785 |
\end{itemize} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
786 |
\end{column} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
787 |
\end{columns}\medskip |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
788 |
|
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
789 |
\small |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
790 |
\begin{itemize} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
791 |
\item Solving more than one strand will {\bf not} give you more |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
792 |
marks.\\[-2mm] |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
793 |
\item The exam will contain in much, much smaller form |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
794 |
elements from both (but will also be in lectures and HW). |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
795 |
\end{itemize} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
796 |
|
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
797 |
\end{frame} |
0 | 798 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
799 |
||
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
800 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
801 |
\begin{frame}[c] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
802 |
\frametitle{\begin{tabular}{c}\\[3cm]\alert{Questions?}\end{tabular}} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
803 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
804 |
\mbox{} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
805 |
\end{frame} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
806 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
0 | 807 |
\end{document} |
808 |
||
809 |
%%% Local Variables: |
|
810 |
%%% mode: latex |
|
811 |
%%% TeX-master: t |
|
812 |
%%% End: |
|
813 |