slides/slides04.tex
changeset 451 4a5876f321ae
parent 447 68769db65185
child 452 b93f4d2aeee1
--- a/slides/slides04.tex	Thu Oct 13 13:13:27 2016 +0100
+++ b/slides/slides04.tex	Sat Oct 15 14:27:01 2016 +0100
@@ -1053,13 +1053,77 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
 
 
-
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
 \begin{frame}[c]
 
 {\footnotesize\lstinputlisting[language=Scala,numbers=none,
 xleftmargin=-5mm] {../progs/app06.scala}}
 
 \end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[t]
+\frametitle{Rectification Example}
+
+\begin{center}
+\bl{$\only<1>{(b \cdot c)}%
+     \only<2-3>{(\underline{b \cdot c})}%
+     \only<1-3>{+}% 
+     \only<1>{(\ZERO + \ONE)}%
+     \only<2-3>{(\underline{\ZERO + \ONE})}$}%
+\only<4->{%
+\bl{$\underline{(b \cdot c) + (\ZERO + \ONE)}$}%
+}
+$\mapsto$
+\bl{$(b \cdot c) + \ONE$}
+\end{center}\bigskip
+
+\onslide<3->{%
+\begin{center}
+\begin{tabular}{lcl}
+\bl{$f_{s1}$} & \bl{$=$} & \bl{$\lambda v.v$}\\
+\bl{$f_{s2}$} & \bl{$=$} & \bl{$\lambda v. \textit{Right}(v)$}
+\end{tabular}
+\end{center}}
+
+\only<4>{%
+\begin{center}
+\begin{tabular}{@{}l@{\hspace{1mm}}l@{}}
+\bl{$f_{alt}(f_{s1}, f_{s2}) \dn$}\\
+\quad \bl{$\lambda v.\,$} 
+        case \bl{$v = Left(v')$}: 
+      & return \bl{$Left(f_{s1}(v'))$}\\
+\quad \phantom{$\lambda v.\,$} 
+        case \bl{$v = Right(v')$}: 
+      & return \bl{$Right(f_{s2}(v'))$}\\ 
+\end{tabular}
+\end{center}}%
+\only<5->{%
+\begin{center}
+\begin{tabular}{@{}l@{\hspace{1mm}}l@{}}
+\only<5->{\phantom{\bl{$f_{alt}(f_{s1}, f_{s2}) \dn$}}}\\
+\quad \bl{$\lambda v.\,$} 
+        case \bl{$v = Left(v')$}: 
+      & return \bl{$Left(v')$}\\
+\quad \phantom{$\lambda v.\,$} 
+        case \bl{$v = Right(v')$}: 
+      & return \bl{$Right(Right(v'))$}\\ 
+\end{tabular}
+\end{center}}%
+
+\only<6->{%
+\begin{center}
+\begin{tabular}{@{}l@{\hspace{4mm}}l@{}}
+\bl{$\textit{mkeps}$} simplified case: &
+\bl{$\textit{Right}(\textit{Empty})$}\\
+rectified case: &
+\bl{$\textit{Right}(\textit{Right}(\textit{Empty}))$}
+\end{tabular}
+\end{center}}%
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -1103,6 +1167,116 @@
 \end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c]
+\frametitle{Environments}
+
+Obtaining the ``recorded'' parts of a value: 
+
+\begin{center}
+\begin{tabular}{lcl}
+  \bl{$env(Empty)$}     & \bl{$\dn$} & \bl{$[]$}\\
+  \bl{$env(Char(c))$}   & \bl{$\dn$} & \bl{$[]$}\\
+  \bl{$env(Left(v))$}   & \bl{$\dn$} & \bl{$env(v)$}\\
+  \bl{$env(Right(v))$}  & \bl{$\dn$} & \bl{$env(v)$}\\
+  \bl{$env(Seq(v_1,v_2))$}& \bl{$\dn$} & \bl{$env(v_1) \,@\, env(v_2)$}\\
+  \bl{$env([v_1,\ldots ,v_n])$} & \bl{$\dn$} & 
+     \bl{$env(v_1) \,@\ldots @\, env(v_n)$}\\
+  \bl{$env(Rec(x:v))$} & \bl{$\dn$} & \bl{$(x:|v|) :: env(v)$}\\
+\end{tabular}
+\end{center}
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c]
+\frametitle{While Tokens}
+
+\begin{center}
+\begin{tabular}{@{}r@{\hspace{2mm}}c@{\hspace{2mm}}l@{}}
+\pcode{WHILE\_REGS} & $\dn$ & \raisebox{-1mm}{\large(}\pcode{("k" : KEYWORD)} +\\ 
+                  &       & \phantom{(}\pcode{("i" : ID)} +\\ 
+                  &       & \phantom{(}\pcode{("o" : OP)} + \\
+                  &       & \phantom{(}\pcode{("n" : NUM)} + \\
+                  &       & \phantom{(}\pcode{("s" : SEMI)} +\\ 
+                  &       & \phantom{(}\pcode{("p" : (LPAREN + RPAREN))} +\\ 
+                  &       & \phantom{(}\pcode{("b" : (BEGIN + END))} +\\ 
+                  &       & \phantom{(}\pcode{("w" : WHITESPACE)}\raisebox{-1mm}{\large)$^*$}
+\end{tabular}
+\end{center}
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[t]
+
+\consolas
+\begin{center}
+\code{"if true then then 42 else +"}
+\end{center}
+
+\only<1>{
+\small\begin{tabular}{l}
+KEYWORD(if),\\ 
+WHITESPACE,\\ 
+IDENT(true),\\ 
+WHITESPACE,\\ 
+KEYWORD(then),\\ 
+WHITESPACE,\\ 
+KEYWORD(then),\\ 
+WHITESPACE,\\ 
+NUM(42),\\ 
+WHITESPACE,\\ 
+KEYWORD(else),\\ 
+WHITESPACE,\\ 
+OP(+)
+\end{tabular}}
+
+\only<2>{
+\small\begin{tabular}{l}
+KEYWORD(if),\\ 
+IDENT(true),\\ 
+KEYWORD(then),\\ 
+KEYWORD(then),\\ 
+NUM(42),\\ 
+KEYWORD(else),\\ 
+OP(+)
+\end{tabular}}
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c]
+\frametitle{Two Rules}
+
+\begin{itemize}
+\item Longest match rule (``maximal munch rule''): The 
+longest initial substring matched by any regular expression is taken
+as next token.\bigskip
+
+\item Rule priority:
+For a particular longest initial substring, the first regular
+expression that can match determines the token.
+
+\end{itemize}
+
+%\url{http://www.technologyreview.com/tr10/?year=2011}
+  
+%finite deterministic automata/ nondeterministic automaton
+
+%\item problem with infix operations, for example i-12
+
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
+
+
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \begin{frame}[c]