handouts/ho05.tex
changeset 157 b6eee9571a63
parent 156 95eaee695636
child 158 77e8397ec2ec
equal deleted inserted replaced
156:95eaee695636 157:b6eee9571a63
   208 \noindent
   208 \noindent
   209 and so on. So even if both regular expressions match in the example above,
   209 and so on. So even if both regular expressions match in the example above,
   210 we can give the regular expression for \ref{Page ??} as follows
   210 we can give the regular expression for \ref{Page ??} as follows
   211 
   211 
   212 Let us see how our algorithm for lexing works in detail. The regular 
   212 Let us see how our algorithm for lexing works in detail. The regular 
   213 expressions and their ranking are shown above. 
   213 expressions and their ranking are shown above. For our algorithm it will  
       
   214 be helpful to have a look at the function \emph{zeroable}
       
   215 defined as follows:
       
   216 
       
   217 \begin{center}
       
   218 \begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}}
       
   219 $zeroable(\varnothing)$      & $\dn$ & $true$\\
       
   220 $zeroable(\epsilon)$           & $\dn$ &  $f\!alse$\\
       
   221 $zeroable (c)$                    & $\dn$ &  $f\!alse$\\
       
   222 $zeroable (r_1 + r_2)$        & $\dn$ &  $zeroable(r_1) \wedge zeroable(r_2)$ \\ 
       
   223 $zeroable (r_1 \cdot r_2)$  & $\dn$ &  $zeroable(r_1) \vee zeroable(r_2)$ \\
       
   224 $zeroable (r^*)$                  & $\dn$ & $f\!alse$\\
       
   225 \end{tabular}
       
   226 \end{center}
       
   227 
       
   228 \noindent
       
   229 In contrast to the function $nullable(r)$, which test whether a regular expression
       
   230 can match the empty string, the $zeroable$ function identifies whether a regular
       
   231 expression cannot match anything at all. 
       
   232 
       
   233 \begin{center}
       
   234 \texttt{\Grid{$c_1$\VS{} true\VS{} then\VS{} x\VS{} else\VS{} y \ldots }}
       
   235 \end{center}
       
   236 
       
   237 \noindent
       
   238 The crucial idea of the algorithm is to build the derivative of all 
       
   239 
   214 \end{document}
   240 \end{document}
   215 
   241 
   216 %%% Local Variables: 
   242 %%% Local Variables: 
   217 %%% mode: latex
   243 %%% mode: latex
   218 %%% TeX-master: t
   244 %%% TeX-master: t