slides/slides06.tex
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Sat, 30 Nov 2013 00:06:02 +0000
changeset 214 5be68de225e9
parent 184 2e9134d25a2b
child 215 828303e8e4af
permissions -rw-r--r--
added
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
\documentclass[dvipsnames,14pt,t]{beamer}
168
e60c4a9ba340 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
     2
\usepackage{beamerthemeplaincu}
e60c4a9ba340 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
     3
%\usepackage[T1]{fontenc}
e60c4a9ba340 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
     4
%\usepackage[latin1]{inputenc}
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
\usepackage{mathpartir}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
\usepackage[absolute,overlay]{textpos}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
\usepackage{ifthen}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
\usepackage{tikz}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
\usepackage{pgf}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
\usepackage{calc} 
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
\usepackage{ulem}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
\usepackage{courier}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
\usepackage{listings}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
\renewcommand{\uline}[1]{#1}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
\usetikzlibrary{arrows}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
\usetikzlibrary{automata}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
\usetikzlibrary{shapes}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
\usetikzlibrary{shadows}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
\usetikzlibrary{positioning}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
\usetikzlibrary{calc}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
\usetikzlibrary{plotmarks}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
\usepackage{graphicx} 
168
e60c4a9ba340 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    23
\setmonofont{Consolas}
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
\definecolor{javared}{rgb}{0.6,0,0} % for strings
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
\definecolor{javagreen}{rgb}{0.25,0.5,0.35} % comments
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
\definecolor{javapurple}{rgb}{0.5,0,0.35} % keywords
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
\definecolor{javadocblue}{rgb}{0.25,0.35,0.75} % javadoc
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
168
e60c4a9ba340 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    30
\makeatletter
e60c4a9ba340 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    31
\lst@CCPutMacro\lst@ProcessOther {"2D}{\lst@ttfamily{-{}}{-{}}}
e60c4a9ba340 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    32
\@empty\z@\@empty
e60c4a9ba340 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    33
\makeatother
e60c4a9ba340 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    34
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
\lstdefinelanguage{scala}{
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
  morekeywords={abstract,case,catch,class,def,%
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
    do,else,extends,false,final,finally,%
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
    for,if,implicit,import,match,mixin,%
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
    new,null,object,override,package,%
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
    private,protected,requires,return,sealed,%
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
    super,this,throw,trait,true,try,%
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
    type,val,var,while,with,yield},
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
  otherkeywords={=>,<-,<\%,<:,>:,\#,@},
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
  sensitive=true,
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
  morecomment=[l]{//},
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
  morecomment=[n]{/*}{*/},
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
  morestring=[b]",
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
  morestring=[b]',
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
  morestring=[b]"""
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
168
e60c4a9ba340 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    53
\lstdefinelanguage{while}{
e60c4a9ba340 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    54
  morekeywords={while, if, then. else, read, write},
e60c4a9ba340 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    55
  otherkeywords={=>,<-,<\%,<:,>:,\#,@},
e60c4a9ba340 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    56
  sensitive=true,
e60c4a9ba340 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    57
  morecomment=[l]{//},
e60c4a9ba340 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    58
  morecomment=[n]{/*}{*/},
e60c4a9ba340 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    59
  morestring=[b]",
e60c4a9ba340 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    60
  morestring=[b]',
e60c4a9ba340 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    61
  morestring=[b]"""
e60c4a9ba340 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    62
}
e60c4a9ba340 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    63
e60c4a9ba340 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    64
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
\lstset{language=Scala,
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66
	basicstyle=\ttfamily,
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
	keywordstyle=\color{javapurple}\bfseries,
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
	stringstyle=\color{javagreen},
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
	commentstyle=\color{javagreen},
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
	morecomment=[s][\color{javadocblue}]{/**}{*/},
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
	numbers=left,
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
	numberstyle=\tiny\color{black},
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
	stepnumber=1,
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
	numbersep=10pt,
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
	tabsize=2,
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
	showspaces=false,
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    77
	showstringspaces=false}
168
e60c4a9ba340 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    78
	
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
% beamer stuff 
168
e60c4a9ba340 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
    81
\renewcommand{\slidecaption}{AFL 06, King's College London, 30.~October 2013}
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
\newcommand{\bl}[1]{\textcolor{blue}{#1}}       
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    83
\newcommand{\dn}{\stackrel{\mbox{\scriptsize def}}{=}}% for definitions
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
169
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
    86
\begin{filecontents}{s-grammar1.data}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
    87
1 0.01152
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
    88
51 0.07973
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
    89
101 0.09726
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
    90
151 0.09320
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
    91
201 0.10010
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
    92
251 0.16997
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
    93
301 0.26662
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
    94
351 0.46118
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
    95
401 0.62516
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
    96
451 0.87247
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
    97
501 1.16334
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
    98
551 1.71152
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
    99
601 2.10958
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   100
651 2.44360
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   101
701 2.98488
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   102
751 3.50326
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   103
801 4.11036
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   104
851 4.93394
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   105
901 5.77465
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   106
951 7.39123
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   107
\end{filecontents}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   108
169
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   109
\begin{filecontents}{s-grammar2.data}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   110
1 0.01280
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   111
2 0.00064
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   112
3 0.00173
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   113
4 0.00355
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   114
5 0.00965
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   115
6 0.02674
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   116
7 0.06953
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   117
8 0.11166
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   118
9 0.18707
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   119
10 0.09189
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   120
11 0.12724
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   121
12 0.24337
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   122
13 0.59304
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   123
14 1.53594
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   124
15 4.01195
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   125
16 10.73582
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   126
17 29.51587
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   127
#18 73.14163
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   128
\end{filecontents}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   129
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   130
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   131
\begin{document}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   132
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   133
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   134
\mode<presentation>{
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   135
\begin{frame}<1>[t]
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   136
\frametitle{%
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   137
  \begin{tabular}{@ {}c@ {}}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   138
  \\[-3mm]
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   139
  \LARGE Automata and \\[-2mm] 
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   140
  \LARGE Formal Languages (6)\\[3mm] 
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   141
  \end{tabular}}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   142
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   143
  \normalsize
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   144
  \begin{center}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   145
  \begin{tabular}{ll}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   146
  Email:  & christian.urban at kcl.ac.uk\\
168
e60c4a9ba340 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   147
  Office: & S1.27 (1st floor Strand Building)\\
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   148
  Slides: & KEATS (also home work is there)\\
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   149
  \end{tabular}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   150
  \end{center}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   151
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   152
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   153
\end{frame}}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   154
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
170
fa187fa5b642 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   155
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fa187fa5b642 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   156
\mode<presentation>{
fa187fa5b642 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   157
\begin{frame}[c]
fa187fa5b642 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   158
\frametitle{\begin{tabular}{c}Regular Languages\end{tabular}}
fa187fa5b642 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   159
fa187fa5b642 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   160
While regular expressions are very useful for lexing, 
fa187fa5b642 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   161
there is no regular expression that can recognise the language \bl{$a^nb^n$}.\bigskip
fa187fa5b642 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   162
fa187fa5b642 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   163
\begin{center}
fa187fa5b642 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   164
\bl{$(((()()))())$} \;\;vs.\;\; \bl{$(((()()))()))$}
fa187fa5b642 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   165
\end{center}
fa187fa5b642 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   166
fa187fa5b642 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   167
fa187fa5b642 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   168
\end{frame}}
fa187fa5b642 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   169
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   170
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   171
50
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   172
\newcommand{\qq}{\mbox{\texttt{"}}}
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   173
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   174
\mode<presentation>{
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   175
\begin{frame}[c]
50
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   176
\frametitle{\begin{tabular}{c}Grammars\end{tabular}}
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   177
53
Christian Urban <urbanc@in.tum.de>
parents: 52
diff changeset
   178
A (context-free) grammar \bl{$G$} consists of
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   179
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   180
\begin{itemize}
50
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   181
\item a finite set of nonterminal symbols (upper case)
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   182
\item a finite terminal symbols or tokens (lower case)
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   183
\item a start symbol (which must be a nonterminal)
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   184
\item a set of rules
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   185
\begin{center}
50
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   186
\bl{$A \rightarrow \text{rhs}$}
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   187
\end{center}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   188
169
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   189
where \bl{rhs} are sequences involving terminals and nonterminals,
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   190
including the empty sequence \bl{$\epsilon$}.\medskip\pause
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   191
169
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   192
We also allow rules
50
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   193
\begin{center}
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   194
\bl{$A \rightarrow \text{rhs}_1 | \text{rhs}_2 | \ldots$}
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   195
\end{center}
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   196
\end{itemize}
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   197
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   198
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   199
\end{frame}}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   200
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   201
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   202
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   203
\mode<presentation>{
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   204
\begin{frame}[c]
50
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   205
\frametitle{\begin{tabular}{c}Palindromes\end{tabular}}
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   206
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   207
\begin{center}
50
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   208
\bl{\begin{tabular}{lcl}
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   209
$S$ & $\rightarrow$ &  $\epsilon$ \\
53
Christian Urban <urbanc@in.tum.de>
parents: 52
diff changeset
   210
$S$ & $\rightarrow$ &  $a\cdot S\cdot a$ \\
Christian Urban <urbanc@in.tum.de>
parents: 52
diff changeset
   211
$S$ & $\rightarrow$ &  $b\cdot S\cdot b$ \\
50
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   212
\end{tabular}}
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   213
\end{center}\pause
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   214
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   215
or
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   216
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   217
\begin{center}
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   218
\bl{\begin{tabular}{lcl}
53
Christian Urban <urbanc@in.tum.de>
parents: 52
diff changeset
   219
$S$ & $\rightarrow$ &  $\epsilon \;|\; a\cdot S\cdot a \;|\;b\cdot S\cdot b$ \\
50
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   220
\end{tabular}}
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   221
\end{center}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   222
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   223
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   224
\end{frame}}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   225
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   226
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   227
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   228
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   229
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   230
\mode<presentation>{
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   231
\begin{frame}[c]
50
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   232
\frametitle{\begin{tabular}{c}Arithmetic Expressions\end{tabular}}
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   233
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   234
\begin{center}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   235
\bl{\begin{tabular}{lcl}
50
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   236
$E$ & $\rightarrow$ &  $num\_token$ \\
53
Christian Urban <urbanc@in.tum.de>
parents: 52
diff changeset
   237
$E$ & $\rightarrow$ &  $E \cdot + \cdot E$ \\
Christian Urban <urbanc@in.tum.de>
parents: 52
diff changeset
   238
$E$ & $\rightarrow$ &  $E \cdot - \cdot E$ \\
Christian Urban <urbanc@in.tum.de>
parents: 52
diff changeset
   239
$E$ & $\rightarrow$ &  $E \cdot * \cdot E$ \\
Christian Urban <urbanc@in.tum.de>
parents: 52
diff changeset
   240
$E$ & $\rightarrow$ &  $( \cdot E \cdot )$ 
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   241
\end{tabular}}
50
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   242
\end{center}\pause
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   243
50
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   244
\bl{\texttt{1 + 2 * 3 + 4}}
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   245
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   246
\end{frame}}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   247
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   248
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   249
169
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   250
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   251
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   252
\mode<presentation>{
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   253
\begin{frame}[c]
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   254
\frametitle{\begin{tabular}{c}A CFG Derivation\end{tabular}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   255
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   256
\begin{enumerate}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   257
\item Begin with a string containing only the start symbol, say \bl{$S$}\bigskip
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
   258
\item Replace any nonterminal \bl{$X$} in the string by the
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
   259
right-hand side of some production \bl{$X \rightarrow \text{rhs}$}\bigskip
169
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   260
\item Repeat 2 until there are no nonterminals
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   261
\end{enumerate}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   262
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   263
\begin{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   264
\bl{$S \rightarrow \ldots \rightarrow \ldots  \rightarrow \ldots  \rightarrow \ldots $}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   265
\end{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   266
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   267
\end{frame}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   268
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   269
  
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   270
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   271
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   272
\mode<presentation>{
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   273
\begin{frame}[c]
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   274
\frametitle{\begin{tabular}{c}Example Derivation\end{tabular}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   275
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   276
\begin{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   277
\bl{\begin{tabular}{lcl}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   278
$S$ & $\rightarrow$ &  $\epsilon \;|\; a\cdot S\cdot a \;|\;b\cdot S\cdot b$ \\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   279
\end{tabular}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   280
\end{center}\bigskip
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   281
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   282
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   283
\begin{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   284
\begin{tabular}{lcl}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   285
\bl{$S$} & \bl{$\rightarrow$} & \bl{$aSa$}\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   286
              & \bl{$\rightarrow$} & \bl{$abSba$}\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   287
              & \bl{$\rightarrow$} & \bl{$abaSaba$}\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   288
              & \bl{$\rightarrow$} & \bl{$abaaba$}\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   289
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   290
 
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   291
\end{tabular}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   292
\end{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   293
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   294
\end{frame}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   295
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   296
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   297
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   298
\mode<presentation>{
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   299
\begin{frame}[c]
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   300
\frametitle{\begin{tabular}{c}Example Derivation\end{tabular}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   301
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   302
\begin{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   303
\bl{\begin{tabular}{lcl}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   304
$E$ & $\rightarrow$ &  $num\_token$ \\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   305
$E$ & $\rightarrow$ &  $E \cdot + \cdot E$ \\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   306
$E$ & $\rightarrow$ &  $E \cdot - \cdot E$ \\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   307
$E$ & $\rightarrow$ &  $E \cdot * \cdot E$ \\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   308
$E$ & $\rightarrow$ &  $( \cdot E \cdot )$ 
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   309
\end{tabular}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   310
\end{center}\bigskip
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   311
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   312
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   313
\begin{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   314
\begin{tabular}{@{}c@{}c@{}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   315
\begin{tabular}{l@{\hspace{1mm}}l@{\hspace{1mm}}l}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   316
\bl{$E$} & \bl{$\rightarrow$} & \bl{$E*E$}\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   317
              & \bl{$\rightarrow$} & \bl{$E+E*E$}\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   318
              & \bl{$\rightarrow$} & \bl{$E+E*E+E$}\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   319
              & \bl{$\rightarrow^+$} & \bl{$1+2*3+4$}\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   320
\end{tabular} &\pause
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   321
\begin{tabular}{l@{\hspace{1mm}}l@{\hspace{1mm}}l}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   322
\bl{$E$} & \bl{$\rightarrow$} & \bl{$E+E$}\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   323
              & \bl{$\rightarrow$} & \bl{$E+E+E$}\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   324
              & \bl{$\rightarrow$} & \bl{$E+E*E+E$}\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   325
              & \bl{$\rightarrow^+$} & \bl{$1+2*3+4$}\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   326
\end{tabular}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   327
\end{tabular}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   328
\end{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   329
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   330
\end{frame}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   331
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   332
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   333
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   334
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   335
\mode<presentation>{
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   336
\begin{frame}[c]
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   337
\frametitle{\begin{tabular}{c}Language of a CFG\end{tabular}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   338
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   339
Let \bl{$G$} be a context-free grammar with start symbol \bl{$S$}. 
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   340
Then the language \bl{$L(G)$} is:
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   341
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   342
\begin{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   343
\bl{$\{c_1\ldots c_n \;|\; \forall i.\; c_i \in T \wedge S \rightarrow^* c_1\ldots c_n \}$}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   344
\end{center}\pause
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   345
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   346
\begin{itemize}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   347
\item Terminals, because there are no rules for replacing them.
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   348
\item Once generated, terminals are ``permanent''.
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   349
\item Terminals ought to be tokens of the language\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   350
(but can also be strings).
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   351
\end{itemize}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   352
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   353
\end{frame}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   354
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   355
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   356
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   357
\mode<presentation>{
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   358
\begin{frame}[c]
50
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   359
\frametitle{\begin{tabular}{c}Parse Trees\end{tabular}}
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   360
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   361
\begin{center}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   362
\bl{\begin{tabular}{lcl}
53
Christian Urban <urbanc@in.tum.de>
parents: 52
diff changeset
   363
$E$ & $\rightarrow$ &  $F \;|\; F \cdot * \cdot F$\\
Christian Urban <urbanc@in.tum.de>
parents: 52
diff changeset
   364
$F$ & $\rightarrow$ & $T \;|\; T \cdot + \cdot T \;|\; T \cdot - \cdot T$\\
Christian Urban <urbanc@in.tum.de>
parents: 52
diff changeset
   365
$T$ & $\rightarrow$ & $num\_token \;|\; ( \cdot E \cdot )$\\
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   366
\end{tabular}}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   367
\end{center}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   368
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   369
\begin{center}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   370
\begin{tikzpicture}[level distance=8mm, blue]
50
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   371
  \node {$E$}
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   372
    child {node {$F$} 
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   373
     child {node {$T$} 
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   374
                 child {node {(\,$E$\,)}
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   375
                            child {node{$F$ *{} $F$}
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   376
                                  child {node {$T$} child {node {2}}}
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   377
                                  child {node {$T$} child {node {3}}} 
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   378
                               }
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   379
                          }
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   380
              }
50
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   381
     child {node {+}}
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   382
     child {node {$T$}
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   383
       child {node {(\,$E$\,)} 
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   384
       child {node {$F$}
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   385
       child {node {$T$ +{} $T$}
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   386
                    child {node {3}}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   387
                    child {node {4}} 
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   388
                 }
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   389
                 }}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   390
    }};
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   391
\end{tikzpicture}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   392
\end{center}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   393
50
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   394
\begin{textblock}{5}(1, 6.5)
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   395
\bl{\texttt{(2*3)+(3+4)}}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   396
\end{textblock}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   397
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   398
\end{frame}}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   399
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
169
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   400
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   401
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   402
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   403
\mode<presentation>{
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   404
\begin{frame}[c]
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   405
\frametitle{\begin{tabular}{c}Arithmetic Expressions\end{tabular}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   406
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   407
\begin{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   408
\bl{\begin{tabular}{lcl}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   409
$E$ & $\rightarrow$ &  $num\_token$ \\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   410
$E$ & $\rightarrow$ &  $E \cdot + \cdot E$ \\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   411
$E$ & $\rightarrow$ &  $E \cdot - \cdot E$ \\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   412
$E$ & $\rightarrow$ &  $E \cdot * \cdot E$ \\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   413
$E$ & $\rightarrow$ &  $( \cdot E \cdot )$ 
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   414
\end{tabular}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   415
\end{center}\pause\bigskip
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   416
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   417
A CFG is \alert{left-recursive} if it has a nonterminal \bl{$E$} such
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   418
that \bl{$E \rightarrow^+ E\cdot \ldots$}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   419
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   420
\end{frame}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   421
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   422
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   423
50
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   424
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   425
\mode<presentation>{
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   426
\begin{frame}[c]
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   427
\frametitle{\begin{tabular}{c}Ambiguous Grammars\end{tabular}}
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   428
169
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   429
A grammar is \alert{ambiguous} if there is a string that has at least two different parse trees.
50
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   430
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   431
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   432
\begin{center}
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   433
\bl{\begin{tabular}{lcl}
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   434
$E$ & $\rightarrow$ &  $num\_token$ \\
53
Christian Urban <urbanc@in.tum.de>
parents: 52
diff changeset
   435
$E$ & $\rightarrow$ &  $E \cdot + \cdot E$ \\
Christian Urban <urbanc@in.tum.de>
parents: 52
diff changeset
   436
$E$ & $\rightarrow$ &  $E \cdot - \cdot E$ \\
Christian Urban <urbanc@in.tum.de>
parents: 52
diff changeset
   437
$E$ & $\rightarrow$ &  $E \cdot * \cdot E$ \\
Christian Urban <urbanc@in.tum.de>
parents: 52
diff changeset
   438
$E$ & $\rightarrow$ &  $( \cdot E \cdot )$ 
50
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   439
\end{tabular}}
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   440
\end{center}
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   441
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   442
\bl{\texttt{1 + 2 * 3 + 4}}
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   443
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   444
\end{frame}}
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   445
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   446
169
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   447
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   448
\mode<presentation>{
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   449
\begin{frame}[c]
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   450
\frametitle{\begin{tabular}{c}Dangling Else\end{tabular}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   451
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   452
Another ambiguous grammar:\bigskip
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   453
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   454
\begin{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   455
\bl{\begin{tabular}{lcl}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   456
$E$ & $\rightarrow$ &  if $E$ then $E$\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   457
 & $|$ &  if $E$ then $E$ else $E$ \\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   458
 & $|$ &  \ldots
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   459
\end{tabular}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   460
\end{center}\bigskip
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   461
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   462
\bl{\texttt{if a then if x then y else c}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   463
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   464
\end{frame}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   465
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   466
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   467
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   468
\mode<presentation>{
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   469
\begin{frame}[c]
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   470
\frametitle{\begin{tabular}{c}Parser Combinators\end{tabular}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   471
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   472
Parser combinators: \bigskip
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   473
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   474
\begin{minipage}{1.1\textwidth}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   475
\begin{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   476
\mbox{}\hspace{-12mm}\mbox{}$\underbrace{\text{list of tokens}}_{\text{input}}$ \bl{$\Rightarrow$} 
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   477
$\underbrace{\text{set of (parsed input, unparsed input)}}_{\text{output}}$
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   478
\end{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   479
\end{minipage}\bigskip
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   480
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   481
\begin{itemize}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   482
\item sequencing
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   483
\item alternative
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   484
\item semantic action
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   485
\end{itemize}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   486
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   487
\end{frame}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   488
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   489
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   490
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   491
\mode<presentation>{
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   492
\begin{frame}[c]
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   493
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   494
Alternative parser (code \bl{$p\;||\;q$})\bigskip
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   495
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   496
\begin{itemize}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   497
\item apply \bl{$p$} and also \bl{$q$}; then combine the outputs
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   498
\end{itemize}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   499
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   500
\begin{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   501
\large \bl{$p(\text{input}) \cup q(\text{input})$}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   502
\end{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   503
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   504
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   505
\end{frame}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   506
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   507
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   508
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   509
\mode<presentation>{
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   510
\begin{frame}[c]
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   511
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   512
Sequence parser (code \bl{$p\sim q$})\bigskip
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   513
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   514
\begin{itemize}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   515
\item apply first \bl{$p$} producing a set of pairs
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   516
\item then apply \bl{$q$} to the unparsed parts
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   517
\item then combine the results:\\ \mbox{}\;\;((output$_1$, output$_2$), unparsed part)
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   518
\end{itemize}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   519
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   520
\begin{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   521
\begin{tabular}{l}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   522
\large \bl{$\{((o_1, o_2), u_2) \;|\;$}\\[2mm] 
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   523
\large\mbox{}\hspace{15mm} \bl{$(o_1, u_1) \in p(\text{input}) \wedge$}\\[2mm]
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   524
\large\mbox{}\hspace{15mm} \bl{$(o_2, u_2) \in q(u_1)\}$}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   525
\end{tabular}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   526
\end{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   527
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   528
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   529
\end{frame}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   530
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   531
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   532
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   533
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   534
\mode<presentation>{
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   535
\begin{frame}[c]
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   536
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   537
Function parser (code \bl{$p \Rightarrow f$})\bigskip
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   538
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   539
\begin{itemize}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   540
\item apply \bl{$p$} producing a set of pairs
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   541
\item then apply the function \bl{$f$} to each first component
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   542
\end{itemize}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   543
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   544
\begin{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   545
\begin{tabular}{l}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   546
\large \bl{$\{(f(o_1), u_1) \;|\; (o_1, u_1) \in p(\text{input})\}$}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   547
\end{tabular}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   548
\end{center}\bigskip\bigskip\pause
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   549
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   550
\bl{$f$} is the semantic action (``what to do with the parsed input'')
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   551
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   552
\end{frame}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   553
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   554
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   555
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   556
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   557
\mode<presentation>{
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   558
\begin{frame}[c]
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   559
\frametitle{\begin{tabular}{c}Semantic Actions\end{tabular}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   560
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   561
Addition
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   562
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   563
\begin{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   564
\bl{$T \sim + \sim E \Rightarrow \underbrace{f((x,y), z) \Rightarrow x + z}_{\text{semantic action}}$}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   565
\end{center}\pause
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   566
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   567
Multiplication
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   568
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   569
\begin{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   570
\bl{$F \sim * \sim T \Rightarrow f((x,y), z) \Rightarrow x * z$}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   571
\end{center}\pause
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   572
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   573
Parenthesis
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   574
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   575
\begin{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   576
\bl{$\text{(} \sim E \sim \text{)} \Rightarrow f((x,y), z) \Rightarrow y$}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   577
\end{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   578
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   579
\end{frame}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   580
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   581
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   582
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   583
\mode<presentation>{
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   584
\begin{frame}[c]
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   585
\frametitle{\begin{tabular}{c}Types of Parsers\end{tabular}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   586
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   587
\begin{itemize}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   588
\item {\bf Sequencing}: if \bl{$p$} returns results of type \bl{$T$}, and \bl{$q$} results of type \bl{$S$},
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   589
then \bl{$p \sim q$} returns results of type
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   590
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   591
\begin{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   592
\bl{$T \times S$}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   593
\end{center}\pause
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   594
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   595
\item {\bf Alternative}: if \bl{$p$} returns results of type \bl{$T$} then  \bl{$q$} \alert{must} also have results of type \bl{$T$},
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   596
and \bl{$p \;||\; q$} returns results of type
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   597
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   598
\begin{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   599
\bl{$T$}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   600
\end{center}\pause
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   601
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   602
\item {\bf Semantic Action}: if \bl{$p$} returns results of type \bl{$T$} and \bl{$f$} is a function from
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   603
\bl{$T$} to \bl{$S$}, then
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   604
\bl{$p \Rightarrow f$} returns results of type
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   605
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   606
\begin{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   607
\bl{$S$}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   608
\end{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   609
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   610
\end{itemize}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   611
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   612
\end{frame}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   613
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   614
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   615
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   616
\mode<presentation>{
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   617
\begin{frame}[c]
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   618
\frametitle{\begin{tabular}{c}Input Types of Parsers\end{tabular}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   619
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   620
\begin{itemize}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   621
\item input: \alert{string}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   622
\item output: set of (output\_type, \alert{string})
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   623
\end{itemize}\bigskip\pause
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   624
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   625
actually it can be any input type as long as it is a kind of sequence
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   626
(for example a string)
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   627
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   628
\end{frame}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   629
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   630
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   631
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   632
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   633
\mode<presentation>{
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   634
\begin{frame}[c]
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   635
\frametitle{\begin{tabular}{c}Scannerless Parsers\end{tabular}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   636
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   637
\begin{itemize}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   638
\item input: \alert{string}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   639
\item output: set of (output\_type, \alert{string})
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   640
\end{itemize}\bigskip
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   641
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   642
but lexers are better when whitespaces or comments need to be filtered out;
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   643
then input is a sequence of tokens
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   644
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   645
\end{frame}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   646
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   647
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   648
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   649
\mode<presentation>{
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   650
\begin{frame}[c]
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   651
\frametitle{\begin{tabular}{c}Successful Parses\end{tabular}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   652
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   653
\begin{itemize}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   654
\item input: string
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   655
\item output: \alert{set of} (output\_type, string)
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   656
\end{itemize}\bigskip
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   657
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   658
a parse is successful whenever the input has been
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   659
fully ``consumed'' (that is the second component is empty)
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   660
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   661
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   662
\end{frame}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   663
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   664
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   665
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   666
\mode<presentation>{
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   667
\begin{frame}[c]
170
fa187fa5b642 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
   668
\frametitle{Abstract Parser Class}
169
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   669
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   670
\mbox{\lstset{language=Scala}\fontsize{10}{12}\selectfont
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   671
\texttt{\lstinputlisting{../progs/app7.scala}}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   672
\end{frame}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   673
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   674
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   675
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   676
\mode<presentation>{
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   677
\begin{frame}[c]
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   678
{\lstset{language=Scala}\fontsize{10}{12}\selectfont
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   679
\texttt{\lstinputlisting{../progs/app8.scala}}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   680
\end{frame}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   681
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   682
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   683
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   684
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   685
\mode<presentation>{
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   686
\begin{frame}[c]
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   687
\frametitle{\begin{tabular}{c}Two Grammars\end{tabular}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   688
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   689
Which languages are recognised by the following two grammars?
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   690
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   691
\begin{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   692
\bl{\begin{tabular}{lcl}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   693
$S$ & $\rightarrow$ &  $1 \cdot S \cdot S$\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   694
        & $|$ & $\epsilon$
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   695
\end{tabular}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   696
\end{center}\bigskip
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   697
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   698
\begin{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   699
\bl{\begin{tabular}{lcl}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   700
$U$ & $\rightarrow$ &  $1 \cdot U$\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   701
        & $|$ & $\epsilon$
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   702
\end{tabular}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   703
\end{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   704
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   705
\end{frame}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   706
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   707
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   708
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   709
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   710
\mode<presentation>{
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   711
\begin{frame}[t]
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   712
\frametitle{\begin{tabular}{c}Ambiguous Grammars\end{tabular}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   713
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   714
\mbox{}\\[-25mm]\mbox{}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   715
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   716
\begin{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   717
\begin{tikzpicture}[y=.2cm, x=.009cm]
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   718
 	%axis
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   719
	\draw (0,0) -- coordinate (x axis mid) (1000,0);
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   720
    	\draw (0,0) -- coordinate (y axis mid) (0,30);
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   721
    	%ticks
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   722
    	\foreach \x in {0, 20, 100, 200,...,1000}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   723
     		\draw (\x,1pt) -- (\x,-3pt)
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   724
			node[anchor=north] {\small \x};
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   725
    	\foreach \y in {0,5,...,30}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   726
     		\draw (1pt,\y) -- (-3pt,\y) 
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   727
     			node[anchor=east] {\small\y}; 
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   728
	%labels      
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   729
	\node[below=0.6cm] at (x axis mid) {\bl{1}s};
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   730
	\node[rotate=90, left=1.2cm] at (y axis mid) {secs};
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   731
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   732
	%plots
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   733
	\draw[color=blue] plot[mark=*, mark options={fill=white}] 
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   734
		file {s-grammar1.data};
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   735
         \only<2->{\draw[color=red] plot[mark=triangle*, mark options={fill=white} ] 
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   736
                  file {s-grammar2.data};}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   737
	%legend
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   738
	\begin{scope}[shift={(400,20)}] 
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   739
	\draw[color=blue] (0,0) -- 
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   740
		plot[mark=*, mark options={fill=white}] (0.25,0) -- (0.5,0) 
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   741
		node[right]{\small unambiguous};
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   742
	\only<2->{\draw[yshift=\baselineskip, color=red] (0,0) -- 
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   743
                plot[mark=triangle*, mark options={fill=white}] (0.25,0) -- (0.5,0)
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   744
                node[right]{\small ambiguous};}  
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   745
	\end{scope}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   746
\end{tikzpicture}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   747
\end{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   748
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   749
\end{frame}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   750
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   751
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   752
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   753
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   754
\mode<presentation>{
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   755
\begin{frame}[c]
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   756
\frametitle{\begin{tabular}{c}While-Language\end{tabular}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   757
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   758
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   759
\begin{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   760
\bl{\begin{tabular}{@{}lcl@{}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   761
$Stmt$ & $\rightarrow$ &  $\text{skip}$\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   762
              & $|$ & $Id := AExp$\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   763
              & $|$ & $\text{if}\; B\!Exp \;\text{then}\; Block \;\text{else}\; Block$\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   764
              & $|$ & $\text{while}\; B\!Exp \;\text{do}\; Block$\medskip\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   765
$Stmts$ & $\rightarrow$ &  $Stmt \;\text{;}\; Stmts$\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   766
              & $|$ & $Stmt$\medskip\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   767
$Block$ & $\rightarrow$ &  $\{ Stmts \}$\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   768
                & $|$ & $Stmt$\medskip\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   769
$AExp$ & $\rightarrow$ & \ldots\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   770
$BExp$ & $\rightarrow$ & \ldots\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   771
\end{tabular}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   772
\end{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   773
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   774
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   775
\end{frame}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   776
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   777
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   778
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   779
\mode<presentation>{
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   780
\begin{frame}[c]
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   781
\frametitle{\begin{tabular}{c}An Interpreter\end{tabular}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   782
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   783
\begin{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   784
\bl{\begin{tabular}{l}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   785
$\{$\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   786
\;\;$x := 5 \text{;}$\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   787
\;\;$y := x * 3\text{;}$\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   788
\;\;$y := x * 4\text{;}$\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   789
\;\;$x := u * 3$\\
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   790
$\}$
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   791
\end{tabular}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   792
\end{center}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   793
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   794
\begin{itemize}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   795
\item the interpreter has to record the value of \bl{$x$} before assigning a value to \bl{$y$}\pause
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   796
\item \bl{\text{eval}(stmt, env)}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   797
\end{itemize}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   798
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   799
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   800
\end{frame}}
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   801
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
57df3d7b4a25 added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   802
50
Christian Urban <urbanc@in.tum.de>
parents: 49
diff changeset
   803
184
2e9134d25a2b added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
   804
  
53
Christian Urban <urbanc@in.tum.de>
parents: 52
diff changeset
   805
51
6fe4facb56a6 updated
Christian Urban <urbanc@in.tum.de>
parents: 50
diff changeset
   806
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   807
\end{document}
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   808
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   809
%%% Local Variables:  
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   810
%%% mode: latex
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   811
%%% TeX-master: t
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   812
%%% End: 
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   813