22.10.2013 Views

4 - Forth Interest Group

4 - Forth Interest Group

4 - Forth Interest Group

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Another advantage to using start states is the ability to<br />

recognize an erroneous construct, without needing an<br />

explicit regular expression for it. If the above example had<br />

been written using only regular expressions, it would look<br />

like that in Figure Two-b.<br />

Which would you rather debug?<br />

Start states are also useful if a regular expression can be<br />

used in more than one way. For example, the C convention<br />

of enclosing comments in / * */ pairs can cause confusion<br />

with arbitrary pathnames used in C preprocessor statements<br />

such as this:<br />

#include <br />

Although this does have the potential for causing problerns,<br />

they can be avoided either by using start states, or by<br />

realizing that the scanner will have to return a token<br />

coresponding to the string rather than a comment<br />

starting with / * . h. However, if the '

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!