slides/slides06.tex
author Christian Urban <urbanc@in.tum.de>
Thu, 14 Nov 2019 13:50:29 +0000
changeset 688 ec181dab18e6
parent 686 05cfce0fdef7
child 702 39e21a33ffb0
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
666
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
     1
% !TEX program = xelatex
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
\documentclass[dvipsnames,14pt,t]{beamer}
295
19f23c4c2167 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
     3
\usepackage{../slides}
19f23c4c2167 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
     4
\usepackage{../graphics}
215
828303e8e4af updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
     5
\usepackage{../langs}
828303e8e4af updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 184
diff changeset
     6
\usepackage{../data}
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
     7
\usepackage{../grammar}
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
% beamer stuff 
445
e7d0157f0471 updated slides
Christian Urban <urbanc@in.tum.de>
parents: 368
diff changeset
    10
\renewcommand{\slidecaption}{CFL 06, King's College London}
e7d0157f0471 updated slides
Christian Urban <urbanc@in.tum.de>
parents: 368
diff changeset
    11
e7d0157f0471 updated slides
Christian Urban <urbanc@in.tum.de>
parents: 368
diff changeset
    12
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
    13
\newcommand{\bl}[1]{\textcolor{blue}{#1}}       
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
    14
%\newcommand{\dn}{\stackrel{\mbox{\scriptsize def}}{=}}% for definitions
366
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
    15
\newcommand{\qq}{\mbox{\texttt{"}}}
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
\begin{document}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
295
19f23c4c2167 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
    20
\begin{frame}[t]
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
\frametitle{%
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
  \begin{tabular}{@ {}c@ {}}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
  \\[-3mm]
445
e7d0157f0471 updated slides
Christian Urban <urbanc@in.tum.de>
parents: 368
diff changeset
    24
  \LARGE Compilers and \\[-2mm] 
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
  \LARGE Formal Languages (6)\\[3mm] 
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
  \end{tabular}}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
  \normalsize
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
  \begin{center}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
  \begin{tabular}{ll}
683
c6c79d21f8a8 updated
Christian Urban <urbanc@in.tum.de>
parents: 666
diff changeset
    31
    Email:  & christian.urban at kcl.ac.uk\\
c6c79d21f8a8 updated
Christian Urban <urbanc@in.tum.de>
parents: 666
diff changeset
    32
    Office Hours: & Thursdays 12 -- 14\\
c6c79d21f8a8 updated
Christian Urban <urbanc@in.tum.de>
parents: 666
diff changeset
    33
    Location: & N7.07 (North Wing, Bush House)\\
c6c79d21f8a8 updated
Christian Urban <urbanc@in.tum.de>
parents: 666
diff changeset
    34
    Slides \& Progs: & KEATS (also homework is there)\\  
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
  \end{tabular}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
  \end{center}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
295
19f23c4c2167 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
    38
\end{frame}
19f23c4c2167 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
    39
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
531
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    43
% \begin{frame}[c]
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    44
% \small
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    45
% \mbox{}\\[5mm]
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    46
% %\begin{textblock}{10}(3,5)
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    47
% \begin{tikzpicture}[scale=1.5,
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    48
%                     node distance=1cm,
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    49
%                     every node/.style={minimum size=7mm}]
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    50
% \node (r1)  {\bl{$r_1$}};
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    51
% \node (r2) [right=of r1] {\bl{$r_2$}};
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    52
% \draw[->,line width=1mm]  (r1) -- (r2) node[above,midway] {\bl{$der\,a$}};
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    53
% \node (r3) [right=of r2] {\bl{$r_3$}};
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    54
% \draw[->,line width=1mm]  (r2) -- (r3) node[above,midway] {\bl{$der\,b$}};
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    55
% \node (r4) [right=of r3] {\bl{$r_4$}};
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    56
% \draw[->,line width=1mm]  (r3) -- (r4) node[above,midway] {\bl{$der\,c$}};
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    57
% \draw (r4) node[anchor=west] {\;\raisebox{3mm}{\bl{$nullable$}}};
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    58
% \node (v4) [below=of r4] {\bl{$v_4$}};
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    59
% \draw[->,line width=1mm]  (r4) -- (v4);
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    60
% \node (v3) [left=of v4] {\bl{$v_3$}};
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    61
% \draw[->,line width=1mm]  (v4) -- (v3) node[below,midway] {\bl{$inj\,c$}};
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    62
% \node (v2) [left=of v3] {\bl{$v_2$}};
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    63
% \draw[->,line width=1mm]  (v3) -- (v2) node[below,midway] {\bl{$inj\,b$}};
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    64
% \node (v1) [left=of v2] {\bl{$v_1$}};
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    65
% \draw[->,line width=1mm]  (v2) -- (v1) node[below,midway] {\bl{$inj\,a$}};
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    66
% \draw[->,line width=0.5mm]  (r3) -- (v3);
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    67
% \draw[->,line width=0.5mm]  (r2) -- (v2);
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    68
% \draw[->,line width=0.5mm]  (r1) -- (v1);
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    69
% \draw (r4) node[anchor=north west] {\;\raisebox{-8mm}{\bl{$mkeps$}}};
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    70
% \end{tikzpicture}
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    71
% %\end{textblock}
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
    72
531
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    73
% \begin{center}
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    74
% \begin{tabular}{l@{\hspace{1mm}}c@{\hspace{1mm}}l}
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    75
%   \\[-10mm]
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    76
%   \bl{$inj\,(c)\,c\,Empty$} & \bl{$\dn$}  & \bl{$Char\,c$}\\
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    77
%   \bl{$inj\,(r_1 + r_2)\,c\,Left(v)$} & \bl{$\dn$}  & \bl{$Left(inj\,r_1\,c\,v)$}\\
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    78
%   \bl{$inj\,(r_1 + r_2)\,c\,Right(v)$} & \bl{$\dn$}  & \bl{$Right(inj\,r_2\,c\,v)$}\\
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    79
%   \bl{$inj\,(r_1 \cdot r_2)\,c\,Seq(v_1,v_2)$} & \bl{$\dn$}  & \bl{$Seq(inj\,r_1\,c\,v_1,v_2)$}\\
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    80
%   \bl{$inj\,(r_1 \cdot r_2)\,c\,Left(Seq(v_1,v_2))$} & \bl{$\dn$}  & \bl{$Seq(inj\,r_1\,c\,v_1,v_2)$}\\
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    81
%   \bl{$inj\,(r_1 \cdot r_2)\,c\,Right(v)$} & \bl{$\dn$}  & \bl{$Seq(mkeps(r_1),inj\,r_2\,c\,v)$}\\
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    82
%   \bl{$inj\,(r^*)\,c\,Seq(v,vs)$} & \bl{$\dn$}  & \bl{$inj\,r\,c\,v\,::\,vs$}\\
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    83
% \end{tabular}
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    84
% \end{center}
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
    85
531
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    86
% \end{frame}
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
    87
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
    88
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
    89
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
683
c6c79d21f8a8 updated
Christian Urban <urbanc@in.tum.de>
parents: 666
diff changeset
    90
\begin{frame}[t]
c6c79d21f8a8 updated
Christian Urban <urbanc@in.tum.de>
parents: 666
diff changeset
    91
\frametitle{Starting Symbol}
c6c79d21f8a8 updated
Christian Urban <urbanc@in.tum.de>
parents: 666
diff changeset
    92
c6c79d21f8a8 updated
Christian Urban <urbanc@in.tum.de>
parents: 666
diff changeset
    93
\bl{\begin{plstx}[margin=1cm]
c6c79d21f8a8 updated
Christian Urban <urbanc@in.tum.de>
parents: 666
diff changeset
    94
  : \meta{S} ::= \meta{A}\cdot\meta{S}\cdot\meta{B} |
c6c79d21f8a8 updated
Christian Urban <urbanc@in.tum.de>
parents: 666
diff changeset
    95
                 \meta{B}\cdot\meta{S}\cdot\meta{A} | \epsilon\\
c6c79d21f8a8 updated
Christian Urban <urbanc@in.tum.de>
parents: 666
diff changeset
    96
  : \meta{A} ::= a | \epsilon\\
c6c79d21f8a8 updated
Christian Urban <urbanc@in.tum.de>
parents: 666
diff changeset
    97
  : \meta{B} ::= b\\  
c6c79d21f8a8 updated
Christian Urban <urbanc@in.tum.de>
parents: 666
diff changeset
    98
\end{plstx}}
c6c79d21f8a8 updated
Christian Urban <urbanc@in.tum.de>
parents: 666
diff changeset
    99
c6c79d21f8a8 updated
Christian Urban <urbanc@in.tum.de>
parents: 666
diff changeset
   100
\end{frame}
c6c79d21f8a8 updated
Christian Urban <urbanc@in.tum.de>
parents: 666
diff changeset
   101
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
c6c79d21f8a8 updated
Christian Urban <urbanc@in.tum.de>
parents: 666
diff changeset
   102
c6c79d21f8a8 updated
Christian Urban <urbanc@in.tum.de>
parents: 666
diff changeset
   103
c6c79d21f8a8 updated
Christian Urban <urbanc@in.tum.de>
parents: 666
diff changeset
   104
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   105
\begin{frame}[c]
683
c6c79d21f8a8 updated
Christian Urban <urbanc@in.tum.de>
parents: 666
diff changeset
   106
\frametitle{Hierarchy of Languages}
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   107
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   108
Recall that languages are sets of strings.
295
19f23c4c2167 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
   109
19f23c4c2167 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
   110
\begin{center}
19f23c4c2167 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
   111
\begin{tikzpicture}
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   112
[rect/.style={draw=black!50, top color=white,bottom color=black!20, rectangle, very thick, rounded corners}]
295
19f23c4c2167 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
   113
19f23c4c2167 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
   114
\draw (0,0) node [rect, text depth=39mm, text width=68mm] {all languages};
19f23c4c2167 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
   115
\draw (0,-0.4) node [rect, text depth=28.5mm, text width=64mm] {decidable languages};
19f23c4c2167 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
   116
\draw (0,-0.85) node [rect, text depth=17mm] {context sensitive languages};
19f23c4c2167 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
   117
\draw (0,-1.14) node [rect, text depth=9mm, text width=50mm] {context-free languages};
19f23c4c2167 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
   118
\draw (0,-1.4) node [rect] {regular languages};
19f23c4c2167 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
   119
\end{tikzpicture}
19f23c4c2167 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
   120
19f23c4c2167 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
   121
\end{center}
19f23c4c2167 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
   122
366
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   123
\end{frame}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   124
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   125
531
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   126
   
366
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   127
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   128
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   129
\begin{frame}[c]
598
e3ad67cd5123 updated
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   130
\frametitle{Parser Combinators}
e3ad67cd5123 updated
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   131
  
366
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   132
Atomic parsers, for example
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   133
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   134
\begin{center}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   135
\bl{$1::rest \;\Rightarrow\; \{(1, rest)\}$} 
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   136
\end{center}\bigskip
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   137
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   138
\begin{itemize}
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   139
\item you consume one or more tokens from the\\ 
366
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   140
  input (stream)
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   141
\item also works for characters and strings
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   142
\end{itemize}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   143
\end{frame}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   144
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   145
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   146
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   147
\begin{frame}[c]
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   148
686
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 685
diff changeset
   149
Alternative parser (code \bl{$p\;|\;q$})\bigskip
366
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   150
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   151
\begin{itemize}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   152
\item apply \bl{$p$} and also \bl{$q$}; then combine 
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   153
  the outputs
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   154
\end{itemize}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   155
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   156
\begin{center}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   157
\large \bl{$p(\text{input}) \cup q(\text{input})$}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   158
\end{center}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   159
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   160
\end{frame}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   161
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   162
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   163
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   164
\begin{frame}[c]
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   165
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   166
Sequence parser (code \bl{$p\sim q$})\bigskip
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   167
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   168
\begin{itemize}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   169
\item apply first \bl{$p$} producing a set of pairs
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   170
\item then apply \bl{$q$} to the unparsed parts
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   171
\item then combine the results:\medskip 
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   172
\begin{center}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   173
((output$_1$, output$_2$), unparsed part)
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   174
\end{center}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   175
\end{itemize}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   176
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   177
\begin{center}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   178
\begin{tabular}{l}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   179
\large \bl{$\{((o_1, o_2), u_2) \;|\;$}\\[2mm] 
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   180
\large\mbox{}\hspace{15mm} \bl{$(o_1, u_1) \in p(\text{input}) \wedge$}\\[2mm]
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   181
\large\mbox{}\hspace{15mm} \bl{$(o_2, u_2) \in q(u_1)\}$}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   182
\end{tabular}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   183
\end{center}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   184
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   185
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   186
\end{frame}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   187
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   188
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   189
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   190
\begin{frame}[c]
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   191
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   192
Function parser (code \bl{$p \Rightarrow f\;$})\bigskip
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   193
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   194
\begin{itemize}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   195
\item apply \bl{$p$} producing a set of pairs
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   196
\item then apply the function \bl{$f$} to each first component
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   197
\end{itemize}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   198
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   199
\begin{center}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   200
\begin{tabular}{l}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   201
\large \bl{$\{(f(o_1), u_1) \;|\; (o_1, u_1) \in p(\text{input})\}$}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   202
\end{tabular}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   203
\end{center}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   204
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   205
\end{frame}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   206
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   207
531
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   208
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   209
\begin{frame}[c]
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   210
\frametitle{Types of Parsers}
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   211
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   212
\begin{itemize}
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   213
\item {\bf Sequencing}: if \bl{$p$} returns results of type \bl{$T$}, and \bl{$q$} results of type \bl{$S$},
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   214
then \bl{$p \sim q$} returns results of type
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   215
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   216
\begin{center}
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   217
\bl{$T \times S$}
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   218
\end{center}\pause
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   219
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   220
\item {\bf Alternative}: if \bl{$p$} returns results of type \bl{$T$} then  \bl{$q$} \alert{must} also have results of type \bl{$T$},
686
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 685
diff changeset
   221
and \bl{$p \;|\; q$} returns results of type
531
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   222
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   223
\begin{center}
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   224
\bl{$T$}
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   225
\end{center}\pause
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   226
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   227
\item {\bf Semantic Action}: if \bl{$p$} returns results of type \bl{$T$} and \bl{$f$} is a function from
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   228
\bl{$T$} to \bl{$S$}, then
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   229
\bl{$p \Rightarrow f$} returns results of type
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   230
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   231
\begin{center}
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   232
\bl{$S$}
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   233
\end{center}
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   234
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   235
\end{itemize}
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   236
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   237
\end{frame}
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   238
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   239
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   240
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   241
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   242
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   243
\begin{frame}[c]
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   244
\frametitle{Two Grammars}
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   245
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   246
Which languages are recognised by the following two grammars?
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   247
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   248
\bl{\begin{plstx}[margin=3cm]
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   249
: \meta{S} ::= \liningnums{1}\cdot\meta{S}\cdot \meta{S} | \epsilon\\
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   250
\end{plstx}}
531
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   251
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   252
\bl{\begin{plstx}[margin=3cm]
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   253
: \meta{U} ::= \liningnums{1}\cdot\meta{U} | \epsilon\\
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   254
\end{plstx}}
531
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   255
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   256
\end{frame}
Christian Urban <urbanc@in.tum.de>
parents: 500
diff changeset
   257
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
366
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   258
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   259
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   260
\begin{frame}[t]
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   261
\frametitle{Ambiguous Grammars}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   262
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   263
\begin{center}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   264
\begin{tikzpicture}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   265
\begin{axis}[xlabel={\pcode{1}s},ylabel={time in secs},
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   266
    enlargelimits=false,
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   267
    xtick={0,100,...,1000},
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   268
    xmax=1050,
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   269
    ymax=33,
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   270
    ytick={0,5,...,30},
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   271
    scaled ticks=false,
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   272
    axis lines=left,
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   273
    width=11cm,
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   274
    height=7cm, 
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   275
    legend entries={unambiguous,ambiguous},  
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   276
    legend pos=north east,
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   277
    legend cell align=left,
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   278
    x tick label style={font=\small,/pgf/number format/1000 sep={}}]
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   279
\addplot[blue,mark=*, mark options={fill=white}] 
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   280
  table {s-grammar1.data};
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   281
\only<2>{
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   282
  \addplot[red,mark=triangle*, mark options={fill=white}] 
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   283
  table {s-grammar2.data};}  
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   284
\end{axis}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   285
\end{tikzpicture}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   286
\end{center}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   287
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   288
\end{frame}
295
19f23c4c2167 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
   289
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
19f23c4c2167 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
   290
19f23c4c2167 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
   291
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19f23c4c2167 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
   292
\begin{frame}[c]
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   293
\frametitle{Arithmetic Expressions}
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   294
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   295
A grammar for arithmetic expressions and numbers:
50
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   296
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   297
\bl{\begin{plstx}[margin=1cm]
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   298
    : \meta{E} ::= \meta{E} \cdot + \cdot \meta{E}
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   299
    | \meta{E} \cdot * \cdot \meta{E}
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   300
    | ( \cdot \meta{E} \cdot )  | \meta{N}\\
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   301
    : \meta{N} ::= \meta{N} \cdot \meta{N} |
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   302
    0 | 1 | \ldots | 9\\
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   303
\end{plstx}}
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   304
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   305
Unfortunately it is left-recursive (and ambiguous).\medskip\\
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   306
A problem for \alert{recursive descent parsers} (e.g.~parser
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   307
combinators).  \bigskip\pause
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   308
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   309
\end{frame}
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   310
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   311
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   312
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   313
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   314
\begin{frame}[t]
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   315
\frametitle{Numbers}
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   316
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   317
\bl{\begin{plstx}[margin=1cm]
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   318
    : \meta{N} ::= \meta{N} \cdot \meta{N} |
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   319
    0 | 1 | \ldots | 9\\
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   320
\end{plstx}}
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   321
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   322
A non-left-recursive, non-ambiguous grammar for numbers:
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   323
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   324
\bl{\begin{plstx}[margin=1cm]
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   325
    : \meta{N} ::= 0 \cdot \meta{N} | 1 \cdot \meta{N} | \ldots |
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   326
    0 | 1 | \ldots | 9\\
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   327
\end{plstx}}
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   328
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   329
\end{frame}
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   330
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   331
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   332
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   333
\begin{frame}[c]
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   334
\frametitle{Removing Left-Recursion}
295
19f23c4c2167 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
   335
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   336
The rule for numbers is directly left-recursive:
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   337
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   338
\begin{center}
50
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   339
\bl{\begin{tabular}{lcl}
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   340
$\meta{N}$ & $::=$ & $\meta{N} \cdot \meta{N} \;|\; 0 \;|\; 1\;\;\;\;(\ldots)$ 
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   341
\end{tabular}}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   342
\end{center}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   343
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   344
Translate
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   345
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   346
\begin{center}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   347
\begin{tabular}{ccc}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   348
\bl{\begin{tabular}{lcl}
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   349
$\meta{N}$ & $::=$ & $\meta{N} \cdot \alpha$\\
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   350
 &  $\;|\;$ & $\beta$\\
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   351
 \\ 
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   352
\end{tabular}} 
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   353
& {\Large$\Rightarrow$} &
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   354
\bl{\begin{tabular}{lcl}
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   355
$\meta{N}$ & $::=$ & $\beta \cdot \meta{N}'$\\
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   356
$\meta{N}'$ & $::=$ & $\alpha \cdot \meta{N}'$\\
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   357
 &  $\;|\;$ & $\epsilon$ 
50
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   358
\end{tabular}}
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   359
\end{tabular}
50
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   360
\end{center}\pause
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   361
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   362
Which means in this case:
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   363
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   364
\begin{center}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   365
\bl{\begin{tabular}{lcl}
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   366
$\meta{N}$ & $\rightarrow$ & $0 \cdot \meta{N}' \;|\; 1 \cdot \meta{N}'$\\
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   367
$\meta{N}'$ & $\rightarrow$ & $\meta{N} \cdot \meta{N}' \;|\; \epsilon$\\
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   368
\end{tabular}}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   369
\end{center}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   370
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   371
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   372
\end{frame}
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   373
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   374
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   375
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
685
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   376
%\begin{frame}[c]
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   377
%\frametitle{Operator Precedences}
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   378
%
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   379
%
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   380
%To disambiguate
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   381
%
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   382
%\begin{center}
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   383
%\bl{\begin{tabular}{lcl}
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   384
%$\meta{E}$ & $::=$ &  $\meta{E} \cdot + \cdot \meta{E} \;|\;\meta{E} \cdot * \cdot \meta{E} \;|\;( \cdot \meta{E} \cdot ) \;|\;\meta{N}$ \\
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   385
%\end{tabular}}
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   386
%\end{center}
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   387
%
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   388
%Decide on how many precedence levels, say\medskip\\
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   389
%highest for \bl{$()$}, medium for \bl{*}, lowest for \bl{+}
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   390
%
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   391
%\begin{center}
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   392
%\bl{\begin{tabular}{lcl}
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   393
%$\meta{E}_{low}$ & $::=$ & $\meta{E}_{med} \cdot + \cdot \meta{E}_{low} \;|\; \meta{E}_{med}$ \\
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   394
%$\meta{E}_{med}$ & $::=$ & $\meta{E}_{hi} \cdot * \cdot \meta{E}_{med} \;|\; \meta{E}_{hi}$\\
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   395
%$\meta{E}_{hi}$ & $::=$ &  $( \cdot \meta{E}_{low} \cdot ) \;|\;\meta{N}$ \\
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   396
%\end{tabular}}
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   397
%\end{center}\pause
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   398
%
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   399
%\small What happens with \bl{$1 + 3  + 4$}?
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   400
%\end{frame}
366
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   401
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   402
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   403
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   404
\begin{frame}[c]
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   405
\frametitle{Chomsky Normal Form}
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   406
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   407
All rules must be of the form
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   408
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   409
\begin{center}
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   410
\bl{$\meta{A} ::= a$}
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   411
\end{center}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   412
50
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   413
or
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   414
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   415
\begin{center}
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   416
\bl{$\meta{A} ::= \meta{B}\cdot \meta{C}$}
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   417
\end{center}
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   418
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   419
No rule can contain \bl{$\epsilon$}.
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   420
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   421
\end{frame}
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   422
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   423
169
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   424
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   425
\begin{frame}[c]
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   426
\frametitle{\begin{tabular}{c}$\epsilon$-Removal\end{tabular}}
169
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   427
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   428
\begin{enumerate}
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   429
\item If \bl{$A::= \alpha \cdot B \cdot \beta$} and \bl{$B ::= \epsilon$} are in the grammar,
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   430
then add \bl{$A::= \alpha \cdot \beta$} (iterate if necessary).
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   431
\item Throw out all \bl{$B ::= \epsilon$}.
169
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   432
\end{enumerate}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   433
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   434
\small
169
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   435
\begin{center}
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   436
\begin{tabular}{ccc}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   437
\bl{\begin{tabular}{l@{\hspace{1mm}}c@{\hspace{1mm}}l}
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   438
$N$ & $::=$ & $0 \cdot N' \;|\; 1\cdot N'$\\
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   439
$N'$ & $::=$ & $N \cdot N'\;|\;\epsilon$\\
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   440
\\ 
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   441
\\
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   442
\\
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   443
\\
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   444
\\
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   445
\end{tabular}} &
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   446
\bl{\begin{tabular}{l@{\hspace{1mm}}c@{\hspace{1mm}}l}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   447
\\
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   448
$N$ & $::=$ & $0 \cdot N' \;|\; 1\cdot N'\;|\;0\;|\;1$\\
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   449
$N'$ & $::=$ & $N \cdot N'\;|\;N\;|\;\epsilon$\\
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   450
\\
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   451
$N$ & $::=$ & $0 \cdot N' \;|\; 1\cdot N'\;|\;0\;|\;1$\\
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   452
$N'$ & $::=$ & $N \cdot N'\;|\;N$\\
169
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   453
\end{tabular}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   454
\end{tabular}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   455
\end{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   456
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   457
\pause\normalsize
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   458
\begin{center}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   459
\bl{\begin{tabular}{l@{\hspace{1mm}}c@{\hspace{1mm}}l}
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   460
$N$ & $::=$ & $0 \cdot N\;|\; 1\cdot N\;|\;0\;|\;1$\\
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   461
\end{tabular}}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   462
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   463
\end{center}
368
a9911966c0df updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 366
diff changeset
   464
\end{frame}
169
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   465
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   466
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   467
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   468
169
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   469
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   470
\begin{frame}[c]
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   471
\frametitle{CYK Algorithm}
169
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   472
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   473
If grammar is in Chomsky normalform \ldots
169
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   474
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   475
\begin{center}
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   476
\bl{\begin{tabular}{@ {}lcl@ {}}
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   477
$\meta{S}$ & $::=$ &  $\meta{N}\cdot \meta{P}$ \\
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   478
$\meta{P}$ & $::=$ &  $\meta{V}\cdot \meta{N}$ \\
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   479
$\meta{N}$ & $::=$ &  $\meta{N}\cdot \meta{N}$ \\
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   480
$\meta{N}$ & $::=$ &  $\texttt{students} \;|\; \texttt{Jeff} \;|\; \texttt{geometry} \;|\; \texttt{trains} $ \\
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   481
$\meta{V}$ & $::=$ &  $\texttt{trains}$ 
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   482
\end{tabular}}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   483
\end{center}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   484
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   485
\bl{\texttt{Jeff trains geometry students}}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   486
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   487
\end{frame}
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   488
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   489
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   490
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   491
\begin{frame}[c]
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   492
\frametitle{CYK Algorithm}
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   493
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   494
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   495
\begin{itemize}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   496
\item fastest possible algorithm for recognition problem
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   497
\item runtime is \bl{$O(n^3)$}\bigskip
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   498
\item grammars need to be transformed into CNF
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   499
\end{itemize}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   500
597
ce8419e3915c updated
Christian Urban <urbanc@in.tum.de>
parents: 531
diff changeset
   501
\end{frame}
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   502
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
169
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   503
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   504
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
366
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   505
\begin{frame}[c]
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   506
\frametitle{The Goal of this Course}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   507
\mbox{}\\[-26mm]\mbox{}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   508
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   509
\begin{center}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   510
  \begin{tikzpicture}[scale=1,
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   511
                      node/.style={
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   512
                      rectangle,rounded corners=3mm,
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   513
                      very thick,draw=black!50,
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   514
                      minimum height=18mm, minimum width=20mm,
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   515
                      top color=white,bottom color=black!20}]
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   516
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   517
  \node at (3.05, 1.8) {\Large\bf Write a Compiler};
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   518
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   519
  \node (0) at (-2.3,0) {}; 
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   520
  
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   521
  \node (A) at (0,0)  [node] {};
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   522
  \node [below right] at (A.north west) {lexer};
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   523
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   524
  \node (B) at (3,0)  [node] {};
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   525
  \node [below right=1mm] at (B.north west) 
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   526
    {\mbox{}\hspace{-1mm}parser};
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   527
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   528
  \node (C) at (6,0)  [node] {};
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   529
  \node [below right] at (C.north west) 
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   530
    {\mbox{}\hspace{-1mm}code gen};
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   531
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   532
  \node (1) at (8.4,0) {}; 
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   533
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   534
  \draw [->,line width=4mm] (0) -- (A); 
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   535
  \draw [->,line width=4mm] (A) -- (B); 
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   536
  \draw [->,line width=4mm] (B) -- (C); 
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   537
  \draw [->,line width=4mm] (C) -- (1); 
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   538
  \end{tikzpicture}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   539
  \end{center}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   540
  
598
e3ad67cd5123 updated
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   541
We have a lexer and a parser\ldots
366
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   542
  
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   543
\end{frame}
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   544
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   545
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
169
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   546
\begin{frame}[c]
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   547
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   548
\begin{center}
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   549
\bl{\begin{tabular}{@{}lcl@{}}
598
e3ad67cd5123 updated
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   550
\meta{Stmt} & $::=$ &  $\texttt{skip}$\\
e3ad67cd5123 updated
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   551
              & $|$ & \textit{Id}\;\texttt{:=}\;\meta{AExp}\\
e3ad67cd5123 updated
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   552
              & $|$ & \texttt{if}\; \meta{BExp} \;\texttt{then}\; \meta{Block} \;\texttt{else}\; \meta{Block}\\
e3ad67cd5123 updated
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   553
              & $|$ & \texttt{while}\; \meta{BExp} \;\texttt{do}\; \meta{Block}\\
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   554
              & $|$ & \texttt{read}\;\textit{Id}\\
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   555
              & $|$ & \texttt{write}\;\textit{Id}\\
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   556
              & $|$ & \texttt{write}\;\textit{String}\medskip\\
598
e3ad67cd5123 updated
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   557
\meta{Stmts} & $::=$ &  \meta{Stmt} \;\texttt{;}\; \meta{Stmts}\\
e3ad67cd5123 updated
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   558
              & $|$ & \meta{Stmt}\medskip\\
e3ad67cd5123 updated
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   559
\meta{Block} & $::=$ &  \texttt{\{}\,\meta{Stmts}\,\texttt{\}}\\
e3ad67cd5123 updated
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   560
                & $|$ & \meta{Stmt}\medskip\\
e3ad67cd5123 updated
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   561
\meta{AExp} & $::=$ & \ldots\\
e3ad67cd5123 updated
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   562
\meta{BExp} & $::=$ & \ldots\\
50
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   563
\end{tabular}}
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   564
\end{center}
366
5a83336a9690 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 365
diff changeset
   565
\end{frame}
169
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   566
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   567
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   568
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   569
\mode<presentation>{
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   570
\begin{frame}[c]
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   571
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   572
\mbox{\lstinputlisting[language=while]{../progs/fib.while}}
169
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   573
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   574
\end{frame}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   575
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   576
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   577
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   578
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   579
\begin{frame}[c]
598
e3ad67cd5123 updated
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   580
\frametitle{An Interpreter}
169
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   581
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   582
\begin{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   583
\bl{\begin{tabular}{l}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   584
$\{$\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   585
\;\;$x := 5 \text{;}$\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   586
\;\;$y := x * 3\text{;}$\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   587
\;\;$y := x * 4\text{;}$\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   588
\;\;$x := u * 3$\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   589
$\}$
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   590
\end{tabular}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   591
\end{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   592
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   593
\begin{itemize}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   594
\item the interpreter has to record the value of \bl{$x$} before assigning a value to \bl{$y$}\pause
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   595
\item \bl{\text{eval}(stmt, env)}
169
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   596
\end{itemize}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   597
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   598
598
e3ad67cd5123 updated
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   599
\end{frame}
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   600
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   601
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   602
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   603
\begin{frame}[c]
598
e3ad67cd5123 updated
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   604
\frametitle{An Interpreter}
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   605
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   606
\begin{center}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   607
\bl{\begin{tabular}{@{}lcl@{}}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   608
$\text{eval}(n, E)$ & $\dn$ & $n$\\
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   609
$\text{eval}(x, E)$ & $\dn$ & $E(x)$ \;\;\;\textcolor{black}{lookup \bl{$x$} in \bl{$E$}}\\
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   610
$\text{eval}(a_1 + a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) + \text{eval}(a_2, E)$\\
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   611
$\text{eval}(a_1 - a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) - \text{eval}(a_2, E)$\\
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   612
$\text{eval}(a_1 * a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) * \text{eval}(a_2, E)$\bigskip\\
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   613
$\text{eval}(a_1 = a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) = \text{eval}(a_2, E)$\\
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   614
$\text{eval}(a_1\,!\!= a_2, E)$ & $\dn$ & $\neg(\text{eval}(a_1, E) = \text{eval}(a_2, E))$\\
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   615
$\text{eval}(a_1 < a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) < \text{eval}(a_2, E)$\
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   616
\end{tabular}}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   617
\end{center}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   618
598
e3ad67cd5123 updated
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   619
\end{frame}
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   620
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
598
e3ad67cd5123 updated
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   621
e3ad67cd5123 updated
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   622
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   623
\begin{frame}[c]
598
e3ad67cd5123 updated
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   624
\frametitle{An Interpreter (2)}
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   625
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   626
\begin{center}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   627
\bl{\begin{tabular}{@{}lcl@{}}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   628
$\text{eval}(\text{skip}, E)$ & $\dn$ & $E$\\
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   629
$\text{eval}(x:=a, E)$ & $\dn$ & \bl{$E(x \mapsto \text{eval}(a, E))$}\\
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   630
\multicolumn{3}{@{}l@{}}{$\text{eval}(\text{if}\;b\;\text{then}\;cs_1\;\text{else}\;cs_2 , E) \dn$}\\
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   631
\multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{if}\;\text{eval}(b,E)\;\text{then}\;
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   632
\text{eval}(cs_1,E)$}\\
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   633
\multicolumn{3}{@{}l@{}}{\hspace{2cm}$\phantom{\text{if}\;\text{eval}(b,E)\;}\text{else}\;\text{eval}(cs_2,E)$}\\
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   634
\multicolumn{3}{@{}l@{}}{$\text{eval}(\text{while}\;b\;\text{do}\;cs, E) \dn$}\\
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   635
\multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{if}\;\text{eval}(b,E)$}\\
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   636
\multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{then}\;
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   637
\text{eval}(\text{while}\;b\;\text{do}\;cs, \text{eval}(cs,E))$}\\
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   638
\multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{else}\; E$}\\
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   639
$\text{eval}(\text{write}\; x, E)$ & $\dn$ & $\{\;\text{println}(E(x))\; ;\;E\;\}$\\
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   640
\end{tabular}}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   641
\end{center}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   642
598
e3ad67cd5123 updated
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   643
\end{frame}
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   644
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   645
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   646
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   647
\begin{frame}[c]
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   648
\frametitle{\begin{tabular}{c}Test Program\end{tabular}}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   649
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   650
\mbox{}\\[-18mm]\mbox{}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   651
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   652
{\lstset{language=While}%%\fontsize{10}{12}\selectfont
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   653
\texttt{\lstinputlisting{../progs/loops.while}}}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   654
295
19f23c4c2167 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
   655
\end{frame}
169
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   656
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   657
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   658
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   659
\mode<presentation>{
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   660
\begin{frame}[t]
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   661
\frametitle{\begin{tabular}{c}Interpreted Code\end{tabular}}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   662
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   663
\begin{center}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   664
\begin{tikzpicture}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   665
\begin{axis}[axis x line=bottom, axis y line=left, xlabel=n, ylabel=secs, legend style=small]
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   666
\addplot+[smooth] file {interpreted.data};
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   667
\end{axis}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   668
\end{tikzpicture}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   669
\end{center}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   670
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   671
\end{frame}}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   672
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   673
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   674
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   675
\begin{frame}[c]
685
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   676
\frametitle{Java Virtual Machine}
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   677
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   678
\begin{itemize}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   679
\item introduced in 1995
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   680
\item is a stack-based VM (like Postscript, CLR of .Net)
685
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   681
\item contains a JIT compiler\\
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   682
\begin{itemize}
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   683
\item From the Cradle to the Holy Graal - the JDK Story
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   684
\item \url{https://www.youtube.com/watch?v=h419kfbLhUI}
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   685
\end{itemize}
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   686
\item is garbage collected $\Rightarrow$ no buffer overflows
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   687
\item some languages compile to the JVM: Scala, Clojure\ldots
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   688
\end{itemize}
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   689
685
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   690
\end{frame}
365
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   691
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
9b71dead1219 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 295
diff changeset
   692
685
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   693
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   694
\begin{frame}[c]
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   695
\frametitle{LLVM}
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   696
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   697
\begin{itemize}
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   698
\item LLVM started by academics in 2000 (University of Illinois in 
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   699
Urbana-Champaign)
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   700
\item suite of compiler tools
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   701
\item SSA-based intermediate language
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   702
\item no need to allocate registers
686
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 685
diff changeset
   703
\item source languages: C, C++, Rust, Go, Swift
05cfce0fdef7 updated
Christian Urban <urbanc@in.tum.de>
parents: 685
diff changeset
   704
\item target CPUs: x86, ARM, PowerPC, \ldots
685
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   705
\end{itemize}  
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   706
\end{frame}
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   707
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
75d9f9e5906f updated
Christian Urban <urbanc@in.tum.de>
parents: 683
diff changeset
   708
  
50
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   709
598
e3ad67cd5123 updated
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   710
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
666
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   711
%\begin{frame}[c]
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   712
%  \frametitle{Coursework: MkEps}
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   713
%
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   714
%\begin{center}
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   715
%\begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}}
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   716
%  \bl{$mkeps([c_1 c_2 \ldots c_n])$}  & \bl{$\dn$} & $\bl{undefined}$\\
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   717
%  \bl{$mkeps(r^*)$}                   & \bl{$\dn$} & $\bl{Stars\,[]}$\\
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   718
%  \bl{$mkeps(r^{\{n\}})$}              & \bl{$\dn$} & $\bl{Stars\,(mkeps(r))^n}$\\
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   719
%  \bl{$mkeps(r^{\{n..\}})$}            & \bl{$\dn$} & $\bl{Stars\,(mkeps(r))^n}$\\
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   720
%  \bl{$mkeps(r^{\{..n\}})$}            & \bl{$\dn$} & $\bl{Stars\,[]}$\\
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   721
%  \bl{$mkeps(r^{\{n..m\}})$}           & \bl{$\dn$} & $\bl{Stars\,(mkeps(r))^n}$\medskip\\
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   722
%  
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   723
%  \bl{$mkeps(r^+)$}                   & \bl{$\dn$} & \bl{$mkeps(r^{\{1..\}})$}\\
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   724
%  \bl{$mkeps(r^?)$}                   & \bl{$\dn$} & \bl{$mkeps(r^{\{..1\}})$}\\
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   725
%\end{tabular}
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   726
%\end{center}
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   727
%
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   728
%\end{frame}
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   729
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   730
%
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   731
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   732
%\begin{frame}[c]
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   733
%  \frametitle{Coursework: Inj}
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   734
%
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   735
%\begin{center}
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   736
%\begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}}
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   737
%  \bl{$inj([c_1 c_2 \ldots c_n])\,c\,Empty$}  & \bl{$\dn$} & $\bl{Chr\,c}$\\
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   738
%  \bl{$inj(r^*)\,c\;(Seq\,v\,(Stars\,vs))$}                   & \bl{$\dn$} & $\bl{Stars\,(inj\,r\,c\,v::vs)}$\\
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   739
%  \bl{$inj(r^{\{n\}})\,c\;(Seq\,v\,(Stars\,vs))$}              & \bl{$\dn$} & $\bl{Stars\,(inj\,r\,c\,v::vs)}$\\
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   740
%  \bl{$inj(r^{\{n..\}})\,c\;(Seq\,v\,(Stars\,vs))$}            & \bl{$\dn$} & $\bl{Stars\,(inj\,r\,c\,v::vs)}$\\
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   741
%  \bl{$inj(r^{\{..n\}})\,c\;(Seq\,v\,(Stars\,vs))$}            & \bl{$\dn$} & $\bl{Stars\,(inj\,r\,c\,v::vs)}$\\
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   742
%  \bl{$inj(r^{\{n..m\}})\,c\;(Seq\,v\,(Stars\,vs))$}           & \bl{$\dn$} & $\bl{Stars\,(inj\,r\,c\,v::vs)}$\medskip\\
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   743
%  
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   744
%  \bl{$inj(r^+)\,c\,v$}                   & \bl{$\dn$} & \bl{$inj(r^{\{1..\}})\,c\,v$}\\
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   745
%  \bl{$inj(r^?)\,c\,v$}                   & \bl{$\dn$} & \bl{$inj(r^{\{..1\}})\,c\,v$}\\
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   746
%\end{tabular}
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   747
%\end{center}
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   748
%
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   749
%\end{frame}
4fbdc80076cb updated
Christian Urban <urbanc@in.tum.de>
parents: 599
diff changeset
   750
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
598
e3ad67cd5123 updated
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   751
e3ad67cd5123 updated
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   752
e3ad67cd5123 updated
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   753
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   754
\end{document}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   755
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   756
%%% Local Variables:  
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   757
%%% mode: latex
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   758
%%% TeX-master: t
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   759
%%% End: 
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   760