handouts/ho05.tex
changeset 156 95eaee695636
parent 155 9b2d128765e1
child 157 b6eee9571a63
equal deleted inserted replaced
155:9b2d128765e1 156:95eaee695636
   196 \begin{center}
   196 \begin{center}
   197 \texttt{\Grid{then\VS\dots}}
   197 \texttt{\Grid{then\VS\dots}}
   198 \end{center}
   198 \end{center}
   199 
   199 
   200 \noindent
   200 \noindent
   201 Clearly, this string should clearly be identified as a keyword. The problem is that also the regular expression \textit{IDENT} for identifiers would also match this string. To solve this ambiguity we need to rank our regular expressions.
   201 Clearly, this string should clearly be identified as a keyword. The problem is that also the regular expression \textit{IDENT} for identifiers would also match this string. To overcome this ambiguity we need to rank our 
   202 
   202 regular expressions. In our running example we just use the ranking
   203 
   203 
   204 
   204 \[
       
   205 \textit{KEYWORD} < \textit{IDENT} < \textit{OP} < \ldots
       
   206 \]
       
   207 
       
   208 \noindent
       
   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
       
   211 
       
   212 Let us see how our algorithm for lexing works in detail. The regular 
       
   213 expressions and their ranking are shown above. 
   205 \end{document}
   214 \end{document}
   206 
   215 
   207 %%% Local Variables: 
   216 %%% Local Variables: 
   208 %%% mode: latex
   217 %%% mode: latex
   209 %%% TeX-master: t
   218 %%% TeX-master: t