slides/slides05.tex
author Christian Urban <christian.urban@kcl.ac.uk>
Tue, 27 Oct 2020 13:46:01 +0000
changeset 792 34132a854d03
parent 743 6acabeecdf75
child 795 ff2894dfc399
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
582
d236e75e1d55 updated
Christian Urban <urbanc@in.tum.de>
parents: 550
diff changeset
     1
664
dc2f5eb33a9a updated
Christian Urban <urbanc@in.tum.de>
parents: 593
diff changeset
     2
% !TEX program = xelatex
743
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
     3
\documentclass[dvipsnames,14pt,t,xelatex,aspectratio=169,xcolor={table}]{beamer}
270
4dbeaf43031d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
     4
\usepackage{../slides}
4dbeaf43031d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
     5
\usepackage{../graphics}
215
828303e8e4af updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
     6
\usepackage{../langs}
828303e8e4af updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
     7
\usepackage{../data}
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
     8
\usepackage{../grammar}
44
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
270
4dbeaf43031d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
    10
\hfuzz=220pt 
4dbeaf43031d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
    11
4dbeaf43031d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
    12
\pgfplotsset{compat=1.11}
4dbeaf43031d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
    13
4dbeaf43031d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
    14
\newcommand{\bl}[1]{\textcolor{blue}{#1}}  
44
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
% beamer stuff 
445
e7d0157f0471 updated slides
Christian Urban <urbanc@in.tum.de>
parents: 370
diff changeset
    17
\renewcommand{\slidecaption}{CFL 05, King's College London}
270
4dbeaf43031d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
    18
44
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
\begin{document}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
270
4dbeaf43031d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
    23
\begin{frame}[t]
44
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
\frametitle{%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
  \begin{tabular}{@ {}c@ {}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
  \\[-3mm]
445
e7d0157f0471 updated slides
Christian Urban <urbanc@in.tum.de>
parents: 370
diff changeset
    27
  \LARGE Compilers and \\[-2mm] 
743
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    28
  \LARGE Formal Languages\\[3mm] 
44
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
  \end{tabular}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
  \normalsize
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
  \begin{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
  \begin{tabular}{ll}
664
dc2f5eb33a9a updated
Christian Urban <urbanc@in.tum.de>
parents: 593
diff changeset
    34
    Email:  & christian.urban at kcl.ac.uk\\
743
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    35
    %Office Hours: & Thursdays 12 -- 14\\
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    36
    %Location: & N7.07 (North Wing, Bush House)\\
664
dc2f5eb33a9a updated
Christian Urban <urbanc@in.tum.de>
parents: 593
diff changeset
    37
    Slides \& Progs: & KEATS (also homework is there)\\  
44
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
  \end{tabular}
743
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    39
\end{center}
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    40
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    41
  \begin{center}
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    42
    \begin{tikzpicture}
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    43
      \node[drop shadow,fill=white,inner sep=0pt] 
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    44
      {\footnotesize\rowcolors{1}{capri!10}{white}
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    45
        \begin{tabular}{|p{4.8cm}|p{4.8cm}|}\hline
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    46
          1 Introduction, Languages          & 6 While-Language \\
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    47
          2 Regular Expressions, Derivatives & 7 Compilation, JVM \\
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    48
          3 Automata, Regular Languages      & 8 Compiling Functional Languages \\
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    49
          4 Lexing, Tokenising               & 9 Optimisations \\
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    50
          \cellcolor{blue!50}
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    51
          5 Grammars, Parsing                & 10 LLVM \\ \hline
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    52
        \end{tabular}%
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    53
      };
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    54
    \end{tikzpicture}
44
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
  \end{center}
270
4dbeaf43031d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 215
diff changeset
    56
\end{frame}
289
c22c8baff491 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 272
diff changeset
    57
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
44
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
667
412556272333 updated
Christian Urban <urbanc@in.tum.de>
parents: 666
diff changeset
    59
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
743
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    60
%\begin{frame}[c]
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    61
%  \frametitle{Coursework 1: Submissions}
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    62
%  
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    63
%  \begin{itemize}
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    64
%  \item Scala (29)
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    65
%  \item Haskell (1)
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    66
%  \item Kotlin (1)
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    67
%  \item Rust (1)
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    68
%  \end{itemize}\bigskip\bigskip  
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    69
%  
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    70
%  \small
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    71
%  Please get in contact if you intend to do CW Strand 2. No zips please.
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    72
%  Give definitions also on paper if asked. BTW, simp 
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    73
%  can stay unchanged. Use \texttt{ders} for CW2, not \texttt{ders2}!
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    74
%  \end{frame}
289
c22c8baff491 updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 272
diff changeset
    75
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
743
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    76
    
528
68fab15cd6fb updated
cu
parents: 500
diff changeset
    77
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
68fab15cd6fb updated
cu
parents: 500
diff changeset
    78
\begin{frame}[t]
68fab15cd6fb updated
cu
parents: 500
diff changeset
    79
\frametitle{Lexer, Parser}
68fab15cd6fb updated
cu
parents: 500
diff changeset
    80
\mbox{}\\[-16mm]\mbox{}
68fab15cd6fb updated
cu
parents: 500
diff changeset
    81
68fab15cd6fb updated
cu
parents: 500
diff changeset
    82
\begin{center}
68fab15cd6fb updated
cu
parents: 500
diff changeset
    83
  \begin{tikzpicture}[scale=1,
68fab15cd6fb updated
cu
parents: 500
diff changeset
    84
                      node/.style={
68fab15cd6fb updated
cu
parents: 500
diff changeset
    85
                      rectangle,rounded corners=3mm,
68fab15cd6fb updated
cu
parents: 500
diff changeset
    86
                      very thick,draw=black!50,
68fab15cd6fb updated
cu
parents: 500
diff changeset
    87
                      minimum height=18mm, minimum width=20mm,
743
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
    88
                      top color=white,bottom color=black!20,drop shadow}]
528
68fab15cd6fb updated
cu
parents: 500
diff changeset
    89
  \node (0) at (-2.3,0) {}; 
68fab15cd6fb updated
cu
parents: 500
diff changeset
    90
  
68fab15cd6fb updated
cu
parents: 500
diff changeset
    91
  \node (A) at (0,0)  [node] {};
68fab15cd6fb updated
cu
parents: 500
diff changeset
    92
  \node [below right] at (A.north west) {lexer};
68fab15cd6fb updated
cu
parents: 500
diff changeset
    93
68fab15cd6fb updated
cu
parents: 500
diff changeset
    94
  \node (B) at (3,0)  [node] {};
68fab15cd6fb updated
cu
parents: 500
diff changeset
    95
  \node [below right=1mm] at (B.north west) 
68fab15cd6fb updated
cu
parents: 500
diff changeset
    96
    {\mbox{}\hspace{-1mm}parser};
68fab15cd6fb updated
cu
parents: 500
diff changeset
    97
68fab15cd6fb updated
cu
parents: 500
diff changeset
    98
  \node (C) at (6,0)  [node] {};
68fab15cd6fb updated
cu
parents: 500
diff changeset
    99
  \node [below right] at (C.north west) 
68fab15cd6fb updated
cu
parents: 500
diff changeset
   100
    {\mbox{}\hspace{-1mm}code gen};
68fab15cd6fb updated
cu
parents: 500
diff changeset
   101
68fab15cd6fb updated
cu
parents: 500
diff changeset
   102
  \node (1) at (8.4,0) {}; 
68fab15cd6fb updated
cu
parents: 500
diff changeset
   103
68fab15cd6fb updated
cu
parents: 500
diff changeset
   104
  \draw [->,line width=4mm] (0) -- (A); 
68fab15cd6fb updated
cu
parents: 500
diff changeset
   105
  \draw [->,line width=4mm] (A) -- (B); 
68fab15cd6fb updated
cu
parents: 500
diff changeset
   106
  \draw [->,line width=4mm] (B) -- (C); 
68fab15cd6fb updated
cu
parents: 500
diff changeset
   107
  \draw [->,line width=4mm] (C) -- (1); 
68fab15cd6fb updated
cu
parents: 500
diff changeset
   108
  \end{tikzpicture}
68fab15cd6fb updated
cu
parents: 500
diff changeset
   109
  \end{center}
68fab15cd6fb updated
cu
parents: 500
diff changeset
   110
  
68fab15cd6fb updated
cu
parents: 500
diff changeset
   111
Today a parser.  
68fab15cd6fb updated
cu
parents: 500
diff changeset
   112
  
68fab15cd6fb updated
cu
parents: 500
diff changeset
   113
\end{frame}
68fab15cd6fb updated
cu
parents: 500
diff changeset
   114
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   115
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   116
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   117
\begin{frame}[c]
550
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 529
diff changeset
   118
\frametitle{What Parsing is Not}
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 529
diff changeset
   119
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 529
diff changeset
   120
Usually parsing does not check semantic correctness, e.g.
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 529
diff changeset
   121
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 529
diff changeset
   122
\begin{itemize}
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 529
diff changeset
   123
\item  whether a function is not used before it
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 529
diff changeset
   124
  is defined
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 529
diff changeset
   125
\item whether a function has the correct number of arguments 
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 529
diff changeset
   126
  or are of correct type
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 529
diff changeset
   127
\item whether a variable can be declared twice in a scope  
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 529
diff changeset
   128
\end{itemize}  
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 529
diff changeset
   129
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 529
diff changeset
   130
\end{frame}
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 529
diff changeset
   131
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 529
diff changeset
   132
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 529
diff changeset
   133
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 529
diff changeset
   134
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 529
diff changeset
   135
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 529
diff changeset
   136
\begin{frame}[c]
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   137
\frametitle{Regular Languages}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   138
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   139
While regular expressions are very useful for lexing, there is
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   140
no regular expression that can recognise the language
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   141
\bl{$a^nb^n$}.\bigskip
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   142
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   143
\begin{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   144
\bl{$(((()()))())$} \;\;vs.\;\; \bl{$(((()()))()))$}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   145
\end{center}\bigskip\bigskip
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   146
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   147
\small
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   148
\noindent So we cannot find out with regular expressions
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   149
whether parentheses are matched or unmatched. Also regular
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   150
expressions are not recursive, e.g.~\bl{$(1 + 2) + 3$}.
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   151
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   152
\end{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   153
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   154
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   155
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   156
\begin{frame}[c]
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   157
\frametitle{Hierarchy of Languages}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   158
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   159
\begin{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   160
\begin{tikzpicture}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   161
[rect/.style={draw=black!50, 
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   162
              top color=white,
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   163
              bottom color=black!20, 
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   164
              rectangle, 
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   165
              very thick, 
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   166
              rounded corners}, scale=1.2]
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   167
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   168
\draw (0,0) node [rect, text depth=39mm, text width=68mm] {all languages};
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   169
\draw (0,-0.4) node [rect, text depth=28.5mm, text width=64mm] {decidable languages};
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   170
\draw (0,-0.85) node [rect, text depth=17mm] {context sensitive languages};
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   171
\draw (0,-1.14) node [rect, text depth=9mm, text width=50mm] {context-free languages};
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   172
\draw (0,-1.4) node [rect] {regular languages};
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   173
\end{tikzpicture}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   174
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   175
\end{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   176
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   177
\end{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   178
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   179
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   180
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   181
\begin{frame}[c]
792
34132a854d03 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 743
diff changeset
   182
\frametitle{CFGs}
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   183
360
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 358
diff changeset
   184
A \alert{\bf context-free grammar} \bl{$G$} consists of
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   185
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   186
\begin{itemize}
664
dc2f5eb33a9a updated
Christian Urban <urbanc@in.tum.de>
parents: 593
diff changeset
   187
\item a finite set of nonterminal symbols (e.g.~$\meta{A}$ upper case)
dc2f5eb33a9a updated
Christian Urban <urbanc@in.tum.de>
parents: 593
diff changeset
   188
\item a finite set terminal symbols or tokens (lower case)
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   189
\item a start symbol (which must be a nonterminal)
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   190
\item a set of rules
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   191
\begin{center}
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   192
\bl{$\meta{A} ::= \textit{rhs}$}
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   193
\end{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   194
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   195
where \bl{\textit{rhs}} are sequences involving terminals and nonterminals,
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   196
including the empty sequence \bl{$\epsilon$}.\medskip\pause
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   197
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   198
We also allow rules
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   199
\begin{center}
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   200
\bl{$\meta{A} ::= \textit{rhs}_1 | \textit{rhs}_2 | \ldots$}
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   201
\end{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   202
\end{itemize}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   203
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   204
\end{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   205
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   206
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   207
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
582
d236e75e1d55 updated
Christian Urban <urbanc@in.tum.de>
parents: 550
diff changeset
   208
\begin{frame}[t]
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   209
\frametitle{Palindromes}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   210
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   211
A grammar for palindromes over the alphabet~\bl{$\{a,b\}$}:
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   212
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   213
\bl{\begin{plstx}[margin=3cm]
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   214
: \meta{S} ::= a\cdot\meta{S}\cdot a\\
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   215
: \meta{S} ::= b\cdot\meta{S}\cdot b\\
588
a4646557016d updated
Christian Urban <urbanc@in.tum.de>
parents: 583
diff changeset
   216
: \meta{S} ::= a\\
a4646557016d updated
Christian Urban <urbanc@in.tum.de>
parents: 583
diff changeset
   217
: \meta{S} ::= b\\
a4646557016d updated
Christian Urban <urbanc@in.tum.de>
parents: 583
diff changeset
   218
: \meta{S} ::= \epsilon\\
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   219
\end{plstx}}\pause
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   220
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   221
or
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   222
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   223
\bl{\begin{plstx}[margin=2cm]
588
a4646557016d updated
Christian Urban <urbanc@in.tum.de>
parents: 583
diff changeset
   224
: \meta{S} ::=  a\cdot \meta{S}\cdot a | b\cdot \meta{S}\cdot b | a | b | \epsilon\\
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   225
\end{plstx}}\pause\bigskip
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   226
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   227
\small
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   228
Can you find the grammar rules for matched parentheses?
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   229
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   230
\end{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   231
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   232
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   233
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   234
\begin{frame}[c]
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   235
\frametitle{Arithmetic Expressions}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   236
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   237
\bl{\begin{plstx}[margin=3cm,one per line]
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   238
: \meta{E} ::=  num\_token 
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   239
   | \meta{E} \cdot + \cdot \meta{E} 
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   240
   | \meta{E} \cdot - \cdot \meta{E} 
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   241
   | \meta{E} \cdot * \cdot \meta{E} 
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   242
   | ( \cdot \meta{E} \cdot ) \\
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   243
\end{plstx}}\pause
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   244
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   245
\bl{\texttt{1 + 2 * 3 + 4}}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   246
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   247
\end{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   248
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   249
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   250
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   251
\begin{frame}[c]
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   252
\frametitle{A CFG Derivation}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   253
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   254
\begin{enumerate}
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   255
\item Begin with a string containing only the start symbol, say \bl{\meta{S}}\bigskip
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   256
\item Replace any nonterminal \bl{\meta{X}} in the string by the
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   257
right-hand side of some production \bl{$\meta{X} ::= \textit{rhs}$}\bigskip
582
d236e75e1d55 updated
Christian Urban <urbanc@in.tum.de>
parents: 550
diff changeset
   258
\item Repeat 2 until there are no nonterminals left
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   259
\end{enumerate}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   260
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   261
\begin{center}
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   262
\bl{$\meta{S} \rightarrow \ldots \rightarrow \ldots  \rightarrow \ldots  \rightarrow \ldots $}
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   263
\end{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   264
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   265
\end{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   266
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   267
  
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   268
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   269
\begin{frame}[t]
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   270
\frametitle{Example Derivation}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   271
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   272
\bl{\begin{plstx}[margin=2cm]
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   273
: \meta{S} ::=  \epsilon | a\cdot \meta{S}\cdot a | b\cdot \meta{S}\cdot b \\
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   274
\end{plstx}}\bigskip
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   275
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   276
\begin{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   277
\begin{tabular}{lcl}
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   278
\bl{\meta{S}} & \bl{$\rightarrow$} & \bl{$a\meta{S}a$}\\
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   279
              & \bl{$\rightarrow$} & \bl{$ab\meta{S}ba$}\\
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   280
              & \bl{$\rightarrow$} & \bl{$aba\meta{S}aba$}\\
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   281
              & \bl{$\rightarrow$} & \bl{$abaaba$}\\
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   282
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   283
 
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   284
\end{tabular}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   285
\end{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   286
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   287
\end{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   288
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   289
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   290
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   291
\begin{frame}[t]
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   292
\frametitle{Example Derivation}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   293
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   294
\bl{\begin{plstx}[margin=3cm,one per line]
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   295
: \meta{E} ::=  num\_token 
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   296
   | \meta{E} \cdot + \cdot \meta{E} 
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   297
   | \meta{E} \cdot - \cdot \meta{E} 
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   298
   | \meta{E} \cdot * \cdot \meta{E} 
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   299
   | ( \cdot \meta{E} \cdot ) \\
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   300
\end{plstx}}
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   301
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   302
\small
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   303
\begin{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   304
\begin{tabular}{@{}c@{}c@{}}
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   305
\begin{tabular}{@{\hspace{-2mm}}l@{\hspace{1mm}}l@{\hspace{1mm}}l@{\hspace{4mm}}}
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   306
\bl{\meta{E}} & \bl{$\rightarrow$} & \bl{$\meta{E}*\meta{E}$}\\
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   307
              & \bl{$\rightarrow$} & \bl{$\meta{E}+\meta{E}*\meta{E}$}\\
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   308
              & \bl{$\rightarrow$} & \bl{$\meta{E}+\meta{E}*\meta{E}+\meta{E}$}\\
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   309
              & \bl{$\rightarrow^+$} & \bl{$1+2*3+4$}\\
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   310
\end{tabular} &\pause
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   311
\begin{tabular}{@{}l@{\hspace{0mm}}l@{\hspace{1mm}}l}
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   312
\bl{$\meta{E}$} & \bl{$\rightarrow$} & \bl{$\meta{E}+\meta{E}$}\\
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   313
                & \bl{$\rightarrow$} & \bl{$\meta{E}+\meta{E}+\meta{E}$}\\
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   314
                & \bl{$\rightarrow$} & \bl{$\meta{E}+\meta{E}*\meta{E}+\meta{E}$}\\
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   315
                & \bl{$\rightarrow^+$} & \bl{$1+2*3+4$}\\
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   316
\end{tabular}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   317
\end{tabular}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   318
\end{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   319
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   320
\end{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   321
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   322
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   323
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   324
\begin{frame}[c]
664
dc2f5eb33a9a updated
Christian Urban <urbanc@in.tum.de>
parents: 593
diff changeset
   325
\frametitle{Context Sensitive Grammars}
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   326
360
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 358
diff changeset
   327
It is much harder to find out whether a string is parsed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 358
diff changeset
   328
by a context sensitive grammar:
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   329
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   330
\bl{\begin{plstx}[margin=2cm]
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   331
: \meta{S} ::= b\meta{S}\meta{A}\meta{A} | \epsilon\\
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   332
: \meta{A} ::= a\\
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   333
: b\meta{A} ::= \meta{A}b\\
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   334
\end{plstx}}\pause
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   335
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   336
\begin{center}
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   337
\bl{$\meta{S} \rightarrow\ldots\rightarrow^? ababaa$}
665
6d74d2a0a4b0 updated
Christian Urban <urbanc@in.tum.de>
parents: 664
diff changeset
   338
\end{center}\pause
6d74d2a0a4b0 updated
Christian Urban <urbanc@in.tum.de>
parents: 664
diff changeset
   339
6d74d2a0a4b0 updated
Christian Urban <urbanc@in.tum.de>
parents: 664
diff changeset
   340
\begin{center}
6d74d2a0a4b0 updated
Christian Urban <urbanc@in.tum.de>
parents: 664
diff changeset
   341
  \tt Time flies like an arrow;\\ 
6d74d2a0a4b0 updated
Christian Urban <urbanc@in.tum.de>
parents: 664
diff changeset
   342
  fruit flies like bananas.
6d74d2a0a4b0 updated
Christian Urban <urbanc@in.tum.de>
parents: 664
diff changeset
   343
  \end{center}  
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   344
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   345
\end{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   346
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   347
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   348
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   349
\begin{frame}[c]
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   350
\frametitle{Language of a CFG}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   351
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   352
Let \bl{$G$} be a context-free grammar with start symbol \bl{\meta{S}}. 
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   353
Then the language \bl{$L(G)$} is:
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   354
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   355
\begin{center}
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   356
\bl{$\{c_1\ldots c_n \;|\; \forall i.\; c_i \in T \wedge \meta{S} \rightarrow^* c_1\ldots c_n \}$}
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   357
\end{center}\pause
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   359
\begin{itemize}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   360
\item Terminals, because there are no rules for replacing them.
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   361
\item Once generated, terminals are ``permanent''.
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   362
\item Terminals ought to be tokens of the language\\
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   363
(but can also be strings).
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   364
\end{itemize}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   365
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   366
\end{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   367
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   368
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   369
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   370
\begin{frame}[t]
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   371
\frametitle{Parse Trees}
582
d236e75e1d55 updated
Christian Urban <urbanc@in.tum.de>
parents: 550
diff changeset
   372
\mbox{}\\[-12mm]
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   373
593
bb24d4e207b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 588
diff changeset
   374
\bl{\begin{plstx}: \meta{E} ::= \meta{T} | \meta{T} \cdot + \cdot \meta{E} |  \meta{T} \cdot - \cdot \meta{E}\\
529
5c28e4134ee1 updated
cu
parents: 528
diff changeset
   375
: \meta{T} ::= \meta{F} | \meta{F} \cdot * \cdot \meta{T}\\
5c28e4134ee1 updated
cu
parents: 528
diff changeset
   376
: \meta{F} ::= num\_token | ( \cdot \meta{E} \cdot )\\
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   377
\end{plstx}}
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   378
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   379
\begin{center}\small
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   380
\begin{tikzpicture}[level distance=8mm, blue]
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   381
  \node {$\meta{E}$}
529
5c28e4134ee1 updated
cu
parents: 528
diff changeset
   382
    child {node {$\meta{T}$} 
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   383
     child {node {$\meta{T}$} 
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   384
                 child {node {(\,$\meta{E}$\,)}
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   385
                            child {node{$\meta{F}$ *{} $\meta{F}$}
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   386
                                  child {node {$\meta{T}$} child {node {2}}}
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   387
                                  child {node {$\meta{T}$} child {node {3}}} 
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   388
                               }
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   389
                          }
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   390
              }
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   391
     child {node {+}}
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   392
     child {node {$\meta{T}$}
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   393
       child {node {(\,$\meta{E}$\,)} 
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   394
       child {node {$\meta{F}$}
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   395
       child {node {$\meta{T}$ +{} $\meta{T}$}
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   396
                    child {node {3}}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   397
                    child {node {4}} 
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   398
                 }
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   399
                 }}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   400
    }};
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   401
\end{tikzpicture}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   402
\end{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   403
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   404
\begin{textblock}{5}(1, 6.5)
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   405
\bl{\texttt{(2*3)+(3+4)}}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   406
\end{textblock}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   407
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   408
\end{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   409
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   410
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   411
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   412
\begin{frame}[t]
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   413
\frametitle{Arithmetic Expressions}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   414
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   415
\bl{\begin{plstx}[margin=3cm,one per line]
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   416
: \meta{E} ::=  num\_token 
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   417
   | \meta{E} \cdot + \cdot \meta{E} 
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   418
   | \meta{E} \cdot - \cdot \meta{E} 
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   419
   | \meta{E} \cdot * \cdot \meta{E} 
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   420
   | ( \cdot \meta{E} \cdot ) \\
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   421
\end{plstx}}\pause\bigskip
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   422
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   423
A CFG is \alert{\bf left-recursive} if it has a nonterminal \bl{$\meta{E}$} such
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   424
that \bl{$\meta{E} \rightarrow^+ \meta{E}\cdot \ldots$}
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   425
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   426
\end{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   427
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   428
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   429
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   430
\begin{frame}[t]
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   431
\frametitle{Ambiguous Grammars}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   432
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   433
A grammar is \alert{\bf ambiguous} if there is a string that
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   434
has at least two different parse trees.
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   435
451
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   436
\bl{\begin{plstx}[margin=3cm,one per line]: \meta{E} ::=  num\_token 
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   437
   | \meta{E} \cdot + \cdot \meta{E} 
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   438
   | \meta{E} \cdot - \cdot \meta{E} 
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   439
   | \meta{E} \cdot * \cdot \meta{E} 
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   440
   | ( \cdot \meta{E} \cdot ) \\
4a5876f321ae updated
Christian Urban <urbanc@in.tum.de>
parents: 445
diff changeset
   441
\end{plstx}}
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   442
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   443
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   444
\bl{\texttt{1 + 2 * 3 + 4}}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   445
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   446
\end{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   447
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   448
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   449
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   450
\begin{frame}[c]
582
d236e75e1d55 updated
Christian Urban <urbanc@in.tum.de>
parents: 550
diff changeset
   451
\frametitle{`Dangling' Else}
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   452
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   453
Another ambiguous grammar:\bigskip
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   454
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   455
\begin{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   456
\bl{\begin{tabular}{lcl}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   457
$E$ & $\rightarrow$ &  if $E$ then $E$\\
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   458
 & $|$ &  if $E$ then $E$ else $E$ \\
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   459
 & $|$ &  \ldots
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   460
\end{tabular}}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   461
\end{center}\bigskip
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   462
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   463
\bl{\texttt{if a then if x then y else c}}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   464
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   465
\end{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   466
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   467
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   468
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   469
\begin{frame}[c]
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   470
\frametitle{Parser Combinators}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   471
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   472
One of the simplest ways to implement a parser, see
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   473
{\small\url{https://vimeo.com/142341803}}\bigskip
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   474
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   475
Parser combinators: \bigskip
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   476
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   477
\begin{minipage}{1.1\textwidth}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   478
\begin{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   479
\mbox{}\hspace{-12mm}\mbox{}$\underbrace{\text{list of tokens}}_{\text{input}}$ \bl{$\Rightarrow$} 
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   480
$\underbrace{\text{set of (parsed input, unparsed input)}}_{\text{output}}$
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   481
\end{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   482
\end{minipage}\bigskip
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   483
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   484
\begin{itemize}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   485
\item atomic parsers
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   486
\item sequencing
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   487
\item alternative
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   488
\item semantic action
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   489
\end{itemize}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   490
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   491
\end{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   492
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   493
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   494
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   495
\begin{frame}[c]
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   496
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   497
Atomic parsers, for example, number tokens
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   498
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   499
\begin{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   500
\bl{$\texttt{Num(123)}::rest \;\Rightarrow\; \{(\texttt{Num(123)}, rest)\}$} 
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   501
\end{center}\bigskip
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   502
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   503
\begin{itemize}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   504
\item you consume one or more token from the\\ 
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   505
  input (stream)
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   506
\item also works for characters and strings
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   507
\end{itemize}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   508
\end{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   509
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   510
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   511
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   512
\begin{frame}[c]
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   513
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   514
Alternative parser (code \bl{$p\;||\;q$})\bigskip
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   515
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   516
\begin{itemize}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   517
\item apply \bl{$p$} and also \bl{$q$}; then combine 
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   518
  the outputs
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   519
\end{itemize}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   520
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   521
\begin{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   522
\large \bl{$p(\text{input}) \cup q(\text{input})$}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   523
\end{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   524
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   525
\end{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   526
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   527
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   528
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   529
\begin{frame}[c]
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   530
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   531
Sequence parser (code \bl{$p\sim q$})\bigskip
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   532
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   533
\begin{itemize}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   534
\item apply first \bl{$p$} producing a set of pairs
528
68fab15cd6fb updated
cu
parents: 500
diff changeset
   535
\item then apply \bl{$q$} to the unparsed part
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   536
\item then combine the results:\medskip 
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   537
\begin{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   538
((output$_1$, output$_2$), unparsed part)
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   539
\end{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   540
\end{itemize}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   541
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   542
\begin{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   543
\begin{tabular}{l}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   544
\large \bl{$\{((o_1, o_2), u_2) \;|\;$}\\[2mm] 
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   545
\large\mbox{}\hspace{15mm} \bl{$(o_1, u_1) \in p(\text{input}) \wedge$}\\[2mm]
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   546
\large\mbox{}\hspace{15mm} \bl{$(o_2, u_2) \in q(u_1)\}$}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   547
\end{tabular}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   548
\end{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   549
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   550
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   551
\end{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   552
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   553
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   554
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   555
\begin{frame}[c]
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   556
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   557
Function parser (code \bl{$p \Rightarrow f\;$})\bigskip
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   558
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   559
\begin{itemize}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   560
\item apply \bl{$p$} producing a set of pairs
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   561
\item then apply the function \bl{$f$} to each first component
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   562
\end{itemize}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   563
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   564
\begin{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   565
\begin{tabular}{l}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   566
\large \bl{$\{(f(o_1), u_1) \;|\; (o_1, u_1) \in p(\text{input})\}$}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   567
\end{tabular}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   568
\end{center}\bigskip\bigskip\pause
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   569
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   570
\bl{$f$} is the semantic action (``what to do with the parsed input'')
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   571
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   572
\end{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   573
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   574
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   575
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   576
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   577
\mode<presentation>{
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   578
\begin{frame}[c]
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   579
\frametitle{\begin{tabular}{c}Semantic Actions\end{tabular}}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   580
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   581
Addition
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   582
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   583
\begin{center}
582
d236e75e1d55 updated
Christian Urban <urbanc@in.tum.de>
parents: 550
diff changeset
   584
\bl{$\meta{T} \sim + \sim \meta{E} \Rightarrow \underbrace{f\,((x,y), z) \Rightarrow x + z}_{\text{semantic action}}$}
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   585
\end{center}\pause
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   586
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   587
Multiplication
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   588
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   589
\begin{center}
582
d236e75e1d55 updated
Christian Urban <urbanc@in.tum.de>
parents: 550
diff changeset
   590
\bl{$\meta{F} \sim * \sim \meta{T} \Rightarrow f\,((x,y), z) \Rightarrow x * z$}
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   591
\end{center}\pause
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   592
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   593
Parenthesis
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   594
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   595
\begin{center}
582
d236e75e1d55 updated
Christian Urban <urbanc@in.tum.de>
parents: 550
diff changeset
   596
\bl{$\text{(} \sim \meta{E} \sim \text{)} \Rightarrow f\,((x,y), z) \Rightarrow y$}
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   597
\end{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   598
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   599
\end{frame}}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   600
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   601
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   602
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   603
\begin{frame}[c]
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   604
\frametitle{Types of Parsers}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   605
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   606
\begin{itemize}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   607
\item {\bf Sequencing}: if \bl{$p$} returns results of type \bl{$T$}, and \bl{$q$} results of type \bl{$S$},
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   608
then \bl{$p \sim q$} returns results of type
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   609
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   610
\begin{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   611
\bl{$T \times S$}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   612
\end{center}\pause
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   613
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   614
\item {\bf Alternative}: if \bl{$p$} returns results of type \bl{$T$} then  \bl{$q$} \alert{must} also have results of type \bl{$T$},
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   615
and \bl{$p \;||\; q$} returns results of type
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   616
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   617
\begin{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   618
\bl{$T$}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   619
\end{center}\pause
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   620
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   621
\item {\bf Semantic Action}: if \bl{$p$} returns results of type \bl{$T$} and \bl{$f$} is a function from
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   622
\bl{$T$} to \bl{$S$}, then
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   623
\bl{$p \Rightarrow f$} returns results of type
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   624
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   625
\begin{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   626
\bl{$S$}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   627
\end{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   628
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   629
\end{itemize}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   630
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   631
\end{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   632
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   633
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   634
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   635
\begin{frame}[c]
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   636
\frametitle{Input Types of Parsers}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   637
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   638
\begin{itemize}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   639
\item input: \alert{token list}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   640
\item output: set of (output\_type, \alert{token list})
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   641
\end{itemize}\bigskip\pause
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   642
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   643
actually it can be any input type as long as it is a kind of
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   644
sequence (for example a string)
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   645
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   646
\end{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   647
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   648
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   649
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   650
\begin{frame}[c]
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   651
\frametitle{Scannerless Parsers}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   652
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   653
\begin{itemize}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   654
\item input: \alert{string}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   655
\item output: set of (output\_type, \alert{string})
664
dc2f5eb33a9a updated
Christian Urban <urbanc@in.tum.de>
parents: 593
diff changeset
   656
\end{itemize}\bigskip\bigskip
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   657
664
dc2f5eb33a9a updated
Christian Urban <urbanc@in.tum.de>
parents: 593
diff changeset
   658
but using lexers is better because whitespaces or comments can be
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   659
filtered out; then input is a sequence of tokens
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   660
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   661
\end{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   662
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   663
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   664
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   665
\begin{frame}[c]
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   666
\frametitle{Successful Parses}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   667
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   668
\begin{itemize}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   669
\item input: string
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   670
\item output: \alert{set of} (output\_type, string)
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   671
\end{itemize}\bigskip
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   672
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   673
a parse is successful whenever the input has been fully
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   674
``consumed'' (that is the second component is empty)
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   675
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   676
\end{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   677
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   678
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   679
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   680
\begin{frame}[c]
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   681
\frametitle{Abstract Parser Class}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   682
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   683
\small
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   684
\lstinputlisting[language=Scala,xleftmargin=1mm]
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   685
 {../progs/app7.scala}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   686
\end{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   687
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   688
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   689
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   690
\begin{frame}[c]
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   691
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   692
\small
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   693
\fontsize{10}{12}\selectfont
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   694
\lstinputlisting[language=Scala,xleftmargin=1mm]
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   695
  {../progs/app8.scala}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   696
\end{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   697
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   698
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   699
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   700
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   701
\begin{frame}[c]
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   702
\frametitle{Two Grammars}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   703
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   704
Which languages are recognised by the following two grammars?
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   705
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   706
\begin{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   707
\bl{\begin{tabular}{lcl}
582
d236e75e1d55 updated
Christian Urban <urbanc@in.tum.de>
parents: 550
diff changeset
   708
$\meta{S}$ & $\rightarrow$ &  $1 \cdot \meta{S} \cdot \meta{S}$\\
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   709
        & $|$ & $\epsilon$
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   710
\end{tabular}}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   711
\end{center}\bigskip
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   712
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   713
\begin{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   714
\bl{\begin{tabular}{lcl}
582
d236e75e1d55 updated
Christian Urban <urbanc@in.tum.de>
parents: 550
diff changeset
   715
$\meta{U}$ & $\rightarrow$ &  $1 \cdot \meta{U}$\\
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   716
        & $|$ & $\epsilon$
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   717
\end{tabular}}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   718
\end{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   719
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   720
\end{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   721
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   722
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   723
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   724
\begin{frame}[t]
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   725
\frametitle{Ambiguous Grammars}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   726
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   727
\begin{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   728
\begin{tikzpicture}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   729
\begin{axis}[xlabel={\pcode{1}s},ylabel={time in secs},
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   730
    enlargelimits=false,
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   731
    xtick={0,100,...,1000},
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   732
    xmax=1050,
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   733
    ymax=33,
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   734
    ytick={0,5,...,30},
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   735
    scaled ticks=false,
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   736
    axis lines=left,
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   737
    width=11cm,
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   738
    height=7cm, 
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   739
    legend entries={unambiguous,ambiguous},  
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   740
    legend pos=north east,
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   741
    legend cell align=left,
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   742
    x tick label style={font=\small,/pgf/number format/1000 sep={}}]
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   743
\addplot[blue,mark=*, mark options={fill=white}] 
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   744
  table {s-grammar1.data};
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   745
\only<2>{
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   746
  \addplot[red,mark=triangle*, mark options={fill=white}] 
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   747
  table {s-grammar2.data};}  
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   748
\end{axis}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   749
\end{tikzpicture}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   750
\end{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   751
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   752
\end{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   753
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   754
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   755
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   756
\begin{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   757
\frametitle{While-Language}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   758
\mbox{}\\[-23mm]\mbox{}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   759
370
a65767fe5d71 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 361
diff changeset
   760
\bl{\begin{plstx}[rhs style=,one per line]: \meta{Stmt} ::= skip
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   761
         | \meta{Id} := \meta{AExp}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   762
         | if \meta{BExp} then \meta{Block} else \meta{Block}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   763
         | while \meta{BExp} do \meta{Block}\\
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   764
: \meta{Stmts} ::= \meta{Stmt} ; \meta{Stmts}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   765
          | \meta{Stmt}\\
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   766
: \meta{Block} ::= \{ \meta{Stmts} \}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   767
          | \meta{Stmt}\\
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   768
: \meta{AExp} ::= \ldots\\
370
a65767fe5d71 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 361
diff changeset
   769
: \meta{BExp} ::= \ldots\\\end{plstx}}
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   770
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   771
\end{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   772
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   773
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   774
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   775
\begin{frame}[c]
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   776
\frametitle{An Interpreter}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   777
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   778
\begin{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   779
\bl{\begin{tabular}{l}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   780
$\{$\\
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   781
\;\;$x := 5 \text{;}$\\
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   782
\;\;$y := x * 3\text{;}$\\
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   783
\;\;$y := x * 4\text{;}$\\
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   784
\;\;$x := u * 3$\\
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   785
$\}$
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   786
\end{tabular}}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   787
\end{center}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   788
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   789
\begin{itemize}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   790
\item the interpreter has to record the value of \bl{$x$} before assigning a value to \bl{$y$}\pause
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   791
\item \bl{\texttt{eval(stmt, env)}}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   792
\end{itemize}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   793
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   794
\end{frame}
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   795
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   796
465
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   797
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   798
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   799
\mode<presentation>{
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   800
\begin{frame}[c]
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   801
\frametitle{\begin{tabular}{c}Interpreter\end{tabular}}
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   802
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   803
\begin{center}
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   804
\bl{\begin{tabular}{@{}lcl@{}}
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   805
$\text{eval}(n, E)$ & $\dn$ & $n$\\
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   806
$\text{eval}(x, E)$ & $\dn$ & $E(x)$ \;\;\;\textcolor{black}{lookup \bl{$x$} in \bl{$E$}}\\
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   807
$\text{eval}(a_1 + a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) + \text{eval}(a_2, E)$\\
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   808
$\text{eval}(a_1 - a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) - \text{eval}(a_2, E)$\\
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   809
$\text{eval}(a_1 * a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) * \text{eval}(a_2, E)$\bigskip\\
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   810
$\text{eval}(a_1 = a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) = \text{eval}(a_2, E)$\\
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   811
$\text{eval}(a_1\,!\!= a_2, E)$ & $\dn$ & $\neg(\text{eval}(a_1, E) = \text{eval}(a_2, E))$\\
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   812
$\text{eval}(a_1 < a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) < \text{eval}(a_2, E)$\
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   813
\end{tabular}}
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   814
\end{center}
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   815
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   816
\end{frame}}
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   817
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   818
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   819
\mode<presentation>{
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   820
\begin{frame}[c]
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   821
\frametitle{\begin{tabular}{c}Interpreter (2)\end{tabular}}
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   822
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   823
\begin{center}
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   824
\bl{\begin{tabular}{@{}lcl@{}}
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   825
$\text{eval}(\text{skip}, E)$ & $\dn$ & $E$\\
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   826
$\text{eval}(x:=a, E)$ & $\dn$ & \bl{$E(x \mapsto \text{eval}(a, E))$}\\
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   827
\multicolumn{3}{@{}l@{}}{$\text{eval}(\text{if}\;b\;\text{then}\;cs_1\;\text{else}\;cs_2 , E) \dn$}\\
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   828
\multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{if}\;\text{eval}(b,E)\;\text{then}\;
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   829
\text{eval}(cs_1,E)$}\\
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   830
\multicolumn{3}{@{}l@{}}{\hspace{2cm}$\phantom{\text{if}\;\text{eval}(b,E)\;}\text{else}\;\text{eval}(cs_2,E)$}\\
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   831
\multicolumn{3}{@{}l@{}}{$\text{eval}(\text{while}\;b\;\text{do}\;cs, E) \dn$}\\
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   832
\multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{if}\;\text{eval}(b,E)$}\\
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   833
\multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{then}\;
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   834
\text{eval}(\text{while}\;b\;\text{do}\;cs, \text{eval}(cs,E))$}\\
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   835
\multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{else}\; E$}\\
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   836
$\text{eval}(\text{write}\; x, E)$ & $\dn$ & $\{\;\text{println}(E(x))\; ;\;E\;\}$\\
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   837
\end{tabular}}
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   838
\end{center}
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   839
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   840
\end{frame}}
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   841
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   842
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   843
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   844
\begin{frame}[c]
582
d236e75e1d55 updated
Christian Urban <urbanc@in.tum.de>
parents: 550
diff changeset
   845
\frametitle{Test Program}
465
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   846
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   847
\mbox{}\\[-18mm]\mbox{}
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   848
743
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
   849
??%{\lstset{language=While}%%\fontsize{10}{12}\selectfont
6acabeecdf75 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 671
diff changeset
   850
%\texttt{\lstinputlisting{../progs/loops.while}}}
465
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   851
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   852
\end{frame}
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   853
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   854
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   855
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   856
\mode<presentation>{
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   857
\begin{frame}[t]
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   858
\frametitle{\begin{tabular}{c}Interpreted Code\end{tabular}}
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   859
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   860
\begin{center}
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   861
\begin{tikzpicture}
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   862
\begin{axis}[axis x line=bottom, axis y line=left, xlabel=n, ylabel=secs, legend style=small]
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   863
\addplot+[smooth] file {interpreted.data};
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   864
\end{axis}
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   865
\end{tikzpicture}
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   866
\end{center}
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   867
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   868
\end{frame}}
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   869
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   870
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   871
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   872
\mode<presentation>{
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   873
\begin{frame}[c]
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   874
\frametitle{\begin{tabular}{c}Java Virtual Machine\end{tabular}}
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   875
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   876
\begin{itemize}
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   877
\item introduced in 1995
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   878
\item is a stack-based VM (like Postscript, CLR of .Net)
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   879
\item contains a JIT compiler
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   880
\item many languages take advantage of JVM's infrastructure (JRE)
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   881
\item is garbage collected $\Rightarrow$ no buffer overflows
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   882
\item some languages compile to the JVM: Scala, Clojure\ldots
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   883
\end{itemize}
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   884
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   885
\end{frame}}
b5e1cfaf3319 updated
Christian Urban <urbanc@in.tum.de>
parents: 462
diff changeset
   886
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
358
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   887
b3129cff41e9 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 290
diff changeset
   888
44
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   889
\end{document}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   890
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   891
%%% Local Variables:  
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   892
%%% mode: latex
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   893
%%% TeX-master: t
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   894
%%% End: 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   895