author | Christian Urban <christian.urban@kcl.ac.uk> |
Sat, 21 Oct 2023 09:09:09 +0100 | |
changeset 943 | 5365ef60707e |
parent 940 | 46eee459a999 |
child 953 | 5e070fb0332a |
permissions | -rw-r--r-- |
661 | 1 |
% !TEX program = xelatex |
743 | 2 |
\documentclass[dvipsnames,14pt,t,xelatex,aspectratio=169,xcolor={table}]{beamer} |
270
4dbeaf43031d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
3 |
\usepackage{../slides} |
871 | 4 |
\usepackage{../graphicss} |
215
828303e8e4af
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
5 |
\usepackage{../langs} |
828303e8e4af
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
145
diff
changeset
|
6 |
\usepackage{../data} |
33 | 7 |
|
270
4dbeaf43031d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
8 |
\hfuzz=220pt |
4dbeaf43031d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
9 |
|
4dbeaf43031d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
10 |
\pgfplotsset{compat=1.11} |
145
920f675b4ed1
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
144
diff
changeset
|
11 |
|
722 | 12 |
|
788 | 13 |
\usepackage{tcolorbox} |
14 |
\newtcolorbox{mybox}{colback=red!5!white,colframe=red!75!black} |
|
15 |
\newtcolorbox{mybox2}[1]{colback=red!5!white,colframe=red!75!black,fonttitle=\bfseries,title=#1} |
|
16 |
\newtcolorbox{mybox3}[1]{colback=Cyan!5!white,colframe=Cyan!75!black,fonttitle=\bfseries,title=#1} |
|
17 |
||
722 | 18 |
% a hand written lexer for SML |
19 |
% https://ponyo.org/ |
|
20 |
% https://github.com/eatonphil/ponyo/blob/master/src/Sml/Lexer.sml |
|
788 | 21 |
\beamertemplateballitem |
722 | 22 |
|
270
4dbeaf43031d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
23 |
\newcommand{\bl}[1]{\textcolor{blue}{#1}} |
33 | 24 |
|
445 | 25 |
\renewcommand{\slidecaption}{CFL 04, King's College London} |
33 | 26 |
|
27 |
\begin{document} |
|
28 |
||
29 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
270
4dbeaf43031d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
30 |
\begin{frame}[t] |
33 | 31 |
\frametitle{% |
32 |
\begin{tabular}{@ {}c@ {}} |
|
33 |
\\[-3mm] |
|
892 | 34 |
\LARGE Compilers and \\[-1mm] |
35 |
\LARGE Formal Languages\\[-5mm] |
|
33 | 36 |
\end{tabular}} |
37 |
||
38 |
\normalsize |
|
39 |
\begin{center} |
|
40 |
\begin{tabular}{ll} |
|
940 | 41 |
Email: & christian.urban at kcl.ac.uk\\ |
42 |
Office Hour: & Thurdays 15 -- 16\\ |
|
892 | 43 |
Location: & N7.07 (North Wing, Bush House)\\ |
44 |
Slides \& Progs: & KEATS\\ |
|
45 |
Pollev: & \texttt{\alert{https://pollev.com/cfltutoratki576}}\\ |
|
33 | 46 |
\end{tabular} |
47 |
\end{center} |
|
660 | 48 |
|
743 | 49 |
\begin{center} |
50 |
\begin{tikzpicture} |
|
51 |
\node[drop shadow,fill=white,inner sep=0pt] |
|
52 |
{\footnotesize\rowcolors{1}{capri!10}{white} |
|
53 |
\begin{tabular}{|p{4.8cm}|p{4.8cm}|}\hline |
|
54 |
1 Introduction, Languages & 6 While-Language \\ |
|
55 |
2 Regular Expressions, Derivatives & 7 Compilation, JVM \\ |
|
56 |
3 Automata, Regular Languages & 8 Compiling Functional Languages \\ |
|
57 |
\cellcolor{blue!50} |
|
58 |
4 Lexing, Tokenising & 9 Optimisations \\ |
|
59 |
5 Grammars, Parsing & 10 LLVM \\ \hline |
|
60 |
\end{tabular}% |
|
61 |
}; |
|
62 |
\end{tikzpicture} |
|
63 |
\end{center} |
|
270
4dbeaf43031d
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
265
diff
changeset
|
64 |
\end{frame} |
574 | 65 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
66 |
||
943 | 67 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
68 |
\begin{frame}[c] |
|
69 |
\frametitle{While Tokens} |
|
70 |
||
71 |
\begin{center} |
|
72 |
\begin{tabular}{rcl} |
|
73 |
\pcode{WHILE\_REGS} & $\dn$ & \raisebox{-1mm}{\large(}\pcode{("k" : KEYWORD)} +\\ |
|
74 |
& & \phantom{(}\pcode{("i" : ID)} +\\ |
|
75 |
& & \phantom{(}\pcode{("o" : OP)} + \\ |
|
76 |
& & \phantom{(}\pcode{("n" : NUM)} + \\ |
|
77 |
& & \phantom{(}\pcode{("s" : SEMI)} +\\ |
|
78 |
& & \phantom{(}\pcode{("p" : (LPAREN + RPAREN))} +\\ |
|
79 |
& & \phantom{(}\pcode{("b" : (BEGIN + END))} +\\ |
|
80 |
& & \phantom{(}\pcode{("w" : WHITESPACE)}\raisebox{-1mm}{\large)$^*$} |
|
81 |
\end{tabular} |
|
82 |
\end{center} |
|
83 |
||
84 |
\end{frame} |
|
85 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
139
6e7c3db9023d
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
86 |
|
6e7c3db9023d
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
87 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
785 | 88 |
%\begin{frame}[c] |
89 |
%\frametitle{Coursework} |
|
90 |
% |
|
91 |
%\begin{itemize} |
|
92 |
%\item \bl{$\der\,c\,(r^+) \dn \der\,c (r\cdot r^*)$}\quad given |
|
93 |
%that \bl{$r^+ \dn r\cdot r^*$} |
|
94 |
%\end{itemize}\bigskip\pause |
|
661 | 95 |
|
785 | 96 |
%\begin{center} |
97 |
%\begin{tabular}{lcl} |
|
98 |
%\bl{$\der\,c\,(r\cdot r^*)$} & \bl{$\dn$} & |
|
99 |
%\only<2-4>{if \bl{$nullable\,r$}}% |
|
100 |
%\only<5>{\bl{$(\der\,c\,r)\cdot r^*$}}\\ |
|
101 |
% & & |
|
102 |
% \only<2>{then \bl{$(\der\,c\,r)\cdot r^* \,+\, \der\,c\,(r^*)$}}% |
|
103 |
% \only<3>{then \bl{$(\der\,c\,r)\cdot r^* \,+\, (\der\,c\,r)\cdot r^*$}}% |
|
104 |
% \only<4>{then \bl{$(\der\,c\,r)\cdot r^*$}}\\ |
|
105 |
% & & \only<2-4>{else \bl{$(\der\,c\,r)\cdot r^*$}} |
|
106 |
%\end{tabular} |
|
107 |
%\end{center} |
|
108 |
%\end{frame} |
|
661 | 109 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
110 |
||
111 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
785 | 112 |
%\begin{frame}[c] |
113 |
% \frametitle{Coursework (2)} |
|
114 |
% |
|
115 |
% \begin{itemize} |
|
116 |
% \item \bl{\texttt{CFUN(f: Char => Boolean)}} |
|
117 |
% \end{itemize}\medskip |
|
118 |
% |
|
119 |
% \begin{center} |
|
120 |
% \begin{tabular}{l} |
|
121 |
% \bl{\texttt{CHAR(c: Char)}} \bl{$\dn$}\\ |
|
122 |
% \quad\bl{\texttt{CFUN(\_ == c)}}\medskip\\ |
|
123 |
% \bl{\texttt{RANGE(cs: Set[Char])}} \bl{$\dn$}\\ |
|
124 |
% \quad\bl{\texttt{CFUN(cs.contains(\_))}}\medskip\\ |
|
125 |
% \bl{\texttt{ALL}} \bl{$\dn$}\\ |
|
126 |
% \quad\bl{\texttt{CFUN((c: Char) => true)}}\\ |
|
127 |
% \end{tabular} |
|
128 |
% \end{center} |
|
129 |
%\end{frame} |
|
661 | 130 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
743 | 131 |
|
272
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
132 |
|
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
133 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
134 |
\begin{frame}[c] |
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
135 |
\frametitle{The Goal of this Course} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
136 |
\mbox{}\\[-26mm]\mbox{} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
137 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
138 |
\begin{center} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
139 |
\begin{tikzpicture}[scale=1, |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
140 |
node/.style={ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
141 |
rectangle,rounded corners=3mm, |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
142 |
very thick,draw=black!50, |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
143 |
minimum height=18mm, minimum width=20mm, |
743 | 144 |
top color=white,bottom color=black!20,drop shadow}] |
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
145 |
|
578 | 146 |
\node at (3.05, 1.8) {\Large\bf Write a compiler}; |
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
147 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
148 |
\node (0) at (-2.3,0) {}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
149 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
150 |
\node (A) at (0,0) [node] {}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
151 |
\node [below right] at (A.north west) {lexer}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
152 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
153 |
\node (B) at (3,0) [node] {}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
154 |
\node [below right=1mm] at (B.north west) |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
155 |
{\mbox{}\hspace{-1mm}parser}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
156 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
157 |
\node (C) at (6,0) [node] {}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
158 |
\node [below right] at (C.north west) |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
159 |
{\mbox{}\hspace{-1mm}code gen}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
160 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
161 |
\node (1) at (8.4,0) {}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
162 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
163 |
\draw [->,line width=4mm] (0) -- (A); |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
164 |
\draw [->,line width=4mm] (A) -- (B); |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
165 |
\draw [->,line width=4mm] (B) -- (C); |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
166 |
\draw [->,line width=4mm] (C) -- (1); |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
167 |
\end{tikzpicture} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
168 |
\end{center} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
169 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
170 |
Today a lexer. |
579 | 171 |
|
172 |
\only<2>{ |
|
173 |
\begin{textblock}{1}(6,9.8) |
|
174 |
\begin{tabular}{c} |
|
175 |
\includegraphics[scale=0.13]{../pics/rosetta.jpg}\\[-2mm] |
|
176 |
\footnotesize lexing $\Rightarrow$ recognising words (Stone of Rosetta) |
|
177 |
\end{tabular} |
|
178 |
\end{textblock}} |
|
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
179 |
\end{frame} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
180 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
181 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
182 |
\begin{frame}[c] |
578 | 183 |
\frametitle{Regular Expressions} |
184 |
||
185 |
In programming languages they are often used to recognise:\medskip |
|
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
186 |
|
578 | 187 |
\begin{itemize} |
662 | 188 |
\item operands, digits |
578 | 189 |
\item identifiers |
190 |
\item numbers (non-leading zeros) |
|
191 |
\item keywords |
|
192 |
\item comments |
|
193 |
\end{itemize}\bigskip |
|
194 |
||
195 |
\mbox{}\hfill\bl{\url{http://www.regexper.com}} |
|
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
196 |
\end{frame} |
578 | 197 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
198 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
199 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
200 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
201 |
\begin{frame}[c] |
521 | 202 |
\frametitle{Lexing: Test Case} |
272
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
203 |
|
785 | 204 |
\mbox{\lstinputlisting[language=While]{../progs/while-tests/fib.while}} |
272
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
205 |
|
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
206 |
\end{frame} |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
207 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
208 |
|
578 | 209 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
210 |
%\begin{frame}[c] |
|
211 |
%\frametitle{?? Test Case} |
|
212 |
% |
|
213 |
%\mbox{\lstinputlisting[language=While]{../progs/collatz.while}} |
|
214 |
% |
|
215 |
%\end{frame} |
|
139
6e7c3db9023d
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
216 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
6e7c3db9023d
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
217 |
|
35 | 218 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
272
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
219 |
\begin{frame}[t] |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
220 |
|
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
221 |
\tt |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
222 |
\begin{center}\large |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
223 |
\code{"if true then then 42 else +"} |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
224 |
\end{center} |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
225 |
|
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
226 |
|
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
227 |
\begin{tabular}{@{}l} |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
228 |
KEYWORD: \\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
229 |
\hspace{5mm}{if}, {then}, {else},\\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
230 |
WHITESPACE:\\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
231 |
\hspace{5mm}{" "}, {$\backslash$n},\\ |
521 | 232 |
IDENTIFIER:\\ |
272
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
233 |
\hspace{5mm}LETTER $\cdot$ (LETTER + DIGIT + {\_})$^*$\\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
234 |
NUM:\\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
235 |
\hspace{5mm}(NONZERODIGIT $\cdot$ DIGIT$^*$) + {0}\\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
236 |
OP:\\ |
521 | 237 |
\hspace{5mm}+, -, *, \%, <, <=\\ |
272
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
238 |
COMMENT:\\ |
277
8eb3261294ba
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
274
diff
changeset
|
239 |
\hspace{5mm}{$\slash$*} $\cdot$ $\sim$(ALL$^*$ $\cdot$ (*$\slash$) $\cdot$ ALL$^*$) $\cdot$ {*$\slash$} |
272
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
240 |
\end{tabular} |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
241 |
|
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
242 |
\end{frame} |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
243 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
244 |
|
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
245 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
246 |
\begin{frame}[t] |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
247 |
|
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
248 |
\tt |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
249 |
\begin{center}\large |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
250 |
\code{"if true then then 42 else +"} |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
251 |
\end{center} |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
252 |
|
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
253 |
\only<1>{ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
254 |
\small\begin{tabular}{l} |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
255 |
KEYWORD(if),\\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
256 |
WHITESPACE,\\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
257 |
IDENT(true),\\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
258 |
WHITESPACE,\\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
259 |
KEYWORD(then),\\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
260 |
WHITESPACE,\\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
261 |
KEYWORD(then),\\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
262 |
WHITESPACE,\\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
263 |
NUM(42),\\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
264 |
WHITESPACE,\\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
265 |
KEYWORD(else),\\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
266 |
WHITESPACE,\\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
267 |
OP(+) |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
268 |
\end{tabular}} |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
269 |
|
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
270 |
\only<2>{ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
271 |
\small\begin{tabular}{l} |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
272 |
KEYWORD(if),\\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
273 |
IDENT(true),\\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
274 |
KEYWORD(then),\\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
275 |
KEYWORD(then),\\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
276 |
NUM(42),\\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
277 |
KEYWORD(else),\\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
278 |
OP(+) |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
279 |
\end{tabular}} |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
280 |
|
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
281 |
\end{frame} |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
282 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
283 |
|
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
284 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
285 |
\begin{frame}[c] |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
286 |
|
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
287 |
|
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
288 |
There is one small problem with the tokenizer. How should we |
578 | 289 |
tokenize\ldots? |
272
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
290 |
|
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
291 |
\begin{center} |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
292 |
\large\code{"x-3"} |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
293 |
\end{center} |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
294 |
|
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
295 |
\tt |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
296 |
\begin{tabular}{@{}l} |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
297 |
ID: \ldots\\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
298 |
OP:\\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
299 |
\hspace{5mm}\texttt{"+"}, \texttt{"-"}\\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
300 |
NUM:\\ |
939 | 301 |
\hspace{5mm}(NONZERODIGIT $\cdot$ DIGIT$^*$) + {"0"}\\ |
272
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
302 |
NUMBER:\\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
303 |
\hspace{5mm}NUM + (\texttt{"-"} $\cdot$ NUM)\\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
304 |
\end{tabular} |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
305 |
|
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
306 |
\end{frame} |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
307 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
308 |
|
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
309 |
\begin{frame}[c] |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
310 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
311 |
The same problem with\medskip |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
312 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
313 |
\[ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
314 |
\bl{(ab + a) \cdot (c + bc)} |
353
b88670c5d04b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
352
diff
changeset
|
315 |
\]\medskip |
b88670c5d04b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
352
diff
changeset
|
316 |
|
662 | 317 |
and the string $\bl{abc}$.\pause\bigskip |
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
318 |
|
662 | 319 |
Or, keywords are \code{if} etc and identifiers are |
353
b88670c5d04b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
352
diff
changeset
|
320 |
letters followed by ``letters + numbers + \_''$^*$ |
b88670c5d04b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
352
diff
changeset
|
321 |
|
b88670c5d04b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
352
diff
changeset
|
322 |
\[ |
785 | 323 |
\bl{\texttt{if}}\qquad\bl{\texttt{iffoo}} |
353
b88670c5d04b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
352
diff
changeset
|
324 |
\] |
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
325 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
326 |
\end{frame} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
327 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
328 |
|
272
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
329 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
330 |
\begin{frame}[c] |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
331 |
\frametitle{POSIX: Two Rules} |
33 | 332 |
|
38 | 333 |
\begin{itemize} |
272
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
334 |
\item Longest match rule (``maximal munch rule''): The |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
335 |
longest initial substring matched by any regular expression is taken |
278
c7890e677e06
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
277
diff
changeset
|
336 |
as the next token.\bigskip |
272
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
337 |
|
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
338 |
\item Rule priority: |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
339 |
For a particular longest initial substring, the first regular |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
340 |
expression that can match determines the token. |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
341 |
\end{itemize}\bigskip\bigskip\pause |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
342 |
|
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
343 |
\small |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
344 |
\hfill most posix matchers are buggy\\ |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
345 |
\footnotesize |
353
b88670c5d04b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
352
diff
changeset
|
346 |
\hfill |
b88670c5d04b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
352
diff
changeset
|
347 |
\url{http://www.haskell.org/haskellwiki/Regex_Posix} |
b88670c5d04b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
352
diff
changeset
|
348 |
\smallskip\pause |
b88670c5d04b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
352
diff
changeset
|
349 |
|
b88670c5d04b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
352
diff
changeset
|
350 |
\hfill \small traditional lexers are fast, but hairy |
272
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
351 |
|
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
352 |
%\url{http://www.technologyreview.com/tr10/?year=2011} |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
353 |
%finite deterministic automata/ nondeterministic automaton |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
354 |
%\item problem with infix operations, for example i-12 |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
355 |
|
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
356 |
\end{frame} |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
357 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
358 |
|
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
359 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
360 |
\begin{frame}[c] |
581 | 361 |
\frametitle{Sulzmann \& Lu Matcher} |
272
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
362 |
|
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
363 |
We want to match the string \bl{$abc$} using \bl{$r_1$}: |
38 | 364 |
|
272
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
365 |
\begin{center} |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
366 |
\begin{tikzpicture}[scale=2,node distance=1.3cm,every node/.style={minimum size=8mm}] |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
367 |
\node (r1) {\bl{$r_1$}}; |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
368 |
\node (r2) [right=of r1] {\bl{$r_2$}}; |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
369 |
\draw[->,line width=1mm] (r1) -- (r2) node[above,midway] {\bl{$der\,a$}};\pause |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
370 |
\node (r3) [right=of r2] {\bl{$r_3$}}; |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
371 |
\draw[->,line width=1mm] (r2) -- (r3) node[above,midway] {\bl{$der\,b$}};\pause |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
372 |
\node (r4) [right=of r3] {\bl{$r_4$}}; |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
373 |
\draw[->,line width=1mm] (r3) -- (r4) node[above,midway] {\bl{$der\,c$}};\pause |
521 | 374 |
\draw (r4) node[anchor=west] {\;\raisebox{3mm}{\bl{$nullable?$}}};\pause |
272
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
375 |
\node (v4) [below=of r4] {\bl{$v_4$}}; |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
376 |
\draw[->,line width=1mm] (r4) -- (v4);\pause |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
377 |
\node (v3) [left=of v4] {\bl{$v_3$}}; |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
378 |
\draw[->,line width=1mm] (v4) -- (v3) node[below,midway] {\bl{$inj\,c$}};\pause |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
379 |
\node (v2) [left=of v3] {\bl{$v_2$}}; |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
380 |
\draw[->,line width=1mm] (v3) -- (v2) node[below,midway] {\bl{$inj\,b$}};\pause |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
381 |
\node (v1) [left=of v2] {\bl{$v_1$}}; |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
382 |
\draw[->,line width=1mm] (v2) -- (v1) node[below,midway] {\bl{$inj\,a$}};\pause |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
383 |
\draw[->,line width=0.5mm] (r3) -- (v3); |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
384 |
\draw[->,line width=0.5mm] (r2) -- (v2); |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
385 |
\draw[->,line width=0.5mm] (r1) -- (v1); |
273
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
386 |
\draw (r4) node[anchor=north west] {\;\raisebox{-8mm}{\bl{$mkeps$}}}; |
272
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
387 |
\end{tikzpicture} |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
388 |
\end{center} |
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
389 |
|
1446bc47a294
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
270
diff
changeset
|
390 |
\end{frame} |
33 | 391 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
392 |
||
273
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
393 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
394 |
\begin{frame}[c] |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
395 |
\frametitle{Regexes and Values} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
396 |
|
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
397 |
Regular expressions and their corresponding values: |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
398 |
|
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
399 |
\begin{center} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
400 |
\begin{columns} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
401 |
\begin{column}{3cm} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
402 |
\begin{tabular}{@{}rrl@{}} |
445 | 403 |
\bl{$r$} & \bl{$::=$} & \bl{$\ZERO$}\\ |
404 |
& \bl{$\mid$} & \bl{$\ONE$} \\ |
|
273
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
405 |
& \bl{$\mid$} & \bl{$c$} \\ |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
406 |
& \bl{$\mid$} & \bl{$r_1 \cdot r_2$}\\ |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
407 |
& \bl{$\mid$} & \bl{$r_1 + r_2$} \\ |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
408 |
\\ |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
409 |
& \bl{$\mid$} & \bl{$r^*$} \\ |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
410 |
\\ |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
411 |
\end{tabular} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
412 |
\end{column} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
413 |
\begin{column}{3cm} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
414 |
\begin{tabular}{@{\hspace{-7mm}}rrl@{}} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
415 |
\bl{$v$} & \bl{$::=$} & \\ |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
416 |
& & \bl{$Empty$} \\ |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
417 |
& \bl{$\mid$} & \bl{$Char(c)$} \\ |
279
f406c6677b8c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
278
diff
changeset
|
418 |
& \bl{$\mid$} & \bl{$Seq(v_1,v_2)$}\\ |
273
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
419 |
& \bl{$\mid$} & \bl{$Left(v)$} \\ |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
420 |
& \bl{$\mid$} & \bl{$Right(v)$} \\ |
578 | 421 |
& \bl{$\mid$} & \bl{$Stars\,[]$} \\ |
422 |
& \bl{$\mid$} & \bl{$Stars\,[v_1,\ldots\,v_n]$} \\ |
|
273
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
423 |
\end{tabular} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
424 |
\end{column} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
425 |
\end{columns} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
426 |
\end{center} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
427 |
|
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
428 |
\end{frame} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
429 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
430 |
|
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
431 |
\begin{frame}[c] |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
432 |
\small |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
433 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
434 |
{\small\lstinputlisting[language=Scala,numbers=none, |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
435 |
xleftmargin=-5mm] {../progs/app01.scala}} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
436 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
437 |
{\small\lstinputlisting[language=Scala,numbers=none, |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
438 |
xleftmargin=-5mm] {../progs/app02.scala}} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
439 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
440 |
\end{frame} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
441 |
|
273
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
442 |
|
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
443 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
444 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
445 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
446 |
\begin{frame}[c] |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
447 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
448 |
\begin{textblock}{10}(3,5) |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
449 |
\begin{tikzpicture}[scale=2,node distance=1.3cm,every node/.style={minimum size=8mm}] |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
450 |
\node (r1) {\bl{$r_1$}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
451 |
\node (r2) [right=of r1] {\bl{$r_2$}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
452 |
\draw[->,line width=1mm] (r1) -- (r2) node[above,midway] {\bl{$der\,a$}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
453 |
\node (r3) [right=of r2] {\bl{$r_3$}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
454 |
\draw[->,line width=1mm] (r2) -- (r3) node[above,midway] {\bl{$der\,b$}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
455 |
\node (r4) [right=of r3] {\bl{$r_4$}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
456 |
\draw[->,line width=1mm] (r3) -- (r4) node[above,midway] {\bl{$der\,c$}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
457 |
\draw (r4) node[anchor=west] {\;\raisebox{3mm}{\bl{$nullable$}}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
458 |
\node (v4) [below=of r4] {\bl{$v_4$}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
459 |
\draw[->,line width=1mm] (r4) -- (v4); |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
460 |
\node (v3) [left=of v4] {\bl{$v_3$}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
461 |
\draw[->,line width=1mm] (v4) -- (v3) node[below,midway] {\bl{$inj\,c$}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
462 |
\node (v2) [left=of v3] {\bl{$v_2$}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
463 |
\draw[->,line width=1mm] (v3) -- (v2) node[below,midway] {\bl{$inj\,b$}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
464 |
\node (v1) [left=of v2] {\bl{$v_1$}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
465 |
\draw[->,line width=1mm] (v2) -- (v1) node[below,midway] {\bl{$inj\,a$}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
466 |
\draw[->,line width=0.5mm] (r3) -- (v3); |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
467 |
\draw[->,line width=0.5mm] (r2) -- (v2); |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
468 |
\draw[->,line width=0.5mm] (r1) -- (v1); |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
469 |
\draw (r4) node[anchor=north west] {\;\raisebox{-8mm}{\bl{$mkeps$}}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
470 |
\end{tikzpicture} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
471 |
\end{textblock} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
472 |
|
662 | 473 |
\only<1->{ |
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
474 |
\begin{textblock}{6}(1,0.8) |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
475 |
\begin{bubble}[6cm] |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
476 |
\small |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
477 |
\begin{tabular}{ll} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
478 |
\bl{$r_1$}: & \bl{$a \cdot (b \cdot c)$}\\ |
445 | 479 |
\bl{$r_2$}: & \bl{$\ONE \cdot (b \cdot c)$}\\ |
480 |
\bl{$r_3$}: & \bl{$(\ZERO \cdot (b \cdot c)) + (\ONE \cdot c)$}\\ |
|
481 |
\bl{$r_4$}: & \bl{$(\ZERO \cdot (b \cdot c)) + ((\ZERO \cdot c) + \ONE)$}\\ |
|
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
482 |
\end{tabular} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
483 |
\end{bubble} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
484 |
\end{textblock}} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
485 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
486 |
\only<2->{ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
487 |
\begin{textblock}{6}(5,11.4) |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
488 |
\begin{bubble}[7.6cm] |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
489 |
\small |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
490 |
\begin{tabular}{ll} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
491 |
\bl{$v_1$}: & \bl{$Seq(Char(a), Seq(Char(b), Char(c)))$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
492 |
\bl{$v_2$}: & \bl{$Seq(Empty, Seq(Char(b), Char(c)))$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
493 |
\bl{$v_3$}: & \bl{$Right(Seq(Empty, Char(c)))$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
494 |
\bl{$v_4$}: & \bl{$Right(Right(Empty))$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
495 |
\end{tabular} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
496 |
\end{bubble} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
497 |
\end{textblock}} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
498 |
\end{frame} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
499 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
500 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
501 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
502 |
\begin{frame}[c] |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
503 |
\frametitle{Flatten} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
504 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
505 |
Obtaining the string underlying a value: |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
506 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
507 |
\begin{center} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
508 |
\begin{tabular}{lcl} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
509 |
\bl{$|Empty|$} & \bl{$\dn$} & \bl{$[]$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
510 |
\bl{$|Char(c)|$} & \bl{$\dn$} & \bl{$[c]$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
511 |
\bl{$|Left(v)|$} & \bl{$\dn$} & \bl{$|v|$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
512 |
\bl{$|Right(v)|$} & \bl{$\dn$} & \bl{$|v|$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
513 |
\bl{$|Seq(v_1,v_2)|$}& \bl{$\dn$} & \bl{$|v_1| \,@\, |v_2|$}\\ |
786 | 514 |
\bl{$|Stars\,[v_1,\ldots ,v_n]|$} & \bl{$\dn$} & \bl{$|v_1| \,@\ldots @\, |v_n|$}\\ |
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
515 |
\end{tabular} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
516 |
\end{center} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
517 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
518 |
\end{frame} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
519 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
520 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
521 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
522 |
\begin{frame}[c] |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
523 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
524 |
\begin{textblock}{10}(3,5) |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
525 |
\begin{tikzpicture}[scale=2,node distance=1.3cm,every node/.style={minimum size=8mm}] |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
526 |
\node (r1) {\bl{$r_1$}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
527 |
\node (r2) [right=of r1] {\bl{$r_2$}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
528 |
\draw[->,line width=1mm] (r1) -- (r2) node[above,midway] {\bl{$der\,a$}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
529 |
\node (r3) [right=of r2] {\bl{$r_3$}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
530 |
\draw[->,line width=1mm] (r2) -- (r3) node[above,midway] {\bl{$der\,b$}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
531 |
\node (r4) [right=of r3] {\bl{$r_4$}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
532 |
\draw[->,line width=1mm] (r3) -- (r4) node[above,midway] {\bl{$der\,c$}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
533 |
\draw (r4) node[anchor=west] {\;\raisebox{3mm}{\bl{$nullable$}}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
534 |
\node (v4) [below=of r4] {\bl{$v_4$}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
535 |
\draw[->,line width=1mm] (r4) -- (v4); |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
536 |
\node (v3) [left=of v4] {\bl{$v_3$}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
537 |
\draw[->,line width=1mm] (v4) -- (v3) node[below,midway] {\bl{$inj\,c$}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
538 |
\node (v2) [left=of v3] {\bl{$v_2$}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
539 |
\draw[->,line width=1mm] (v3) -- (v2) node[below,midway] {\bl{$inj\,b$}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
540 |
\node (v1) [left=of v2] {\bl{$v_1$}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
541 |
\draw[->,line width=1mm] (v2) -- (v1) node[below,midway] {\bl{$inj\,a$}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
542 |
\draw[->,line width=0.5mm] (r3) -- (v3); |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
543 |
\draw[->,line width=0.5mm] (r2) -- (v2); |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
544 |
\draw[->,line width=0.5mm] (r1) -- (v1); |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
545 |
\draw (r4) node[anchor=north west] {\;\raisebox{-8mm}{\bl{$mkeps$}}}; |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
546 |
\end{tikzpicture} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
547 |
\end{textblock} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
548 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
549 |
\begin{textblock}{6}(1,0.8) |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
550 |
\begin{bubble}[6cm] |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
551 |
\small |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
552 |
\begin{tabular}{ll} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
553 |
\bl{$r_1$}: & \bl{$a \cdot (b \cdot c)$}\\ |
445 | 554 |
\bl{$r_2$}: & \bl{$\ONE \cdot (b \cdot c)$}\\ |
555 |
\bl{$r_3$}: & \bl{$(\ZERO \cdot (b \cdot c)) + (\ONE \cdot c)$}\\ |
|
556 |
\bl{$r_4$}: & \bl{$(\ZERO \cdot (b \cdot c)) + ((\ZERO \cdot c) + \ONE)$}\\ |
|
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
557 |
\end{tabular} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
558 |
\end{bubble} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
559 |
\end{textblock} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
560 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
561 |
\begin{textblock}{6}(1,11.4) |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
562 |
\begin{bubble}[7.6cm] |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
563 |
\small |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
564 |
\begin{tabular}{ll} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
565 |
\bl{$v_1$}: & \bl{$Seq(Char(a), Seq(Char(b), Char(c)))$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
566 |
\bl{$v_2$}: & \bl{$Seq(Empty, Seq(Char(b), Char(c)))$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
567 |
\bl{$v_3$}: & \bl{$Right(Seq(Empty, Char(c)))$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
568 |
\bl{$v_4$}: & \bl{$Right(Right(Empty))$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
569 |
\end{tabular} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
570 |
\end{bubble} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
571 |
\end{textblock} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
572 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
573 |
\begin{textblock}{6}(12,11.4) |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
574 |
\begin{bubble}[2cm] |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
575 |
\small |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
576 |
\begin{tabular}{ll} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
577 |
\bl{$|v_1|$}: & \bl{$abc$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
578 |
\bl{$|v_2|$}: & \bl{$bc$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
579 |
\bl{$|v_3|$}: & \bl{$c$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
580 |
\bl{$|v_4|$}: & \bl{$[]$} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
581 |
\end{tabular} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
582 |
\end{bubble} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
583 |
\end{textblock} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
584 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
585 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
586 |
\end{frame} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
587 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
588 |
|
662 | 589 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
590 |
\begin{frame}[c] |
|
591 |
\frametitle{Mkeps} |
|
592 |
||
593 |
Finding a (posix) value for recognising the empty string: |
|
594 |
||
595 |
\begin{center} |
|
596 |
\begin{tabular}{lcl} |
|
597 |
\bl{$mkeps\,(\ONE)$} & \bl{$\dn$} & \bl{$Empty$}\\ |
|
598 |
\bl{$mkeps\,(r_1 + r_2)$} & \bl{$\dn$} & \bl{if $nullable(r_1)$} \\ |
|
599 |
& & \bl{then $Left(mkeps(r_1))$}\\ |
|
600 |
& & \bl{else $Right(mkeps(r_2))$}\\ |
|
601 |
\bl{$mkeps\,(r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{$Seq(mkeps(r_1),mkeps(r_2))$}\\ |
|
602 |
\bl{$mkeps\,(r^*)$} & \bl{$\dn$} & \bl{$Stars\,[]$} \\ |
|
603 |
\end{tabular} |
|
604 |
\end{center} |
|
605 |
||
606 |
\end{frame} |
|
607 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
785 | 608 |
|
609 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
610 |
\begin{frame}[c] |
|
611 |
\frametitle{Inject} |
|
612 |
\large |
|
613 |
||
614 |
\begin{center} |
|
615 |
\begin{tikzpicture}[scale=3,node distance=1.2cm, |
|
616 |
every node/.style={minimum size=7mm}] |
|
617 |
\node (r) {$r$}; |
|
618 |
\node (rd) [right=of r]{$r_{der}$}; |
|
619 |
\draw[->,line width=1mm](r)--(rd) node[above,midway] {$\der\,c$}; |
|
620 |
\node (vd) [below=of r2]{$v_{der}$}; |
|
621 |
\draw[->,line width=1mm](rd) -- (vd); |
|
622 |
\node (v) [left=of vd] {$v$}; |
|
623 |
\draw[->,line width=1mm](vd)--(v) node[below,midway] {$inj\,c$}; |
|
624 |
\draw[->,line width=0.5mm,dotted](r) -- (v) node[left,midway,red] {\bf ?}; |
|
625 |
\end{tikzpicture} |
|
626 |
\end{center} |
|
627 |
\end{frame} |
|
628 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
629 |
||
662 | 630 |
|
786 | 631 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
662 | 632 |
\begin{frame}[c] |
633 |
\frametitle{Inject} |
|
634 |
||
635 |
Injecting (``Adding'') a character to a value\\[-12mm]\mbox{} |
|
636 |
||
637 |
\begin{center} |
|
638 |
\begin{tabular}{@{\hspace{-3mm}}l@{\hspace{1mm}}c@{\hspace{1mm}}l@{}} |
|
639 |
\bl{$inj\,(c)\,c\,(Empty)$} & \bl{$\dn$} & \bl{$Char\,c$}\\ |
|
640 |
\bl{$inj\,(r_1 + r_2)\,c\,(Left(v))$} & \bl{$\dn$} & \bl{$Left(inj\,r_1\,c\,v)$}\\ |
|
641 |
\bl{$inj\,(r_1 + r_2)\,c\,(Right(v))$} & \bl{$\dn$} & \bl{$Right(inj\,r_2\,c\,v)$}\\ |
|
642 |
\bl{$inj\,(r_1 \cdot r_2)\,c\,(Seq(v_1,v_2))$} & \bl{$\dn$} & \bl{$Seq(inj\,r_1\,c\,v_1,v_2)$}\\ |
|
643 |
\bl{$inj\,(r_1 \cdot r_2)\,c\,(Left(Seq(v_1,v_2)))$} & \bl{$\dn$} & \bl{$Seq(inj\,r_1\,c\,v_1,v_2)$}\\ |
|
644 |
\bl{$inj\,(r_1 \cdot r_2)\,c\,(Right(v))$} & \bl{$\dn$} & \bl{$Seq(mkeps(r_1),inj\,r_2\,c\,v)$}\\ |
|
645 |
\bl{$inj\,(r^*)\,c\,(Seq(v,Stars\,vs))$} & \bl{$\dn$} & \bl{$Stars\,(inj\,r\,c\,v\,::\,vs)$}\\ |
|
646 |
\end{tabular} |
|
647 |
\end{center}\bigskip |
|
648 |
||
649 |
\footnotesize |
|
650 |
\begin{tabular}{l@{\hspace{2mm}}l} |
|
651 |
\bl{$inj$}: & 1st arg $\mapsto$ a rexp; 2nd arg $\mapsto$ a character; |
|
652 |
3rd arg $\mapsto$ a value\\ |
|
653 |
& result $\mapsto$ a value |
|
654 |
\end{tabular} |
|
655 |
\end{frame} |
|
786 | 656 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
657 |
||
658 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
659 |
\begin{frame}[t] |
|
660 |
||
661 |
\begin{center} |
|
662 |
\begin{tabular}{@{\hspace{-3mm}}l@{\hspace{1mm}}c@{\hspace{1mm}}l@{}} |
|
663 |
\bl{$inj\,(c)\,c\,(Empty)$} & \bl{$\dn$} & \bl{$Char\,c$}\\ |
|
664 |
\end{tabular} |
|
665 |
\end{center} |
|
666 |
||
667 |
\end{frame} |
|
668 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
669 |
||
670 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
671 |
\begin{frame}[t] |
|
672 |
||
673 |
\begin{center} |
|
674 |
\begin{tabular}{@{\hspace{-3mm}}l@{\hspace{1mm}}c@{\hspace{1mm}}l@{}} |
|
675 |
\bl{$inj\,(r_1 + r_2)\,c\,(Left(v))$} & \bl{$\dn$} & \bl{$Left(inj\,r_1\,c\,v)$}\\ |
|
676 |
\bl{$inj\,(r_1 + r_2)\,c\,(Right(v))$} & \bl{$\dn$} & \bl{$Right(inj\,r_2\,c\,v)$}\\ |
|
677 |
||
678 |
\end{tabular} |
|
679 |
\end{center} |
|
680 |
||
681 |
\end{frame} |
|
682 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
683 |
||
684 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
685 |
\begin{frame}[t] |
|
686 |
||
687 |
\begin{center} |
|
688 |
\begin{tabular}{@{\hspace{-8mm}}l@{\hspace{1mm}}c@{\hspace{1mm}}l@{}} |
|
689 |
\\[-15mm] |
|
690 |
\bl{$inj\,(r_1 \cdot r_2)\,c\,(Seq(v_1,v_2))$} & \bl{$\dn$} & \bl{$Seq(inj\,r_1\,c\,v_1,v_2)$}\\ |
|
691 |
\bl{$inj\,(r_1 \cdot r_2)\,c\,(Left(Seq(v_1,v_2)))$} & \bl{$\dn$} & \bl{$Seq(inj\,r_1\,c\,v_1,v_2)$}\\ |
|
692 |
\bl{$inj\,(r_1 \cdot r_2)\,c\,(Right(v))$} & \bl{$\dn$} & \bl{$Seq(mkeps(r_1),inj\,r_2\,c\,v)$}\\ |
|
693 |
\end{tabular} |
|
694 |
\end{center} |
|
695 |
||
696 |
||
697 |
\begin{textblock}{13}(1,13.4) |
|
698 |
\begin{bubble}[13cm] |
|
699 |
\small |
|
700 |
\bl{$\der\, c\, (r_1 \cdot r_2)$} \bl{$\dn$} \bl{\textbf{if} $nullable (r_1)$} |
|
701 |
\bl{\textbf{then} $(\der\,c\,r_1) \cdot r_2 + \der\, c\, r_2$} |
|
702 |
\bl{\textbf{else} $(\der\, c\, r_1) \cdot r_2$} |
|
703 |
\end{bubble} |
|
704 |
\end{textblock} |
|
705 |
||
706 |
\end{frame} |
|
707 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
708 |
||
709 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
710 |
\begin{frame}[t] |
|
711 |
||
712 |
\begin{center} |
|
713 |
\begin{tabular}{@{\hspace{-3mm}}l@{\hspace{1mm}}c@{\hspace{1mm}}l@{}} |
|
714 |
\bl{$inj\,(r^*)\,c\,(Seq(v,Stars\,vs))$} & \bl{$\dn$} & \bl{$Stars\,(inj\,r\,c\,v\,::\,vs)$} |
|
715 |
\end{tabular} |
|
716 |
\end{center} |
|
717 |
||
718 |
\end{frame} |
|
719 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
720 |
||
662 | 721 |
|
273
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
722 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
723 |
\begin{frame}[c] |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
724 |
\frametitle{Lexing} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
725 |
|
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
726 |
\begin{center} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
727 |
\begin{tabular}{l@{\hspace{1mm}}c@{\hspace{1mm}}l} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
728 |
\bl{$lex\,r\,[]$} & \bl{$\dn$} & \bl{if $nullable(r)$ then $mkeps(r)$ else $error$}\\ |
786 | 729 |
\bl{$lex\,r\,a::s$} & \bl{$\dn$} & \bl{$inj\,r\,a\,lex(der(a,r), s)$}\\ |
273
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
730 |
\end{tabular} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
731 |
\end{center} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
732 |
|
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
733 |
\footnotesize |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
734 |
\bl{$lex$}: returns a value |
280
267bd65b2e29
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
279
diff
changeset
|
735 |
|
267bd65b2e29
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
279
diff
changeset
|
736 |
\begin{center} |
267bd65b2e29
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
279
diff
changeset
|
737 |
\begin{tikzpicture}[scale=2,node distance=1.0cm,every node/.style={minimum size=6mm}] |
267bd65b2e29
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
279
diff
changeset
|
738 |
\node (r1) {\bl{$r_1$}}; |
267bd65b2e29
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
279
diff
changeset
|
739 |
\node (r2) [right=of r1] {\bl{$r_2$}}; |
267bd65b2e29
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
279
diff
changeset
|
740 |
\draw[->,line width=1mm] (r1) -- (r2) node[above,midway] {\bl{$der\,a$}}; |
267bd65b2e29
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
279
diff
changeset
|
741 |
\node (r3) [right=of r2] {\bl{$r_3$}}; |
267bd65b2e29
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
279
diff
changeset
|
742 |
\draw[->,line width=1mm] (r2) -- (r3) node[above,midway] {\bl{$der\,b$}}; |
267bd65b2e29
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
279
diff
changeset
|
743 |
\node (r4) [right=of r3] {\bl{$r_4$}}; |
267bd65b2e29
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
279
diff
changeset
|
744 |
\draw[->,line width=1mm] (r3) -- (r4) node[above,midway] {\bl{$der\,c$}}; |
267bd65b2e29
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
279
diff
changeset
|
745 |
\draw (r4) node[anchor=west] {\;\raisebox{3mm}{\bl{$nullable$}}}; |
267bd65b2e29
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
279
diff
changeset
|
746 |
\node (v4) [below=of r4] {\bl{$v_4$}}; |
267bd65b2e29
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
279
diff
changeset
|
747 |
\draw[->,line width=1mm] (r4) -- (v4); |
267bd65b2e29
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
279
diff
changeset
|
748 |
\node (v3) [left=of v4] {\bl{$v_3$}}; |
267bd65b2e29
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
279
diff
changeset
|
749 |
\draw[->,line width=1mm] (v4) -- (v3) node[below,midway] {\bl{$inj\,c$}}; |
267bd65b2e29
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
279
diff
changeset
|
750 |
\node (v2) [left=of v3] {\bl{$v_2$}}; |
267bd65b2e29
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
279
diff
changeset
|
751 |
\draw[->,line width=1mm] (v3) -- (v2) node[below,midway] {\bl{$inj\,b$}}; |
267bd65b2e29
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
279
diff
changeset
|
752 |
\node (v1) [left=of v2] {\bl{$v_1$}}; |
267bd65b2e29
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
279
diff
changeset
|
753 |
\draw[->,line width=1mm] (v2) -- (v1) node[below,midway] {\bl{$inj\,a$}}; |
267bd65b2e29
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
279
diff
changeset
|
754 |
\draw[->,line width=0.5mm] (r3) -- (v3); |
267bd65b2e29
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
279
diff
changeset
|
755 |
\draw[->,line width=0.5mm] (r2) -- (v2); |
267bd65b2e29
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
279
diff
changeset
|
756 |
\draw[->,line width=0.5mm] (r1) -- (v1); |
267bd65b2e29
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
279
diff
changeset
|
757 |
\draw (r4) node[anchor=north west] {\;\raisebox{-8mm}{\bl{$mkeps$}}}; |
267bd65b2e29
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
279
diff
changeset
|
758 |
\end{tikzpicture} |
267bd65b2e29
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
279
diff
changeset
|
759 |
\end{center} |
267bd65b2e29
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
279
diff
changeset
|
760 |
|
273
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
761 |
\end{frame} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
762 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
763 |
|
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
764 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
765 |
\begin{frame}[c] |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
766 |
\frametitle{Records} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
767 |
|
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
768 |
\begin{itemize} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
769 |
\item new regex: \bl{$(x:r)$}\hspace{7mm}new value: \bl{$Rec(x,v)$}\medskip\pause |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
770 |
|
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
771 |
\item \bl{$nullable(x:r) \dn nullable(r)$} |
671 | 772 |
\item \bl{$der\,c\,(x:r) \dn der\,c\,r$} |
273
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
773 |
\item \bl{$mkeps(x:r) \dn Rec(x, mkeps(r))$} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
774 |
\item \bl{$inj\,(x:r)\,c\,v \dn Rec(x, inj\,r\,c\,v)$} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
775 |
\end{itemize}\bigskip\bigskip\pause |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
776 |
|
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
777 |
\small |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
778 |
for extracting subpatterns \bl{$(z: ((x:ab) + (y:ba))$} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
779 |
|
786 | 780 |
\begin{textblock}{6}(10,10) |
781 |
\begin{bubble}[2cm] |
|
782 |
\small |
|
783 |
\begin{tabular}{l} |
|
784 |
\bl{$(id : r_{id})$}\\ |
|
785 |
\bl{$(key : r_{key})$}\\ |
|
786 |
\end{tabular} |
|
787 |
\end{bubble} |
|
788 |
\end{textblock} |
|
789 |
||
790 |
||
273
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
791 |
\end{frame} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
792 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
793 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
794 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
795 |
\begin{frame}[c] |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
796 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
797 |
\begin{itemize} |
445 | 798 |
\item A regular expression for email addresses |
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
799 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
800 |
\begin{center} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
801 |
\begin{tabular}{l} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
802 |
(name: \bl{$[a\mbox{-}z0\mbox{-}9\_\!\_\,.-]^+$})\bl{$\cdot @\cdot$}\\ |
794 | 803 |
\qquad(domain: \bl{$[a\mbox{-}z0\mbox{-}9\,-]^+$}) \bl{$\cdot .\cdot$}\\ |
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
804 |
\qquad\qquad(top\_level: \bl{$[a\mbox{-}z\,.]^{\{2,6\}}$}) |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
805 |
\end{tabular} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
806 |
\end{center} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
807 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
808 |
\bl{\[ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
809 |
\texttt{christian.urban@kcl.ac.uk} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
810 |
\]} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
811 |
|
445 | 812 |
\item the result environment: |
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
813 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
814 |
\begin{center} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
815 |
\begin{tabular}{l} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
816 |
\bl{$[(name:\texttt{christian.urban}),$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
817 |
\bl{$\phantom{[}(domain:\texttt{kcl}),$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
818 |
\bl{$\phantom{[}(top\_level:\texttt{ac.uk})]$} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
819 |
\end{tabular} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
820 |
\end{center} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
821 |
\end{itemize} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
822 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
823 |
\end{frame} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
824 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
825 |
|
273
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
826 |
|
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
827 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
828 |
\begin{frame}[c] |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
829 |
\frametitle{While Tokens} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
830 |
|
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
831 |
\begin{center} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
832 |
\begin{tabular}{rcl} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
833 |
\pcode{WHILE\_REGS} & $\dn$ & \raisebox{-1mm}{\large(}\pcode{("k" : KEYWORD)} +\\ |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
834 |
& & \phantom{(}\pcode{("i" : ID)} +\\ |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
835 |
& & \phantom{(}\pcode{("o" : OP)} + \\ |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
836 |
& & \phantom{(}\pcode{("n" : NUM)} + \\ |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
837 |
& & \phantom{(}\pcode{("s" : SEMI)} +\\ |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
838 |
& & \phantom{(}\pcode{("p" : (LPAREN + RPAREN))} +\\ |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
839 |
& & \phantom{(}\pcode{("b" : (BEGIN + END))} +\\ |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
840 |
& & \phantom{(}\pcode{("w" : WHITESPACE)}\raisebox{-1mm}{\large)$^*$} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
841 |
\end{tabular} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
842 |
\end{center} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
843 |
|
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
844 |
\end{frame} |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
845 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
b56d5e4468c0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
272
diff
changeset
|
846 |
|
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
847 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
848 |
|
274
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
849 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
850 |
\begin{frame}[c] |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
851 |
\frametitle{Simplification} |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
852 |
|
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
853 |
\begin{itemize} |
522 | 854 |
\item If we simplify after the derivative, then we are building the |
578 | 855 |
value for the simplified regular expression, but \alert{\textbf{not}} for the original |
274
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
856 |
regular expression. |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
857 |
\end{itemize} |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
858 |
|
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
859 |
\begin{center} |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
860 |
\begin{tikzpicture}[scale=2,node distance=1.3cm,every node/.style={minimum size=8mm}] |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
861 |
\node (r1) {\bl{$r_1$}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
862 |
\node (r2) [right=of r1] {\bl{$r_2$}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
863 |
\draw[->,line width=1mm] (r1) -- (r2) node[above,midway] {\bl{$der\,a$}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
864 |
\node (r3) [right=of r2] {\bl{$r_3$}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
865 |
\draw[->,line width=1mm] (r2) -- (r3) node[above,midway] {\bl{$der\,b$}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
866 |
\node (r4) [right=of r3] {\bl{$r_4$}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
867 |
\draw[->,line width=1mm] (r3) -- (r4) node[above,midway] {\bl{$der\,c$}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
868 |
\draw (r4) node[anchor=west] {\;\raisebox{3mm}{\bl{$nullable$}}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
869 |
\node (v4) [below=of r4] {\bl{$v_4$}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
870 |
\draw[->,line width=1mm] (r4) -- (v4); |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
871 |
\node (v3) [left=of v4] {\bl{$v_3$}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
872 |
\draw[->,line width=1mm] (v4) -- (v3) node[below,midway] {\bl{$inj\,c$}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
873 |
\node (v2) [left=of v3] {\bl{$v_2$}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
874 |
\draw[->,line width=1mm] (v3) -- (v2) node[below,midway] {\bl{$inj\,b$}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
875 |
\node (v1) [left=of v2] {\bl{$v_1$}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
876 |
\draw[->,line width=1mm] (v2) -- (v1) node[below,midway] {\bl{$inj\,a$}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
877 |
\draw[->,line width=0.5mm] (r3) -- (v3); |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
878 |
\draw[->,line width=0.5mm] (r2) -- (v2); |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
879 |
\draw[->,line width=0.5mm] (r1) -- (v1); |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
880 |
\draw (r4) node[anchor=north west] {\;\raisebox{-8mm}{\bl{$mkeps$}}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
881 |
\end{tikzpicture} |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
882 |
\end{center} |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
883 |
|
792 | 884 |
\small\pause |
445 | 885 |
\hspace{4.5cm}\bl{$(\ZERO \cdot (b \cdot c)) + ((\ZERO \cdot c) + \ONE)$} |
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
886 |
$\mapsto$ |
445 | 887 |
\bl{$\ONE$} |
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
888 |
|
274
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
889 |
\end{frame} |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
890 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
891 |
|
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
892 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
893 |
\begin{frame}[c] |
447
68769db65185
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
445
diff
changeset
|
894 |
|
68769db65185
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
445
diff
changeset
|
895 |
Normally we would have |
68769db65185
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
445
diff
changeset
|
896 |
|
68769db65185
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
445
diff
changeset
|
897 |
\begin{center} |
68769db65185
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
445
diff
changeset
|
898 |
\bl{$(\ZERO \cdot (b \cdot c)) + ((\ZERO \cdot c) + \ONE)$} |
68769db65185
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
445
diff
changeset
|
899 |
\end{center} |
68769db65185
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
445
diff
changeset
|
900 |
|
452
b93f4d2aeee1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
451
diff
changeset
|
901 |
and answer how this regular expression matches the empty string |
578 | 902 |
with the value |
447
68769db65185
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
445
diff
changeset
|
903 |
|
68769db65185
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
445
diff
changeset
|
904 |
\begin{center} |
68769db65185
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
445
diff
changeset
|
905 |
\bl{$Right(Right(Empty))$} |
68769db65185
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
445
diff
changeset
|
906 |
\end{center}\bigskip |
68769db65185
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
445
diff
changeset
|
907 |
|
578 | 908 |
But now we simplify this to \bl{$\ONE$} and would produce \bl{$Empty$} (see \textit{mkeps}). |
447
68769db65185
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
445
diff
changeset
|
909 |
|
68769db65185
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
445
diff
changeset
|
910 |
\end{frame} |
68769db65185
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
445
diff
changeset
|
911 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
68769db65185
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
445
diff
changeset
|
912 |
|
68769db65185
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
445
diff
changeset
|
913 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
68769db65185
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
445
diff
changeset
|
914 |
\begin{frame}[c] |
274
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
915 |
\frametitle{Rectification} |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
916 |
|
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
917 |
\def\arraystretch{1.05} |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
918 |
\begin{center} |
445 | 919 |
\begin{tabular}{l@{\hspace{2mm}}c@{\hspace{2mm}}l@{\hspace{8mm}}l} |
274
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
920 |
& & & \hspace{5mm}rectification \\ |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
921 |
& & & \hspace{5mm}functions:\\ |
445 | 922 |
\bl{$r \cdot \ZERO$} & $\mapsto$ & \bl{$\ZERO$} & \\ |
923 |
\bl{$\ZERO \cdot r$} & $\mapsto$ & \bl{$\ZERO$} & \\ |
|
924 |
\bl{$r \cdot \ONE$} & $\mapsto$ & \bl{$r$} & \bl{$\lambda f_1\,f_2\,v.\, Seq(f_1\,v, f_2\,Empty)$}\\ |
|
925 |
\bl{$\ONE \cdot r$} & $\mapsto$ & \bl{$r$} & \bl{$\lambda f_1\,f_2\,v.\, Seq(f_1\,Empty, f_2\,v)$}\\ |
|
926 |
\bl{$r + \ZERO$} & $\mapsto$ & \bl{$r$} & \bl{$\lambda f_1\,f_2\,v.\, Left(f_1\,v)$}\\ |
|
927 |
\bl{$\ZERO + r$} & $\mapsto$ & \bl{$r$} & \bl{$\lambda f_1\,f_2\,v.\, Right(f_2\,v)$}\\ |
|
274
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
928 |
\bl{$r + r$} & $\mapsto$ & \bl{$r$} & \bl{$\lambda f_1\,f_2\,v.\, Left(f_1\,v)$} |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
929 |
\end{tabular} |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
930 |
\end{center}\medskip\pause |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
931 |
|
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
932 |
\small |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
933 |
old \bl{$simp$} returns a rexp;\\ |
445 | 934 |
new \bl{$simp$} returns a rexp and a rectification~function. |
274
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
935 |
\end{frame} |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
936 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
937 |
|
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
938 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
939 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
940 |
\begin{frame}[c] |
788 | 941 |
\frametitle{Rectification $\_ + \_$} |
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
942 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
943 |
\begin{center} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
944 |
\begin{tabular}{l} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
945 |
\bl{$simp(r)$}:\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
946 |
\quad case \bl{$r = r_1 + r_2$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
947 |
\qquad let \bl{$(r_{1s}, f_{1s}) = simp(r_1)$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
948 |
\qquad \phantom{let} \bl{$(r_{2s}, f_{2s}) = simp(r_2)$}\smallskip\\ |
445 | 949 |
\qquad case \bl{$r_{1s} = \ZERO$}: |
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
950 |
return \bl{$(r_{2s}, \lambda v. \,Right(f_{2s}(v)))$}\\ |
445 | 951 |
\qquad case \bl{$r_{2s} = \ZERO$}: |
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
952 |
return \bl{$(r_{1s}, \lambda v. \,Left(f_{1s}(v)))$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
953 |
\qquad case \bl{$r_{1s} = r_{2s}$}: |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
954 |
return \bl{$(r_{1s}, \lambda v. \,Left(f_{1s}(v)))$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
955 |
\qquad otherwise: |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
956 |
return \bl{$(r_{1s} + r_{2s}, f_{alt}(f_{1s}, f_{2s}))$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
957 |
\end{tabular} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
958 |
\end{center} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
959 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
960 |
\small |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
961 |
\begin{center} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
962 |
\begin{tabular}{l@{\hspace{1mm}}l} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
963 |
\bl{$f_{alt}(f_1, f_2) \dn$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
964 |
\qquad \bl{$\lambda v.\,$} case \bl{$v = Left(v')$}: |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
965 |
& return \bl{$Left(f_1(v'))$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
966 |
\qquad \phantom{$\lambda v.\,$} case \bl{$v = Right(v')$}: |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
967 |
& return \bl{$Right(f_2(v'))$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
968 |
\end{tabular} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
969 |
\end{center} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
970 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
971 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
972 |
\end{frame} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
973 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
974 |
|
445 | 975 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
976 |
\begin{frame}[c] |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
977 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
978 |
{\footnotesize\lstinputlisting[language=Scala,numbers=none, |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
979 |
xleftmargin=-5mm] {../progs/app05.scala}} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
980 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
981 |
\end{frame} |
445 | 982 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
983 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
984 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
985 |
\begin{frame}[c] |
788 | 986 |
\frametitle{Rectification $\_ \cdot \_$} |
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
987 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
988 |
\begin{center} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
989 |
\begin{tabular}{@{\hspace{-3mm}}l} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
990 |
\bl{$simp(r)$}:\ldots\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
991 |
\quad case \bl{$r = r_1 \cdot r_2$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
992 |
\qquad let \bl{$(r_{1s}, f_{1s}) = simp(r_1)$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
993 |
\qquad \phantom{let} \bl{$(r_{2s}, f_{2s}) = simp(r_2)$}\smallskip\\ |
445 | 994 |
\qquad case \bl{$r_{1s} = \ZERO$}: |
995 |
return \bl{$(\ZERO, f_{error})$}\\ |
|
996 |
\qquad case \bl{$r_{2s} = \ZERO$}: |
|
997 |
return \bl{$(\ZERO, f_{error})$}\\ |
|
998 |
\qquad case \bl{$r_{1s} = \ONE$}: |
|
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
999 |
return \bl{$(r_{2s}, \lambda v. \,Seq(f_{1s}(Empty), f_{2s}(v)))$}\\ |
445 | 1000 |
\qquad case \bl{$r_{2s} = \ONE$}: |
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1001 |
return \bl{$(r_{1s}, \lambda v. \,Seq(f_{1s}(v), f_{2s}(Empty)))$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1002 |
\qquad otherwise: |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1003 |
return \bl{$(r_{1s} \cdot r_{2s}, f_{seq}(f_{1s}, f_{2s}))$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1004 |
\end{tabular} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1005 |
\end{center} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1006 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1007 |
\small |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1008 |
\begin{center} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1009 |
\begin{tabular}{l@{\hspace{1mm}}l} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1010 |
\bl{$f_{seq}(f_1, f_2) \dn$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1011 |
\qquad \bl{$\lambda v.\,$ case $v = Seq(v_1, v_2)$}: |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1012 |
& return \bl{$Seq(f_1(v_1), f_2(v_2))$}\\ |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1013 |
\end{tabular} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1014 |
\end{center} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1015 |
\end{frame} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1016 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1017 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1018 |
|
451 | 1019 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1020 |
\begin{frame}[c] |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1021 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1022 |
{\footnotesize\lstinputlisting[language=Scala,numbers=none, |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1023 |
xleftmargin=-5mm] {../progs/app06.scala}} |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1024 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1025 |
\end{frame} |
451 | 1026 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1027 |
||
1028 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1029 |
\begin{frame}[t] |
|
1030 |
\frametitle{Rectification Example} |
|
1031 |
||
1032 |
\begin{center} |
|
1033 |
\bl{$\only<1>{(b \cdot c)}% |
|
1034 |
\only<2-3>{(\underline{b \cdot c})}% |
|
1035 |
\only<1-3>{+}% |
|
1036 |
\only<1>{(\ZERO + \ONE)}% |
|
1037 |
\only<2-3>{(\underline{\ZERO + \ONE})}$}% |
|
1038 |
\only<4->{% |
|
1039 |
\bl{$\underline{(b \cdot c) + (\ZERO + \ONE)}$}% |
|
1040 |
} |
|
1041 |
$\mapsto$ |
|
1042 |
\bl{$(b \cdot c) + \ONE$} |
|
1043 |
\end{center}\bigskip |
|
1044 |
||
1045 |
\onslide<3->{% |
|
1046 |
\begin{center} |
|
1047 |
\begin{tabular}{lcl} |
|
1048 |
\bl{$f_{s1}$} & \bl{$=$} & \bl{$\lambda v.v$}\\ |
|
1049 |
\bl{$f_{s2}$} & \bl{$=$} & \bl{$\lambda v. \textit{Right}(v)$} |
|
1050 |
\end{tabular} |
|
1051 |
\end{center}} |
|
1052 |
||
1053 |
\only<4>{% |
|
1054 |
\begin{center} |
|
1055 |
\begin{tabular}{@{}l@{\hspace{1mm}}l@{}} |
|
1056 |
\bl{$f_{alt}(f_{s1}, f_{s2}) \dn$}\\ |
|
1057 |
\quad \bl{$\lambda v.\,$} |
|
1058 |
case \bl{$v = Left(v')$}: |
|
1059 |
& return \bl{$Left(f_{s1}(v'))$}\\ |
|
1060 |
\quad \phantom{$\lambda v.\,$} |
|
1061 |
case \bl{$v = Right(v')$}: |
|
1062 |
& return \bl{$Right(f_{s2}(v'))$}\\ |
|
1063 |
\end{tabular} |
|
1064 |
\end{center}}% |
|
1065 |
\only<5->{% |
|
1066 |
\begin{center} |
|
1067 |
\begin{tabular}{@{}l@{\hspace{1mm}}l@{}} |
|
1068 |
\only<5->{\phantom{\bl{$f_{alt}(f_{s1}, f_{s2}) \dn$}}}\\ |
|
1069 |
\quad \bl{$\lambda v.\,$} |
|
1070 |
case \bl{$v = Left(v')$}: |
|
1071 |
& return \bl{$Left(v')$}\\ |
|
1072 |
\quad \phantom{$\lambda v.\,$} |
|
1073 |
case \bl{$v = Right(v')$}: |
|
1074 |
& return \bl{$Right(Right(v'))$}\\ |
|
1075 |
\end{tabular} |
|
1076 |
\end{center}}% |
|
1077 |
||
1078 |
\only<6->{% |
|
1079 |
\begin{center} |
|
1080 |
\begin{tabular}{@{}l@{\hspace{4mm}}l@{}} |
|
1081 |
\bl{$\textit{mkeps}$} simplified case: & |
|
1082 |
\bl{$\textit{Right}(\textit{Empty})$}\\ |
|
1083 |
rectified case: & |
|
1084 |
\bl{$\textit{Right}(\textit{Right}(\textit{Empty}))$} |
|
1085 |
\end{tabular} |
|
1086 |
\end{center}}% |
|
1087 |
||
1088 |
\end{frame} |
|
1089 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1090 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1091 |
|
274
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1092 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1093 |
\begin{frame}[c] |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1094 |
\frametitle{Lexing with Simplification} |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1095 |
|
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1096 |
\begin{center} |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1097 |
\begin{tabular}{l@{\hspace{1mm}}c@{\hspace{1mm}}l} |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1098 |
\bl{$lex\,r\,[]$} & \bl{$\dn$} & \bl{if $nullable(r)$ then $mkeps(r)$ else $error$}\\ |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1099 |
\bl{$lex\,r\,c::s$} & \bl{$\dn$} & \bl{let $(r', frect) = simp(der(c, r))$}\smallskip\\ |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1100 |
& & \bl{$inj\,r\,c\,(frect(lex(r', s)))$}\\ |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1101 |
\end{tabular} |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1102 |
\end{center}\bigskip |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1103 |
|
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1104 |
\begin{center}\small |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1105 |
\begin{tikzpicture}[node distance=1.1cm,every node/.style={minimum size=7mm}] |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1106 |
\node (r1) {\bl{$r_1$}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1107 |
\node (r2) [right=of r1] {\bl{$r_2$}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1108 |
\draw[->,line width=1mm] (r1) -- (r2) node[above,midway] {\bl{$der\,a$}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1109 |
\node (r3) [right=of r2] {\bl{$r_3$}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1110 |
\draw[->,line width=1mm] (r2) -- (r3) node[above,midway] {\bl{$der\,b$}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1111 |
\node (r4) [right=of r3] {\bl{$r_4$}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1112 |
\draw[->,line width=1mm] (r3) -- (r4) node[above,midway] {\bl{$der\,c$}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1113 |
\draw (r4) node[anchor=west] {\;\raisebox{3mm}{\bl{$nullable$}}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1114 |
\node (v4) [below=of r4] {\bl{$v_4$}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1115 |
\draw[->,line width=1mm] (r4) -- (v4); |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1116 |
\node (v3) [left=of v4] {\bl{$v_3$}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1117 |
\draw[->,line width=1mm] (v4) -- (v3) node[below,midway] {\bl{$inj\,c$}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1118 |
\node (v2) [left=of v3] {\bl{$v_2$}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1119 |
\draw[->,line width=1mm] (v3) -- (v2) node[below,midway] {\bl{$inj\,b$}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1120 |
\node (v1) [left=of v2] {\bl{$v_1$}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1121 |
\draw[->,line width=1mm] (v2) -- (v1) node[below,midway] {\bl{$inj\,a$}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1122 |
\draw[->,line width=0.5mm] (r3) -- (v3); |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1123 |
\draw[->,line width=0.5mm] (r2) -- (v2); |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1124 |
\draw[->,line width=0.5mm] (r1) -- (v1); |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1125 |
\draw (r4) node[anchor=north west] {\;\raisebox{-8mm}{\bl{$mkeps$}}}; |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1126 |
\end{tikzpicture} |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1127 |
\end{center} |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1128 |
|
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1129 |
|
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1130 |
\end{frame} |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1131 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
21f0f24424ab
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
273
diff
changeset
|
1132 |
|
451 | 1133 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1134 |
\begin{frame}[c] |
|
1135 |
\frametitle{Environments} |
|
1136 |
||
1137 |
Obtaining the ``recorded'' parts of a value: |
|
1138 |
||
1139 |
\begin{center} |
|
1140 |
\begin{tabular}{lcl} |
|
1141 |
\bl{$env(Empty)$} & \bl{$\dn$} & \bl{$[]$}\\ |
|
1142 |
\bl{$env(Char(c))$} & \bl{$\dn$} & \bl{$[]$}\\ |
|
1143 |
\bl{$env(Left(v))$} & \bl{$\dn$} & \bl{$env(v)$}\\ |
|
1144 |
\bl{$env(Right(v))$} & \bl{$\dn$} & \bl{$env(v)$}\\ |
|
1145 |
\bl{$env(Seq(v_1,v_2))$}& \bl{$\dn$} & \bl{$env(v_1) \,@\, env(v_2)$}\\ |
|
578 | 1146 |
\bl{$env(Stars\,[v_1,\ldots ,v_n])$} & \bl{$\dn$} & |
451 | 1147 |
\bl{$env(v_1) \,@\ldots @\, env(v_n)$}\\ |
1148 |
\bl{$env(Rec(x:v))$} & \bl{$\dn$} & \bl{$(x:|v|) :: env(v)$}\\ |
|
1149 |
\end{tabular} |
|
1150 |
\end{center} |
|
1151 |
||
1152 |
\end{frame} |
|
1153 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1154 |
||
1155 |
||
1156 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1157 |
\begin{frame}[c] |
|
1158 |
\frametitle{While Tokens} |
|
1159 |
||
1160 |
\begin{center} |
|
1161 |
\begin{tabular}{@{}r@{\hspace{2mm}}c@{\hspace{2mm}}l@{}} |
|
1162 |
\pcode{WHILE\_REGS} & $\dn$ & \raisebox{-1mm}{\large(}\pcode{("k" : KEYWORD)} +\\ |
|
1163 |
& & \phantom{(}\pcode{("i" : ID)} +\\ |
|
1164 |
& & \phantom{(}\pcode{("o" : OP)} + \\ |
|
1165 |
& & \phantom{(}\pcode{("n" : NUM)} + \\ |
|
1166 |
& & \phantom{(}\pcode{("s" : SEMI)} +\\ |
|
1167 |
& & \phantom{(}\pcode{("p" : (LPAREN + RPAREN))} +\\ |
|
1168 |
& & \phantom{(}\pcode{("b" : (BEGIN + END))} +\\ |
|
1169 |
& & \phantom{(}\pcode{("w" : WHITESPACE)}\raisebox{-1mm}{\large)$^*$} |
|
1170 |
\end{tabular} |
|
1171 |
\end{center} |
|
1172 |
||
1173 |
\end{frame} |
|
1174 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1175 |
||
1176 |
||
1177 |
||
1178 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1179 |
\begin{frame}[t] |
|
1180 |
||
1181 |
\consolas |
|
1182 |
\begin{center} |
|
1183 |
\code{"if true then then 42 else +"} |
|
1184 |
\end{center} |
|
1185 |
||
1186 |
\only<1>{ |
|
1187 |
\small\begin{tabular}{l} |
|
1188 |
KEYWORD(if),\\ |
|
1189 |
WHITESPACE,\\ |
|
1190 |
IDENT(true),\\ |
|
1191 |
WHITESPACE,\\ |
|
1192 |
KEYWORD(then),\\ |
|
1193 |
WHITESPACE,\\ |
|
1194 |
KEYWORD(then),\\ |
|
1195 |
WHITESPACE,\\ |
|
1196 |
NUM(42),\\ |
|
1197 |
WHITESPACE,\\ |
|
1198 |
KEYWORD(else),\\ |
|
1199 |
WHITESPACE,\\ |
|
1200 |
OP(+) |
|
1201 |
\end{tabular}} |
|
1202 |
||
1203 |
\only<2>{ |
|
1204 |
\small\begin{tabular}{l} |
|
1205 |
KEYWORD(if),\\ |
|
1206 |
IDENT(true),\\ |
|
1207 |
KEYWORD(then),\\ |
|
1208 |
KEYWORD(then),\\ |
|
1209 |
NUM(42),\\ |
|
1210 |
KEYWORD(else),\\ |
|
1211 |
OP(+) |
|
1212 |
\end{tabular}} |
|
1213 |
||
1214 |
\end{frame} |
|
1215 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1216 |
||
1217 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1218 |
\begin{frame}[c] |
|
521 | 1219 |
\frametitle{Lexer: Two Rules} |
451 | 1220 |
|
1221 |
\begin{itemize} |
|
1222 |
\item Longest match rule (``maximal munch rule''): The |
|
1223 |
longest initial substring matched by any regular expression is taken |
|
1224 |
as next token.\bigskip |
|
1225 |
||
1226 |
\item Rule priority: |
|
1227 |
For a particular longest initial substring, the first regular |
|
1228 |
expression that can match determines the token. |
|
1229 |
||
1230 |
\end{itemize} |
|
1231 |
||
1232 |
%\url{http://www.technologyreview.com/tr10/?year=2011} |
|
1233 |
||
1234 |
%finite deterministic automata/ nondeterministic automaton |
|
1235 |
||
1236 |
%\item problem with infix operations, for example i-12 |
|
1237 |
||
1238 |
||
1239 |
\end{frame} |
|
1240 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1241 |
||
1242 |
||
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1243 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1244 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
788 | 1245 |
%\begin{frame}[c] |
1246 |
%\begin{center} |
|
1247 |
%\begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}} |
|
1248 |
%\bl{$zeroable(\ZERO)$} & \bl{$\dn$} & \bl{$true$}\\ |
|
1249 |
%\bl{$zeroable(\ONE)$} & \bl{$\dn$} & \bl{$\textit{false}$}\\ |
|
1250 |
%\bl{$zeroable(c)$} & \bl{$\dn$} & \bl{$\textit{false}$}\\ |
|
1251 |
%\bl{$zeroable(r_1 + r_2)$} & \bl{$\dn$} & \bl{$zeroable(r_1) \wedge zeroable(r_2)$}\\ |
|
1252 |
%\bl{$zeroable(r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{$zeroable(r_1) \vee zeroable(r_2)$}\\ |
|
1253 |
%\bl{$zeroable(r^*)$} & \bl{$\dn$} & \bl{$\textit{false}$}\\ |
|
1254 |
%\end{tabular} |
|
1255 |
%\end{center} |
|
1256 |
% |
|
1257 |
%\begin{center} |
|
1258 |
%\bl{$zeroable(r)$} if and only if \bl{$L(r) = \{\}$} |
|
1259 |
%\end{center} |
|
1260 |
% |
|
1261 |
% |
|
1262 |
%\end{frame} |
|
352
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1263 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1264 |
|
1e1b0fe66107
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
283
diff
changeset
|
1265 |
|
743 | 1266 |
|
1267 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
788 | 1268 |
%\begin{frame}[c] |
1269 |
%\frametitle{\begin{tabular}{c}Last Week\\[-2mm] |
|
1270 |
% Regexes and Values\end{tabular}} |
|
1271 |
% |
|
1272 |
%Regular expressions and their corresponding values: |
|
1273 |
% |
|
1274 |
%\begin{center} |
|
1275 |
%\begin{columns} |
|
1276 |
%\begin{column}{3cm} |
|
1277 |
%\begin{tabular}{@{}rrl@{}} |
|
1278 |
% \bl{$r$} & \bl{$::=$} & \bl{$\ZERO$}\\ |
|
1279 |
% & \bl{$\mid$} & \bl{$\ONE$} \\ |
|
1280 |
% & \bl{$\mid$} & \bl{$c$} \\ |
|
1281 |
% & \bl{$\mid$} & \bl{$r_1 \cdot r_2$}\\ |
|
1282 |
% & \bl{$\mid$} & \bl{$r_1 + r_2$} \\ |
|
1283 |
% \\ |
|
1284 |
% & \bl{$\mid$} & \bl{$r^*$} \\ |
|
1285 |
% \end{tabular} |
|
1286 |
%\end{column} |
|
1287 |
%\begin{column}{3cm} |
|
1288 |
%\begin{tabular}{@{\hspace{-7mm}}rrl@{}} |
|
1289 |
% \bl{$v$} & \bl{$::=$} & \\ |
|
1290 |
% & & \bl{$Empty$} \\ |
|
1291 |
% & \bl{$\mid$} & \bl{$Char(c)$} \\ |
|
1292 |
% & \bl{$\mid$} & \bl{$Seq(v_1,v_2)$}\\ |
|
1293 |
% & \bl{$\mid$} & \bl{$Left(v)$} \\ |
|
1294 |
% & \bl{$\mid$} & \bl{$Right(v)$} \\ |
|
1295 |
% & \bl{$\mid$} & \bl{$Stars [v_1,\ldots\,v_n]$} \\ |
|
1296 |
% \end{tabular} |
|
1297 |
%\end{column} |
|
1298 |
%\end{columns} |
|
1299 |
%\end{center} |
|
1300 |
% |
|
1301 |
%\end{frame} |
|
743 | 1302 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1303 |
||
1304 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
788 | 1305 |
%\begin{frame}[c] |
1306 |
% |
|
1307 |
%\begin{textblock}{10}(3,5) |
|
1308 |
%\begin{tikzpicture}[scale=2,node distance=1.3cm,every node/.style={minimum size=8mm}] |
|
1309 |
%\node (r1) {\bl{$r_1$}}; |
|
1310 |
%\node (r2) [right=of r1] {\bl{$r_2$}}; |
|
1311 |
%\draw[->,line width=1mm] (r1) -- (r2) node[above,midway] {\bl{$der\,a$}}; |
|
1312 |
%\node (r3) [right=of r2] {\bl{$r_3$}}; |
|
1313 |
%\draw[->,line width=1mm] (r2) -- (r3) node[above,midway] {\bl{$der\,b$}}; |
|
1314 |
%\node (r4) [right=of r3] {\bl{$r_4$}}; |
|
1315 |
%\draw[->,line width=1mm] (r3) -- (r4) node[above,midway] {\bl{$der\,c$}}; |
|
1316 |
%\draw (r4) node[anchor=west] {\;\raisebox{3mm}{\bl{$nullable$}}}; |
|
1317 |
%\node (v4) [below=of r4] {\bl{$v_4$}}; |
|
1318 |
%\draw[->,line width=1mm] (r4) -- (v4); |
|
1319 |
%\node (v3) [left=of v4] {\bl{$v_3$}}; |
|
1320 |
%\draw[->,line width=1mm] (v4) -- (v3) node[below,midway] {\bl{$inj\,c$}}; |
|
1321 |
%\node (v2) [left=of v3] {\bl{$v_2$}}; |
|
1322 |
%\draw[->,line width=1mm] (v3) -- (v2) node[below,midway] {\bl{$inj\,b$}}; |
|
1323 |
%\node (v1) [left=of v2] {\bl{$v_1$}}; |
|
1324 |
%\draw[->,line width=1mm] (v2) -- (v1) node[below,midway] {\bl{$inj\,a$}}; |
|
1325 |
%\draw[->,line width=0.5mm] (r3) -- (v3); |
|
1326 |
%\draw[->,line width=0.5mm] (r2) -- (v2); |
|
1327 |
%\draw[->,line width=0.5mm] (r1) -- (v1); |
|
1328 |
%\draw (r4) node[anchor=north west] {\;\raisebox{-8mm}{\bl{$mkeps$}}}; |
|
1329 |
%\end{tikzpicture} |
|
1330 |
%\end{textblock} |
|
1331 |
% |
|
1332 |
%\begin{textblock}{6}(1,0.8) |
|
1333 |
%\begin{bubble}[6cm] |
|
1334 |
%\small |
|
1335 |
%\begin{tabular}{ll} |
|
1336 |
%\bl{$r_1$}: & \bl{$a \cdot (b \cdot c)$}\\ |
|
1337 |
%\bl{$r_2$}: & \bl{$\ONE \cdot (b \cdot c)$}\\ |
|
1338 |
%\bl{$r_3$}: & \bl{$(\ZERO \cdot (b \cdot c)) + (\ONE \cdot c)$}\\ |
|
1339 |
%\bl{$r_4$}: & \bl{$(\ZERO \cdot (b \cdot c)) + ((\ZERO \cdot c) + \ONE)$}\\ |
|
1340 |
%\end{tabular} |
|
1341 |
%\end{bubble} |
|
1342 |
%\end{textblock} |
|
1343 |
% |
|
1344 |
%\begin{textblock}{6}(1,11.4) |
|
1345 |
%\begin{bubble}[7.6cm] |
|
1346 |
%\small |
|
1347 |
%\begin{tabular}{ll} |
|
1348 |
%\bl{$v_1$}: & \bl{$Seq(Char(a), Seq(Char(b), Char(c)))$}\\ |
|
1349 |
%\bl{$v_2$}: & \bl{$Seq(Empty, Seq(Char(b), Char(c)))$}\\ |
|
1350 |
%\bl{$v_3$}: & \bl{$Right(Seq(Empty, Char(c)))$}\\ |
|
1351 |
%\bl{$v_4$}: & \bl{$Right(Right(Empty))$}\\ |
|
1352 |
%\end{tabular} |
|
1353 |
%\end{bubble} |
|
1354 |
%\end{textblock} |
|
1355 |
% |
|
1356 |
%\begin{textblock}{6}(12,11.4) |
|
1357 |
%\begin{bubble}[2cm] |
|
1358 |
%\small |
|
1359 |
%\begin{tabular}{ll} |
|
1360 |
%\bl{$|v_1|$}: & \bl{$abc$}\\ |
|
1361 |
%\bl{$|v_2|$}: & \bl{$bc$}\\ |
|
1362 |
%\bl{$|v_3|$}: & \bl{$c$}\\ |
|
1363 |
%\bl{$|v_4|$}: & \bl{$[]$} |
|
1364 |
%\end{tabular} |
|
1365 |
%\end{bubble} |
|
1366 |
%\end{textblock} |
|
1367 |
% |
|
1368 |
% |
|
1369 |
%%\end{frame} |
|
1370 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1371 |
% |
|
1372 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1373 |
%\begin{frame}[c] |
|
1374 |
%\frametitle{Simplification} |
|
1375 |
% |
|
1376 |
%\begin{itemize} |
|
1377 |
%\item If we simplify after the derivative, then we are builing the |
|
1378 |
%value for the simplified regular expression, but \emph{not} for the original |
|
1379 |
%regular expression. |
|
1380 |
%\end{itemize} |
|
1381 |
% |
|
1382 |
%\begin{center} |
|
1383 |
%\begin{tikzpicture}[scale=2,node distance=1.3cm,every node/.style={minimum size=8mm}] |
|
1384 |
%\node (r1) {\bl{$r_1$}}; |
|
1385 |
%\node (r2) [right=of r1] {\bl{$r_2$}}; |
|
1386 |
%\draw[->,line width=1mm] (r1) -- (r2) node[above,midway] {\bl{$der\,a$}}; |
|
1387 |
%\node (r3) [right=of r2] {\bl{$r_3$}}; |
|
1388 |
%\draw[->,line width=1mm] (r2) -- (r3) node[above,midway] {\bl{$der\,b$}}; |
|
1389 |
%\node (r4) [right=of r3] {\bl{$r_4$}}; |
|
1390 |
%\draw[->,line width=1mm] (r3) -- (r4) node[above,midway] {\bl{$der\,c$}}; |
|
1391 |
%\draw (r4) node[anchor=west] {\;\raisebox{3mm}{\bl{$nullable$}}}; |
|
1392 |
%\node (v4) [below=of r4] {\bl{$v_4$}}; |
|
1393 |
%\draw[->,line width=1mm] (r4) -- (v4); |
|
1394 |
%\node (v3) [left=of v4] {\bl{$v_3$}}; |
|
1395 |
%\draw[->,line width=1mm] (v4) -- (v3) node[below,midway] {\bl{$inj\,c$}}; |
|
1396 |
%\node (v2) [left=of v3] {\bl{$v_2$}}; |
|
1397 |
%\draw[->,line width=1mm] (v3) -- (v2) node[below,midway] {\bl{$inj\,b$}}; |
|
1398 |
%\node (v1) [left=of v2] {\bl{$v_1$}}; |
|
1399 |
%\draw[->,line width=1mm] (v2) -- (v1) node[below,midway] {\bl{$inj\,a$}}; |
|
1400 |
%\draw[->,line width=0.5mm] (r3) -- (v3); |
|
1401 |
%\draw[->,line width=0.5mm] (r2) -- (v2); |
|
1402 |
%\draw[->,line width=0.5mm] (r1) -- (v1); |
|
1403 |
%\draw (r4) node[anchor=north west] {\;\raisebox{-8mm}{\bl{$mkeps$}}}; |
|
1404 |
%\end{tikzpicture} |
|
1405 |
%\end{center} |
|
1406 |
% |
|
1407 |
%\small |
|
1408 |
%\hspace{4.5cm}\bl{$(b \cdot c) + (\ZERO + \ONE)$} |
|
1409 |
%$\mapsto$ |
|
1410 |
%\bl{$(b \cdot c) + \ONE$} |
|
1411 |
% |
|
1412 |
%\end{frame} |
|
1413 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1414 |
% |
|
1415 |
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
743 | 1416 |
% \begin{frame}[t] |
1417 |
||
1418 |
% \begin{center} |
|
1419 |
% \bl{$\only<1>{(b \cdot c)}% |
|
1420 |
% \only<2-3>{(\underline{b \cdot c})}% |
|
1421 |
% \only<1-3>{+}% |
|
1422 |
% \only<1>{(\ZERO + \ONE)}% |
|
1423 |
% \only<2-3>{(\underline{\ZERO + \ONE})}$}% |
|
1424 |
% \only<4->{% |
|
1425 |
% \bl{$\underline{(b \cdot c) + (\ZERO + \ONE)}$}% |
|
1426 |
% } |
|
1427 |
% $\mapsto$ |
|
1428 |
% \bl{$(b \cdot c) + \ONE$} |
|
1429 |
% \end{center}\bigskip |
|
1430 |
||
1431 |
% \onslide<3->{% |
|
1432 |
% \begin{center} |
|
1433 |
% \begin{tabular}{lcl} |
|
1434 |
% \bl{$f_{s1}$} & \bl{$=$} & \bl{$\lambda v.v$}\\ |
|
1435 |
% \bl{$f_{s2}$} & \bl{$=$} & \bl{$\lambda v. \textit{Right}(v)$} |
|
1436 |
% \end{tabular} |
|
1437 |
% \end{center}} |
|
1438 |
||
1439 |
% \only<4>{% |
|
1440 |
% \begin{center} |
|
1441 |
% \begin{tabular}{@{}l@{\hspace{1mm}}l@{}} |
|
1442 |
% \bl{$f_{alt}(f_{s1}, f_{s2}) \dn$}\\ |
|
1443 |
% \quad \bl{$\lambda v.\,$} |
|
1444 |
% case \bl{$v = Left(v')$}: |
|
1445 |
% & return \bl{$Left(f_{s1}(v'))$}\\ |
|
1446 |
% \quad \phantom{$\lambda v.\,$} |
|
1447 |
% case \bl{$v = Right(v')$}: |
|
1448 |
% & return \bl{$Right(f_{s2}(v'))$}\\ |
|
1449 |
% \end{tabular} |
|
1450 |
% \end{center}}% |
|
1451 |
% \only<5->{% |
|
1452 |
% \begin{center} |
|
1453 |
% \begin{tabular}{@{}l@{\hspace{1mm}}l@{}} |
|
1454 |
% \only<5->{\phantom{\bl{$f_{alt}(f_{s1}, f_{s2}) \dn$}}}\\ |
|
1455 |
% \quad \bl{$\lambda v.\,$} |
|
1456 |
% case \bl{$v = Left(v')$}: |
|
1457 |
% & return \bl{$Left(v')$}\\ |
|
1458 |
% \quad \phantom{$\lambda v.\,$} |
|
1459 |
% case \bl{$v = Right(v')$}: |
|
1460 |
% & return \bl{$Right(Right(v'))$}\\ |
|
1461 |
% \end{tabular} |
|
1462 |
% \end{center}}% |
|
1463 |
||
1464 |
% \only<6->{% |
|
1465 |
% \begin{center} |
|
1466 |
% \begin{tabular}{@{}l@{\hspace{4mm}}l@{}} |
|
1467 |
% \bl{$\textit{mkeps}$} simplified case: & |
|
1468 |
% \bl{$\textit{Right}(\textit{Empty})$}\\ |
|
1469 |
% rectified case: & |
|
1470 |
% \bl{$\textit{Right}(\textit{Right}(\textit{Empty}))$} |
|
1471 |
% \end{tabular} |
|
1472 |
% \end{center}}% |
|
1473 |
||
1474 |
% \end{frame} |
|
1475 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1476 |
||
788 | 1477 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1478 |
%\begin{frame}[c] |
|
1479 |
%\frametitle{Records} |
|
1480 |
% |
|
1481 |
%\begin{itemize} |
|
1482 |
%\item new regex: \bl{$(x:r)$}\hspace{7mm}new value: \bl{$Rec(x,v)$}\medskip\pause |
|
1483 |
% |
|
1484 |
%\item \bl{$nullable(x:r) \dn nullable(r)$} |
|
1485 |
%\item \bl{$der\,c\,(x:r) \dn der\,c\,r$} |
|
1486 |
%\item \bl{$mkeps(x:r) \dn Rec(x, mkeps(r))$} |
|
1487 |
%\item \bl{$inj\,(x:r)\,c\,v \dn Rec(x, inj\,r\,c\,v)$} |
|
1488 |
%\end{itemize}\bigskip\bigskip\pause |
|
1489 |
% |
|
1490 |
%\small |
|
1491 |
%for extracting subpatterns \bl{$(z: ((x:ab) + (y:ba))$} |
|
1492 |
% |
|
1493 |
%\end{frame} |
|
1494 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
743 | 1495 |
|
1496 |
||
1497 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1498 |
\begin{frame}[c] |
|
1499 |
\frametitle{Environments} |
|
1500 |
||
1501 |
Obtaining the ``recorded'' parts of a value: |
|
1502 |
||
1503 |
\begin{center} |
|
1504 |
\begin{tabular}{lcl} |
|
1505 |
\bl{$env(Empty)$} & \bl{$\dn$} & \bl{$[]$}\\ |
|
1506 |
\bl{$env(Char(c))$} & \bl{$\dn$} & \bl{$[]$}\\ |
|
1507 |
\bl{$env(Left(v))$} & \bl{$\dn$} & \bl{$env(v)$}\\ |
|
1508 |
\bl{$env(Right(v))$} & \bl{$\dn$} & \bl{$env(v)$}\\ |
|
1509 |
\bl{$env(Seq(v_1,v_2))$}& \bl{$\dn$} & \bl{$env(v_1) \,@\, env(v_2)$}\\ |
|
1510 |
\bl{$env(Stars [v_1,\ldots ,v_n])$} & \bl{$\dn$} & |
|
1511 |
\bl{$env(v_1) \,@\ldots @\, env(v_n)$}\\ |
|
1512 |
\bl{$env(Rec(x:v))$} & \bl{$\dn$} & \bl{$(x:|v|) :: env(v)$}\\ |
|
1513 |
\end{tabular} |
|
1514 |
\end{center} |
|
1515 |
||
1516 |
\end{frame} |
|
1517 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1518 |
||
1519 |
||
1520 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1521 |
\begin{frame}[c] |
|
1522 |
\frametitle{While Tokens} |
|
1523 |
||
1524 |
\begin{center} |
|
1525 |
\begin{tabular}{@{}r@{\hspace{2mm}}c@{\hspace{2mm}}l@{}} |
|
1526 |
\pcode{WHILE\_REGS} & $\dn$ & \raisebox{-1mm}{\large(}\pcode{("k" : KEYWORD)} +\\ |
|
1527 |
& & \phantom{(}\pcode{("i" : ID)} +\\ |
|
1528 |
& & \phantom{(}\pcode{("o" : OP)} + \\ |
|
1529 |
& & \phantom{(}\pcode{("n" : NUM)} + \\ |
|
1530 |
& & \phantom{(}\pcode{("s" : SEMI)} +\\ |
|
1531 |
& & \phantom{(}\pcode{("p" : (LPAREN + RPAREN))} +\\ |
|
1532 |
& & \phantom{(}\pcode{("b" : (BEGIN + END))} +\\ |
|
1533 |
& & \phantom{(}\pcode{("w" : WHITESPACE)}\raisebox{-1mm}{\large)$^*$} |
|
1534 |
\end{tabular} |
|
1535 |
\end{center} |
|
1536 |
||
1537 |
\end{frame} |
|
1538 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1539 |
||
1540 |
||
1541 |
||
1542 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1543 |
\begin{frame}[t] |
|
1544 |
||
1545 |
\consolas |
|
1546 |
\begin{center} |
|
1547 |
\code{"if true then then 42 else +"} |
|
1548 |
\end{center} |
|
1549 |
||
1550 |
\only<1>{ |
|
1551 |
\small\begin{tabular}{l} |
|
1552 |
KEYWORD(if),\\ |
|
1553 |
WHITESPACE,\\ |
|
1554 |
IDENT(true),\\ |
|
1555 |
WHITESPACE,\\ |
|
1556 |
KEYWORD(then),\\ |
|
1557 |
WHITESPACE,\\ |
|
1558 |
KEYWORD(then),\\ |
|
1559 |
WHITESPACE,\\ |
|
1560 |
NUM(42),\\ |
|
1561 |
WHITESPACE,\\ |
|
1562 |
KEYWORD(else),\\ |
|
1563 |
WHITESPACE,\\ |
|
1564 |
OP(+) |
|
1565 |
\end{tabular}} |
|
1566 |
||
1567 |
\only<2>{ |
|
1568 |
\small\begin{tabular}{l} |
|
1569 |
KEYWORD(if),\\ |
|
1570 |
IDENT(true),\\ |
|
1571 |
KEYWORD(then),\\ |
|
1572 |
KEYWORD(then),\\ |
|
1573 |
NUM(42),\\ |
|
1574 |
KEYWORD(else),\\ |
|
1575 |
OP(+) |
|
1576 |
\end{tabular}} |
|
1577 |
||
1578 |
\end{frame} |
|
1579 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1580 |
||
1581 |
||
1582 |
||
1583 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1584 |
%\begin{frame}[c] |
|
1585 |
%\frametitle{Coursework: PLs (16)} |
|
1586 |
% |
|
1587 |
%\begin{itemize} |
|
1588 |
%\item Java (16) |
|
1589 |
%\item C++, C, C\# (14) |
|
1590 |
%\item JavaScript (10) |
|
1591 |
%\item Scala (9) |
|
1592 |
%\item Python (9) |
|
1593 |
%\item PHP (6) |
|
1594 |
%\item Haskell (3) |
|
1595 |
%\item Ruby (4) |
|
1596 |
%\item Bash, Perl, Powershell (2) |
|
1597 |
%\item TypeScript (1) |
|
1598 |
%\item R (1) |
|
1599 |
%\item Coconut (1) |
|
1600 |
%\item Pascal (1) |
|
1601 |
%\end{itemize} |
|
1602 |
% |
|
1603 |
%\end{frame} |
|
1604 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1605 |
||
1606 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1607 |
%\begin{frame}[c] |
|
1608 |
%\frametitle{Coursework: Nullable} |
|
1609 |
% |
|
1610 |
%\begin{center} |
|
1611 |
%\begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}} |
|
1612 |
% \bl{$nullable([c_1 c_2 \ldots c_n])$} & \bl{$\dn$} & $?$\\ |
|
1613 |
% \bl{$nullable(r^+)$} & \bl{$\dn$} & $?$\\ |
|
1614 |
% \bl{$nullable(r^?)$} & \bl{$\dn$} & $?$\\ |
|
1615 |
% \bl{$nullable(r^{\{n\}})$} & \bl{$\dn$} & $?$\\ |
|
1616 |
% \bl{$nullable(r^{\{n..\}})$} & \bl{$\dn$} & $?$\\ |
|
1617 |
% \bl{$nullable(r^{\{..n\}})$} & \bl{$\dn$} & $?$\\ |
|
1618 |
% \bl{$nullable(r^{\{n..m\}})$} & \bl{$\dn$} & $?$\\ |
|
1619 |
% \bl{$nullable(\sim{}r)$} & \bl{$\dn$} & $?$\\ |
|
1620 |
% |
|
1621 |
%\end{tabular} |
|
1622 |
%\end{center} |
|
1623 |
% |
|
1624 |
%\end{frame} |
|
1625 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1626 |
||
1627 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1628 |
%\begin{frame}[c] |
|
1629 |
%%%\frametitle{Coursework: der} |
|
1630 |
% |
|
1631 |
%\begin{center} |
|
1632 |
%\begin{tabular}{@ {}l@ {\hspace{1mm}}c@ {\hspace{1mm}}l@ {}} |
|
1633 |
% \bl{$der\, c\, ([c_1 c_2 \ldots c_n])$} & \bl{$\dn$} & $?$\\ |
|
1634 |
% \bl{$der\, c\, (r^+)$} & \bl{$\dn$} & $?$\\ |
|
1635 |
% \bl{$der\, c\, (r^?)$} & \bl{$\dn$} & $?$\\ |
|
1636 |
% \bl{$der\, c\, (r^{\{n\}})$} & \bl{$\dn$} & |
|
1637 |
% \bl{$if\;n=0\;then\;\ZERO\;else\;(der\,c\,r)\cdot r^{\{n-\liningnums{1}\}}$}\\ |
|
1638 |
% \bl{$der\, c\, (r^{\{n..\}})$} & \bl{$\dn$} & |
|
1639 |
% \bl{$if\;n=0\;then (der\,c\,r)\cdot r^*$}\\ |
|
1640 |
% & & \bl{$\phantom{if\;n=0\;}else \;(der\,c\,r)\cdot r^{\{n-\liningnums{1}..\}}$}\\ |
|
1641 |
% \bl{$der\, c\, (r^{\{..n\}})$} & \bl{$\dn$} & |
|
1642 |
% \bl{$if\;n=0\;then\;\ZERO\;else\;(der\,c\,r)\cdot r^{\{..n-\liningnums{1}\}}$}\\ |
|
1643 |
% |
|
1644 |
% \bl{$der\, c\, (r^{\{n..m\}})$} & \bl{$\dn$} & |
|
1645 |
% \bl{$if\;n = 0 \wedge m = 0\;then\;\ZERO\; else$}\\ |
|
1646 |
% \multicolumn{3}{l}{\bl{$if\;n = 0 \wedge m > 0\;then\;(der\,c\,r)\cdot r^{\{..m-\liningnums{1}\}}$}}\\ |
|
1647 |
% \multicolumn{3}{l}{\bl{$\phantom{if\;n = 0 \wedge m > 0\;}else |
|
1648 |
% \;(der\,c\,r)\cdot r^{\{n-\liningnums{1}..m-\liningnums{1}\}}$}}\\ |
|
1649 |
% \bl{$der\, c\, (\sim{}r)$} & \bl{$\dn$} & $?$\\ |
|
1650 |
%\end{tabular} |
|
1651 |
%\end{center} |
|
1652 |
% |
|
1653 |
%\end{frame} |
|
1654 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1655 |
||
1656 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1657 |
%\begin{frame}[c] |
|
1658 |
%\frametitle{Coursework: CFUN} |
|
1659 |
% |
|
1660 |
%\begin{center} |
|
1661 |
%\begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}} |
|
1662 |
% \bl{$nullable(CFUN(\_))$} & \bl{$\dn$} & \bl{$false$}\\ |
|
1663 |
% \bl{$der\,c\,(CFUN(f))$} & \bl{$\dn$} & |
|
1664 |
% \bl{$if\;f(c)\;then\;\ONE\;else\;\ZERO$}\bigskip\\ |
|
1665 |
% \bl{$CHAR(c)$} & \bl{$\dn$} & \bl{$CFUN(\lambda{}d.\;c=d)$}\\ |
|
1666 |
% \bl{$CSET([c_1,\ldots,c_n])$} & \bl{$\dn$} & \bl{$CFUN(\lambda{}d.\;d\in [c_1,\ldots,c_n])$}\\ |
|
1667 |
% \bl{$ALL$} & \bl{$\dn$} & \bl{$CFUN(\lambda{}d.\;true)$}\\ |
|
1668 |
%\end{tabular} |
|
1669 |
%\end{center} |
|
1670 |
% |
|
1671 |
%\end{frame} |
|
1672 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
788 | 1673 |
|
847 | 1674 |
|
1675 |
||
892 | 1676 |
\begin{frame}<1-28>[c] |
788 | 1677 |
\end{frame} |
1678 |
||
1679 |
\begin{frame}[c] |
|
943 | 1680 |
\frametitle{Week 3 Feedback} |
1681 |
\begin{center} |
|
1682 |
\includegraphics[scale=0.30]{s0.png} |
|
1683 |
\end{center} |
|
1684 |
\end{frame} |
|
1685 |
||
1686 |
||
1687 |
\begin{frame}[c] |
|
788 | 1688 |
\begin{center} |
1689 |
\begin{tabular}{cc} |
|
943 | 1690 |
\includegraphics[scale=0.20]{s1.png} & |
1691 |
\includegraphics[scale=0.20]{s2.png} \\ |
|
1692 |
\includegraphics[scale=0.20]{s3.png} & |
|
1693 |
\includegraphics[scale=0.20]{s4.png} \\ |
|
892 | 1694 |
\end{tabular} |
1695 |
\end{center} |
|
1696 |
\end{frame} |
|
1697 |
||
1698 |
\begin{frame}[c] |
|
1699 |
\begin{center} |
|
1700 |
\begin{tabular}{cc} |
|
943 | 1701 |
\includegraphics[scale=0.20]{s5.png} & |
1702 |
\includegraphics[scale=0.20]{s6.png} \\ |
|
1703 |
\includegraphics[scale=0.20]{s7.png} & |
|
1704 |
\includegraphics[scale=0.20]{s8.png} \\ |
|
788 | 1705 |
\end{tabular} |
1706 |
\end{center} |
|
1707 |
\end{frame} |
|
1708 |
||
1709 |
\begin{frame}[c] |
|
1710 |
\begin{center} |
|
1711 |
\begin{tabular}{cc} |
|
943 | 1712 |
\includegraphics[scale=0.20]{s9.png} & |
1713 |
\includegraphics[scale=0.20]{s10.png} |
|
788 | 1714 |
\end{tabular} |
1715 |
\end{center} |
|
1716 |
\end{frame} |
|
1717 |
||
892 | 1718 |
|
1719 |
||
788 | 1720 |
\begin{frame}[c] |
892 | 1721 |
\small |
1722 |
\begin{itemize} |
|
943 | 1723 |
\item[$\bullet$] Great lecturer. Looking forward to the next lecture! |
1724 |
||
1725 |
\item[$\bullet$] Would it be possible for you to post the answer of |
|
1726 |
the homework to KEATS after sgts each week? It will be very |
|
1727 |
helpful for us to prepare for the exam. Thank you. |
|
892 | 1728 |
|
943 | 1729 |
\item[$\bullet$] A lot of the parts of the LGT are going through |
1730 |
what was covered in the videos. While this is helpful to refresh |
|
1731 |
students' minds, I think it would be better if the Pollev |
|
1732 |
questions were checked more regularly to focus on what students |
|
1733 |
want support with |
|
1734 |
\end{itemize}\bigskip |
|
892 | 1735 |
|
943 | 1736 |
$\Rightarrow$ Reluctant, but I am prepared for selected questions to |
1737 |
make the answers public. |
|
1738 |
||
1739 |
$\Rightarrow$ The content viewing numbers are a bit worrying. Therefore |
|
1740 |
the reflex on my side to lecture the content again. |
|
788 | 1741 |
\end{frame} |
743 | 1742 |
|
892 | 1743 |
\begin{frame}[c] |
1744 |
\small |
|
943 | 1745 |
\begin{minipage}{1.3\textwidth} |
1746 |
\begin{itemize} |
|
1747 |
\item[$\bullet$] |
|
1748 |
Regarding module content, the content is not only interesting but relevant, up-to-date, and applicable to the real world. The practical, real-world application of the module is made abundantly clear through the coursework-focused delivery of the module. The content of the module progresses fast, but that is due to the nature of the content and the aims of the module. The learning aims and assessment are clearly explained. |
|
892 | 1749 |
|
943 | 1750 |
Regarding teaching, Dr. Urban is incredibly helpful both inside (and even outside) contact hours. I can tell the lecturer is very passionate about teaching the module. TAs are on hand to help with all aspects of the module, with the lecturer having taken care to have dedicated TAs for resolving technical issues. Discussions both on the forum and in lessons are encouraged, and the module is structured so that high engagement with the content and live lessons will make it easier for students to do the module (which is, of course, a good thing). |
1751 |
||
1752 |
Only 3 weeks in I would very highly recommend the module. It is a difficult subject, but a pleasure to study at the same time. |
|
892 | 1753 |
\end{itemize} |
943 | 1754 |
\end{minipage} |
892 | 1755 |
\end{frame} |
1756 |
||
1757 |
\begin{frame}[c] |
|
1758 |
\small |
|
943 | 1759 |
\begin{minipage}{1.2\textwidth} |
1760 |
\begin{itemize} |
|
1761 |
\item[$\bullet$] Professor Christian is incredibly patient. He always stays longer after live session lectures to answer additional questions, even though he doesn't need to. He made me feel that no questions are stupid. Thanks so much! |
|
1762 |
||
1763 |
\item[$\bullet$] I am enjoying your module at the moment, I think you clearly explain every point and answer all questions during the live tutorial. |
|
1764 |
||
1765 |
\item[$\bullet$] It would be helpful to be given the full set of coursework templates on GitHub so that there is less ambiguity regarding future courseworks. |
|
1766 |
||
1767 |
\item[$\bullet$] Maybe some additional exercises in the LGT would be useful |
|
1768 |
\item[$\bullet$] This module handout are the most useful thing I have ever seen in this uni. |
|
1769 |
\item[$\bullet$] This module is structured very well and is very interesting. Thank you |
|
892 | 1770 |
\end{itemize} |
943 | 1771 |
$\Rightarrow$ In case of CW3 the starting files are comb1.sc and comb2.sc uploaded to KEATS. |
1772 |
\end{minipage} |
|
892 | 1773 |
\end{frame} |
1774 |
||
943 | 1775 |
|
892 | 1776 |
\begin{frame}[c] |
943 | 1777 |
\begin{center} |
1778 |
\includegraphics[scale=0.30]{~/Desktop/feynman-teaching.jpeg} |
|
1779 |
\end{center} |
|
892 | 1780 |
\end{frame} |
1781 |
||
1782 |
\end{document} |
|
1783 |
||
1784 |
||
33 | 1785 |
%%% Local Variables: |
1786 |
%%% mode: latex |
|
1787 |
%%% TeX-master: t |
|
1788 |
%%% End: |
|
1789 |