slides/slides05.tex
changeset 528 68fab15cd6fb
parent 500 c502933be072
child 529 5c28e4134ee1
equal deleted inserted replaced
527:2a62f0845f98 528:68fab15cd6fb
    35   \end{tabular}
    35   \end{tabular}
    36   \end{center}
    36   \end{center}
    37 \end{frame}
    37 \end{frame}
    38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
    38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
    39 
    39 
    40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    40 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    41 \begin{frame}[c]
    41 % \begin{frame}[c]
    42 \frametitle{Survey: Thanks!}
    42 % \frametitle{Survey: Thanks!}
    43 \small
    43 % \small
    44 
    44 
    45 \begin{itemize}
    45 % \begin{itemize}
    46 \item {\bf My Voice} ``could be a bit louder''
    46 % \item {\bf My Voice} ``could be a bit louder''
    47 \item {\bf Writing} ``sometimes a bit difficult to read''
    47 % \item {\bf Writing} ``sometimes a bit difficult to read''
    48 \item {\bf Recording} ``video caps of blackboard''
    48 % \item {\bf Recording} ``video caps of blackboard''
    49 \item ``It's all great''
    49 % \item ``It's all great''
    50 \end{itemize}
    50 % \end{itemize}
    51   
    51   
    52 \end{frame}
    52 % \end{frame}
    53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
    53 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
    54 
    54 
    55 
    55 
    56 
    56 
    57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    58 \begin{frame}[c]
    58 \begin{frame}[c]
   201 \bl{$(b \cdot c) + \ONE$}
   201 \bl{$(b \cdot c) + \ONE$}
   202 
   202 
   203 \end{frame}
   203 \end{frame}
   204 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
   204 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
   205 
   205 
   206 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   206 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   207 \begin{frame}[t]
   207 % \begin{frame}[t]
   208 
   208 
   209 \begin{center}
   209 % \begin{center}
   210 \bl{$\only<1>{(b \cdot c)}%
   210 % \bl{$\only<1>{(b \cdot c)}%
   211      \only<2-3>{(\underline{b \cdot c})}%
   211 %      \only<2-3>{(\underline{b \cdot c})}%
   212      \only<1-3>{+}% 
   212 %      \only<1-3>{+}% 
   213      \only<1>{(\ZERO + \ONE)}%
   213 %      \only<1>{(\ZERO + \ONE)}%
   214      \only<2-3>{(\underline{\ZERO + \ONE})}$}%
   214 %      \only<2-3>{(\underline{\ZERO + \ONE})}$}%
   215 \only<4->{%
   215 % \only<4->{%
   216 \bl{$\underline{(b \cdot c) + (\ZERO + \ONE)}$}%
   216 % \bl{$\underline{(b \cdot c) + (\ZERO + \ONE)}$}%
   217 }
   217 % }
   218 $\mapsto$
   218 % $\mapsto$
   219 \bl{$(b \cdot c) + \ONE$}
   219 % \bl{$(b \cdot c) + \ONE$}
   220 \end{center}\bigskip
   220 % \end{center}\bigskip
   221 
   221 
   222 \onslide<3->{%
   222 % \onslide<3->{%
   223 \begin{center}
   223 % \begin{center}
   224 \begin{tabular}{lcl}
   224 % \begin{tabular}{lcl}
   225 \bl{$f_{s1}$} & \bl{$=$} & \bl{$\lambda v.v$}\\
   225 % \bl{$f_{s1}$} & \bl{$=$} & \bl{$\lambda v.v$}\\
   226 \bl{$f_{s2}$} & \bl{$=$} & \bl{$\lambda v. \textit{Right}(v)$}
   226 % \bl{$f_{s2}$} & \bl{$=$} & \bl{$\lambda v. \textit{Right}(v)$}
   227 \end{tabular}
   227 % \end{tabular}
   228 \end{center}}
   228 % \end{center}}
   229 
   229 
   230 \only<4>{%
   230 % \only<4>{%
   231 \begin{center}
   231 % \begin{center}
   232 \begin{tabular}{@{}l@{\hspace{1mm}}l@{}}
   232 % \begin{tabular}{@{}l@{\hspace{1mm}}l@{}}
   233 \bl{$f_{alt}(f_{s1}, f_{s2}) \dn$}\\
   233 % \bl{$f_{alt}(f_{s1}, f_{s2}) \dn$}\\
   234 \quad \bl{$\lambda v.\,$} 
   234 % \quad \bl{$\lambda v.\,$} 
   235         case \bl{$v = Left(v')$}: 
   235 %         case \bl{$v = Left(v')$}: 
   236       & return \bl{$Left(f_{s1}(v'))$}\\
   236 %       & return \bl{$Left(f_{s1}(v'))$}\\
   237 \quad \phantom{$\lambda v.\,$} 
   237 % \quad \phantom{$\lambda v.\,$} 
   238         case \bl{$v = Right(v')$}: 
   238 %         case \bl{$v = Right(v')$}: 
   239       & return \bl{$Right(f_{s2}(v'))$}\\ 
   239 %       & return \bl{$Right(f_{s2}(v'))$}\\ 
   240 \end{tabular}
   240 % \end{tabular}
   241 \end{center}}%
   241 % \end{center}}%
   242 \only<5->{%
   242 % \only<5->{%
   243 \begin{center}
   243 % \begin{center}
   244 \begin{tabular}{@{}l@{\hspace{1mm}}l@{}}
   244 % \begin{tabular}{@{}l@{\hspace{1mm}}l@{}}
   245 \only<5->{\phantom{\bl{$f_{alt}(f_{s1}, f_{s2}) \dn$}}}\\
   245 % \only<5->{\phantom{\bl{$f_{alt}(f_{s1}, f_{s2}) \dn$}}}\\
   246 \quad \bl{$\lambda v.\,$} 
   246 % \quad \bl{$\lambda v.\,$} 
   247         case \bl{$v = Left(v')$}: 
   247 %         case \bl{$v = Left(v')$}: 
   248       & return \bl{$Left(v')$}\\
   248 %       & return \bl{$Left(v')$}\\
   249 \quad \phantom{$\lambda v.\,$} 
   249 % \quad \phantom{$\lambda v.\,$} 
   250         case \bl{$v = Right(v')$}: 
   250 %         case \bl{$v = Right(v')$}: 
   251       & return \bl{$Right(Right(v'))$}\\ 
   251 %       & return \bl{$Right(Right(v'))$}\\ 
   252 \end{tabular}
   252 % \end{tabular}
   253 \end{center}}%
   253 % \end{center}}%
   254 
   254 
   255 \only<6->{%
   255 % \only<6->{%
   256 \begin{center}
   256 % \begin{center}
   257 \begin{tabular}{@{}l@{\hspace{4mm}}l@{}}
   257 % \begin{tabular}{@{}l@{\hspace{4mm}}l@{}}
   258 \bl{$\textit{mkeps}$} simplified case: &
   258 % \bl{$\textit{mkeps}$} simplified case: &
   259 \bl{$\textit{Right}(\textit{Empty})$}\\
   259 % \bl{$\textit{Right}(\textit{Empty})$}\\
   260 rectified case: &
   260 % rectified case: &
   261 \bl{$\textit{Right}(\textit{Right}(\textit{Empty}))$}
   261 % \bl{$\textit{Right}(\textit{Right}(\textit{Empty}))$}
   262 \end{tabular}
   262 % \end{tabular}
   263 \end{center}}%
   263 % \end{center}}%
   264 
   264 
   265 \end{frame}
   265 % \end{frame}
   266 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   266 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   267 
   267 
   268 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   268 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   269 \begin{frame}[c]
   269 \begin{frame}[c]
   270 \frametitle{Records}
   270 \frametitle{Records}
   271 
   271 
   369 \end{frame}
   369 \end{frame}
   370 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   370 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   371 
   371 
   372 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   372 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   373 \begin{frame}[c]
   373 \begin{frame}[c]
   374 \frametitle{Two Rules}
   374 \frametitle{Coursework: Nullable}
   375 
   375 
   376 \begin{itemize}
   376 \begin{center}
   377 \item Longest match rule (``maximal munch rule''): The 
   377 \begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}}
   378 longest initial substring matched by any regular expression is taken
   378   \bl{$nullable([c_1 c_2 \ldots c_n])$}  & \bl{$\dn$} & $?$\\
   379 as next token.\bigskip
   379   \bl{$nullable(r^+)$}                   & \bl{$\dn$} & $?$\\
   380 
   380   \bl{$nullable(r^?)$}                   & \bl{$\dn$} & $?$\\
   381 \item Rule priority:
   381   \bl{$nullable(r^{\{n\}})$}              & \bl{$\dn$} & $?$\\
   382 For a particular longest initial substring, the first regular
   382   \bl{$nullable(r^{\{n..\}})$}            & \bl{$\dn$} & $?$\\
   383 expression that can match determines the token.
   383   \bl{$nullable(r^{\{..n\}})$}            & \bl{$\dn$} & $?$\\
   384 
   384   \bl{$nullable(r^{\{n..m\}})$}           & \bl{$\dn$} & $?$\\
   385 \end{itemize}
   385   \bl{$nullable(\sim{}r)$}               & \bl{$\dn$} & $?$\\
   386 
   386                                                         
   387 %\url{http://www.technologyreview.com/tr10/?year=2011}
   387 \end{tabular}
       
   388 \end{center}
       
   389 
       
   390 \end{frame}
       
   391 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   392 
       
   393 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   394 \begin{frame}[c]
       
   395 %%\frametitle{Coursework: der}
       
   396 
       
   397 \begin{center}
       
   398 \begin{tabular}{@ {}l@ {\hspace{1mm}}c@ {\hspace{1mm}}l@ {}}
       
   399   \bl{$der\, c\, ([c_1 c_2 \ldots c_n])$}  & \bl{$\dn$} & $?$\\
       
   400   \bl{$der\, c\, (r^+)$}                   & \bl{$\dn$} & $?$\\
       
   401   \bl{$der\, c\, (r^?)$}                   & \bl{$\dn$} & $?$\\
       
   402   \bl{$der\, c\, (r^{\{n\}})$}              & \bl{$\dn$} &
       
   403      \bl{$if\;n=0\;then\;\ZERO\;else\;(der\,c\,r)\cdot r^{\{n-1\}}$}\\
       
   404   \bl{$der\, c\, (r^{\{n..\}})$}            & \bl{$\dn$} &
       
   405      \bl{$if\;n=0\;then (der\,c\,r)\cdot r^*$}\\
       
   406   & & \bl{$\phantom{if\;n=0\;}else \;(der\,c\,r)\cdot r^{\{n-1..\}}$}\\
       
   407   \bl{$der\, c\, (r^{\{..n\}})$}            & \bl{$\dn$} &
       
   408      \bl{$if\;n=0\;then\;\ZERO\;else\;(der\,c\,r)\cdot r^{\{..n-1\}}$}\\
   388   
   409   
   389 %finite deterministic automata/ nondeterministic automaton
   410   \bl{$der\, c\, (r^{\{n..m\}})$}          & \bl{$\dn$} &
   390 
   411      \bl{$if\;n = 0 \wedge m = 0\;then\;\ZERO\; else$}\\
   391 %\item problem with infix operations, for example i-12
   412   \multicolumn{3}{l}{\bl{$if\;n = 0 \wedge m > 0\;then\;(der\,c\,r)\cdot r^{\{..m-1\}}$}}\\
   392 
   413   \multicolumn{3}{l}{\bl{$\phantom{if\;n = 0 \wedge m > 0\;}else
   393 
   414           \;(der\,c\,r)\cdot r^{\{n-1..m-1\}}$}}\\
   394 \end{frame}
   415   \bl{$der\, c\, (\sim{}r)$}              & \bl{$\dn$} & $?$\\
   395 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
   416 \end{tabular}
   396 
   417 \end{center}
   397 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   418 
   398 \begin{frame}[c]
   419 \end{frame}
   399 \frametitle{Coursework}
   420 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   421 
       
   422 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   423 \begin{frame}[c]
       
   424 \frametitle{Coursework: CFUN}
   400 
   425 
   401 \begin{center}
   426 \begin{center}
   402 \begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}}
   427 \begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}}
   403 \bl{$nullable([c_1 c_2 \ldots c_n])$}  & \bl{$\dn$} & $?$\\
   428   \bl{$nullable(CFUN(\_))$}  & \bl{$\dn$} & \bl{$false$}\\
   404 \bl{$nullable(r^+)$}                   & \bl{$\dn$} & $?$\\
   429   \bl{$der\,c\,(CFUN(f))$}   & \bl{$\dn$} &
   405 \bl{$nullable(r^?)$}                   & \bl{$\dn$} & $?$\\
   430      \bl{$if\;f(c)\;then\;\ONE\;else\;\ZERO$}\bigskip\\
   406 \bl{$nullable(r^{\{n,m\}})$}            & \bl{$\dn$} & $?$\\
   431   \bl{$CHAR(c)$}                   & \bl{$\dn$} & \bl{$CFUN(\lambda{}d.\;c=d)$}\\
   407 \bl{$nullable(\sim{}r)$}               & \bl{$\dn$} & $?$\medskip\\
   432   \bl{$CSET([c_1,\ldots,c_n])$} & \bl{$\dn$} & \bl{$CFUN(\lambda{}d.\;d\in [c_1,\ldots,c_n])$}\\
   408 \bl{$der\, c\, ([c_1 c_2 \ldots c_n])$}  & \bl{$\dn$} & $?$\\
   433   \bl{$ALL$}                   & \bl{$\dn$} & \bl{$CFUN(\lambda{}d.\;true)$}\\                                                      
   409 \bl{$der\, c\, (r^+)$}                   & \bl{$\dn$} & $?$\\
       
   410 \bl{$der\, c\, (r^?)$}                   & \bl{$\dn$} & $?$\\
       
   411 \bl{$der\, c\, (r^{\{n,m\}})$}            & \bl{$\dn$} & $?$\\
       
   412 \bl{$der\, c\, (\sim{}r)$}               & \bl{$\dn$} & $?$\\
       
   413 \end{tabular}
   434 \end{tabular}
   414 \end{center}
   435 \end{center}
   415 
   436 
   416 \end{frame}
   437 \end{frame}
   417 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   438 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   418 
   439 
       
   440 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   441 \begin{frame}[t]
       
   442 \frametitle{Lexer, Parser}
       
   443 \mbox{}\\[-16mm]\mbox{}
       
   444 
       
   445 \begin{center}
       
   446   \begin{tikzpicture}[scale=1,
       
   447                       node/.style={
       
   448                       rectangle,rounded corners=3mm,
       
   449                       very thick,draw=black!50,
       
   450                       minimum height=18mm, minimum width=20mm,
       
   451                       top color=white,bottom color=black!20}]
       
   452   \node (0) at (-2.3,0) {}; 
       
   453   
       
   454   \node (A) at (0,0)  [node] {};
       
   455   \node [below right] at (A.north west) {lexer};
       
   456 
       
   457   \node (B) at (3,0)  [node] {};
       
   458   \node [below right=1mm] at (B.north west) 
       
   459     {\mbox{}\hspace{-1mm}parser};
       
   460 
       
   461   \node (C) at (6,0)  [node] {};
       
   462   \node [below right] at (C.north west) 
       
   463     {\mbox{}\hspace{-1mm}code gen};
       
   464 
       
   465   \node (1) at (8.4,0) {}; 
       
   466 
       
   467   \draw [->,line width=4mm] (0) -- (A); 
       
   468   \draw [->,line width=4mm] (A) -- (B); 
       
   469   \draw [->,line width=4mm] (B) -- (C); 
       
   470   \draw [->,line width=4mm] (C) -- (1); 
       
   471   \end{tikzpicture}
       
   472   \end{center}
       
   473   
       
   474 Today a parser.  
       
   475   
       
   476 \end{frame}
       
   477 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   419 
   478 
   420 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   479 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   421 \begin{frame}[c]
   480 \begin{frame}[c]
   422 \frametitle{Regular Languages}
   481 \frametitle{Regular Languages}
   423 
   482 
   809 
   868 
   810 Sequence parser (code \bl{$p\sim q$})\bigskip
   869 Sequence parser (code \bl{$p\sim q$})\bigskip
   811 
   870 
   812 \begin{itemize}
   871 \begin{itemize}
   813 \item apply first \bl{$p$} producing a set of pairs
   872 \item apply first \bl{$p$} producing a set of pairs
   814 \item then apply \bl{$q$} to the unparsed parts
   873 \item then apply \bl{$q$} to the unparsed part
   815 \item then combine the results:\medskip 
   874 \item then combine the results:\medskip 
   816 \begin{center}
   875 \begin{center}
   817 ((output$_1$, output$_2$), unparsed part)
   876 ((output$_1$, output$_2$), unparsed part)
   818 \end{center}
   877 \end{center}
   819 \end{itemize}
   878 \end{itemize}