slides/slides04.tex
changeset 273 b56d5e4468c0
parent 272 1446bc47a294
child 274 21f0f24424ab
equal deleted inserted replaced
272:1446bc47a294 273:b56d5e4468c0
   569 \node (v1) [left=of v2] {\bl{$v_1$}};
   569 \node (v1) [left=of v2] {\bl{$v_1$}};
   570 \draw[->,line width=1mm]  (v2) -- (v1) node[below,midway] {\bl{$inj\,a$}};\pause
   570 \draw[->,line width=1mm]  (v2) -- (v1) node[below,midway] {\bl{$inj\,a$}};\pause
   571 \draw[->,line width=0.5mm]  (r3) -- (v3);
   571 \draw[->,line width=0.5mm]  (r3) -- (v3);
   572 \draw[->,line width=0.5mm]  (r2) -- (v2);
   572 \draw[->,line width=0.5mm]  (r2) -- (v2);
   573 \draw[->,line width=0.5mm]  (r1) -- (v1);
   573 \draw[->,line width=0.5mm]  (r1) -- (v1);
   574 \end{tikzpicture}
   574 \draw (r4) node[anchor=north west] {\;\raisebox{-8mm}{\bl{$mkeps$}}};
   575 \end{center}
   575 \end{tikzpicture}
   576 
   576 \end{center}
   577 \end{frame}
   577 
   578 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   578 \end{frame}
       
   579 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
       
   580 
       
   581 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   582 \begin{frame}[c]
       
   583 \frametitle{Regexes and Values}
       
   584 
       
   585 Regular expressions and their corresponding values:
       
   586 
       
   587 \begin{center}
       
   588 \begin{columns}
       
   589 \begin{column}{3cm}
       
   590 \begin{tabular}{@{}rrl@{}}
       
   591   \bl{$r$} & \bl{$::=$}  & \bl{$\varnothing$}\\
       
   592            & \bl{$\mid$} & \bl{$\epsilon$}   \\
       
   593            & \bl{$\mid$} & \bl{$c$}          \\
       
   594            & \bl{$\mid$} & \bl{$r_1 \cdot r_2$}\\
       
   595            & \bl{$\mid$} & \bl{$r_1 + r_2$}   \\
       
   596   \\
       
   597            & \bl{$\mid$} & \bl{$r^*$}         \\
       
   598   \\
       
   599   \end{tabular}
       
   600 \end{column}
       
   601 \begin{column}{3cm}
       
   602 \begin{tabular}{@{\hspace{-7mm}}rrl@{}}
       
   603   \bl{$v$} & \bl{$::=$}  & \\
       
   604            &             & \bl{$Empty$}   \\
       
   605            & \bl{$\mid$} & \bl{$Char(c)$}          \\
       
   606            & \bl{$\mid$} & \bl{$Seq(v_1\,v_2)$}\\
       
   607            & \bl{$\mid$} & \bl{$Left(v)$}   \\
       
   608            & \bl{$\mid$} & \bl{$Right(v)$}  \\
       
   609            & \bl{$\mid$} & \bl{$[]$}      \\
       
   610            & \bl{$\mid$} & \bl{$[v_1,\ldots\,v_n]$} \\
       
   611   \end{tabular}
       
   612 \end{column}
       
   613 \end{columns}
       
   614 \end{center}
       
   615 
       
   616 \end{frame}
       
   617 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
       
   618 
       
   619 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   620 \begin{frame}[c]
       
   621 \frametitle{Mkeps}
       
   622 
       
   623 Finding a (posix) value for recognising the empty string
       
   624 
       
   625 \begin{center}
       
   626 \begin{tabular}{lcl}
       
   627   \bl{$mkeps\,\epsilon$}  & \bl{$\dn$}  & \bl{$Empty$}\\
       
   628   \bl{$mkeps\,r_1 + r_2$} & \bl{$\dn$}  & \bl{if $nullable(r_1)$}  \\
       
   629                           &             & \bl{then $Left(mkeps(r_1))$}\\
       
   630                           &             & \bl{else $Right(mkeps(r_2))$}\\
       
   631   \bl{$mkeps\,r_1 \cdot r_2$}  & \bl{$\dn$} & \bl{$Seq(mkeps(r_1),mkeps(r_2))$}\\
       
   632   \bl{$mkeps\,r^*$}      & \bl{$\dn$} & \bl{$[]$}  \\
       
   633 \end{tabular}
       
   634 \end{center}
       
   635 
       
   636 \end{frame}
       
   637 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
       
   638 
       
   639 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   640 \begin{frame}[c]
       
   641 \frametitle{Inject}
       
   642 
       
   643 Injecting (``Adding'') a character to a value\\
       
   644 
       
   645 \begin{center}
       
   646 \begin{tabular}{l@{\hspace{1mm}}c@{\hspace{1mm}}l}
       
   647   \bl{$inj\,(c)\,c\,Empty$} & \bl{$\dn$}  & \bl{$Char\,c$}\\
       
   648   \bl{$inj\,(r_1 + r_2)\,c\,Left(v)$} & \bl{$\dn$}  & \bl{$Left(inj\,r_1\,c\,v)$}\\
       
   649   \bl{$inj\,(r_1 + r_2)\,c\,Right(v)$} & \bl{$\dn$}  & \bl{$Right(inj\,r_2\,c\,v)$}\\
       
   650   \bl{$inj\,(r_1 \cdot r_2)\,c\,Seq(v_1,v_2)$} & \bl{$\dn$}  & \bl{$Seq(inj\,r_1\,c\,v_1,v_2)$}\\
       
   651   \bl{$inj\,(r_1 \cdot r_2)\,c\,Left(Seq(v_1,v_2))$} & \bl{$\dn$}  & \bl{$Seq(inj\,r_1\,c\,v_1,v_2)$}\\
       
   652   \bl{$inj\,(r_1 \cdot r_2)\,c\,Right(v)$} & \bl{$\dn$}  & \bl{$Seq(mkeps(r_1),inj\,r_2\,c\,v)$}\\
       
   653   \bl{$inj\,(r^*)\,c\,Sequ(v,vs)$} & \bl{$\dn$}  & \bl{$inj\,r\,c\,v\,::\,vs$}\\
       
   654 \end{tabular}
       
   655 \end{center}\bigskip
       
   656 
       
   657 \footnotesize
       
   658 \bl{$inj$}: 1st arg $\mapsto$ a rexp; 2nd arg $\mapsto$ a character; 3rd arg $\mapsto$ a value 
       
   659 \end{frame}
       
   660 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
       
   661 
       
   662 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   663 \begin{frame}[c]
       
   664 \frametitle{Lexing}
       
   665 
       
   666 \begin{center}
       
   667 \begin{tabular}{l@{\hspace{1mm}}c@{\hspace{1mm}}l}
       
   668   \bl{$lex\,r\,[]$} & \bl{$\dn$}  & \bl{if $nullable(r)$ then $mkeps(r)$ else $error$}\\
       
   669   \bl{$lex\,r\,c::s$} & \bl{$\dn$}  & \bl{$inj\,r\,c\,lex(der(c,r), s)$}\\
       
   670 \end{tabular}
       
   671 \end{center}
       
   672 
       
   673 \footnotesize
       
   674 \bl{$lex$}: returns a value
       
   675 \end{frame}
       
   676 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
       
   677 
       
   678 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   679 \begin{frame}[c]
       
   680 \frametitle{Records}
       
   681 
       
   682 \begin{itemize}
       
   683 \item new regex: \bl{$(x:r)$}\hspace{7mm}new value: \bl{$Rec(x,v)$}\medskip\pause
       
   684 
       
   685 \item \bl{$nullable(x:r) \dn nullable(r)$}
       
   686 \item \bl{$der\,c\,(x:r) \dn (x:der\,c\,r)$}
       
   687 \item \bl{$mkeps(x:r) \dn Rec(x, mkeps(r))$}
       
   688 \item \bl{$inj\,(x:r)\,c\,v \dn Rec(x, inj\,r\,c\,v)$}
       
   689 \end{itemize}\bigskip\bigskip\pause
       
   690 
       
   691 \small
       
   692 for extracting subpatterns \bl{$(z: ((x:ab) + (y:ba))$}
       
   693 
       
   694 \end{frame}
       
   695 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   696 
       
   697 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   698 \begin{frame}[c]
       
   699 \frametitle{While Tokens}
       
   700 
       
   701 \begin{center}
       
   702 \begin{tabular}{rcl}
       
   703 \pcode{WHILE\_REGS} & $\dn$ & \raisebox{-1mm}{\large(}\pcode{("k" : KEYWORD)} +\\ 
       
   704                   &       & \phantom{(}\pcode{("i" : ID)} +\\ 
       
   705                   &       & \phantom{(}\pcode{("o" : OP)} + \\
       
   706                   &       & \phantom{(}\pcode{("n" : NUM)} + \\
       
   707                   &       & \phantom{(}\pcode{("s" : SEMI)} +\\ 
       
   708                   &       & \phantom{(}\pcode{("p" : (LPAREN + RPAREN))} +\\ 
       
   709                   &       & \phantom{(}\pcode{("b" : (BEGIN + END))} +\\ 
       
   710                   &       & \phantom{(}\pcode{("w" : WHITESPACE)}\raisebox{-1mm}{\large)$^*$}
       
   711 \end{tabular}
       
   712 \end{center}
       
   713 
       
   714 \end{frame}
       
   715 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
   579 
   716 
   580 \end{document}
   717 \end{document}
   581 
   718 
   582 %%% Local Variables:  
   719 %%% Local Variables:  
   583 %%% mode: latex
   720 %%% mode: latex