| 
876
 | 
     1  | 
% !TEX program = xelatex
  | 
| 
 | 
     2  | 
\documentclass[dvipsnames,14pt,t,xelatex,aspectratio=169,xcolor={table}]{beamer}
 | 
| 
 | 
     3  | 
\usepackage{../slides}
 | 
| 
 | 
     4  | 
\usepackage{../graphicss}
 | 
| 
 | 
     5  | 
\usepackage{../langs}
 | 
| 
 | 
     6  | 
\usepackage{../data}
 | 
| 
 | 
     7  | 
\usetikzlibrary{cd}
 | 
| 
929
 | 
     8  | 
\usepackage{listings-rust}
 | 
| 
964
 | 
     9  | 
\usepackage{ulem}
 | 
| 
876
 | 
    10  | 
  | 
| 
 | 
    11  | 
\usepackage{tcolorbox}
 | 
| 
 | 
    12  | 
\newtcolorbox{mybox}{colback=red!5!white,colframe=red!75!black}
 | 
| 
 | 
    13  | 
\newtcolorbox{mybox2}[1]{colback=red!5!white,colframe=red!75!black,fonttitle=\bfseries,title=#1}
 | 
| 
 | 
    14  | 
\newtcolorbox{mybox3}[1]{colback=Cyan!5!white,colframe=Cyan!75!black,fonttitle=\bfseries,title=#1}
 | 
| 
 | 
    15  | 
  | 
| 
 | 
    16  | 
  | 
| 
 | 
    17  | 
  | 
| 
 | 
    18  | 
\hfuzz=220pt 
  | 
| 
 | 
    19  | 
  | 
| 
 | 
    20  | 
\lstset{language=Scala,
 | 
| 
 | 
    21  | 
        style=mystyle,
  | 
| 
 | 
    22  | 
        numbersep=0pt,
  | 
| 
 | 
    23  | 
        numbers=none,
  | 
| 
 | 
    24  | 
        xleftmargin=0mm}
  | 
| 
 | 
    25  | 
  | 
| 
 | 
    26  | 
\newcommand{\bl}[1]{\textcolor{blue}{#1}}     
 | 
| 
 | 
    27  | 
 
  | 
| 
 | 
    28  | 
% beamer stuff 
  | 
| 
 | 
    29  | 
\renewcommand{\slidecaption}{CFL 01, King's College London}
 | 
| 
 | 
    30  | 
  | 
| 
 | 
    31  | 
%% https://cs.rit.edu/~hh/teaching/_media/cc18/lectures/lect1/main.pdf
  | 
| 
 | 
    32  | 
%% https://cs.rit.edu/~hh/teaching/_media/cc18/lectures/lect2/main.pdf
  | 
| 
 | 
    33  | 
%% https://cs.rit.edu/~hh/teaching/_media/cc18/lectures/lect3/main.pdf
  | 
| 
 | 
    34  | 
  | 
| 
928
 | 
    35  | 
  | 
| 
876
 | 
    36  | 
\begin{document}
 | 
| 
 | 
    37  | 
  | 
| 
 | 
    38  | 
%\begin{frame}[t]
 | 
| 
 | 
    39  | 
%
  | 
| 
 | 
    40  | 
%\begin{mybox}
 | 
| 
 | 
    41  | 
%A physical explanation the \emph{dynamic matrix}\\
 | 
| 
 | 
    42  | 
%lots of text
  | 
| 
 | 
    43  | 
%\end{mybox}
 | 
| 
 | 
    44  | 
  | 
| 
 | 
    45  | 
  | 
| 
 | 
    46  | 
%\begin{mybox2}{Test}
 | 
| 
 | 
    47  | 
%A physical explanation the \emph{dynamic matrix}\\
 | 
| 
 | 
    48  | 
%lots of text
  | 
| 
 | 
    49  | 
%\end{mybox2}
 | 
| 
 | 
    50  | 
  | 
| 
 | 
    51  | 
%\begin{mybox3}{Test}
 | 
| 
 | 
    52  | 
%A physical explanation the \emph{dynamic matrix}\\
 | 
| 
 | 
    53  | 
%lots of text
  | 
| 
 | 
    54  | 
%\end{mybox3}
 | 
| 
906
 | 
    55  | 
% \end{frame}
 | 
| 
 | 
    56  | 
  | 
| 
 | 
    57  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
921
 | 
    58  | 
%\begin{frame}[t]
 | 
| 
 | 
    59  | 
%\frametitle{%  
 | 
| 
 | 
    60  | 
%  \begin{tabular}{@ {}c@ {}}
 | 
| 
 | 
    61  | 
%  \\[-3mm]
  | 
| 
 | 
    62  | 
%  \LARGE Lunch with a Lecturer (29 March)\\[5mm] 
  | 
| 
 | 
    63  | 
%  \end{tabular}}
 | 
| 
 | 
    64  | 
%
  | 
| 
 | 
    65  | 
%  I teach CFL (compilers) and PEP (Scala)\bigskip
  | 
| 
 | 
    66  | 
%
  | 
| 
 | 
    67  | 
%  \begin{itemize}
 | 
| 
 | 
    68  | 
%  \item did undergraduate in Germany
  | 
| 
 | 
    69  | 
%  \item Master in St Andrews
  | 
| 
 | 
    70  | 
%  \item PhD in Cambridge  
  | 
| 
 | 
    71  | 
%  \end{itemize}\bigskip\bigskip
 | 
| 
 | 
    72  | 
%
  | 
| 
 | 
    73  | 
%  use mainly the Isabelle theorem prover in my work (see 6CCS3VER)
  | 
| 
 | 
    74  | 
%
  | 
| 
 | 
    75  | 
%  write code in functional programming languages (Scala, SML, Ocaml, Haskell)
  | 
| 
 | 
    76  | 
%\end{frame}
 | 
| 
906
 | 
    77  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
    78  | 
  | 
| 
921
 | 
    79  | 
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
    80  | 
% \begin{frame}[c]
 | 
| 
 | 
    81  | 
% \frametitle{Why Bother with Regexes?}
 | 
| 
906
 | 
    82  | 
  | 
| 
921
 | 
    83  | 
% \begin{columns}[t,onlytextwidth]
 | 
| 
 | 
    84  | 
% \begin{column}{1.8cm}
 | 
| 
 | 
    85  | 
% \mbox{}   
 | 
| 
 | 
    86  | 
% \end{column}    
 | 
| 
 | 
    87  | 
% \begin{column}{.5\textwidth}
 | 
| 
 | 
    88  | 
% \small{}Ruby, Python, Java 8\medskip\\
 | 
| 
 | 
    89  | 
% \begin{tikzpicture}\footnotesize
 | 
| 
 | 
    90  | 
% \begin{axis}[
 | 
| 
 | 
    91  | 
%     xlabel={$n$},
 | 
| 
 | 
    92  | 
%     x label style={at={(1.05,0.0)}},
 | 
| 
 | 
    93  | 
%     ylabel={time in secs},
 | 
| 
 | 
    94  | 
%     enlargelimits=false,
  | 
| 
 | 
    95  | 
%     xtick={0,5,...,30},
 | 
| 
 | 
    96  | 
%     xmax=33,
  | 
| 
 | 
    97  | 
%     ymax=35,
  | 
| 
 | 
    98  | 
%     ytick={0,5,...,30},
 | 
| 
 | 
    99  | 
%     scaled ticks=false,
  | 
| 
 | 
   100  | 
%     axis lines=left,
  | 
| 
 | 
   101  | 
%     width=\textwidth,
  | 
| 
 | 
   102  | 
%     height=4cm, 
  | 
| 
 | 
   103  | 
%     legend entries={Python,Ruby},  
 | 
| 
 | 
   104  | 
%     legend pos=north west,
  | 
| 
 | 
   105  | 
%     legend cell align=left]
  | 
| 
 | 
   106  | 
% \addplot[blue,mark=*, mark options={fill=white}] table {re-python.data};
 | 
| 
 | 
   107  | 
% \addplot[brown,mark=triangle*, mark options={fill=white}] table {re-ruby.data};
 | 
| 
 | 
   108  | 
% \end{axis}
 | 
| 
 | 
   109  | 
% \end{tikzpicture}
 | 
| 
 | 
   110  | 
% \begin{tikzpicture}\footnotesize
 | 
| 
 | 
   111  | 
% \begin{axis}[
 | 
| 
 | 
   112  | 
%     xlabel={$n$},
 | 
| 
 | 
   113  | 
%     x label style={at={(1.05,0.0)}},
 | 
| 
 | 
   114  | 
%     ylabel={time in secs},
 | 
| 
 | 
   115  | 
%     enlargelimits=false,
  | 
| 
 | 
   116  | 
%     xtick={0,5,...,30},
 | 
| 
 | 
   117  | 
%     xmax=33,
  | 
| 
 | 
   118  | 
%     ymax=35,
  | 
| 
 | 
   119  | 
%     ytick={0,5,...,30},
 | 
| 
 | 
   120  | 
%     scaled ticks=false,
  | 
| 
 | 
   121  | 
%     axis lines=left,
  | 
| 
 | 
   122  | 
%     width=\textwidth,
  | 
| 
 | 
   123  | 
%     height=4cm, 
  | 
| 
 | 
   124  | 
%     legend entries={Python, Java 8, JavaScript, Swift},  
 | 
| 
 | 
   125  | 
%     legend pos=north west,
  | 
| 
 | 
   126  | 
%     legend cell align=left]
  | 
| 
 | 
   127  | 
% \addplot[blue,mark=*, mark options={fill=white}] table {re-python2.data};   
 | 
| 
 | 
   128  | 
% \addplot[cyan,mark=*, mark options={fill=white}] table {re-java.data};
 | 
| 
 | 
   129  | 
% \addplot[red,mark=*, mark options={fill=white}] table {re-js.data};
 | 
| 
 | 
   130  | 
% \addplot[magenta,mark=*, mark options={fill=white}] table {re-swift.data};
 | 
| 
 | 
   131  | 
% \end{axis}
 | 
| 
 | 
   132  | 
% \end{tikzpicture}
 | 
| 
 | 
   133  | 
% %
  | 
| 
 | 
   134  | 
% \end{column}
 | 
| 
 | 
   135  | 
% \begin{column}{.5\textwidth}
 | 
| 
 | 
   136  | 
% \small{}In PEP \& CFL \medskip\\
 | 
| 
 | 
   137  | 
% \begin{tikzpicture}\footnotesize
 | 
| 
 | 
   138  | 
% \begin{axis}[
 | 
| 
 | 
   139  | 
%     xlabel={$n$},
 | 
| 
 | 
   140  | 
%     x label style={at={(1.07,0.0)}},
 | 
| 
 | 
   141  | 
%     ylabel={time in secs},
 | 
| 
 | 
   142  | 
%     enlargelimits=false,
  | 
| 
 | 
   143  | 
%     xtick={0,5000,...,10000},
 | 
| 
 | 
   144  | 
%     xmax=11000,
  | 
| 
 | 
   145  | 
%     ymax=35,
  | 
| 
 | 
   146  | 
%     ytick={0,5,...,30},
 | 
| 
 | 
   147  | 
%     scaled ticks=false,
  | 
| 
 | 
   148  | 
%     axis lines=left,
  | 
| 
 | 
   149  | 
%     width=\textwidth,
  | 
| 
 | 
   150  | 
%     height=4cm]
  | 
| 
 | 
   151  | 
% \addplot[green,mark=square*,mark options={fill=white}] table {re2.data};
 | 
| 
 | 
   152  | 
% \addplot[black,mark=square*,mark options={fill=white}] table {re3.data};
 | 
| 
 | 
   153  | 
% \end{axis}
 | 
| 
 | 
   154  | 
% \end{tikzpicture}
 | 
| 
 | 
   155  | 
% \begin{tikzpicture}\footnotesize
 | 
| 
 | 
   156  | 
% \begin{axis}[
 | 
| 
 | 
   157  | 
%     xlabel={$n$},
 | 
| 
 | 
   158  | 
%     x label style={at={(1.07,0.0)}},
 | 
| 
 | 
   159  | 
%     ylabel={time in secs},
 | 
| 
 | 
   160  | 
%     enlargelimits=false,
  | 
| 
 | 
   161  | 
%     ymax=35,
  | 
| 
 | 
   162  | 
%     ytick={0,5,...,30},
 | 
| 
 | 
   163  | 
%     scaled ticks=false,
  | 
| 
 | 
   164  | 
%     axis lines=left,
  | 
| 
 | 
   165  | 
%     width=\textwidth,
  | 
| 
 | 
   166  | 
%     height=4cm]
  | 
| 
 | 
   167  | 
% \addplot[black,mark=square*,mark options={fill=white}] table {re3a.data};
 | 
| 
 | 
   168  | 
% \end{axis}
 | 
| 
 | 
   169  | 
% \end{tikzpicture}
 | 
| 
 | 
   170  | 
% \end{column}
 | 
| 
 | 
   171  | 
% \end{columns}
 | 
| 
 | 
   172  | 
% \medskip
  | 
| 
906
 | 
   173  | 
  | 
| 
921
 | 
   174  | 
% \begin{textblock}{3}(-0.1,3.3)
 | 
| 
 | 
   175  | 
% \small\hfill\bl{\texttt{[a?]\{n\}[a]\{n\}}}:
 | 
| 
 | 
   176  | 
% \end{textblock}
 | 
| 
906
 | 
   177  | 
  | 
| 
921
 | 
   178  | 
% \begin{textblock}{3}(-0.1,8.7)  
 | 
| 
 | 
   179  | 
% \small\hfill\bl{\texttt{(a*)*b}}:
 | 
| 
 | 
   180  | 
% \end{textblock}
 | 
| 
906
 | 
   181  | 
  | 
| 
921
 | 
   182  | 
% \begin{textblock}{3}(0.3,13)
 | 
| 
 | 
   183  | 
% \small{}matching with strings
 | 
| 
 | 
   184  | 
% \bl{$\underbrace{\texttt{a}...\texttt{a}}_n$}  
 | 
| 
 | 
   185  | 
% \end{textblock}
 | 
| 
906
 | 
   186  | 
  | 
| 
921
 | 
   187  | 
% \end{frame} 
 | 
| 
 | 
   188  | 
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
  | 
| 
906
 | 
   189  | 
    
  | 
| 
 | 
   190  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
921
 | 
   191  | 
% \begin{frame}[c,fragile]
 | 
| 
 | 
   192  | 
%   \frametitle{Incidents}
 | 
| 
906
 | 
   193  | 
    
  | 
| 
921
 | 
   194  | 
%   \begin{itemize}
 | 
| 
 | 
   195  | 
%   \item a global outage on 2 July 2019 at \textbf{Cloudflare} 
 | 
| 
 | 
   196  | 
%   (first one for six years)\medskip
  | 
| 
906
 | 
   197  | 
  
  | 
| 
921
 | 
   198  | 
%   \begin{center}\small\color{blue}
 | 
| 
 | 
   199  | 
%   \begin{verbatim}  
 | 
| 
 | 
   200  | 
%   (?:(?:\"|'|\]|\}|\\|\d|(?:nan|infinity|true|false|
  | 
| 
 | 
   201  | 
%   null|undefined|symbol|math)|\`|\-|\+)+[)]*;?((?:\s
  | 
| 
 | 
   202  | 
%   |-|~|!|{}|\|\||\+)*.*(?:.*=.*)))  
 | 
| 
 | 
   203  | 
%   \end{verbatim}
 | 
| 
 | 
   204  | 
%   \end{center}\bigskip\bigskip\bigskip\bigskip\bigskip\bigskip\bigskip    
 | 
| 
906
 | 
   205  | 
  
  | 
| 
921
 | 
   206  | 
%   \item on 20 July 2016 the \textbf{Stack Exchange} webpage went down
 | 
| 
 | 
   207  | 
%     because of an evil regular expression
  | 
| 
984
 | 
   208  | 
%     \here{https://stackstatus.tumblr.com/post/147710624694/outage-postmortem-july-20-2016}    
 | 
| 
921
 | 
   209  | 
%   \end{itemize}
 | 
| 
906
 | 
   210  | 
  
  | 
| 
921
 | 
   211  | 
%   \begin{textblock}{6}(6,7.6)
 | 
| 
 | 
   212  | 
%     \includegraphics[scale=0.14]{../pics/cloudflare.png}\\
 | 
| 
 | 
   213  | 
%     \footnotesize
  | 
| 
 | 
   214  | 
%     It serves more web traffic than Twitter, Amazon, Apple,
  | 
| 
 | 
   215  | 
%     Instagram, Bing \& Wikipedia combined.
  | 
| 
 | 
   216  | 
%     \here{https://blog.cloudflare.com/details-of-the-cloudflare-outage-on-july-2-2019/}
 | 
| 
 | 
   217  | 
%     \end{textblock}
 | 
| 
906
 | 
   218  | 
  
  | 
| 
921
 | 
   219  | 
%   \end{frame}
 | 
| 
 | 
   220  | 
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
  | 
| 
906
 | 
   221  | 
    
  | 
| 
921
 | 
   222  | 
% %\begin{frame}[c]
 | 
| 
 | 
   223  | 
% %
  | 
| 
 | 
   224  | 
% %\frametitle{}
 | 
| 
 | 
   225  | 
% %\begin{mybox3}{}\it
 | 
| 
 | 
   226  | 
%  ``This conversation is interesting to me, and I've researched it a little bit... I also disagree with Dr. Urban on the cost/benefit of non-GC languages...[..]\\
  | 
| 
 | 
   227  | 
%
  | 
| 
 | 
   228  | 
%  But regardless, Scala is a lot slower than, say, C or Rust. To say it's not is basically wrong (imo)....[..]
  | 
| 
 | 
   229  | 
%  ''\\
  | 
| 
 | 
   230  | 
%\mbox{}\hfill-- Oliver Iliffe,  discussion this year in PEP
 | 
| 
 | 
   231  | 
%\end{mybox3}\pause
 | 
| 
 | 
   232  | 
%
  | 
| 
 | 
   233  | 
%\end{frame}
 | 
| 
906
 | 
   234  | 
  | 
| 
921
 | 
   235  | 
%\begin{frame}<1-10>
 | 
| 
 | 
   236  | 
%\end{frame}  
 | 
| 
876
 | 
   237  | 
  | 
| 
 | 
   238  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
   239  | 
\begin{frame}[t]
 | 
| 
 | 
   240  | 
\frametitle{%  
 | 
| 
 | 
   241  | 
  \begin{tabular}{@ {}c@ {}}
 | 
| 
 | 
   242  | 
  \\[-3mm]
  | 
| 
 | 
   243  | 
  \LARGE Compilers and \\[-1mm] 
  | 
| 
989
 | 
   244  | 
  \LARGE Formal Languages\\[-3mm] 
  | 
| 
876
 | 
   245  | 
  \end{tabular}}
 | 
| 
 | 
   246  | 
  | 
| 
880
 | 
   247  | 
  %\begin{center}
 | 
| 
876
 | 
   248  | 
  %\includegraphics[scale=0.3]{pics/ante1.jpg}\hspace{5mm}
 | 
| 
 | 
   249  | 
  %\includegraphics[scale=0.31]{pics/ante2.jpg}\\
 | 
| 
 | 
   250  | 
  %\footnotesize\textcolor{gray}{Antikythera automaton, 100 BC (Archimedes?)}
 | 
| 
880
 | 
   251  | 
  %\end{center}
 | 
| 
876
 | 
   252  | 
  | 
| 
 | 
   253  | 
  \normalsize
  | 
| 
 | 
   254  | 
  \begin{center}
 | 
| 
 | 
   255  | 
  \begin{tabular}{ll}
 | 
| 
 | 
   256  | 
  Email:  & christian.urban at kcl.ac.uk\\
  | 
| 
989
 | 
   257  | 
  Office Hour: & Fridays 11:30 -- 12:30\\
  | 
| 
880
 | 
   258  | 
  Location: & N7.07 (North Wing, Bush House)\\
  | 
| 
876
 | 
   259  | 
  Slides \& Progs: & KEATS\\
  | 
| 
989
 | 
   260  | 
  %Pollev: & \texttt{\alert{https://pollev.com/cfltutoratki576}}\\  
 | 
| 
876
 | 
   261  | 
  \end{tabular}
 | 
| 
 | 
   262  | 
  \end{center}
 | 
| 
 | 
   263  | 
  | 
| 
 | 
   264  | 
  \begin{center}
 | 
| 
 | 
   265  | 
    \begin{tikzpicture}
 | 
| 
 | 
   266  | 
      \node[drop shadow,fill=white,inner sep=0pt] 
  | 
| 
 | 
   267  | 
      {\footnotesize\rowcolors{1}{capri!10}{white}
 | 
| 
 | 
   268  | 
        \begin{tabular}{|p{4.8cm}|p{4.8cm}|}\hline
 | 
| 
 | 
   269  | 
          \cellcolor{blue!50}
 | 
| 
 | 
   270  | 
          1 Introduction, Languages          & 6 While-Language \\
  | 
| 
 | 
   271  | 
          2 Regular Expressions, Derivatives & 7 Compilation, JVM \\
  | 
| 
 | 
   272  | 
          3 Automata, Regular Languages      & 8 Compiling Functional Languages \\
  | 
| 
 | 
   273  | 
          4 Lexing, Tokenising               & 9 Optimisations \\
  | 
| 
 | 
   274  | 
          5 Grammars, Parsing                & 10 LLVM \\ \hline
  | 
| 
 | 
   275  | 
        \end{tabular}%
 | 
| 
 | 
   276  | 
      };
  | 
| 
 | 
   277  | 
    \end{tikzpicture}
 | 
| 
 | 
   278  | 
  \end{center}
 | 
| 
 | 
   279  | 
  | 
| 
 | 
   280  | 
\end{frame}
 | 
| 
 | 
   281  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
   282  | 
  | 
| 
 | 
   283  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
   284  | 
\begin{frame}<1-12>[c]
 | 
| 
 | 
   285  | 
\frametitle{The Goal of this Module\ldots}
 | 
| 
 | 
   286  | 
  | 
| 
 | 
   287  | 
\begin{center}
 | 
| 
 | 
   288  | 
  \begin{tikzpicture}[scale=1,
 | 
| 
 | 
   289  | 
                      node/.style={
 | 
| 
 | 
   290  | 
                      rectangle,rounded corners=3mm,
  | 
| 
 | 
   291  | 
                      very thick,draw=black!50,minimum height=18mm, minimum width=20mm,
  | 
| 
 | 
   292  | 
                      top color=white,bottom color=black!20,drop shadow}]
  | 
| 
 | 
   293  | 
  | 
| 
 | 
   294  | 
  \node at (3.05, 1.8) {\Large\bf \ldots{} you write a compiler};
 | 
| 
 | 
   295  | 
  | 
| 
 | 
   296  | 
  \node (0) at (-2.3,0) {};  
 | 
| 
 | 
   297  | 
  \node [above=5mm of 0]
  | 
| 
 | 
   298  | 
  {\makebox[0mm]{\footnotesize
 | 
| 
 | 
   299  | 
      \begin{tabular}{@{}l@{}}input\\[-1mm]program\end{tabular}}}; 
 | 
| 
 | 
   300  | 
     
  | 
| 
 | 
   301  | 
  \node (A) at (0,0)  [node] {};
 | 
| 
 | 
   302  | 
  \node [below right] at (A.north west) {lexer};
 | 
| 
 | 
   303  | 
  | 
| 
 | 
   304  | 
  \node (B) at (3,0)  [node] {};
 | 
| 
 | 
   305  | 
  \node [below right=1mm] at (B.north west) {\mbox{}\hspace{-1mm}parser};
 | 
| 
 | 
   306  | 
  | 
| 
 | 
   307  | 
  \node (C) at (6,0)  [node] {};
 | 
| 
 | 
   308  | 
  \node [below right] at (C.north west) {\mbox{}\hspace{-1mm}code gen};
 | 
| 
 | 
   309  | 
  | 
| 
 | 
   310  | 
  \node (1) at (8.4,0) {};
 | 
| 
 | 
   311  | 
  \node [above=5mm of 1]
  | 
| 
 | 
   312  | 
  {\makebox[0mm]{\footnotesize
 | 
| 
 | 
   313  | 
      \begin{tabular}{@{}r@{}}binary\\[-1mm]code\end{tabular}}};
 | 
| 
 | 
   314  | 
  | 
| 
928
 | 
   315  | 
  \draw [->,line width=3mm] (0) -- (A); 
  | 
| 
 | 
   316  | 
  \draw [->,line width=3mm] (A) -- (B); 
  | 
| 
 | 
   317  | 
  \draw [->,line width=3mm] (B) -- (C); 
  | 
| 
 | 
   318  | 
  \draw [->,line width=3mm] (C) -- (1); 
  | 
| 
876
 | 
   319  | 
  \end{tikzpicture}
 | 
| 
 | 
   320  | 
  \end{center}
 | 
| 
 | 
   321  | 
  | 
| 
 | 
   322  | 
\only<2,3,4>{
 | 
| 
 | 
   323  | 
\begin{textblock}{1}(1,2.1)
 | 
| 
 | 
   324  | 
\begin{bubble}[9.8cm]
 | 
| 
 | 
   325  | 
\normalsize
  | 
| 
 | 
   326  | 
lexer input: a string\smallskip\\
  | 
| 
 | 
   327  | 
\hspace{5mm}\code{"read(n);"}\medskip\\
 | 
| 
 | 
   328  | 
lexer output: a sequence of tokens\smallskip\\
  | 
| 
 | 
   329  | 
\hspace{5mm}\code{key(read) lpar id(n) rpar semi}
 | 
| 
 | 
   330  | 
\end{bubble}
 | 
| 
 | 
   331  | 
\end{textblock}} 
 | 
| 
 | 
   332  | 
  | 
| 
 | 
   333  | 
\only<3,4>{
 | 
| 
 | 
   334  | 
\begin{textblock}{1}(6,7.8)
 | 
| 
 | 
   335  | 
\begin{tabular}{c}
 | 
| 
 | 
   336  | 
\includegraphics[scale=0.2]{../pics/rosetta.jpg}\\[-2mm]
 | 
| 
 | 
   337  | 
\footnotesize lexing $\Rightarrow$ recognising words (Stone of Rosetta)
  | 
| 
 | 
   338  | 
\end{tabular}
 | 
| 
 | 
   339  | 
\end{textblock}}
 | 
| 
 | 
   340  | 
  | 
| 
 | 
   341  | 
\only<4>{
 | 
| 
 | 
   342  | 
\begin{textblock}{1}(0.5,12)\small
 | 
| 
 | 
   343  | 
\begin{tabular}{l@{}c@{}l}
 | 
| 
 | 
   344  | 
  \pcode{if}    & $\;\Rightarrow\;$ & keyword\\
 | 
| 
 | 
   345  | 
  \pcode{iffoo} & $\;\Rightarrow\;$ & identifier\\
 | 
| 
 | 
   346  | 
\end{tabular}  
 | 
| 
 | 
   347  | 
\end{textblock}}
 | 
| 
 | 
   348  | 
  | 
| 
 | 
   349  | 
\only<6>{
 | 
| 
 | 
   350  | 
\begin{textblock}{1}(1,1.5)
 | 
| 
 | 
   351  | 
\begin{bubble}[8.5cm]
 | 
| 
 | 
   352  | 
\normalsize
  | 
| 
 | 
   353  | 
parser input: a sequence of tokens\smallskip\\
  | 
| 
 | 
   354  | 
  | 
| 
 | 
   355  | 
{\small\hspace{5mm}\code{key(read) lpar id(n) rpar semi}}\smallskip\\
 | 
| 
 | 
   356  | 
  | 
| 
 | 
   357  | 
parser output: an abstract syntax tree\smallskip\\
  | 
| 
 | 
   358  | 
\footnotesize
  | 
| 
 | 
   359  | 
\hspace{2cm}\begin{tikzpicture}
 | 
| 
 | 
   360  | 
  \node {\code{read}}
 | 
| 
 | 
   361  | 
    child {node {\code{lpar}}}
 | 
| 
 | 
   362  | 
    child {node {\code{n}}}
 | 
| 
 | 
   363  | 
    child {node {\code{rpar}}};
 | 
| 
 | 
   364  | 
\end{tikzpicture}
 | 
| 
 | 
   365  | 
\end{bubble}
 | 
| 
 | 
   366  | 
\end{textblock}}
 | 
| 
 | 
   367  | 
  | 
| 
 | 
   368  | 
\only<8,9>{
 | 
| 
 | 
   369  | 
\begin{textblock}{1}(1,1.5)
 | 
| 
 | 
   370  | 
\begin{bubble}[4cm]
 | 
| 
 | 
   371  | 
\normalsize
  | 
| 
 | 
   372  | 
code generation:\smallskip\\
  | 
| 
 | 
   373  | 
\hspace{5mm}\code{istore 2}\\ 
 | 
| 
 | 
   374  | 
\hspace{5mm}\code{iload 2}\\ 
 | 
| 
 | 
   375  | 
\hspace{5mm}\code{ldc 10}\\
 | 
| 
 | 
   376  | 
\hspace{5mm}\code{isub}\\
 | 
| 
 | 
   377  | 
\hspace{5mm}\code{ifeq Label2}\\ 
 | 
| 
 | 
   378  | 
\hspace{5mm}\code{iload 2}\\
 | 
| 
 | 
   379  | 
\hspace{5mm}\code{...}\\
 | 
| 
 | 
   380  | 
\end{bubble}
 | 
| 
 | 
   381  | 
\end{textblock}}
 | 
| 
 | 
   382  | 
  | 
| 
 | 
   383  | 
\only<9>{
 | 
| 
 | 
   384  | 
\begin{textblock}{6}(8.4,7)
 | 
| 
 | 
   385  | 
\begin{bubble}[5cm]
 | 
| 
 | 
   386  | 
\mbox{\begin{tikzpicture}[scale=0.58,rounded corners=0mm]
 | 
| 
 | 
   387  | 
\begin{axis}[axis x line=bottom, axis y line=left, ylabel=secs,
 | 
| 
 | 
   388  | 
    xlabel=n,
  | 
| 
 | 
   389  | 
    enlargelimits=0.05,
  | 
| 
 | 
   390  | 
    ybar interval=0.7, legend style=small]
  | 
| 
 | 
   391  | 
\addplot file {interpreted2.data};
 | 
| 
 | 
   392  | 
\addplot file {compiled2.data};
 | 
| 
 | 
   393  | 
%\legend{interpreted, compiled}
 | 
| 
 | 
   394  | 
\end{axis}
 | 
| 
 | 
   395  | 
\end{tikzpicture}}
 | 
| 
 | 
   396  | 
\end{bubble}
 | 
| 
 | 
   397  | 
\end{textblock}}
 | 
| 
 | 
   398  | 
  | 
| 
 | 
   399  | 
\only<10>{
 | 
| 
 | 
   400  | 
\begin{textblock}{6}(1,3)
 | 
| 
 | 
   401  | 
  \begin{bubble}[11cm]
 | 
| 
 | 
   402  | 
    Compiler explorers, e.g.: \url{https://gcc.godbolt.org} \;\video{https://youtu.be/ysaBmhMEyUg}
 | 
| 
 | 
   403  | 
  \begin{tikzpicture}[]
 | 
| 
 | 
   404  | 
  \node (0) at (-2.3,0) {\includegraphics[scale=0.3]{pics/csource.png}};
 | 
| 
 | 
   405  | 
  \node (1) [right=35mm] at (0) {\includegraphics[scale=0.3]{pics/cassmbl.png}}; 
 | 
| 
 | 
   406  | 
  \draw [->,line width=4mm, red] (0) -- (1);   
  | 
| 
 | 
   407  | 
  \node (2) [below=20mm] at (0) {\LARGE\bf source};
 | 
| 
 | 
   408  | 
  \node (3) [right=40mm] at (2) {\LARGE\bf binary};
 | 
| 
 | 
   409  | 
  \draw [->,line width=1mm] (2) -- (3);   
  | 
| 
 | 
   410  | 
\end{tikzpicture}
 | 
| 
 | 
   411  | 
\end{bubble}
 | 
| 
 | 
   412  | 
  | 
| 
 | 
   413  | 
\end{textblock}}
 | 
| 
 | 
   414  | 
\only<11>{
 | 
| 
 | 
   415  | 
\begin{textblock}{6}(1,3)
 | 
| 
 | 
   416  | 
  \begin{bubble}[11cm]
 | 
| 
 | 
   417  | 
    Compiler explorer for Java: \url{https://javap.yawk.at} 
 | 
| 
 | 
   418  | 
  \begin{tikzpicture}[]
 | 
| 
 | 
   419  | 
  \node (0) at (-2.3,0) {\includegraphics[scale=0.4]{pics/jsource.png}};
 | 
| 
 | 
   420  | 
  \node (1) [right=35mm] at (0) {\includegraphics[scale=0.4]{pics/jassmbl.png}}; 
 | 
| 
 | 
   421  | 
  \draw [->,line width=4mm, red] (0) -- (1);   
  | 
| 
 | 
   422  | 
  \node (2) [below=20mm] at (0) {\LARGE\bf source};
 | 
| 
 | 
   423  | 
  \node (3) [right=40mm] at (2) {\LARGE\bf byte code};
 | 
| 
 | 
   424  | 
  \draw [->,line width=1mm] (2) -- (3);   
  | 
| 
 | 
   425  | 
\end{tikzpicture}
 | 
| 
 | 
   426  | 
\end{bubble}
 | 
| 
 | 
   427  | 
\end{textblock}}
 | 
| 
 | 
   428  | 
  | 
| 
 | 
   429  | 
  | 
| 
 | 
   430  | 
\end{frame}
 | 
| 
 | 
   431  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
  | 
| 
 | 
   432  | 
  | 
| 
 | 
   433  | 
  | 
| 
 | 
   434  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
   435  | 
\begin{frame}[t]
 | 
| 
 | 
   436  | 
\frametitle{Why Study Compilers?}
 | 
| 
 | 
   437  | 
  | 
| 
 | 
   438  | 
  | 
| 
 | 
   439  | 
John Regehr {\small(Univ.~Utah, LLVM compiler hacker)}
 | 
| 
 | 
   440  | 
\here{https://blog.regehr.org/archives/1419}
 | 
| 
 | 
   441  | 
\smallskip\\
  | 
| 
 | 
   442  | 
  | 
| 
 | 
   443  | 
\begin{bubble}[10.5cm]
 | 
| 
 | 
   444  | 
  \bf ``\ldots{}It’s effectively a perpetual
 | 
| 
 | 
   445  | 
  employment act for solid compiler hackers.''
  | 
| 
 | 
   446  | 
\end{bubble}
 | 
| 
 | 
   447  | 
  | 
| 
 | 
   448  | 
\onslide<1->{
 | 
| 
 | 
   449  | 
\only<2>{
 | 
| 
 | 
   450  | 
\begin{itemize}
 | 
| 
 | 
   451  | 
\item {\bf Hardware is getting weirder
 | 
| 
 | 
   452  | 
  rather than getting clocked faster.}
  | 
| 
 | 
   453  | 
  | 
| 
 | 
   454  | 
\begin{itemize}
 | 
| 
 | 
   455  | 
\item[]  ``Almost all processors are multicores nowadays and it looks
  | 
| 
 | 
   456  | 
  like there is increasing asymmetry in resources across cores.
  | 
| 
 | 
   457  | 
  Processors come with vector units, crypto accelerators etc. We have
  | 
| 
 | 
   458  | 
  DSPs, GPUs, ARM big.little, and Xeon Phi. This is only scratching the
  | 
| 
 | 
   459  | 
  surface.''
  | 
| 
 | 
   460  | 
\end{itemize}  
 | 
| 
 | 
   461  | 
\end{itemize}}
 | 
| 
 | 
   462  | 
\only<3>{
 | 
| 
 | 
   463  | 
\begin{itemize}
 | 
| 
 | 
   464  | 
\item {\bf We’re getting tired of low-level languages and
 | 
| 
 | 
   465  | 
    their associated security disasters.}
  | 
| 
 | 
   466  | 
  
  | 
| 
 | 
   467  | 
\begin{itemize}
 | 
| 
 | 
   468  | 
\item [] ``We want to write new code, to whatever extent possible, in
  | 
| 
 | 
   469  | 
  safer, higher-level languages. Compilers are caught right in the
  | 
| 
 | 
   470  | 
  middle of these opposing trends: one of their main jobs is to help
  | 
| 
 | 
   471  | 
  bridge the large and growing gap between increasingly high-level
  | 
| 
 | 
   472  | 
  languages and increasingly wacky platforms.''
  | 
| 
 | 
   473  | 
\end{itemize}  
 | 
| 
 | 
   474  | 
\end{itemize}}}
 | 
| 
 | 
   475  | 
  | 
| 
 | 
   476  | 
\end{frame}
 | 
| 
 | 
   477  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
   478  | 
  | 
| 
879
 | 
   479  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
929
 | 
   480  | 
% {
 | 
| 
 | 
   481  | 
% \setbeamercolor{background canvas}{bg=cream}
 | 
| 
 | 
   482  | 
% \begin{frame}[c]
 | 
| 
879
 | 
   483  | 
  | 
| 
929
 | 
   484  | 
% \frametitle{}
 | 
| 
 | 
   485  | 
% \begin{mybox3}{}\it
 | 
| 
 | 
   486  | 
%    ``I enjoyed the module - it was genuinely the stand out academic
  | 
| 
 | 
   487  | 
% experience of my undergraduate degree, and very much influenced my
  | 
| 
 | 
   488  | 
% career interests. In fact I am currently working at ARM, in their Open
  | 
| 
 | 
   489  | 
% Source Software group, on AArch64 specific optimisations for the
  | 
| 
 | 
   490  | 
% Java/Kotlin compiler that forms part of the Android Runtime.''\\
  | 
| 
 | 
   491  | 
% \mbox{}\hfill-- Hari Limaye in year 2021/22
 | 
| 
 | 
   492  | 
% \end{mybox3}\pause
 | 
| 
879
 | 
   493  | 
  | 
| 
 | 
   494  | 
  | 
| 
929
 | 
   495  | 
% Student numbers in CFL\medskip\\
  | 
| 
 | 
   496  | 
% \begin{tabular}{ll}
 | 
| 
 | 
   497  | 
% 2019: & 32\\  
  | 
| 
 | 
   498  | 
% 2020: & 59\\  
  | 
| 
 | 
   499  | 
% 2021: & 109\\
  | 
| 
 | 
   500  | 
% 2022: & 121\\  
  | 
| 
 | 
   501  | 
% \end{tabular}  
 | 
| 
879
 | 
   502  | 
  | 
| 
929
 | 
   503  | 
% \end{frame}
 | 
| 
 | 
   504  | 
% }
  | 
| 
879
 | 
   505  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  | 
| 
 | 
   506  | 
  | 
| 
 | 
   507  | 
  | 
| 
 | 
   508  | 
  | 
| 
876
 | 
   509  | 
  | 
| 
 | 
   510  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
   511  | 
\begin{frame}[c]
 | 
| 
 | 
   512  | 
\frametitle{Why Bother with Compilers?}
 | 
| 
 | 
   513  | 
  
  | 
| 
 | 
   514  | 
\textbf{Boeing 777's}: First flight in 1994. They want to achieve
 | 
| 
 | 
   515  | 
triple redundancy for potential hardware faults.
  | 
| 
960
 | 
   516  | 
\here{https://ieeexplore.ieee.org/document/495891}\bigskip
 | 
| 
876
 | 
   517  | 
  
  | 
| 
 | 
   518  | 
They compile 1 Ada program to\medskip
  | 
| 
 | 
   519  | 
  
  | 
| 
 | 
   520  | 
\begin{itemize}
 | 
| 
 | 
   521  | 
  \item Intel 80486
  | 
| 
 | 
   522  | 
  \item Motorola 68040 (old Macintosh's)
  | 
| 
 | 
   523  | 
  \item AMD 29050 (RISC chips used often in laser printers)
  | 
| 
 | 
   524  | 
\end{itemize}\medskip\medskip
 | 
| 
 | 
   525  | 
  
  | 
| 
 | 
   526  | 
using 3 independent compilers.\bigskip\pause
  | 
| 
 | 
   527  | 
  
  | 
| 
 | 
   528  | 
\small Airbus uses C and static analysers. Recently started using CompCert.
  | 
| 
 | 
   529  | 
  | 
| 
 | 
   530  | 
\only<1->{%
 | 
| 
 | 
   531  | 
\begin{textblock}{6}(8,4.5)
 | 
| 
 | 
   532  | 
\includegraphics[scale=0.28]{../pics/777.png}
 | 
| 
 | 
   533  | 
\end{textblock}}
 | 
| 
 | 
   534  | 
  | 
| 
 | 
   535  | 
\end{frame}
 | 
| 
 | 
   536  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
   537  | 
  | 
| 
 | 
   538  | 
  | 
| 
 | 
   539  | 
  | 
| 
 | 
   540  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
   541  | 
\begin{frame}[c]
 | 
| 
 | 
   542  | 
\frametitle{What Do Compilers Do?}
 | 
| 
 | 
   543  | 
  | 
| 
 | 
   544  | 
Remember BF*** from PEP?
  | 
| 
 | 
   545  | 
  | 
| 
 | 
   546  | 
\begin{center}
 | 
| 
 | 
   547  | 
\begin{tabular}{rcl}
 | 
| 
 | 
   548  | 
\bl{\texttt{>}} & $\Rightarrow$ & move one cell right\\
 | 
| 
 | 
   549  | 
\bl{\texttt{<}} & $\Rightarrow$ & move one cell left\\
 | 
| 
 | 
   550  | 
\bl{\texttt{+}} & $\Rightarrow$ & increase cell by one\\
 | 
| 
 | 
   551  | 
\bl{\texttt{-}} & $\Rightarrow$ & decrease cell by one\\
 | 
| 
 | 
   552  | 
\bl{\texttt{.}} & $\Rightarrow$ & print current cell\\
 | 
| 
 | 
   553  | 
\bl{\texttt{,}} & $\Rightarrow$ & input current cell\\
 | 
| 
 | 
   554  | 
\bl{\texttt{[}} & $\Rightarrow$ & loop begin\\
 | 
| 
 | 
   555  | 
\bl{\texttt{]}} & $\Rightarrow$ & loop end\medskip\\
 | 
| 
 | 
   556  | 
                & $\Rightarrow$ & everything else is a comment\\
  | 
| 
 | 
   557  | 
\end{tabular}  
 | 
| 
 | 
   558  | 
\end{center}  
 | 
| 
 | 
   559  | 
  | 
| 
 | 
   560  | 
\end{frame}
 | 
| 
 | 
   561  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  | 
| 
 | 
   562  | 
  | 
| 
 | 
   563  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
   564  | 
\begin{frame}[c]
 | 
| 
 | 
   565  | 
  \frametitle{A ``Compiler'' for BF*** to C}
 | 
| 
 | 
   566  | 
  
  | 
| 
 | 
   567  | 
  \begin{center}
 | 
| 
 | 
   568  | 
  \begin{tabular}{rcl}
 | 
| 
 | 
   569  | 
  \bl{\texttt{>}} & $\Rightarrow$ & \texttt{ptr++}\\
 | 
| 
 | 
   570  | 
  \bl{\texttt{<}} & $\Rightarrow$ & \texttt{ptr--}\\
 | 
| 
 | 
   571  | 
  \bl{\texttt{+}} & $\Rightarrow$ & \texttt{(*ptr)++}\\
 | 
| 
 | 
   572  | 
  \bl{\texttt{-}} & $\Rightarrow$ & \texttt{(*ptr)--}\\
 | 
| 
 | 
   573  | 
  \bl{\texttt{.}} & $\Rightarrow$ & \texttt{putchar(*ptr)}\\
 | 
| 
 | 
   574  | 
  \bl{\texttt{,}} & $\Rightarrow$ & \texttt{*ptr = getchar()}\\
 | 
| 
 | 
   575  | 
  \bl{\texttt{[}} & $\Rightarrow$ & \texttt{while(*ptr)\{}\\
 | 
| 
 | 
   576  | 
  \bl{\texttt{]}} & $\Rightarrow$ & \texttt{\}}\medskip\\
 | 
| 
 | 
   577  | 
                  & $\Rightarrow$ & ignore everything else\\
  | 
| 
 | 
   578  | 
  \end{tabular}  
 | 
| 
 | 
   579  | 
  \end{center}\bigskip  
 | 
| 
 | 
   580  | 
  
  | 
| 
 | 
   581  | 
  \texttt{char field[30000]\\ char *ptr = \&field[15000]}
 | 
| 
 | 
   582  | 
  
  | 
| 
 | 
   583  | 
\end{frame}
 | 
| 
 | 
   584  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
   585  | 
  | 
| 
 | 
   586  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
   587  | 
\begin{frame}[c]
 | 
| 
 | 
   588  | 
  \frametitle{Another~``Compiler''~for~BF~to~C}
 | 
| 
 | 
   589  | 
  
  | 
| 
 | 
   590  | 
  \begin{center}
 | 
| 
 | 
   591  | 
  \begin{tabular}{rcl}
 | 
| 
 | 
   592  | 
  \bl{\texttt{>\ldots>}} & $\Rightarrow$ & \texttt{ptr += n}\\
 | 
| 
 | 
   593  | 
  \bl{\texttt{<\ldots<}} & $\Rightarrow$ & \texttt{ptr -= n}\\
 | 
| 
 | 
   594  | 
  \bl{\texttt{+\ldots+}} & $\Rightarrow$ & \texttt{(*ptr) += n}\\
 | 
| 
 | 
   595  | 
  \bl{\texttt{-\ldots-}} & $\Rightarrow$ & \texttt{(*ptr) -= n}\\
 | 
| 
 | 
   596  | 
  \bl{\texttt{.}} & $\Rightarrow$ & \texttt{putchar(*ptr)}\\
 | 
| 
 | 
   597  | 
  \bl{\texttt{,}} & $\Rightarrow$ & \texttt{*ptr = getchar()}\\
 | 
| 
 | 
   598  | 
  \bl{\texttt{[}} & $\Rightarrow$ & \texttt{while(*ptr)\{}\\
 | 
| 
 | 
   599  | 
  \bl{\texttt{]}} & $\Rightarrow$ & \texttt{\}}\medskip\\
 | 
| 
 | 
   600  | 
                  & $\Rightarrow$ & ignore everything else\\
  | 
| 
 | 
   601  | 
  \end{tabular}  
 | 
| 
 | 
   602  | 
  \end{center}\bigskip  
 | 
| 
 | 
   603  | 
  
  | 
| 
 | 
   604  | 
  \texttt{char field[30000]\\ char *ptr = \&field[15000]}
 | 
| 
 | 
   605  | 
  
  | 
| 
 | 
   606  | 
\end{frame}
 | 
| 
 | 
   607  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  | 
| 
 | 
   608  | 
    
  | 
| 
 | 
   609  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
   610  | 
\begin{frame}[t]
 | 
| 
 | 
   611  | 
\frametitle{A Brief Compiler History}
 | 
| 
 | 
   612  | 
  | 
| 
 | 
   613  | 
\bigskip
  | 
| 
 | 
   614  | 
\begin{itemize}
 | 
| 
 | 
   615  | 
\item Turing Machines, 1936 (a tape as memory)
  | 
| 
 | 
   616  | 
\item Regular Expressions, 1956\\
  | 
| 
 | 
   617  | 
\item The first compiler for COBOL, 1957\\ (Grace Hopper)\medskip
  | 
| 
 | 
   618  | 
\item But surprisingly research papers are still published nowadays\\
  | 
| 
 | 
   619  | 
\item ``Parsing: The Solved Problem That Isn't''
  | 
| 
 | 
   620  | 
  \here{https://tratt.net/laurie/blog/entries/parsing_the_solved_problem_that_isnt.html}
 | 
| 
 | 
   621  | 
\end{itemize}
 | 
| 
 | 
   622  | 
  | 
| 
 | 
   623  | 
  | 
| 
 | 
   624  | 
\begin{textblock}{8.5}(5,7.6)
 | 
| 
 | 
   625  | 
\begin{flushright}
 | 
| 
 | 
   626  | 
\includegraphics[scale=0.3]{pics/hopper.jpg}\\
 | 
| 
 | 
   627  | 
\footnotesize\textcolor{gray}{Grace Hopper}\smallskip\\
 | 
| 
 | 
   628  | 
  | 
| 
 | 
   629  | 
{\small\textcolor{gray}{(she made it to David Letterman's Tonight Show
 | 
| 
964
 | 
   630  | 
    \here{https://youtu.be/oE2uls6iIEU})}}
 | 
| 
876
 | 
   631  | 
\end{flushright}
 | 
| 
 | 
   632  | 
\end{textblock}
 | 
| 
 | 
   633  | 
  | 
| 
 | 
   634  | 
\end{frame}
 | 
| 
 | 
   635  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
  | 
| 
 | 
   636  | 
  | 
| 
 | 
   637  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
964
 | 
   638  | 
{\setbeamercolor{background canvas}{bg=cream}
 | 
| 
876
 | 
   639  | 
\begin{frame}[c]
 | 
| 
989
 | 
   640  | 
\frametitle{How to study for CFL?}
 | 
| 
 | 
   641  | 
  | 
| 
 | 
   642  | 
My recommendation for each week: 
  | 
| 
 | 
   643  | 
  | 
| 
 | 
   644  | 
\begin{itemize}
 | 
| 
 | 
   645  | 
\item read the handout
  | 
| 
 | 
   646  | 
\item watch the videos
  | 
| 
 | 
   647  | 
\item re-read the handout
  | 
| 
 | 
   648  | 
\item do the HW to be discussed at the SGT
  | 
| 
 | 
   649  | 
\item later on do the CW
  | 
| 
 | 
   650  | 
\end{itemize}
 | 
| 
 | 
   651  | 
  | 
| 
 | 
   652  | 
  | 
| 
 | 
   653  | 
\end{frame}}
 | 
| 
 | 
   654  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  | 
| 
 | 
   655  | 
  | 
| 
 | 
   656  | 
  | 
| 
 | 
   657  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
   658  | 
{\setbeamercolor{background canvas}{bg=cream}
 | 
| 
 | 
   659  | 
\begin{frame}[c]
 | 
| 
876
 | 
   660  | 
\frametitle{Some Housekeeping}
 | 
| 
 | 
   661  | 
  | 
| 
929
 | 
   662  | 
\textbf{Exam will be computer-based, invigilated in some big examination hall:}\bigskip
 | 
| 
876
 | 
   663  | 
  | 
| 
 | 
   664  | 
\begin{itemize}
 | 
| 
989
 | 
   665  | 
\item final exam in January (\textbf{40\%})
 | 
| 
 | 
   666  | 
\item coursework (\textbf{60\%- the first part is optional}) 
 | 
| 
876
 | 
   667  | 
\end{itemize}\bigskip\bigskip\pause
 | 
| 
 | 
   668  | 
  | 
| 
 | 
   669  | 
  | 
| 
 | 
   670  | 
\textbf{Weekly Homework (optional):}
 | 
| 
 | 
   671  | 
\begin{itemize}
 | 
| 
960
 | 
   672  | 
\item uploaded on KEATS - solutions will be discussed during the SGTs
  | 
| 
964
 | 
   673  | 
\item \alert{\bf all} questions in the exam will be in some close shape or form from the HWs!!
 | 
| 
876
 | 
   674  | 
\end{itemize}  
 | 
| 
 | 
   675  | 
  | 
| 
964
 | 
   676  | 
\end{frame}}
 | 
| 
 | 
   677  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  | 
| 
 | 
   678  | 
  | 
| 
 | 
   679  | 
  | 
| 
 | 
   680  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  | 
| 
 | 
   681  | 
{
 | 
| 
 | 
   682  | 
\setbeamercolor{background canvas}{bg=cream}
 | 
| 
 | 
   683  | 
\begin{frame}[c]
 | 
| 
 | 
   684  | 
\frametitle{Homework}
 | 
| 
 | 
   685  | 
  | 
| 
 | 
   686  | 
Until 3 years ago: I did not give out solutions; students
  | 
| 
 | 
   687  | 
sent emails to me and I responded to them individually.\bigskip\\
  | 
| 
 | 
   688  | 
  | 
| 
989
 | 
   689  | 
Now: TAs will review the homework mainly during the SGTs.\bigskip\\\pause
  | 
| 
964
 | 
   690  | 
  | 
| 
 | 
   691  | 
Do not harass your TAs for the solutions!
  | 
| 
 | 
   692  | 
  | 
| 
876
 | 
   693  | 
\end{frame}
 | 
| 
964
 | 
   694  | 
}
  | 
| 
876
 | 
   695  | 
  | 
| 
879
 | 
   696  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  | 
| 
929
 | 
   697  | 
{\definecolor{rred}{HTML}{C0504D}
 | 
| 
 | 
   698  | 
\setbeamercolor{background canvas}{bg=cream}
 | 
| 
 | 
   699  | 
\begin{frame}[c]
 | 
| 
 | 
   700  | 
\frametitle{Students in CFL}
 | 
| 
 | 
   701  | 
  | 
| 
 | 
   702  | 
\begin{center}
 | 
| 
 | 
   703  | 
\begin{tikzpicture}
 | 
| 
989
 | 
   704  | 
  \begin{axis}[symbolic x coords={2016,2017,2018,2019,2020,2021,2022,2023,2024,2025},
 | 
| 
 | 
   705  | 
    width  = 1.2\textwidth,
  | 
| 
929
 | 
   706  | 
    height = 5cm,
  | 
| 
 | 
   707  | 
    bar width=8mm,
  | 
| 
 | 
   708  | 
    nodes near coords,
  | 
| 
 | 
   709  | 
    axis lines = left,
  | 
| 
 | 
   710  | 
    text=black,
  | 
| 
 | 
   711  | 
    ymin=0,
  | 
| 
 | 
   712  | 
    clip=false,
  | 
| 
 | 
   713  | 
    hide y axis,
  | 
| 
 | 
   714  | 
    axis line style={-},
 | 
| 
 | 
   715  | 
    name=mygraph
  | 
| 
 | 
   716  | 
    ]
  | 
| 
964
 | 
   717  | 
  | 
| 
 | 
   718  | 
\only<1>{\addplot[ybar,style={rred,fill=rred!75,mark=none},text=black] coordinates {
 | 
| 
989
 | 
   719  | 
(2025,181)
  | 
| 
964
 | 
   720  | 
(2024,173)
  | 
| 
 | 
   721  | 
(2023,169)
  | 
| 
 | 
   722  | 
(2022,111)
  | 
| 
 | 
   723  | 
(2021,98)
  | 
| 
 | 
   724  | 
(2020,59)
  | 
| 
 | 
   725  | 
(2019,38)
  | 
| 
 | 
   726  | 
(2018,20)
  | 
| 
 | 
   727  | 
(2017,22)
  | 
| 
 | 
   728  | 
(2016,8)}};
  | 
| 
929
 | 
   729  | 
\end{axis}
 | 
| 
 | 
   730  | 
\node[anchor=north, yshift=-10mm] at (mygraph.south) {\small{}Student numbers since the start of the compiler module.};
 | 
| 
 | 
   731  | 
  | 
| 
 | 
   732  | 
\end{tikzpicture}
 | 
| 
 | 
   733  | 
\end{center}
 | 
| 
 | 
   734  | 
  | 
| 
 | 
   735  | 
  | 
| 
 | 
   736  | 
\end{frame}
 | 
| 
 | 
   737  | 
}
  | 
| 
 | 
   738  | 
  | 
| 
964
 | 
   739  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
879
 | 
   740  | 
{
 | 
| 
 | 
   741  | 
\setbeamercolor{background canvas}{bg=cream}
 | 
| 
 | 
   742  | 
\begin{frame}[c]
 | 
| 
876
 | 
   743  | 
\frametitle{Some Housekeeping}
 | 
| 
 | 
   744  | 
  | 
| 
989
 | 
   745  | 
\textbf{Coursework (4 parts accounting for 60\%; submission deadline \underline{5th January 2026}):}\bigskip
 | 
| 
876
 | 
   746  | 
  | 
| 
 | 
   747  | 
\begin{itemize}
 | 
| 
989
 | 
   748  | 
\item matcher \xout{(5\%)}\;\;\textcolor{red}{optional}
 | 
| 
876
 | 
   749  | 
\item lexer (10\%)
  | 
| 
989
 | 
   750  | 
\item parser / interpreter (15\%)
  | 
| 
876
 | 
   751  | 
\item JVM compiler (15\%)
  | 
| 
989
 | 
   752  | 
\item LLVM compiler (20\%) 
  | 
| 
 | 
   753  | 
\end{itemize}
 | 
| 
876
 | 
   754  | 
\end{frame}
 | 
| 
964
 | 
   755  | 
}
  | 
| 
 | 
   756  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
   757  | 
{
 | 
| 
 | 
   758  | 
\setbeamercolor{background canvas}{bg=cream}
 | 
| 
989
 | 
   759  | 
\begin{frame}[c]
 | 
| 
 | 
   760  | 
\frametitle{Some Housekeeping}
 | 
| 
 | 
   761  | 
  | 
| 
 | 
   762  | 
\begin{itemize}
 | 
| 
 | 
   763  | 
\item you can use any code I show you and is uploaded to KEATS; therefore 
  | 
| 
 | 
   764  | 
  most students use Scala/Ammonite
  | 
| 
 | 
   765  | 
\item but you can use \alert{any} programming language you like (Haskell, Rust, Swift\ldots you have to show me how to run your code)
 | 
| 
 | 
   766  | 
\pause
  | 
| 
 | 
   767  | 
\item \textcolor{red}{\textbf{you can even use AI for CW}}\pause\bigskip 
 | 
| 
 | 
   768  | 
\item \textbf{BUT YOU CANNOT COPY FROM OR COLLABORATE WITH OTHER STUDENTS!}
 | 
| 
 | 
   769  | 
\end{itemize}
 | 
| 
 | 
   770  | 
\end{frame}
 | 
| 
964
 | 
   771  | 
}
  | 
| 
 | 
   772  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
989
 | 
   773  | 
%{
 | 
| 
 | 
   774  | 
%\setbeamercolor{background canvas}{bg=cream}
 | 
| 
 | 
   775  | 
%\begin{frame}[c,fragile]
 | 
| 
 | 
   776  | 
%\end{frame}  
 | 
| 
 | 
   777  | 
%}
  | 
| 
 | 
   778  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
964
 | 
   779  | 
{
 | 
| 
 | 
   780  | 
\setbeamercolor{background canvas}{bg=cream}
 | 
| 
 | 
   781  | 
\begin{frame}[c,fragile]
 | 
| 
 | 
   782  | 
%%\frametitle{Scala 3}
 | 
| 
876
 | 
   783  | 
  | 
| 
989
 | 
   784  | 
I will show you all my code in Scala 3\bigskip
  | 
| 
964
 | 
   785  | 
  | 
| 
 | 
   786  | 
\begin{minipage}{1.4\textwidth}
 | 
| 
 | 
   787  | 
\begin{lstlisting}[language={},numbers=none,basicstyle=\ttfamily\small]
 | 
| 
989
 | 
   788  | 
$ scala
  | 
| 
 | 
   789  | 
Welcome to Scala 3.7.3 (21.0.8, Java OpenJDK 64-Bit Server VM).
  | 
| 
964
 | 
   790  | 
Type in expressions for evaluation. Or try :help.
  | 
| 
 | 
   791  | 
  | 
| 
 | 
   792  | 
scala> 1 + 2
  | 
| 
 | 
   793  | 
res0: Int = 3
  | 
| 
 | 
   794  | 
\end{lstlisting} %% $
 | 
| 
 | 
   795  | 
\end{minipage}\medskip
 | 
| 
 | 
   796  | 
\pause
  | 
| 
 | 
   797  | 
  | 
| 
989
 | 
   798  | 
%Since Scala 3.5.0, scala-cli is included in "plain" Scala
  | 
| 
 | 
   799  | 
%
  | 
| 
 | 
   800  | 
%\begin{minipage}{1.4\textwidth}
 | 
| 
 | 
   801  | 
%\begin{lstlisting}[language={},numbers=none,basicstyle=\ttfamily\small]
 | 
| 
 | 
   802  | 
%$ scala
  | 
| 
 | 
   803  | 
%Welcome to Scala 3.5.1 (21.0.4, Java OpenJDK 64-Bit Server VM).
  | 
| 
 | 
   804  | 
%Type in expressions for evaluation. Or try :help.
  | 
| 
 | 
   805  | 
%
  | 
| 
 | 
   806  | 
%scala> 
  | 
| 
 | 
   807  | 
%\end{lstlisting} %% $
 | 
| 
 | 
   808  | 
%\end{minipage}
 | 
| 
964
 | 
   809  | 
\end{frame}
 | 
| 
 | 
   810  | 
}
  | 
| 
 | 
   811  | 
  | 
| 
 | 
   812  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  | 
| 
929
 | 
   813  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  | 
| 
 | 
   814  | 
{
 | 
| 
 | 
   815  | 
\setbeamercolor{background canvas}{bg=cream}
 | 
| 
 | 
   816  | 
\begin{frame}[c,fragile]
 | 
| 
 | 
   817  | 
\frametitle{Ammonite \& Scala 3}
 | 
| 
 | 
   818  | 
  | 
| 
964
 | 
   819  | 
Actually in CFL, I will use Amm / Scala 3
  | 
| 
929
 | 
   820  | 
  | 
| 
 | 
   821  | 
\begin{minipage}{1.4\textwidth}
 | 
| 
 | 
   822  | 
\begin{lstlisting}[language={},numbers=none,basicstyle=\ttfamily\small]
 | 
| 
 | 
   823  | 
$ amm
  | 
| 
 | 
   824  | 
Loading...
  | 
| 
989
 | 
   825  | 
Welcome to the Ammonite Repl 3.0.2 (Scala 3.3.5 Java 21.0.8)
  | 
| 
 | 
   826  | 
@ 1 + 2
  | 
| 
929
 | 
   827  | 
res0: Int = 3
  | 
| 
 | 
   828  | 
\end{lstlisting} %% $
 | 
| 
 | 
   829  | 
\end{minipage}\medskip
 | 
| 
 | 
   830  | 
\pause
  | 
| 
 | 
   831  | 
  | 
| 
989
 | 
   832  | 
Do not use Amm + Scala 2! Do not use sbt!
  | 
| 
929
 | 
   833  | 
  | 
| 
 | 
   834  | 
\begin{minipage}{1.4\textwidth}
 | 
| 
 | 
   835  | 
\begin{lstlisting}[language={},numbers=none,basicstyle=\ttfamily\small]
 | 
| 
 | 
   836  | 
$ amm2
  | 
| 
 | 
   837  | 
Loading...
  | 
| 
 | 
   838  | 
Welcome to the Ammonite Repl 2.5.9 (Scala 2.13.11 Java 17.0.7)
  | 
| 
989
 | 
   839  | 
@ 
  | 
| 
929
 | 
   840  | 
\end{lstlisting} %% $
 | 
| 
 | 
   841  | 
\end{minipage}
 | 
| 
 | 
   842  | 
\end{frame}
 | 
| 
 | 
   843  | 
}
  | 
| 
 | 
   844  | 
  | 
| 
 | 
   845  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  | 
| 
 | 
   846  | 
{
 | 
| 
 | 
   847  | 
\setbeamercolor{background canvas}{bg=cream}
 | 
| 
 | 
   848  | 
\begin{frame}[c]
 | 
| 
930
 | 
   849  | 
\frametitle{For Install Problems}
 | 
| 
989
 | 
   850  | 
 
  | 
| 
929
 | 
   851  | 
\begin{itemize}
 | 
| 
989
 | 
   852  | 
\item Flavio Melinte Citea\\ (flavio.melinte\_citea@kcl.ac.uk)\bigskip \\
  | 
| 
 | 
   853  | 
\item Zishan Rahman\\ (zishan.rahman@kcl.ac.uk) 
  | 
| 
929
 | 
   854  | 
\end{itemize}
 | 
| 
 | 
   855  | 
  
  | 
| 
 | 
   856  | 
\end{frame}
 | 
| 
 | 
   857  | 
}
  | 
| 
 | 
   858  | 
  | 
| 
930
 | 
   859  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  | 
| 
 | 
   860  | 
{
 | 
| 
 | 
   861  | 
\setbeamercolor{background canvas}{bg=cream}
 | 
| 
 | 
   862  | 
\begin{frame}[c]
 | 
| 
 | 
   863  | 
  | 
| 
 | 
   864  | 
\begin{minipage}{1.3\textwidth}
 | 
| 
 | 
   865  | 
\begin{mybox3}{}\it\small
 | 
| 
 | 
   866  | 
Unequivocally the worst module I've taken on this course. The subject
  | 
| 
 | 
   867  | 
matter is fascinating, however the insistence on the use of this
  | 
| 
 | 
   868  | 
abomination of a language "Scala" completely ruins it. If you're going
  | 
| 
 | 
   869  | 
to teach something as complex as this, use a proper language, not some
  | 
| 
 | 
   870  | 
"object oriented functional" abomination. Use C, you know, the
  | 
| 
 | 
   871  | 
language that real compilers are written in. I will go to the end of
  | 
| 
 | 
   872  | 
the earth to dissuade others from taking this module so long as Scala
  | 
| 
 | 
   873  | 
is still being used.\\
  | 
| 
 | 
   874  | 
\mbox{}\hfill-- Lone voice in the end-of-year feedback in 2019
 | 
| 
 | 
   875  | 
\end{mybox3}
 | 
| 
 | 
   876  | 
\end{minipage}\bigskip
 | 
| 
 | 
   877  | 
  | 
| 
 | 
   878  | 
\small (for alternative opinions check ``What the students say'' on KEATS)
  | 
| 
 | 
   879  | 
  
  | 
| 
 | 
   880  | 
\end{frame}
 | 
| 
 | 
   881  | 
}
  | 
| 
 | 
   882  | 
  | 
| 
 | 
   883  | 
  | 
| 
929
 | 
   884  | 
  | 
| 
876
 | 
   885  | 
  | 
| 
 | 
   886  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
   887  | 
\begin{frame}[c]
 | 
| 
 | 
   888  | 
\frametitle{Lectures 1 - 5}
 | 
| 
 | 
   889  | 
  | 
| 
 | 
   890  | 
transforming strings into structured data\\[10mm]
  | 
| 
 | 
   891  | 
  | 
| 
 | 
   892  | 
{\LARGE\bf Lexing} {\hfill{}based on regular expressions}\medskip\\
 | 
| 
 | 
   893  | 
\hspace{5mm}(recognising ``words'')\\[6mm]
 | 
| 
 | 
   894  | 
  | 
| 
 | 
   895  | 
{\LARGE\bf Parsing}\medskip\\
 | 
| 
 | 
   896  | 
\hspace{5mm}(recognising ``sentences'')
 | 
| 
 | 
   897  | 
  | 
| 
 | 
   898  | 
\begin{textblock}{1}(10,9.1)
 | 
| 
 | 
   899  | 
\begin{tabular}{c}
 | 
| 
 | 
   900  | 
\includegraphics[scale=0.1]{../pics/rosetta.jpg}\\[-2mm]
 | 
| 
 | 
   901  | 
\footnotesize Stone of Rosetta
  | 
| 
 | 
   902  | 
\end{tabular}
 | 
| 
 | 
   903  | 
\end{textblock}
 | 
| 
 | 
   904  | 
  | 
| 
 | 
   905  | 
\end{frame}
 | 
| 
 | 
   906  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  | 
| 
 | 
   907  | 
  | 
| 
 | 
   908  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
   909  | 
\begin{frame}[c]
 | 
| 
 | 
   910  | 
\frametitle{Lectures 1 - 5}
 | 
| 
 | 
   911  | 
  | 
| 
 | 
   912  | 
transforming strings into structured data\\[10mm]
  | 
| 
 | 
   913  | 
  | 
| 
 | 
   914  | 
{\LARGE\bf Lexing} {\hfill{}based on regular expressions}\medskip\\
 | 
| 
 | 
   915  | 
\hspace{5mm}(recognising ``words'')\\[6mm]
 | 
| 
 | 
   916  | 
  | 
| 
 | 
   917  | 
{\LARGE\bf Parsing}\medskip\\
 | 
| 
 | 
   918  | 
\hspace{5mm}(recognising ``sentences'')
 | 
| 
 | 
   919  | 
  | 
| 
 | 
   920  | 
\begin{textblock}{1}(10,9.1)
 | 
| 
 | 
   921  | 
\begin{tabular}{c}
 | 
| 
 | 
   922  | 
\includegraphics[scale=0.1]{../pics/rosetta.jpg}\\[-2mm]
 | 
| 
 | 
   923  | 
\footnotesize Stone of Rosetta
  | 
| 
 | 
   924  | 
\end{tabular}
 | 
| 
 | 
   925  | 
\end{textblock}
 | 
| 
 | 
   926  | 
  | 
| 
 | 
   927  | 
\end{frame}
 | 
| 
 | 
   928  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  | 
| 
 | 
   929  | 
  | 
| 
 | 
   930  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
   931  | 
\begin{frame}[c]
 | 
| 
 | 
   932  | 
  \frametitle{Lectures 5 - 10}
 | 
| 
 | 
   933  | 
  
  | 
| 
 | 
   934  | 
  code generation for a small imperative and a small functional language\\[10mm]
  | 
| 
 | 
   935  | 
  
  | 
| 
 | 
   936  | 
  {\LARGE\bf Interpreters}\medskip\\
 | 
| 
 | 
   937  | 
  \hspace{5mm}(directly runs a program)\\[6mm]
 | 
| 
 | 
   938  | 
  
  | 
| 
 | 
   939  | 
  {\LARGE\bf Compilers}\medskip\\
 | 
| 
 | 
   940  | 
  \hspace{5mm}(generate JVM code and LLVM-IR code)
 | 
| 
 | 
   941  | 
  
  | 
| 
 | 
   942  | 
  \begin{textblock}{1}(8.8,8.1)
 | 
| 
 | 
   943  | 
  \begin{tabular}{c@{}c}
 | 
| 
 | 
   944  | 
    \includegraphics[scale=0.4]{../pics/javaduke.png} &
 | 
| 
 | 
   945  | 
    \includegraphics[scale=0.23]{../pics/llvmlogo.png}
 | 
| 
 | 
   946  | 
  \end{tabular}
 | 
| 
 | 
   947  | 
  \end{textblock}
 | 
| 
 | 
   948  | 
  
  | 
| 
 | 
   949  | 
  \end{frame}
 | 
| 
 | 
   950  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  | 
| 
 | 
   951  | 
  
  | 
| 
 | 
   952  | 
  | 
| 
 | 
   953  | 
  | 
| 
 | 
   954  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
   955  | 
\begin{frame}[t]
 | 
| 
 | 
   956  | 
\frametitle{Familiar Regular Expresssions}
 | 
| 
 | 
   957  | 
\small
  | 
| 
 | 
   958  | 
\begin{center}
 | 
| 
 | 
   959  | 
\texttt{[a-z0-9\_$\backslash{}$.-]+ @ [a-z0-9$\backslash{}$.-]+ . [a-z$\backslash{}$.]\{2,6\}}
 | 
| 
 | 
   960  | 
\end{center}\smallskip
 | 
| 
 | 
   961  | 
  | 
| 
 | 
   962  | 
\begin{center}
 | 
| 
 | 
   963  | 
\begin{tabular}{@{}lp{8.5cm}@{}}
 | 
| 
 | 
   964  | 
\pcode{re*} & matches 0 or more times\\
 | 
| 
 | 
   965  | 
\pcode{re+} & matches 1 or more times\\
 | 
| 
 | 
   966  | 
\pcode{re?} & matches 0 or 1 times\\
 | 
| 
 | 
   967  | 
\pcode{re\{n\}}	& matches exactly \pcode{n} number of times\\
 | 
| 
 | 
   968  | 
\pcode{re\{n,m\}} & matches at least \pcode{n} and at most {\tt m} times\\
 | 
| 
 | 
   969  | 
\pcode{[...]} & matches any single character inside the brackets\\
 | 
| 
 | 
   970  | 
\pcode{[^...]} & matches any single character not inside the 
 | 
| 
 | 
   971  | 
brackets\\
  | 
| 
 | 
   972  | 
\pcode{a-z A-Z} & character ranges\\
 | 
| 
 | 
   973  | 
\pcode{\\d} & matches digits; equivalent to \pcode{[0-9]}\\
 | 
| 
 | 
   974  | 
\pcode{.} & matches every character except newline\\
 | 
| 
 | 
   975  | 
\pcode{(re)}	& groups regular expressions and remembers 
 | 
| 
 | 
   976  | 
the matched text
  | 
| 
 | 
   977  | 
\end{tabular}
 | 
| 
 | 
   978  | 
\end{center}
 | 
| 
 | 
   979  | 
  | 
| 
 | 
   980  | 
\end{frame}
 | 
| 
 | 
   981  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  | 
| 
879
 | 
   982  | 
{
 | 
| 
 | 
   983  | 
\setbeamercolor{background canvas}{bg=cream}
 | 
| 
 | 
   984  | 
\begin{frame}[t]
 | 
| 
 | 
   985  | 
\frametitle{Notation for REs}
 | 
| 
 | 
   986  | 
  
  | 
| 
 | 
   987  | 
\end{frame}  
 | 
| 
 | 
   988  | 
}
  | 
| 
876
 | 
   989  | 
  | 
| 
930
 | 
   990  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  | 
| 
 | 
   991  | 
{
 | 
| 
 | 
   992  | 
\setbeamercolor{background canvas}{bg=cream}
 | 
| 
 | 
   993  | 
\begin{frame}[t]
 | 
| 
 | 
   994  | 
  
  | 
| 
 | 
   995  | 
\end{frame}  
 | 
| 
 | 
   996  | 
}
  | 
| 
 | 
   997  | 
  | 
| 
 | 
   998  | 
  | 
| 
 | 
   999  | 
  | 
| 
876
 | 
  1000  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1001  | 
\begin{frame}[c]
 | 
| 
 | 
  1002  | 
\frametitle{Some ``innocent'' examples}
 | 
| 
 | 
  1003  | 
  | 
| 
 | 
  1004  | 
Let's try two examples
  | 
| 
 | 
  1005  | 
  | 
| 
 | 
  1006  | 
\begin{center}
 | 
| 
 | 
  1007  | 
  \bl{\texttt{(a*)*b}}
 | 
| 
 | 
  1008  | 
  \hspace{2cm}
 | 
| 
 | 
  1009  | 
  \bl{\texttt{[a?]\{n\}[a]\{n\}}}
 | 
| 
 | 
  1010  | 
\end{center}\bigskip\pause  
 | 
| 
 | 
  1011  | 
  | 
| 
 | 
  1012  | 
and match them with strings of the form
  | 
| 
 | 
  1013  | 
  | 
| 
 | 
  1014  | 
\begin{center}
 | 
| 
 | 
  1015  | 
  \bl{\texttt{a}},
 | 
| 
 | 
  1016  | 
  \bl{\texttt{aa}},
 | 
| 
 | 
  1017  | 
  \bl{\texttt{aaa}},
 | 
| 
 | 
  1018  | 
  \bl{\texttt{aaaa}},
 | 
| 
 | 
  1019  | 
  \bl{\texttt{aaaaa}},
 | 
| 
 | 
  1020  | 
  \bl{$\underbrace{\texttt{a}...\texttt{a}}_n$}  
 | 
| 
 | 
  1021  | 
\end{center}  
 | 
| 
 | 
  1022  | 
  | 
| 
 | 
  1023  | 
\end{frame}
 | 
| 
 | 
  1024  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  | 
| 
 | 
  1025  | 
  | 
| 
 | 
  1026  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1027  | 
\begin{frame}[c]
 | 
| 
 | 
  1028  | 
\frametitle{Why Bother with Regexes?}
 | 
| 
 | 
  1029  | 
  | 
| 
 | 
  1030  | 
\begin{columns}[t,onlytextwidth]
 | 
| 
 | 
  1031  | 
\begin{column}{1.8cm}
 | 
| 
 | 
  1032  | 
\mbox{}   
 | 
| 
 | 
  1033  | 
\end{column}    
 | 
| 
 | 
  1034  | 
\begin{column}{.5\textwidth}
 | 
| 
 | 
  1035  | 
\small{}Ruby, Python, Java 8\medskip\\
 | 
| 
 | 
  1036  | 
\begin{tikzpicture}\footnotesize
 | 
| 
 | 
  1037  | 
\begin{axis}[
 | 
| 
 | 
  1038  | 
    xlabel={$n$},
 | 
| 
 | 
  1039  | 
    x label style={at={(1.05,0.0)}},
 | 
| 
 | 
  1040  | 
    ylabel={time in secs},
 | 
| 
 | 
  1041  | 
    enlargelimits=false,
  | 
| 
 | 
  1042  | 
    xtick={0,5,...,30},
 | 
| 
 | 
  1043  | 
    xmax=33,
  | 
| 
 | 
  1044  | 
    ymax=35,
  | 
| 
 | 
  1045  | 
    ytick={0,5,...,30},
 | 
| 
 | 
  1046  | 
    scaled ticks=false,
  | 
| 
 | 
  1047  | 
    axis lines=left,
  | 
| 
 | 
  1048  | 
    width=\textwidth,
  | 
| 
 | 
  1049  | 
    height=4cm, 
  | 
| 
 | 
  1050  | 
    legend entries={Python,Ruby},  
 | 
| 
 | 
  1051  | 
    legend pos=north west,
  | 
| 
 | 
  1052  | 
    legend cell align=left]
  | 
| 
 | 
  1053  | 
\addplot[blue,mark=*, mark options={fill=white}] table {re-python.data};
 | 
| 
 | 
  1054  | 
\addplot[brown,mark=triangle*, mark options={fill=white}] table {re-ruby.data};
 | 
| 
 | 
  1055  | 
\end{axis}
 | 
| 
 | 
  1056  | 
\end{tikzpicture}
 | 
| 
 | 
  1057  | 
\begin{tikzpicture}\footnotesize
 | 
| 
 | 
  1058  | 
\begin{axis}[
 | 
| 
 | 
  1059  | 
    xlabel={$n$},
 | 
| 
 | 
  1060  | 
    x label style={at={(1.05,0.0)}},
 | 
| 
 | 
  1061  | 
    ylabel={time in secs},
 | 
| 
 | 
  1062  | 
    enlargelimits=false,
  | 
| 
 | 
  1063  | 
    xtick={0,5,...,30},
 | 
| 
 | 
  1064  | 
    xmax=33,
  | 
| 
 | 
  1065  | 
    ymax=35,
  | 
| 
 | 
  1066  | 
    ytick={0,5,...,30},
 | 
| 
 | 
  1067  | 
    scaled ticks=false,
  | 
| 
 | 
  1068  | 
    axis lines=left,
  | 
| 
 | 
  1069  | 
    width=\textwidth,
  | 
| 
 | 
  1070  | 
    height=4cm, 
  | 
| 
 | 
  1071  | 
    legend entries={Python, Java 8, JavaScript, Swift},  
 | 
| 
 | 
  1072  | 
    legend pos=north west,
  | 
| 
 | 
  1073  | 
    legend cell align=left]
  | 
| 
 | 
  1074  | 
\addplot[blue,mark=*, mark options={fill=white}] table {re-python2.data};   
 | 
| 
 | 
  1075  | 
\addplot[cyan,mark=*, mark options={fill=white}] table {re-java.data};
 | 
| 
 | 
  1076  | 
\addplot[red,mark=*, mark options={fill=white}] table {re-js.data};
 | 
| 
 | 
  1077  | 
\addplot[magenta,mark=*, mark options={fill=white}] table {re-swift.data};
 | 
| 
 | 
  1078  | 
\end{axis}
 | 
| 
 | 
  1079  | 
\end{tikzpicture}
 | 
| 
 | 
  1080  | 
%
  | 
| 
 | 
  1081  | 
\end{column}
 | 
| 
 | 
  1082  | 
\begin{column}{.5\textwidth}
 | 
| 
 | 
  1083  | 
\small{}Us (after next lecture)\medskip\\
 | 
| 
 | 
  1084  | 
\begin{tikzpicture}\footnotesize
 | 
| 
 | 
  1085  | 
\begin{axis}[
 | 
| 
 | 
  1086  | 
    xlabel={$n$},
 | 
| 
 | 
  1087  | 
    x label style={at={(1.07,0.0)}},
 | 
| 
 | 
  1088  | 
    ylabel={time in secs},
 | 
| 
 | 
  1089  | 
    enlargelimits=false,
  | 
| 
 | 
  1090  | 
    xtick={0,5000,...,10000},
 | 
| 
 | 
  1091  | 
    xmax=11000,
  | 
| 
 | 
  1092  | 
    ymax=35,
  | 
| 
 | 
  1093  | 
    ytick={0,5,...,30},
 | 
| 
 | 
  1094  | 
    scaled ticks=false,
  | 
| 
 | 
  1095  | 
    axis lines=left,
  | 
| 
 | 
  1096  | 
    width=\textwidth,
  | 
| 
 | 
  1097  | 
    height=4cm]
  | 
| 
 | 
  1098  | 
\addplot[green,mark=square*,mark options={fill=white}] table {re2.data};
 | 
| 
 | 
  1099  | 
\addplot[black,mark=square*,mark options={fill=white}] table {re3.data};
 | 
| 
 | 
  1100  | 
\end{axis}
 | 
| 
 | 
  1101  | 
\end{tikzpicture}
 | 
| 
 | 
  1102  | 
\begin{tikzpicture}\footnotesize
 | 
| 
 | 
  1103  | 
\begin{axis}[
 | 
| 
 | 
  1104  | 
    xlabel={$n$},
 | 
| 
 | 
  1105  | 
    x label style={at={(1.07,0.0)}},
 | 
| 
 | 
  1106  | 
    ylabel={time in secs},
 | 
| 
 | 
  1107  | 
    enlargelimits=false,
  | 
| 
 | 
  1108  | 
    ymax=35,
  | 
| 
 | 
  1109  | 
    ytick={0,5,...,30},
 | 
| 
 | 
  1110  | 
    scaled ticks=false,
  | 
| 
 | 
  1111  | 
    axis lines=left,
  | 
| 
 | 
  1112  | 
    width=\textwidth,
  | 
| 
 | 
  1113  | 
    height=4cm]
  | 
| 
 | 
  1114  | 
\addplot[black,mark=square*,mark options={fill=white}] table {re3a.data};
 | 
| 
 | 
  1115  | 
\end{axis}
 | 
| 
 | 
  1116  | 
\end{tikzpicture}
 | 
| 
 | 
  1117  | 
\end{column}
 | 
| 
 | 
  1118  | 
\end{columns}
 | 
| 
 | 
  1119  | 
\medskip
  | 
| 
 | 
  1120  | 
  | 
| 
 | 
  1121  | 
\begin{textblock}{3}(-0.1,3.3)
 | 
| 
 | 
  1122  | 
\small\hfill\bl{\texttt{[a?]\{n\}[a]\{n\}}}:
 | 
| 
 | 
  1123  | 
\end{textblock}
 | 
| 
 | 
  1124  | 
  | 
| 
 | 
  1125  | 
\begin{textblock}{3}(-0.1,8.7)  
 | 
| 
 | 
  1126  | 
\small\hfill\bl{\texttt{(a*)*b}}:
 | 
| 
 | 
  1127  | 
\end{textblock}
 | 
| 
 | 
  1128  | 
  | 
| 
 | 
  1129  | 
\begin{textblock}{3}(0.3,13)
 | 
| 
 | 
  1130  | 
\small{}matching with strings
 | 
| 
 | 
  1131  | 
\bl{$\underbrace{\texttt{a}...\texttt{a}}_n$}  
 | 
| 
 | 
  1132  | 
\end{textblock}
 | 
| 
 | 
  1133  | 
  | 
| 
 | 
  1134  | 
\end{frame} 
 | 
| 
 | 
  1135  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
  | 
| 
 | 
  1136  | 
    
  | 
| 
 | 
  1137  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1138  | 
\begin{frame}[c,fragile]
 | 
| 
 | 
  1139  | 
  \frametitle{Incidents}
 | 
| 
 | 
  1140  | 
    
  | 
| 
 | 
  1141  | 
  \begin{itemize}
 | 
| 
 | 
  1142  | 
  \item a global outage on 2 July 2019 at \textbf{Cloudflare} 
 | 
| 
 | 
  1143  | 
  (first one for six years)\medskip
  | 
| 
 | 
  1144  | 
  
  | 
| 
 | 
  1145  | 
  \begin{center}\small\color{blue}
 | 
| 
 | 
  1146  | 
  \begin{verbatim}  
 | 
| 
 | 
  1147  | 
  (?:(?:\"|'|\]|\}|\\|\d|(?:nan|infinity|true|false|
  | 
| 
 | 
  1148  | 
  null|undefined|symbol|math)|\`|\-|\+)+[)]*;?((?:\s
  | 
| 
 | 
  1149  | 
  |-|~|!|{}|\|\||\+)*.*(?:.*=.*)))  
 | 
| 
 | 
  1150  | 
  \end{verbatim}
 | 
| 
 | 
  1151  | 
  \end{center}\bigskip\bigskip\bigskip\bigskip\bigskip\bigskip\bigskip    
 | 
| 
 | 
  1152  | 
  
  | 
| 
 | 
  1153  | 
  \item on 20 July 2016 the \textbf{Stack Exchange} webpage went down
 | 
| 
 | 
  1154  | 
    because of an evil regular expression
  | 
| 
984
 | 
  1155  | 
    \here{https://stackstatus.tumblr.com/post/147710624694/outage-postmortem-july-20-2016}    
 | 
| 
876
 | 
  1156  | 
  \end{itemize}
 | 
| 
 | 
  1157  | 
  
  | 
| 
 | 
  1158  | 
  \begin{textblock}{6}(6,7.6)
 | 
| 
 | 
  1159  | 
    \includegraphics[scale=0.14]{../pics/cloudflare.png}\\
 | 
| 
 | 
  1160  | 
    \footnotesize
  | 
| 
 | 
  1161  | 
    It serves more web traffic than Twitter, Amazon, Apple,
  | 
| 
 | 
  1162  | 
    Instagram, Bing \& Wikipedia combined.
  | 
| 
 | 
  1163  | 
    \here{https://blog.cloudflare.com/details-of-the-cloudflare-outage-on-july-2-2019/}
 | 
| 
 | 
  1164  | 
    \end{textblock}
 | 
| 
 | 
  1165  | 
  
  | 
| 
 | 
  1166  | 
  \end{frame}
 | 
| 
 | 
  1167  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
  | 
| 
 | 
  1168  | 
    
  | 
| 
 | 
  1169  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1170  | 
\begin{frame}[c]
 | 
| 
 | 
  1171  | 
\frametitle{Evil Regular Expressions}
 | 
| 
 | 
  1172  | 
  | 
| 
 | 
  1173  | 
\begin{itemize}
 | 
| 
 | 
  1174  | 
\item \alert{R}egular \alert{e}xpression \alert{D}enial \alert{o}f \alert{S}ervice (ReDoS)\medskip
 | 
| 
 | 
  1175  | 
\item Some evil regular expressions:\medskip
  | 
| 
 | 
  1176  | 
\begin{itemize}
 | 
| 
 | 
  1177  | 
\item \bl{\texttt{[a?]\{n\}\;[a]\{n\}}}
 | 
| 
 | 
  1178  | 
\item \bl{\texttt{(a*)*\;b}}  
 | 
| 
 | 
  1179  | 
\item \bl{\texttt{([a-z]+)*}} 
 | 
| 
 | 
  1180  | 
\item \bl{\texttt{(a + aa)*}}
 | 
| 
 | 
  1181  | 
\item \bl{\texttt{(a + a?)*}}
 | 
| 
 | 
  1182  | 
\end{itemize}
 | 
| 
 | 
  1183  | 
  | 
| 
 | 
  1184  | 
\item sometimes also called \alert{catastrophic backtracking}
 | 
| 
 | 
  1185  | 
\item this is a problem for \alert{N}etwork \alert{I}ntrusion
 | 
| 
 | 
  1186  | 
  \alert{D}etection systems, Cloudflare, StackExchange, Atom editor
 | 
| 
 | 
  1187  | 
\item \url{https://vimeo.com/112065252}  
 | 
| 
 | 
  1188  | 
\end{itemize}
 | 
| 
 | 
  1189  | 
  | 
| 
 | 
  1190  | 
\end{frame}
 | 
| 
 | 
  1191  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1192  | 
  | 
| 
929
 | 
  1193  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  | 
| 
964
 | 
  1194  | 
% {
 | 
| 
 | 
  1195  | 
% \setbeamercolor{background canvas}{bg=cream}
 | 
| 
 | 
  1196  | 
% \begin{frame}[c]
 | 
| 
 | 
  1197  | 
% \frametitle{Rust vs.~Scala (from PEP)}
 | 
| 
929
 | 
  1198  | 
  | 
| 
964
 | 
  1199  | 
% \mbox{}
 | 
| 
929
 | 
  1200  | 
  | 
| 
964
 | 
  1201  | 
% \begin{minipage}{1.3\textwidth}
 | 
| 
 | 
  1202  | 
% \begin{mybox3}{}\it\small
 | 
| 
 | 
  1203  | 
% \textbf{Re: Another question of purely academic interest about regex implementation in cw3}
 | 
| 
929
 | 
  1204  | 
  | 
| 
964
 | 
  1205  | 
% This conversation is interesting to me, and I've researched it a
  | 
| 
 | 
  1206  | 
% little bit [...] I also disagree with Dr.~Urban on the cost/benefit of
  | 
| 
 | 
  1207  | 
% non-GC languages [...]\smallskip
  | 
| 
929
 | 
  1208  | 
  | 
| 
964
 | 
  1209  | 
% But regardless, Scala is a lot slower than, say, C or Rust. To say
  | 
| 
 | 
  1210  | 
% it's not is basically wrong (imo). Perhaps one could argue that some
  | 
| 
 | 
  1211  | 
% of the guarantees Scala has makes it easier to write multi-threaded
  | 
| 
 | 
  1212  | 
% programs that utilise more of the CPU... but, in my opinion, this is
  | 
| 
 | 
  1213  | 
% also a bit misleading. Most CPUs have something like 4 to 12 cores
  | 
| 
 | 
  1214  | 
% nowadays. It's very possible that a given Scala program runs 4-12x
  | 
| 
 | 
  1215  | 
% slower than its Rust equivalent. Would you rather have your program
  | 
| 
 | 
  1216  | 
% run quickly and use a single core, or have it run equally
  | 
| 
 | 
  1217  | 
% quickly... and... hog your entire CPU for its duration?\ldots{}
 | 
| 
929
 | 
  1218  | 
  | 
| 
964
 | 
  1219  | 
% \mbox{}\hfill-- Oliver Iliffe,  discussion from PEP
 | 
| 
 | 
  1220  | 
% \end{mybox3}
 | 
| 
 | 
  1221  | 
% \end{minipage}
 | 
| 
929
 | 
  1222  | 
  | 
| 
964
 | 
  1223  | 
% \end{frame}
 | 
| 
 | 
  1224  | 
% }
  | 
| 
929
 | 
  1225  | 
  | 
| 
 | 
  1226  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  | 
| 
964
 | 
  1227  | 
% {
 | 
| 
 | 
  1228  | 
% \setbeamercolor{background canvas}{bg=cream}
 | 
| 
 | 
  1229  | 
% \begin{frame}[c]
 | 
| 
 | 
  1230  | 
% \frametitle{Regex Lib in Rust}
 | 
| 
929
 | 
  1231  | 
  | 
| 
964
 | 
  1232  | 
% \begin{center}
 | 
| 
 | 
  1233  | 
% \includegraphics[scale=0.34]{../pics/rust-regex.png}
 | 
| 
 | 
  1234  | 
% \end{center}
 | 
| 
929
 | 
  1235  | 
  | 
| 
964
 | 
  1236  | 
% \end{frame}
 | 
| 
 | 
  1237  | 
% }
  | 
| 
929
 | 
  1238  | 
  | 
| 
 | 
  1239  | 
  | 
| 
 | 
  1240  | 
  | 
| 
 | 
  1241  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
964
 | 
  1242  | 
% {
 | 
| 
 | 
  1243  | 
% \setbeamercolor{background canvas}{bg=cream}
 | 
| 
 | 
  1244  | 
% \begin{frame}[c,fragile]
 | 
| 
929
 | 
  1245  | 
  | 
| 
964
 | 
  1246  | 
% \begin{columns}[t,onlytextwidth]
 | 
| 
 | 
  1247  | 
% \begin{column}{1\textwidth}
 | 
| 
 | 
  1248  | 
% \small re: \bl{$(abc)^{\{n\}}$}\quad str: \bl{$\underbrace{abc\ldots{}abc}_n$}\medskip\\  
 | 
| 
 | 
  1249  | 
% \begin{tikzpicture}\footnotesize
 | 
| 
 | 
  1250  | 
% \begin{axis}[
 | 
| 
 | 
  1251  | 
%     xlabel={$n$},
 | 
| 
 | 
  1252  | 
%     x label style={at={(1.07,0.0)}},
 | 
| 
 | 
  1253  | 
%     ylabel={time in secs},
 | 
| 
 | 
  1254  | 
%     enlargelimits=false,
  | 
| 
 | 
  1255  | 
%     xmax=65000,
  | 
| 
 | 
  1256  | 
%     ymax=100,
  | 
| 
 | 
  1257  | 
%     xtick={0,15000,...,60000},
 | 
| 
 | 
  1258  | 
%     ytick={0,10,...,90},
 | 
| 
 | 
  1259  | 
%     scaled ticks=false,
  | 
| 
 | 
  1260  | 
%     axis lines=left,
  | 
| 
 | 
  1261  | 
%     width=7cm,
  | 
| 
 | 
  1262  | 
%     height=5cm]
  | 
| 
 | 
  1263  | 
%     \addplot[black,mark=square*,mark options={fill=red}] table [x=x, y=y, col sep=comma, row sep=crcr]
 | 
| 
 | 
  1264  | 
%     {x, y\\
 | 
| 
 | 
  1265  | 
%       0, 0\\
  | 
| 
 | 
  1266  | 
%      5000, 0.487\\ 
  | 
| 
 | 
  1267  | 
%      10000, 1.650\\
  | 
| 
 | 
  1268  | 
%      15000, 3.617\\
  | 
| 
 | 
  1269  | 
%      20000, 6.462\\
  | 
| 
 | 
  1270  | 
%      25000, 10.736\\
  | 
| 
 | 
  1271  | 
%      30000, 17.665\\
  | 
| 
 | 
  1272  | 
%      35000, 25.662\\
  | 
| 
 | 
  1273  | 
%      40000, 36.422\\
  | 
| 
 | 
  1274  | 
%      45000, 49.119\\
  | 
| 
 | 
  1275  | 
%      50000, 62.058\\
  | 
| 
 | 
  1276  | 
%      55000, 75.941\\
  | 
| 
 | 
  1277  | 
%      60000, 93.022\\
  | 
| 
 | 
  1278  | 
%     };
  | 
| 
 | 
  1279  | 
% \end{axis}
 | 
| 
 | 
  1280  | 
% \end{tikzpicture}
 | 
| 
 | 
  1281  | 
% \end{column}
 | 
| 
 | 
  1282  | 
% \end{columns}
 | 
| 
929
 | 
  1283  | 
  | 
| 
964
 | 
  1284  | 
% \begin{textblock}{10}(8.4,3.8)
 | 
| 
 | 
  1285  | 
% \tiny  
  | 
| 
 | 
  1286  | 
% \begin{lstlisting}[language=Rust]
 | 
| 
 | 
  1287  | 
% extern crate regex;
  | 
| 
929
 | 
  1288  | 
  | 
| 
964
 | 
  1289  | 
% use regex::Regex;
  | 
| 
 | 
  1290  | 
% use std::time::Instant;
  | 
| 
929
 | 
  1291  | 
  | 
| 
964
 | 
  1292  | 
% // bounded regular expression example
  | 
| 
929
 | 
  1293  | 
  | 
| 
964
 | 
  1294  | 
% fn main() {
 | 
| 
 | 
  1295  | 
%    for bound in (0..=60000).step_by(5000) {
 | 
| 
929
 | 
  1296  | 
   
  | 
| 
964
 | 
  1297  | 
%       let re = Regex::new(&format!("(abc){{{}}}", bound)).unwrap();
 | 
| 
 | 
  1298  | 
%       let text = "abc".repeat(bound);
  | 
| 
929
 | 
  1299  | 
  | 
| 
964
 | 
  1300  | 
%       let start_time = Instant::now();
  | 
| 
 | 
  1301  | 
%       let is_match = re.is_match(&text);
  | 
| 
 | 
  1302  | 
%       let elapsed_time = start_time.elapsed().as_secs_f64();
  | 
| 
929
 | 
  1303  | 
  | 
| 
964
 | 
  1304  | 
%       println!("Bound: {}, Match: {}, Time: {} seconds", bound, is_match, elapsed_time);
 | 
| 
 | 
  1305  | 
%    }
  | 
| 
 | 
  1306  | 
% }
  | 
| 
 | 
  1307  | 
% \end{lstlisting}    
 | 
| 
 | 
  1308  | 
% \end{textblock}
 | 
| 
 | 
  1309  | 
% \end{frame}
 | 
| 
 | 
  1310  | 
% }  
  | 
| 
929
 | 
  1311  | 
  | 
| 
 | 
  1312  | 
  | 
| 
876
 | 
  1313  | 
  | 
| 
 | 
  1314  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1315  | 
%\begin{frame}[c]
 | 
| 
 | 
  1316  | 
%\frametitle{Today}
 | 
| 
 | 
  1317  | 
%
  | 
| 
 | 
  1318  | 
%\begin{itemize}
 | 
| 
 | 
  1319  | 
%\item While the ultimate goal is to implement a small compiler for the JVM
  | 
| 
 | 
  1320  | 
%  \ldots\bigskip
  | 
| 
 | 
  1321  | 
%\end{itemize}
 | 
| 
 | 
  1322  | 
%
  | 
| 
 | 
  1323  | 
%Let's start with:
  | 
| 
 | 
  1324  | 
%
  | 
| 
 | 
  1325  | 
%\begin{itemize}
 | 
| 
 | 
  1326  | 
%\item a web-crawler
  | 
| 
 | 
  1327  | 
%\item an email harvester
  | 
| 
 | 
  1328  | 
%\item \textcolor{gray}{(a web-scraper)}
 | 
| 
 | 
  1329  | 
%\end{itemize}
 | 
| 
 | 
  1330  | 
%
  | 
| 
 | 
  1331  | 
%\end{frame}
 | 
| 
 | 
  1332  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
  | 
| 
 | 
  1333  | 
  | 
| 
 | 
  1334  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1335  | 
%\begin{frame}[t]
 | 
| 
 | 
  1336  | 
%\frametitle{A Web-Crawler}
 | 
| 
 | 
  1337  | 
%
  | 
| 
 | 
  1338  | 
%\mbox{}\\[10mm]
 | 
| 
 | 
  1339  | 
%
  | 
| 
 | 
  1340  | 
%\begin{enumerate}
 | 
| 
 | 
  1341  | 
%\item given an URL, read the corresponding webpage
  | 
| 
 | 
  1342  | 
%\item extract all links from it
  | 
| 
 | 
  1343  | 
%\item call the web-crawler again for all these links
  | 
| 
 | 
  1344  | 
%\end{enumerate}
 | 
| 
 | 
  1345  | 
%
  | 
| 
 | 
  1346  | 
%\end{frame}
 | 
| 
 | 
  1347  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  | 
| 
 | 
  1348  | 
  | 
| 
 | 
  1349  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1350  | 
%\begin{frame}[t]
 | 
| 
 | 
  1351  | 
%\frametitle{A Web-Crawler}
 | 
| 
 | 
  1352  | 
%
  | 
| 
 | 
  1353  | 
%\mbox{}\\[10mm]
 | 
| 
 | 
  1354  | 
%
  | 
| 
 | 
  1355  | 
%
  | 
| 
 | 
  1356  | 
%\begin{enumerate}
 | 
| 
 | 
  1357  | 
%\item given an URL, read the corresponding webpage
  | 
| 
 | 
  1358  | 
%\item if not possible print, out a problem
  | 
| 
 | 
  1359  | 
%\item if possible, extract all links from it
  | 
| 
 | 
  1360  | 
%\item call the web-crawler again for all these links
  | 
| 
 | 
  1361  | 
%\end{enumerate}\bigskip\pause
 | 
| 
 | 
  1362  | 
%
  | 
| 
 | 
  1363  | 
%\small (we need a bound for the number of recursive calls)
  | 
| 
 | 
  1364  | 
%
  | 
| 
 | 
  1365  | 
%\small (the purpose is to check all links on my own webpage)
  | 
| 
 | 
  1366  | 
%\end{frame}
 | 
| 
 | 
  1367  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  | 
| 
 | 
  1368  | 
  | 
| 
 | 
  1369  | 
  | 
| 
 | 
  1370  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1371  | 
%\begin{frame}[c]
 | 
| 
 | 
  1372  | 
%
  | 
| 
 | 
  1373  | 
%\begin{textblock}{1}(2,5)
 | 
| 
 | 
  1374  | 
%\begin{tabular}{c}
 | 
| 
 | 
  1375  | 
%\includegraphics[scale=0.15]{pics/servers.png}\\[-2mm]
 | 
| 
 | 
  1376  | 
%\small Server
  | 
| 
 | 
  1377  | 
%\end{tabular}
 | 
| 
 | 
  1378  | 
%\end{textblock}
 | 
| 
 | 
  1379  | 
%
  | 
| 
 | 
  1380  | 
%\begin{textblock}{1}(5.6,4)
 | 
| 
 | 
  1381  | 
%  \begin{tikzpicture}[scale=1.1]
 | 
| 
 | 
  1382  | 
%  \draw[white] (0,1) node (X) {};
 | 
| 
 | 
  1383  | 
%  \draw[white] (2,1) node (Y) {};
 | 
| 
 | 
  1384  | 
%   \draw[white] (0,0) node (X1) {};
 | 
| 
 | 
  1385  | 
%  \draw[white] (2,0) node (Y1) {};
 | 
| 
 | 
  1386  | 
%   \draw[white] (0,-1) node (X2) {};
 | 
| 
 | 
  1387  | 
%  \draw[white] (2,-1) node (Y2) {};
 | 
| 
 | 
  1388  | 
%  \draw[red, <-, line width = 2mm] (X) -- (Y);
  | 
| 
 | 
  1389  | 
%  \node [inner sep=5pt,label=above:\textcolor{black}{GET request}] at ($ (X)!.5!(Y) $) {};
 | 
| 
 | 
  1390  | 
%  \draw[red, ->, line width = 2mm] (X1) -- (Y1);
  | 
| 
 | 
  1391  | 
%  \node [inner sep=5pt,label=above:\textcolor{black}{webpage}] at ($ (X1)!.5!(Y1) $) {};
 | 
| 
 | 
  1392  | 
%  \draw[red, <-, line width = 2mm] (X2) -- (Y2);
  | 
| 
 | 
  1393  | 
%  \node [inner sep=7pt,label=above:\textcolor{black}{POST data}] at ($ (X2)!.5!(Y2) $) {};
 | 
| 
 | 
  1394  | 
%  \end{tikzpicture}
 | 
| 
 | 
  1395  | 
%\end{textblock}
 | 
| 
 | 
  1396  | 
%
  | 
| 
 | 
  1397  | 
%
  | 
| 
 | 
  1398  | 
%\begin{textblock}{1}(9,5.5)
 | 
| 
 | 
  1399  | 
%\begin{tabular}{c}
 | 
| 
 | 
  1400  | 
%\includegraphics[scale=0.15]{pics/laptop.png}\\[-2mm]
 | 
| 
 | 
  1401  | 
%\small Browser
  | 
| 
 | 
  1402  | 
%\end{tabular}
 | 
| 
 | 
  1403  | 
%\end{textblock}
 | 
| 
 | 
  1404  | 
%\end{frame}
 | 
| 
 | 
  1405  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  | 
| 
 | 
  1406  | 
  | 
| 
 | 
  1407  | 
  
  | 
| 
 | 
  1408  | 
  | 
| 
 | 
  1409  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1410  | 
%\begin{frame}[c]
 | 
| 
 | 
  1411  | 
%\frametitle{Scala}
 | 
| 
 | 
  1412  | 
%
  | 
| 
 | 
  1413  | 
%\small A simple Scala function for reading webpages:
  | 
| 
 | 
  1414  | 
%\bigskip
  | 
| 
 | 
  1415  | 
%
  | 
| 
 | 
  1416  | 
%\footnotesize
  | 
| 
 | 
  1417  | 
%\lstinputlisting{../progs/app0.scala}
 | 
| 
 | 
  1418  | 
%\medskip\pause
  | 
| 
 | 
  1419  | 
%
  | 
| 
 | 
  1420  | 
%\lstinline{get_page("""https://nms.kcl.ac.uk/christian.urban/""")}
 | 
| 
 | 
  1421  | 
%\bigskip\medskip\pause
  | 
| 
 | 
  1422  | 
%
  | 
| 
 | 
  1423  | 
%
  | 
| 
 | 
  1424  | 
%\small A slightly more complicated version for handling errors:
  | 
| 
 | 
  1425  | 
%\smallskip
  | 
| 
 | 
  1426  | 
%
  | 
| 
 | 
  1427  | 
%\footnotesize
  | 
| 
 | 
  1428  | 
%\lstinputlisting[xleftmargin=-4mm]{../progs/app1.scala}
 | 
| 
 | 
  1429  | 
%
  | 
| 
 | 
  1430  | 
%
  | 
| 
 | 
  1431  | 
%\end{frame}
 | 
| 
 | 
  1432  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  | 
| 
 | 
  1433  | 
  | 
| 
 | 
  1434  | 
 
  | 
| 
 | 
  1435  | 
  | 
| 
 | 
  1436  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1437  | 
%\begin{frame}[t]
 | 
| 
 | 
  1438  | 
%\frametitle{A Regular Expression}
 | 
| 
 | 
  1439  | 
%
  | 
| 
 | 
  1440  | 
%\begin{itemize}
 | 
| 
 | 
  1441  | 
%\item \ldots{} is a pattern or template for specifying strings
 | 
| 
 | 
  1442  | 
%\end{itemize}\bigskip
 | 
| 
 | 
  1443  | 
%  
  | 
| 
 | 
  1444  | 
%\begin{center}  
 | 
| 
 | 
  1445  | 
%\only<1>{\scode{"https?://[^"]*"}}%
 | 
| 
 | 
  1446  | 
%\only<2>{\scode{""""https?://[^"]*"""".r}}
 | 
| 
 | 
  1447  | 
%\end{center}\bigskip\bigskip
 | 
| 
 | 
  1448  | 
%
  | 
| 
 | 
  1449  | 
%matches for example\smallskip\\  
  | 
| 
 | 
  1450  | 
%\hspace{2mm}\code{"http://www.foobar.com"}\\
 | 
| 
 | 
  1451  | 
%\hspace{2mm}\code{"https://www.tls.org"}\smallskip\\
 | 
| 
 | 
  1452  | 
%
  | 
| 
 | 
  1453  | 
%but not\smallskip\\  
  | 
| 
 | 
  1454  | 
%\hspace{2mm}\code{"http://www."foo"bar.com"}\\
 | 
| 
 | 
  1455  | 
%
  | 
| 
 | 
  1456  | 
%\end{frame}
 | 
| 
 | 
  1457  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  | 
| 
 | 
  1458  | 
  | 
| 
 | 
  1459  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1460  | 
%\begin{frame}[c]
 | 
| 
 | 
  1461  | 
%\frametitle{Finding Operations in Scala}
 | 
| 
 | 
  1462  | 
%
  | 
| 
 | 
  1463  | 
%{\bf\code{rexp.findAllIn(string)}}\medskip
 | 
| 
 | 
  1464  | 
%  
  | 
| 
 | 
  1465  | 
%returns a list of all (sub)strings that match the 
  | 
| 
 | 
  1466  | 
%regular expression
  | 
| 
 | 
  1467  | 
%\bigskip\bigskip  
  | 
| 
 | 
  1468  | 
%  
  | 
| 
 | 
  1469  | 
%
  | 
| 
 | 
  1470  | 
%{\bf\code{rexp.findFirstIn(string)}}\medskip
 | 
| 
 | 
  1471  | 
% 
  | 
| 
 | 
  1472  | 
%returns either 
  | 
| 
 | 
  1473  | 
%
  | 
| 
 | 
  1474  | 
%\begin{itemize}
 | 
| 
 | 
  1475  | 
%\item \code{None} if no (sub)string matches or 
 | 
| 
 | 
  1476  | 
%\item \code{Some(s)} with the first (sub)string
 | 
| 
 | 
  1477  | 
%\end{itemize}
 | 
| 
 | 
  1478  | 
%
  | 
| 
 | 
  1479  | 
%\end{frame}
 | 
| 
 | 
  1480  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  | 
| 
 | 
  1481  | 
  | 
| 
 | 
  1482  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1483  | 
%\begin{frame}[c]
 | 
| 
 | 
  1484  | 
%
  | 
| 
 | 
  1485  | 
%\footnotesize
  | 
| 
 | 
  1486  | 
%\lstinputlisting{../progs/app2.scala}
 | 
| 
 | 
  1487  | 
%
  | 
| 
 | 
  1488  | 
%\end{frame}
 | 
| 
 | 
  1489  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  | 
| 
 | 
  1490  | 
  | 
| 
 | 
  1491  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1492  | 
%\begin{frame}[c]
 | 
| 
 | 
  1493  | 
%
  | 
| 
 | 
  1494  | 
%\small
  | 
| 
 | 
  1495  | 
%A version that only crawls links in ``my'' domain:\bigskip
  | 
| 
 | 
  1496  | 
%
  | 
| 
 | 
  1497  | 
%\footnotesize
  | 
| 
 | 
  1498  | 
%\lstinputlisting{../progs/app3.scala}
 | 
| 
 | 
  1499  | 
%
  | 
| 
 | 
  1500  | 
%\end{frame}
 | 
| 
 | 
  1501  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  | 
| 
 | 
  1502  | 
  | 
| 
 | 
  1503  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1504  | 
%\begin{frame}[c]
 | 
| 
 | 
  1505  | 
%\lstset{xleftmargin=-4mm}
 | 
| 
 | 
  1506  | 
%\small
  | 
| 
 | 
  1507  | 
%A little email harvester:
  | 
| 
 | 
  1508  | 
%
  | 
| 
 | 
  1509  | 
%\footnotesize
  | 
| 
 | 
  1510  | 
%\lstinputlisting{../progs/app4.scala}\bigskip
 | 
| 
 | 
  1511  | 
%
  | 
| 
 | 
  1512  | 
%\tiny
  | 
| 
 | 
  1513  | 
%\url{http://net.tutsplus.com/tutorials/other/8-regular-expressions-you-should-know/}
 | 
| 
 | 
  1514  | 
%
  | 
| 
 | 
  1515  | 
%\end{frame}
 | 
| 
 | 
  1516  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  | 
| 
 | 
  1517  | 
  | 
| 
 | 
  1518  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1519  | 
\begin{frame}[t]
 | 
| 
 | 
  1520  | 
\frametitle{(Basic) Regular Expressions}
 | 
| 
 | 
  1521  | 
  | 
| 
 | 
  1522  | 
Their inductive definition:
  | 
| 
 | 
  1523  | 
  | 
| 
 | 
  1524  | 
  | 
| 
 | 
  1525  | 
\begin{textblock}{6}(2,7.5)
 | 
| 
 | 
  1526  | 
  \begin{tabular}{@ {}rrl@ {\hspace{13mm}}l}
 | 
| 
 | 
  1527  | 
  \bl{$r$} & \bl{$::=$}  & \bl{$\ZERO$}  & nothing\\
 | 
| 
 | 
  1528  | 
         & \bl{$\mid$} & \bl{$\ONE$}       & empty string / \pcode{""} / $[]$\\
 | 
| 
 | 
  1529  | 
         & \bl{$\mid$} & \bl{$c$}                         & character\\
 | 
| 
 | 
  1530  | 
         & \bl{$\mid$} & \bl{$r_1 + r_2$}  & alternative / choice\\
 | 
| 
 | 
  1531  | 
         & \bl{$\mid$} & \bl{$r_1 \cdot r_2$} & sequence\\
 | 
| 
 | 
  1532  | 
         & \bl{$\mid$} & \bl{$r^*$}            & star (zero or more)\\
 | 
| 
 | 
  1533  | 
  \end{tabular}
 | 
| 
 | 
  1534  | 
  \end{textblock}
 | 
| 
 | 
  1535  | 
  
  | 
| 
 | 
  1536  | 
  
  | 
| 
 | 
  1537  | 
\only<2->{\footnotesize
 | 
| 
 | 
  1538  | 
\begin{textblock}{9}(2,0.5)
 | 
| 
 | 
  1539  | 
\begin{bubble}[9.8cm]
 | 
| 
 | 
  1540  | 
\lstinputlisting{../progs/app01.scala}
 | 
| 
 | 
  1541  | 
\end{bubble}
 | 
| 
 | 
  1542  | 
\end{textblock}}
 | 
| 
 | 
  1543  | 
  
  | 
| 
 | 
  1544  | 
\end{frame}
 | 
| 
 | 
  1545  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  | 
| 
 | 
  1546  | 
  | 
| 
 | 
  1547  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1548  | 
%\begin{frame}[t]
 | 
| 
 | 
  1549  | 
%\frametitle{Regular Expressions}
 | 
| 
 | 
  1550  | 
%
  | 
| 
 | 
  1551  | 
%\small
  | 
| 
 | 
  1552  | 
%In Scala:\bigskip
  | 
| 
 | 
  1553  | 
%
  | 
| 
 | 
  1554  | 
%\footnotesize
  | 
| 
 | 
  1555  | 
%\lstinputlisting{../progs/app51.scala}
 | 
| 
 | 
  1556  | 
%
  | 
| 
 | 
  1557  | 
%  
  | 
| 
 | 
  1558  | 
%\end{frame}
 | 
| 
 | 
  1559  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  | 
| 
 | 
  1560  | 
  | 
| 
 | 
  1561  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1562  | 
\begin{frame}[t]
 | 
| 
 | 
  1563  | 
\frametitle{Strings}
 | 
| 
 | 
  1564  | 
  | 
| 
 | 
  1565  | 
\ldots are lists of characters. For example \code{"hello"}
 | 
| 
 | 
  1566  | 
  | 
| 
 | 
  1567  | 
\begin{center}
 | 
| 
 | 
  1568  | 
\bl{$[h, e, l, l, o]$} or just \bl{$hello$}
 | 
| 
 | 
  1569  | 
\end{center}
 | 
| 
 | 
  1570  | 
  | 
| 
 | 
  1571  | 
the empty string: \bl{$[]$} or \bl{\pcode{""}}\bigskip\\
 | 
| 
 | 
  1572  | 
  | 
| 
 | 
  1573  | 
the concatenation of two strings:
  | 
| 
 | 
  1574  | 
  | 
| 
 | 
  1575  | 
\begin{center}
 | 
| 
 | 
  1576  | 
\bl{$s_1 \,@\, s_2$}
 | 
| 
 | 
  1577  | 
\end{center}
 | 
| 
 | 
  1578  | 
  | 
| 
 | 
  1579  | 
\bl{\textit{foo $@$ bar = foobar}}\\
 | 
| 
 | 
  1580  | 
\bl{\textit{baz $@\, []$ = baz}}
 | 
| 
 | 
  1581  | 
  
  | 
| 
 | 
  1582  | 
\end{frame}
 | 
| 
 | 
  1583  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  | 
| 
 | 
  1584  | 
  | 
| 
 | 
  1585  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1586  | 
\begin{frame}[c]
 | 
| 
 | 
  1587  | 
\frametitle{Languages, Strings}
 | 
| 
 | 
  1588  | 
  | 
| 
 | 
  1589  | 
\begin{itemize}
 | 
| 
 | 
  1590  | 
\item \alert{\bf Strings} are lists of characters, for example
 | 
| 
 | 
  1591  | 
\begin{center}
 | 
| 
 | 
  1592  | 
\bl{$[]$},\;\bl{$abc$}  \hspace{2cm}(Pattern match: \bl{$c\!::\!s$})
 | 
| 
 | 
  1593  | 
\end{center}\bigskip
 | 
| 
 | 
  1594  | 
  | 
| 
 | 
  1595  | 
  | 
| 
 | 
  1596  | 
\item A \alert{\bf language} is a set of strings, for example\medskip
 | 
| 
 | 
  1597  | 
\begin{center}
 | 
| 
 | 
  1598  | 
\bl{$\{[], hello, \textit{foobar}, a, abc\}$}
 | 
| 
 | 
  1599  | 
\end{center}\bigskip
 | 
| 
 | 
  1600  | 
  | 
| 
 | 
  1601  | 
\item \alert{\bf Concatenation} of strings and languages
 | 
| 
 | 
  1602  | 
  | 
| 
 | 
  1603  | 
\begin{center}
 | 
| 
 | 
  1604  | 
\begin{tabular}{rcl}
 | 
| 
 | 
  1605  | 
\bl{$\textit{foo}\;@\;bar$} & \bl{$=$} & \bl{$\textit{foobar}$}\medskip\\
 | 
| 
 | 
  1606  | 
\bl{$A\;@\;B$} & \bl{$\dn$} & \bl{$\{ s_1\,@\,s_2 \;\mid\; s_1 \in A \wedge s_2 \in B\}$}
 | 
| 
 | 
  1607  | 
\end{tabular}
 | 
| 
 | 
  1608  | 
\end{center}
 | 
| 
 | 
  1609  | 
  | 
| 
 | 
  1610  | 
%\item The \alert{\bf meaning} of a regular expression is a set of 
 | 
| 
 | 
  1611  | 
%  strings, or language.
  | 
| 
 | 
  1612  | 
\end{itemize}  
 | 
| 
 | 
  1613  | 
  | 
| 
 | 
  1614  | 
\only<2>{
 | 
| 
 | 
  1615  | 
\begin{textblock}{4}(10.5,8)
 | 
| 
 | 
  1616  | 
\small
  | 
| 
 | 
  1617  | 
Let
  | 
| 
 | 
  1618  | 
  | 
| 
 | 
  1619  | 
\bl{$A = \{foo, bar\}$} \bl{$B = \{a, b\}$}
 | 
| 
 | 
  1620  | 
\[
  | 
| 
 | 
  1621  | 
\bl{A \,@\, B = \{fooa, foob, bara, barb\}}
 | 
| 
 | 
  1622  | 
\]
  | 
| 
 | 
  1623  | 
\end{textblock}}  
 | 
| 
 | 
  1624  | 
  | 
| 
 | 
  1625  | 
\end{frame}
 | 
| 
 | 
  1626  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  | 
| 
 | 
  1627  | 
  | 
| 
 | 
  1628  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1629  | 
\begin{frame}[c]
 | 
| 
 | 
  1630  | 
  \frametitle{Two Corner Cases}
 | 
| 
 | 
  1631  | 
   
  | 
| 
 | 
  1632  | 
  \Large
  | 
| 
 | 
  1633  | 
  \begin{center}
 | 
| 
 | 
  1634  | 
  \bl{$A \,@\, \{[]\} = \;?$}\bigskip\bigskip\pause\\
 | 
| 
 | 
  1635  | 
  \bl{$A \,@\, \{\} = \;?$}
 | 
| 
 | 
  1636  | 
  \end{center}  
 | 
| 
 | 
  1637  | 
    
  | 
| 
 | 
  1638  | 
  \end{frame}
 | 
| 
 | 
  1639  | 
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
  | 
| 
 | 
  1640  | 
  
  | 
| 
 | 
  1641  | 
  | 
| 
 | 
  1642  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1643  | 
\begin{frame}[c]
 | 
| 
 | 
  1644  | 
\frametitle{The Meaning of a Regex}
 | 
| 
 | 
  1645  | 
  | 
| 
 | 
  1646  | 
 ...all the strings a regular expression can match.   
  | 
| 
 | 
  1647  | 
  | 
| 
 | 
  1648  | 
\begin{center}
 | 
| 
 | 
  1649  | 
 \begin{tabular}{rcl}
 | 
| 
 | 
  1650  | 
 \bl{$L(\ZERO)$}  & \bl{$\dn$} & \bl{$\{\}$}\\
 | 
| 
 | 
  1651  | 
 \bl{$L(\ONE)$}     & \bl{$\dn$} & \bl{$\{[]\}$}\\
 | 
| 
 | 
  1652  | 
 \bl{$L(c)$}            & \bl{$\dn$} & \bl{$\{[c]\}$}\\
 | 
| 
 | 
  1653  | 
 \bl{$L(r_1 + r_2)$}    & \bl{$\dn$} & \bl{$L(r_1) \cup L(r_2)$}\\
 | 
| 
 | 
  1654  | 
 \bl{$L(r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{$L(r_1) \,@\, L(r_2)$}\\
 | 
| 
 | 
  1655  | 
 \bl{$L(r^*)$}           & \bl{$\dn$} & \\
 | 
| 
 | 
  1656  | 
  \end{tabular}
 | 
| 
 | 
  1657  | 
\end{center}
 | 
| 
 | 
  1658  | 
  | 
| 
 | 
  1659  | 
\begin{textblock}{14}(1.5,13.5)\small
 | 
| 
 | 
  1660  | 
\bl{$L$} is a function from regular expressions to 
 | 
| 
 | 
  1661  | 
sets of strings (languages):\smallskip\\
  | 
| 
 | 
  1662  | 
\bl{\quad$L$ : Rexp $\Rightarrow$ Set$[$String$]$}
 | 
| 
 | 
  1663  | 
\end{textblock}
 | 
| 
 | 
  1664  | 
  | 
| 
 | 
  1665  | 
\end{frame}
 | 
| 
 | 
  1666  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1667  | 
  | 
| 
 | 
  1668  | 
  | 
| 
 | 
  1669  | 
  | 
| 
 | 
  1670  | 
  | 
| 
 | 
  1671  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1672  | 
\begin{frame}[c]
 | 
| 
 | 
  1673  | 
  \frametitle{The Power Operation}
 | 
| 
 | 
  1674  | 
  
  | 
| 
 | 
  1675  | 
  \begin{itemize}
 | 
| 
 | 
  1676  | 
  \item The \alert{\textbf{\boldmath$n$th Power}} of a language:
 | 
| 
 | 
  1677  | 
  
  | 
| 
 | 
  1678  | 
  \begin{center}
 | 
| 
 | 
  1679  | 
  \begin{tabular}{lcl}
 | 
| 
 | 
  1680  | 
  \bl{$A^0$}    & \bl{$\dn$} & \bl{$\{[]\}$}\\
 | 
| 
 | 
  1681  | 
  \bl{$A^{n+1}$} & \bl{$\dn$} & \bl{$A \,@\, A^n$}
 | 
| 
 | 
  1682  | 
  \end{tabular}
 | 
| 
 | 
  1683  | 
  \end{center}\bigskip
 | 
| 
 | 
  1684  | 
  
  | 
| 
 | 
  1685  | 
  \item[] For example
  | 
| 
 | 
  1686  | 
  
  | 
| 
 | 
  1687  | 
  \begin{center}
 | 
| 
 | 
  1688  | 
  \begin{tabular}{lcl@{\hspace{10mm}}l}
 | 
| 
 | 
  1689  | 
  \bl{$A^4$} & \bl{$=$} & \bl{$A \,@\, A \,@\, A \,@\, A$} & \bl{$(@\,\{[]\})$}\\
 | 
| 
 | 
  1690  | 
  \bl{$A^1$} & \bl{$=$} & \bl{$A$} & \bl{$(@\,\{[]\})$}\\
 | 
| 
 | 
  1691  | 
  \bl{$A^0$} & \bl{$=$} & \bl{$\{[]\}$}\\
 | 
| 
 | 
  1692  | 
  \end{tabular}
 | 
| 
 | 
  1693  | 
  \end{center}
 | 
| 
 | 
  1694  | 
  
  | 
| 
 | 
  1695  | 
  \end{itemize}  
 | 
| 
 | 
  1696  | 
  
  | 
| 
 | 
  1697  | 
  \end{frame}
 | 
| 
 | 
  1698  | 
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1699  | 
  
  | 
| 
 | 
  1700  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1701  | 
\begin{frame}[c]
 | 
| 
 | 
  1702  | 
\frametitle{The Meaning of a Regex}
 | 
| 
 | 
  1703  | 
  | 
| 
 | 
  1704  | 
\begin{textblock}{15}(1,4)
 | 
| 
 | 
  1705  | 
 \begin{tabular}{rcl}
 | 
| 
 | 
  1706  | 
 \bl{$L(\ZERO)$}  & \bl{$\dn$} & \bl{$\{\}$}\\
 | 
| 
 | 
  1707  | 
 \bl{$L(\ONE)$}     & \bl{$\dn$} & \bl{$\{[]\}$}\\
 | 
| 
 | 
  1708  | 
 \bl{$L(c)$}            & \bl{$\dn$} & \bl{$\{[c]\}$}\\
 | 
| 
 | 
  1709  | 
 \bl{$L(r_1 + r_2)$}    & \bl{$\dn$} & \bl{$L(r_1) \cup L(r_2)$}\\
 | 
| 
 | 
  1710  | 
 \bl{$L(r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{$\{ s_1 \,@\, s_2 \;|\; s_1 \in L(r_1) \wedge s_2 \in L(r_2) \}$}\\
 | 
| 
 | 
  1711  | 
 \bl{$L(r^*)$}           & \bl{$\dn$} & \onslide<2->{\bl{$\bigcup_{0 \le n} L(r)^n$}}\\
 | 
| 
 | 
  1712  | 
  \end{tabular}\bigskip
 | 
| 
 | 
  1713  | 
  
  | 
| 
 | 
  1714  | 
%\onslide<2->{
 | 
| 
 | 
  1715  | 
%\hspace{5mm}\bl{$L(r)^0 \;\dn\; \{[]\}$}\\
 | 
| 
 | 
  1716  | 
%\bl{$L(r)^{n+1} \;\dn\; L(r) \,@\, L(r)^n$}\hspace{9mm}\onslide<3->{\small\textcolor{gray}{(append on sets)}\\
 | 
| 
 | 
  1717  | 
%\small\hspace{5cm}\textcolor{gray}{$\{ s_1 @ s_2 \;|\; s_1\in L(r) \wedge s_2 \in L(r)^n \}$}}
 | 
| 
 | 
  1718  | 
%}  
  | 
| 
 | 
  1719  | 
\end{textblock}
 | 
| 
 | 
  1720  | 
  | 
| 
 | 
  1721  | 
\end{frame}
 | 
| 
 | 
  1722  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  | 
| 
 | 
  1723  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1724  | 
\begin{frame}[c]
 | 
| 
 | 
  1725  | 
  \frametitle{The Star Operation}
 | 
| 
 | 
  1726  | 
  
  | 
| 
 | 
  1727  | 
  \begin{itemize}
 | 
| 
 | 
  1728  | 
  \item The \alert{\bf Kleene Star} of a \underline{language}:
 | 
| 
 | 
  1729  | 
  \bigskip
  | 
| 
 | 
  1730  | 
  
  | 
| 
 | 
  1731  | 
  \begin{center}
 | 
| 
 | 
  1732  | 
  \begin{tabular}{c}
 | 
| 
 | 
  1733  | 
  \bl{$A\star \dn \bigcup_{0\le n} A^n$}
 | 
| 
 | 
  1734  | 
  \end{tabular}
 | 
| 
 | 
  1735  | 
  \end{center}\bigskip
 | 
| 
 | 
  1736  | 
  
  | 
| 
 | 
  1737  | 
  \item[] This expands to 
  | 
| 
 | 
  1738  | 
  
  | 
| 
 | 
  1739  | 
  \[
  | 
| 
 | 
  1740  | 
  \bl{A^0 \cup A^1 \cup A^2 \cup A^3 \cup A^4 \cup \ldots}
 | 
| 
 | 
  1741  | 
  \]
  | 
| 
 | 
  1742  | 
  
  | 
| 
 | 
  1743  | 
  or
  | 
| 
 | 
  1744  | 
  
  | 
| 
 | 
  1745  | 
  \small
  | 
| 
 | 
  1746  | 
  \[
  | 
| 
 | 
  1747  | 
  \bl{\{[]\} \;\cup\; A \;\cup\; A\,@\,A \;\cup\; 
 | 
| 
 | 
  1748  | 
    A\,@\,A\,@\,A \;\cup\; A\,@\,A\,@\,A\,@\,A \cup \ldots}
  | 
| 
 | 
  1749  | 
  \]
  | 
| 
 | 
  1750  | 
  
  | 
| 
 | 
  1751  | 
  \end{itemize}  
 | 
| 
 | 
  1752  | 
  
  | 
| 
 | 
  1753  | 
  \end{frame}
 | 
| 
 | 
  1754  | 
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  | 
| 
 | 
  1755  | 
  | 
| 
 | 
  1756  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1757  | 
\begin{frame}[c]
 | 
| 
 | 
  1758  | 
\frametitle{The Meaning of a Regex}
 | 
| 
 | 
  1759  | 
  | 
| 
 | 
  1760  | 
\begin{textblock}{15}(1,4)
 | 
| 
 | 
  1761  | 
 \begin{tabular}{rcl}
 | 
| 
 | 
  1762  | 
 \bl{$L(\ZERO)$}  & \bl{$\dn$} & \bl{$\{\}$}\\
 | 
| 
 | 
  1763  | 
 \bl{$L(\ONE)$}     & \bl{$\dn$} & \bl{$\{[]\}$}\\
 | 
| 
 | 
  1764  | 
 \bl{$L(c)$}            & \bl{$\dn$} & \bl{$\{[c]\}$}\\
 | 
| 
 | 
  1765  | 
 \bl{$L(r_1 + r_2)$}    & \bl{$\dn$} & \bl{$L(r_1) \cup L(r_2)$}\\
 | 
| 
 | 
  1766  | 
 \bl{$L(r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{$\{ s_1 \,@\, s_2 \;|\; s_1 \in L(r_1) \wedge s_2 \in L(r_2) \}$}\\
 | 
| 
 | 
  1767  | 
 \bl{$L(r^*)$}           & \bl{$\dn$} & \bl{$(L(r))\star$}\\
 | 
| 
 | 
  1768  | 
  \end{tabular}
 | 
| 
 | 
  1769  | 
  
  | 
| 
 | 
  1770  | 
\end{textblock}
 | 
| 
 | 
  1771  | 
  | 
| 
 | 
  1772  | 
\end{frame}
 | 
| 
 | 
  1773  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1774  | 
  | 
| 
 | 
  1775  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1776  | 
\begin{frame}[c]
 | 
| 
 | 
  1777  | 
\frametitle{The Meaning of Matching}
 | 
| 
 | 
  1778  | 
  | 
| 
 | 
  1779  | 
\begin{bubble}[10cm]
 | 
| 
 | 
  1780  | 
\large\bf 
  | 
| 
 | 
  1781  | 
A regular expression \bl{$r$} matches a string~\bl{$s$} 
 | 
| 
 | 
  1782  | 
provided
  | 
| 
 | 
  1783  | 
  | 
| 
 | 
  1784  | 
\begin{center}
 | 
| 
 | 
  1785  | 
\bl{$s \in L(r)$}\\ 
 | 
| 
 | 
  1786  | 
\end{center}
 | 
| 
 | 
  1787  | 
\end{bubble}\bigskip\bigskip
 | 
| 
 | 
  1788  | 
  | 
| 
 | 
  1789  | 
\ldots and the point of the next lecture is 
  | 
| 
 | 
  1790  | 
to decide this problem as fast as possible (unlike Python,
  | 
| 
 | 
  1791  | 
Ruby, Java)
  | 
| 
 | 
  1792  | 
  | 
| 
 | 
  1793  | 
\end{frame}
 | 
| 
879
 | 
  1794  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1795  | 
  | 
| 
 | 
  1796  | 
  | 
| 
876
 | 
  1797  | 
  | 
| 
 | 
  1798  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1799  | 
\begin{frame}[c]
 | 
| 
 | 
  1800  | 
  \frametitle{Questions}
 | 
| 
 | 
  1801  | 
  
  | 
| 
 | 
  1802  | 
  \begin{itemize}
 | 
| 
 | 
  1803  | 
  \item Say \bl{$A = \{[a],[b],[c],[d]\}$}.\bigskip
 | 
| 
 | 
  1804  | 
  
  | 
| 
 | 
  1805  | 
  \item[]
  | 
| 
 | 
  1806  | 
  How many strings are in \bl{$A^4$}\,?
 | 
| 
 | 
  1807  | 
  \bigskip\medskip\pause
  | 
| 
 | 
  1808  | 
  
  | 
| 
 | 
  1809  | 
  
  | 
| 
 | 
  1810  | 
 \item[]
  | 
| 
 | 
  1811  | 
  What if \bl{$A = \{[a],[b],[c],[]\}$};\\ 
 | 
| 
 | 
  1812  | 
  how many strings are then in \bl{$A^4$}\,?
 | 
| 
 | 
  1813  | 
  \end{itemize}  
 | 
| 
 | 
  1814  | 
  
  | 
| 
 | 
  1815  | 
\end{frame}
 | 
| 
 | 
  1816  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
  | 
| 
 | 
  1817  | 
  | 
| 
 | 
  1818  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
879
 | 
  1819  | 
\begin{frame}[c]
 | 
| 
 | 
  1820  | 
  \frametitle{Questions}
 | 
| 
 | 
  1821  | 
  | 
| 
 | 
  1822  | 
  \begin{itemize}
 | 
| 
 | 
  1823  | 
  \item Assume a set $A$ contains 4 strings and a set $B$
  | 
| 
 | 
  1824  | 
  contains 7 strings. None of the strings is the empty
  | 
| 
 | 
  1825  | 
  string.
  | 
| 
 | 
  1826  | 
  | 
| 
 | 
  1827  | 
  \item How many strings are in $A \,@\, B$?
  | 
| 
 | 
  1828  | 
  \end{itemize}
 | 
| 
 | 
  1829  | 
  | 
| 
 | 
  1830  | 
  
  | 
| 
 | 
  1831  | 
\end{frame}
 | 
| 
 | 
  1832  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
  | 
| 
 | 
  1833  | 
  | 
| 
929
 | 
  1834  | 
{
 | 
| 
 | 
  1835  | 
\setbeamercolor{background canvas}{bg=cream}
 | 
| 
 | 
  1836  | 
\begin{frame}[c]
 | 
| 
 | 
  1837  | 
  | 
| 
 | 
  1838  | 
\begin{minipage}{1.3\textwidth}
 | 
| 
 | 
  1839  | 
  | 
| 
 | 
  1840  | 
\end{minipage}
 | 
| 
 | 
  1841  | 
\includegraphics[scale=0.4]{../pics/chatgpt.png}
 | 
| 
 | 
  1842  | 
\end{frame}
 | 
| 
 | 
  1843  | 
}
  | 
| 
 | 
  1844  | 
  | 
| 
 | 
  1845  | 
{
 | 
| 
 | 
  1846  | 
\setbeamercolor{background canvas}{bg=cream}
 | 
| 
 | 
  1847  | 
\begin{frame}[c]
 | 
| 
 | 
  1848  | 
\frametitle{\dots{}for amusement}
 | 
| 
 | 
  1849  | 
  | 
| 
 | 
  1850  | 
\begin{minipage}{1.3\textwidth}
 | 
| 
 | 
  1851  | 
\includegraphics[scale=0.4]{../pics/chatgpt1.png}
 | 
| 
 | 
  1852  | 
\end{minipage}
 | 
| 
 | 
  1853  | 
  | 
| 
 | 
  1854  | 
\end{frame}
 | 
| 
 | 
  1855  | 
}
  | 
| 
 | 
  1856  | 
  | 
| 
879
 | 
  1857  | 
  | 
| 
 | 
  1858  | 
  | 
| 
 | 
  1859  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
876
 | 
  1860  | 
% \begin{frame}[c]
 | 
| 
 | 
  1861  | 
% \frametitle{Languages (Sets of Strings)}
 | 
| 
 | 
  1862  | 
  | 
| 
 | 
  1863  | 
% \begin{itemize}
 | 
| 
 | 
  1864  | 
  | 
| 
 | 
  1865  | 
% \item A \alert{\bf Language} is a set of strings, for example\medskip
 | 
| 
 | 
  1866  | 
% \begin{center}
 | 
| 
 | 
  1867  | 
% \bl{$\{[], hello, foobar, a, abc\}$}
 | 
| 
 | 
  1868  | 
% \end{center}\bigskip
 | 
| 
 | 
  1869  | 
  | 
| 
 | 
  1870  | 
% \item \alert{\bf Concatenation} for strings and languages
 | 
| 
 | 
  1871  | 
  | 
| 
 | 
  1872  | 
% \begin{center}
 | 
| 
 | 
  1873  | 
% \begin{tabular}{rcl}
 | 
| 
 | 
  1874  | 
% \bl{$foo\;@\;bar$} & \bl{$=$} & \bl{$foobar$}\medskip\\
 | 
| 
 | 
  1875  | 
% \bl{$A\;@\;B$}     & \bl{$\dn$} & \bl{$\{ s_1\,@\,s_2 \;\mid\; s_1 \in A \wedge s_2 \in B\}$}
 | 
| 
 | 
  1876  | 
% \end{tabular}
 | 
| 
 | 
  1877  | 
% \end{center}
 | 
| 
 | 
  1878  | 
% \bigskip
  | 
| 
 | 
  1879  | 
  | 
| 
 | 
  1880  | 
% \small
  | 
| 
 | 
  1881  | 
% \item [] For example \bl{$A = \{foo, bar\}$}, \bl{$B = \{a, b\}$}
 | 
| 
 | 
  1882  | 
  | 
| 
 | 
  1883  | 
% \[
  | 
| 
 | 
  1884  | 
% \bl{A \,@\, B = \{fooa, foob, bara, barb\}}
 | 
| 
 | 
  1885  | 
% \]
  | 
| 
 | 
  1886  | 
  | 
| 
 | 
  1887  | 
  | 
| 
 | 
  1888  | 
  | 
| 
 | 
  1889  | 
  | 
| 
 | 
  1890  | 
% \end{itemize}  
 | 
| 
 | 
  1891  | 
% \end{frame}
 | 
| 
 | 
  1892  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  | 
| 
 | 
  1893  | 
  | 
| 
 | 
  1894  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1895  | 
% \begin{frame}[c]
 | 
| 
 | 
  1896  | 
%   \frametitle{Two Corner Cases}
 | 
| 
 | 
  1897  | 
   
  | 
| 
 | 
  1898  | 
%   \Large
  | 
| 
 | 
  1899  | 
%   \begin{center}
 | 
| 
 | 
  1900  | 
%   \bl{$A \,@\, \{[]\} = \;?$}\bigskip\bigskip\pause\\
 | 
| 
 | 
  1901  | 
%   \bl{$A \,@\, \{\} = \;?$}
 | 
| 
 | 
  1902  | 
%   \end{center}  
 | 
| 
 | 
  1903  | 
    
  | 
| 
 | 
  1904  | 
%   \end{frame}
 | 
| 
 | 
  1905  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
  | 
| 
 | 
  1906  | 
  
  | 
| 
 | 
  1907  | 
  | 
| 
 | 
  1908  | 
  | 
| 
 | 
  1909  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1910  | 
% \begin{frame}[c]
 | 
| 
 | 
  1911  | 
% \frametitle{The Meaning of a Regex}
 | 
| 
 | 
  1912  | 
  | 
| 
 | 
  1913  | 
%  ...all the strings a regular expression can match.   
  | 
| 
 | 
  1914  | 
  | 
| 
 | 
  1915  | 
% \begin{center}
 | 
| 
 | 
  1916  | 
%  \begin{tabular}{rcl}
 | 
| 
 | 
  1917  | 
%  \bl{$L(\ZERO)$}  & \bl{$\dn$} & \bl{$\{\}$}\\
 | 
| 
 | 
  1918  | 
%  \bl{$L(\ONE)$}     & \bl{$\dn$} & \bl{$\{[]\}$}\\
 | 
| 
 | 
  1919  | 
%  \bl{$L(c)$}            & \bl{$\dn$} & \bl{$\{[c]\}$}\\
 | 
| 
 | 
  1920  | 
%  \bl{$L(r_1 + r_2)$}    & \bl{$\dn$} & \bl{$L(r_1) \cup L(r_2)$}\\
 | 
| 
 | 
  1921  | 
%  \bl{$L(r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{$L(r_1) \,@\, L(r_2)$}\\
 | 
| 
 | 
  1922  | 
%  \bl{$L(r^*)$}           & \bl{$\dn$} & \\
 | 
| 
 | 
  1923  | 
%   \end{tabular}
 | 
| 
 | 
  1924  | 
% \end{center}
 | 
| 
 | 
  1925  | 
  | 
| 
 | 
  1926  | 
% \begin{textblock}{14}(1.5,13.5)\small
 | 
| 
 | 
  1927  | 
% \bl{$L$} is a function from regular expressions to 
 | 
| 
 | 
  1928  | 
% sets of strings (languages):\smallskip\\
  | 
| 
 | 
  1929  | 
% \bl{\quad$L$ : Rexp $\Rightarrow$ Set$[$String$]$}
 | 
| 
 | 
  1930  | 
% \end{textblock}
 | 
| 
 | 
  1931  | 
  | 
| 
 | 
  1932  | 
% \end{frame}
 | 
| 
 | 
  1933  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1934  | 
  | 
| 
 | 
  1935  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1936  | 
% \begin{frame}[c]
 | 
| 
 | 
  1937  | 
% \frametitle{The Power Operation}
 | 
| 
 | 
  1938  | 
  | 
| 
 | 
  1939  | 
% \begin{itemize}
 | 
| 
 | 
  1940  | 
% \item The \alert{\textbf{\boldmath$n$th Power}} of a language:
 | 
| 
 | 
  1941  | 
  | 
| 
 | 
  1942  | 
% \begin{center}
 | 
| 
 | 
  1943  | 
% \begin{tabular}{lcl}
 | 
| 
 | 
  1944  | 
% \bl{$A^0$}    & \bl{$\dn$} & \bl{$\{[]\}$}\\
 | 
| 
 | 
  1945  | 
% \bl{$A^{n+1}$} & \bl{$\dn$} & \bl{$A \,@\, A^n$}
 | 
| 
 | 
  1946  | 
% \end{tabular}
 | 
| 
 | 
  1947  | 
% \end{center}\bigskip
 | 
| 
 | 
  1948  | 
  | 
| 
 | 
  1949  | 
% \item[] For example
  | 
| 
 | 
  1950  | 
  | 
| 
 | 
  1951  | 
% \begin{center}
 | 
| 
 | 
  1952  | 
% \begin{tabular}{lcl@{\hspace{10mm}}l}
 | 
| 
 | 
  1953  | 
% \bl{$A^4$} & \bl{$=$} & \bl{$A \,@\, A \,@\, A \,@\, A$} & \bl{$(@\,\{[]\})$}\\
 | 
| 
 | 
  1954  | 
% \bl{$A^1$} & \bl{$=$} & \bl{$A$} & \bl{$(@\,\{[]\})$}\\
 | 
| 
 | 
  1955  | 
% \bl{$A^0$} & \bl{$=$} & \bl{$\{[]\}$}\\
 | 
| 
 | 
  1956  | 
% \end{tabular}
 | 
| 
 | 
  1957  | 
% \end{center}
 | 
| 
 | 
  1958  | 
  | 
| 
 | 
  1959  | 
% \end{itemize}  
 | 
| 
 | 
  1960  | 
  | 
| 
 | 
  1961  | 
% \end{frame}
 | 
| 
 | 
  1962  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  | 
| 
 | 
  1963  | 
  | 
| 
 | 
  1964  | 
  | 
| 
 | 
  1965  | 
  | 
| 
 | 
  1966  | 
  | 
| 
 | 
  1967  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1968  | 
% \begin{frame}[c]
 | 
| 
 | 
  1969  | 
% \frametitle{Written Exam}
 | 
| 
 | 
  1970  | 
  | 
| 
 | 
  1971  | 
% \begin{itemize}
 | 
| 
 | 
  1972  | 
% \item Accounts for 80\%.\bigskip
  | 
| 
 | 
  1973  | 
  | 
| 
 | 
  1974  | 
% \item The question ``\textit{Is this relevant for
 | 
| 
 | 
  1975  | 
%       the exam?}'' is very demotivating for the lecturer!\bigskip\\
  | 
| 
 | 
  1976  | 
  | 
| 
 | 
  1977  | 
% \item Deal: Whatever is in the homework (and is not marked
  | 
| 
 | 
  1978  | 
%       ``\textit{optional}'') is relevant for the exam.\bigskip
 | 
| 
 | 
  1979  | 
      
  | 
| 
 | 
  1980  | 
% \item Each lecture has also a handout. There are also handouts about
  | 
| 
 | 
  1981  | 
% notation and Scala.      
  | 
| 
 | 
  1982  | 
% \end{itemize}
 | 
| 
 | 
  1983  | 
  | 
| 
 | 
  1984  | 
% \end{frame}
 | 
| 
 | 
  1985  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  | 
| 
 | 
  1986  | 
  | 
| 
 | 
  1987  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  1988  | 
% \begin{frame}[t]
 | 
| 
 | 
  1989  | 
% \frametitle{Coursework}
 | 
| 
 | 
  1990  | 
  | 
| 
 | 
  1991  | 
% \begin{itemize}
 | 
| 
 | 
  1992  | 
% \item Accounts for 20\%. Two strands. Choose \alert{\bf one}!\bigskip
 | 
| 
 | 
  1993  | 
% \end{itemize}
 | 
| 
 | 
  1994  | 
  | 
| 
 | 
  1995  | 
% \begin{columns}[t]
 | 
| 
 | 
  1996  | 
% \begin{column}{.5\textwidth}
 | 
| 
 | 
  1997  | 
% \underline{\bf Strand 1}\medskip
 | 
| 
 | 
  1998  | 
% \begin{itemize}
 | 
| 
 | 
  1999  | 
% \item 4 programming tasks:
  | 
| 
 | 
  2000  | 
% \begin{itemize}
 | 
| 
 | 
  2001  | 
% \item matcher (4\%, 11.10.) 
  | 
| 
 | 
  2002  | 
% \item lexer (5\%, 04.11.)
  | 
| 
 | 
  2003  | 
% \item parser (5\%, 22.11.)
  | 
| 
 | 
  2004  | 
% \item compiler (6\%, 13.12.)
  | 
| 
 | 
  2005  | 
% \end{itemize}
 | 
| 
 | 
  2006  | 
% \item in any lang.~you like,\\ but I want to see the\\ code
  | 
| 
 | 
  2007  | 
% \end{itemize}
 | 
| 
 | 
  2008  | 
% \end{column}
 | 
| 
 | 
  2009  | 
  | 
| 
 | 
  2010  | 
% \hspace{-45pt}\vrule{}\hspace{10pt}
 | 
| 
 | 
  2011  | 
% \begin{column}{.5\textwidth}
 | 
| 
 | 
  2012  | 
% \underline{\bf Strand 2}\smallskip\begin{itemize}
 | 
| 
 | 
  2013  | 
% \item one task: prove the correctness of a regular expression matcher in 
  | 
| 
 | 
  2014  | 
% the \underline{Isabelle} theorem prover
 | 
| 
 | 
  2015  | 
% \item 20\%, submission on~13.12.\hspace{-5mm}\mbox{}
 | 
| 
 | 
  2016  | 
% \end{itemize}
 | 
| 
 | 
  2017  | 
% \end{column}
 | 
| 
 | 
  2018  | 
% \end{columns}\medskip
 | 
| 
 | 
  2019  | 
  | 
| 
 | 
  2020  | 
% \small
  | 
| 
 | 
  2021  | 
% \begin{itemize}
 | 
| 
 | 
  2022  | 
% \item Solving more than one strand will {\bf not} give you more 
 | 
| 
 | 
  2023  | 
% marks.
  | 
| 
 | 
  2024  | 
  | 
| 
 | 
  2025  | 
% \end{itemize}
 | 
| 
 | 
  2026  | 
  | 
| 
 | 
  2027  | 
% \end{frame}
 | 
| 
 | 
  2028  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  | 
| 
 | 
  2029  | 
  | 
| 
 | 
  2030  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  2031  | 
%\begin{frame}[c]
 | 
| 
 | 
  2032  | 
%\frametitle{Lecture Capture}
 | 
| 
 | 
  2033  | 
%
  | 
| 
 | 
  2034  | 
%\begin{itemize}
 | 
| 
 | 
  2035  | 
%\item Hope it works\ldots\pause actually no, it does not!\medskip\pause
  | 
| 
 | 
  2036  | 
%\item It is important to use lecture capture wisely\\ (it is only the ``baseline''):
  | 
| 
 | 
  2037  | 
%\begin{itemize}  
 | 
| 
 | 
  2038  | 
%\item Lecture recordings are a study and revision aid.
  | 
| 
 | 
  2039  | 
%\item Statistically, there is a clear and direct link between attendance and
  | 
| 
 | 
  2040  | 
%  attainment: students who do not attend lectures, do less well in exams.
  | 
| 
 | 
  2041  | 
%\end{itemize}
 | 
| 
 | 
  2042  | 
%
  | 
| 
 | 
  2043  | 
%\item Attending a lecture is more than watching it online -- if you do not
  | 
| 
 | 
  2044  | 
%attend, you miss out!  
  | 
| 
 | 
  2045  | 
%  
  | 
| 
 | 
  2046  | 
%\end{itemize}
 | 
| 
 | 
  2047  | 
%
  | 
| 
 | 
  2048  | 
%\end{frame}
 | 
| 
 | 
  2049  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  | 
| 
 | 
  2050  | 
  | 
| 
 | 
  2051  | 
  | 
| 
 | 
  2052  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  2053  | 
\begin{frame}[c]
 | 
| 
928
 | 
  2054  | 
\frametitle{\begin{tabular}{c}\\[1cm]\alert{Questions?}\end{tabular}}
 | 
| 
876
 | 
  2055  | 
  | 
| 
 | 
  2056  | 
  | 
| 
 | 
  2057  | 
\begin{tabular}{lll}
 | 
| 
989
 | 
  2058  | 
  SGT TAs:  & Flavio Melinte Citea\\
  | 
| 
 | 
  2059  | 
            & Zoltan Meszaros\bigskip\\
  | 
| 
 | 
  2060  | 
Amm Helpers & Flavio Melinte Citea & (flavio.melinte\_citea@kcl.ac.uk)\\
  | 
| 
 | 
  2061  | 
            & Zishan Rahman & (zishan.rahman@kcl.ac.uk)\medskip\\
  | 
| 
876
 | 
  2062  | 
\end{tabular}  
 | 
| 
 | 
  2063  | 
\mbox{}
 | 
| 
 | 
  2064  | 
\end{frame}
 | 
| 
 | 
  2065  | 
  | 
| 
 | 
  2066  | 
\begin{frame}[c]
 | 
| 
 | 
  2067  | 
\end{frame}
 | 
| 
 | 
  2068  | 
  | 
| 
 | 
  2069  | 
\begin{frame}[c]
 | 
| 
 | 
  2070  | 
\end{frame}
 | 
| 
 | 
  2071  | 
  | 
| 
 | 
  2072  | 
\begin{frame}[c]
 | 
| 
 | 
  2073  | 
\end{frame}
 | 
| 
 | 
  2074  | 
  | 
| 
 | 
  2075  | 
\begin{frame}[c]
 | 
| 
 | 
  2076  | 
\end{frame}
 | 
| 
 | 
  2077  | 
  | 
| 
 | 
  2078  | 
\begin{frame}[c]
 | 
| 
 | 
  2079  | 
\end{frame}
 | 
| 
 | 
  2080  | 
  | 
| 
 | 
  2081  | 
\begin{frame}[c]
 | 
| 
 | 
  2082  | 
\end{frame}
 | 
| 
 | 
  2083  | 
  | 
| 
 | 
  2084  | 
\begin{frame}[c]
 | 
| 
 | 
  2085  | 
\end{frame}
 | 
| 
 | 
  2086  | 
  | 
| 
 | 
  2087  | 
\begin{frame}[c]
 | 
| 
 | 
  2088  | 
\end{frame}
 | 
| 
 | 
  2089  | 
  | 
| 
 | 
  2090  | 
\begin{frame}[c]
 | 
| 
 | 
  2091  | 
\end{frame}
 | 
| 
 | 
  2092  | 
  | 
| 
 | 
  2093  | 
\begin{frame}[c]
 | 
| 
 | 
  2094  | 
\end{frame}
 | 
| 
 | 
  2095  | 
  | 
| 
 | 
  2096  | 
\begin{frame}[c]
 | 
| 
 | 
  2097  | 
\end{frame}
 | 
| 
 | 
  2098  | 
  | 
| 
 | 
  2099  | 
\begin{frame}[c]
 | 
| 
 | 
  2100  | 
\end{frame}
 | 
| 
 | 
  2101  | 
  | 
| 
 | 
  2102  | 
\begin{frame}[c]
 | 
| 
 | 
  2103  | 
\end{frame}
 | 
| 
 | 
  2104  | 
  | 
| 
 | 
  2105  | 
\begin{frame}[c]
 | 
| 
 | 
  2106  | 
\end{frame}
 | 
| 
 | 
  2107  | 
  | 
| 
 | 
  2108  | 
  | 
| 
 | 
  2109  | 
\begin{frame}[c]
 | 
| 
 | 
  2110  | 
\begin{mybox3}{Coursework}
 | 
| 
 | 
  2111  | 
  Do we need to provide instructions on running the coursework files
  | 
| 
 | 
  2112  | 
  if we're using languages other than Scala? Thanks
  | 
| 
 | 
  2113  | 
\end{mybox3}\pause
 | 
| 
 | 
  2114  | 
  | 
| 
 | 
  2115  | 
\begin{mybox2}{Zip-File for Coursework}
 | 
| 
 | 
  2116  | 
  Please, please submit a zipfile that generates a subdirectory
  | 
| 
 | 
  2117  | 
  \begin{center}
 | 
| 
 | 
  2118  | 
  \texttt{NameFamilyName}  
 | 
| 
 | 
  2119  | 
  \end{center}  
 | 
| 
 | 
  2120  | 
\end{mybox2}
 | 
| 
 | 
  2121  | 
\end{frame}
 | 
| 
 | 
  2122  | 
  | 
| 
 | 
  2123  | 
  | 
| 
 | 
  2124  | 
\begin{frame}[c]
 | 
| 
 | 
  2125  | 
\begin{mybox3}{What is the trick?}\small
 | 
| 
 | 
  2126  | 
  What was the trick to improve the evil regular expressions matcher
  | 
| 
 | 
  2127  | 
  to have such good results compared to other programming languages?
  | 
| 
 | 
  2128  | 
  Is it working better on casual regular expressions (the ones that
  | 
| 
 | 
  2129  | 
  Python and Java handle pretty well), too? Or was it just optimised
  | 
| 
 | 
  2130  | 
  for these evil ones?
  | 
| 
 | 
  2131  | 
\end{mybox3}
 | 
| 
 | 
  2132  | 
\end{frame}
 | 
| 
 | 
  2133  | 
  | 
| 
 | 
  2134  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  2135  | 
\begin{frame}[c]
 | 
| 
 | 
  2136  | 
  \frametitle{Thanks to Martin Mikusovic}
 | 
| 
 | 
  2137  | 
  | 
| 
 | 
  2138  | 
\bigskip    
  | 
| 
 | 
  2139  | 
\begin{center}
 | 
| 
 | 
  2140  | 
\begin{tikzpicture}
 | 
| 
 | 
  2141  | 
  \begin{axis}[
 | 
| 
 | 
  2142  | 
    xlabel={$n$},
 | 
| 
 | 
  2143  | 
    x label style={at={(1.05,0.0)}},
 | 
| 
 | 
  2144  | 
    ylabel={time in secs},
 | 
| 
 | 
  2145  | 
    enlargelimits=false,
  | 
| 
 | 
  2146  | 
    xtick={0,5,...,30},
 | 
| 
 | 
  2147  | 
    xmax=33,
  | 
| 
 | 
  2148  | 
    ymax=35,
  | 
| 
 | 
  2149  | 
    ytick={0,10,...,30},
 | 
| 
 | 
  2150  | 
    scaled ticks=false,
  | 
| 
 | 
  2151  | 
    axis lines=left,
  | 
| 
 | 
  2152  | 
    width=9cm,
  | 
| 
 | 
  2153  | 
    height=5.5cm, 
  | 
| 
 | 
  2154  | 
    legend entries={Java 8, Python, JavaScript, Swift},  
 | 
| 
 | 
  2155  | 
    legend pos=north west,
  | 
| 
 | 
  2156  | 
    legend cell align=left]
  | 
| 
 | 
  2157  | 
\addplot[blue,mark=*, mark options={fill=white}] table {re-python2.data};
 | 
| 
 | 
  2158  | 
\addplot[cyan,mark=*, mark options={fill=white}] table {re-java.data};
 | 
| 
 | 
  2159  | 
\addplot[red,mark=*, mark options={fill=white}] table {re-js.data};
 | 
| 
 | 
  2160  | 
\addplot[magenta,mark=*, mark options={fill=white}] table {re-swift.data};
 | 
| 
 | 
  2161  | 
\end{axis}
 | 
| 
 | 
  2162  | 
\end{tikzpicture}
 | 
| 
 | 
  2163  | 
\end{center}
 | 
| 
 | 
  2164  | 
  | 
| 
 | 
  2165  | 
Regex: \bl{$(a^*)^* \cdot b$}
 | 
| 
 | 
  2166  | 
  | 
| 
 | 
  2167  | 
Strings of the form \bl{$\underbrace{\,a\ldots a\,}_{n}$}
 | 
| 
 | 
  2168  | 
  | 
| 
 | 
  2169  | 
\end{frame}
 | 
| 
 | 
  2170  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  2171  | 
  | 
| 
 | 
  2172  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  2173  | 
\begin{frame}[c]
 | 
| 
 | 
  2174  | 
\frametitle{Same Example in Java 9+}
 | 
| 
 | 
  2175  | 
  | 
| 
 | 
  2176  | 
\begin{center}
 | 
| 
 | 
  2177  | 
\begin{tikzpicture}
 | 
| 
 | 
  2178  | 
  \begin{axis}[
 | 
| 
 | 
  2179  | 
    xlabel={$n$},
 | 
| 
 | 
  2180  | 
    x label style={at={(1.09,-0.15)}},
 | 
| 
 | 
  2181  | 
    ylabel={time in secs},
 | 
| 
 | 
  2182  | 
    scaled x ticks=false,
  | 
| 
 | 
  2183  | 
    enlargelimits=false,
  | 
| 
 | 
  2184  | 
    xtick distance=10000,
  | 
| 
 | 
  2185  | 
    xmax=44000, 
  | 
| 
 | 
  2186  | 
    ytick={0,10,...,30}, 
 | 
| 
 | 
  2187  | 
    ymax=35, 
  | 
| 
 | 
  2188  | 
    axis lines=left,
  | 
| 
 | 
  2189  | 
    width=9cm,
  | 
| 
 | 
  2190  | 
    height=5cm, 
  | 
| 
 | 
  2191  | 
    legend entries={Java \liningnums{9}+},
 | 
| 
 | 
  2192  | 
    legend pos=north west,
  | 
| 
 | 
  2193  | 
    legend cell align=left]
  | 
| 
 | 
  2194  | 
\addplot[blue,mark=square*,mark options={fill=white}] table {re-java9.data};
 | 
| 
 | 
  2195  | 
\end{axis}
 | 
| 
 | 
  2196  | 
\end{tikzpicture}
 | 
| 
 | 
  2197  | 
\end{center}
 | 
| 
 | 
  2198  | 
  | 
| 
 | 
  2199  | 
Regex: \bl{$(a^*)^* \cdot b$}
 | 
| 
 | 
  2200  | 
  | 
| 
 | 
  2201  | 
Strings of the form \bl{$\underbrace{\,a\ldots a\,}_{n}$}
 | 
| 
 | 
  2202  | 
  | 
| 
 | 
  2203  | 
\end{frame}
 | 
| 
 | 
  2204  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  2205  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  2206  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  | 
| 
 | 
  2207  | 
% Questions
  | 
| 
 | 
  2208  | 
  | 
| 
 | 
  2209  | 
  | 
| 
 | 
  2210  | 
  | 
| 
 | 
  2211  | 
  | 
| 
 | 
  2212  | 
\begin{frame}[c]
 | 
| 
 | 
  2213  | 
\end{frame}
 | 
| 
 | 
  2214  | 
  | 
| 
 | 
  2215  | 
\begin{frame}[c]
 | 
| 
 | 
  2216  | 
\end{frame}
 | 
| 
 | 
  2217  | 
  | 
| 
 | 
  2218  | 
\begin{frame}[c]
 | 
| 
 | 
  2219  | 
\end{frame}
 | 
| 
 | 
  2220  | 
  | 
| 
 | 
  2221  | 
\begin{frame}[c]
 | 
| 
 | 
  2222  | 
\end{frame}
 | 
| 
 | 
  2223  | 
  | 
| 
879
 | 
  2224  | 
\begin{frame}[c]
 | 
| 
876
 | 
  2225  | 
  | 
| 
 | 
  2226  | 
\end{frame}
 | 
| 
 | 
  2227  | 
  | 
| 
 | 
  2228  | 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  | 
| 
 | 
  2229  | 
\end{document}
 | 
| 
 | 
  2230  | 
  | 
| 
 | 
  2231  | 
%%% Local Variables:  
  | 
| 
 | 
  2232  | 
%%% mode: latex
  | 
| 
 | 
  2233  | 
%%% TeX-master: t
  | 
| 
 | 
  2234  | 
%%% End: 
  | 
| 
 | 
  2235  | 
  |