09.06.2013 Views

Intel XENIX 286 Programmers Guide (86) - Tenox.tc

Intel XENIX 286 Programmers Guide (86) - Tenox.tc

Intel XENIX 286 Programmers Guide (86) - Tenox.tc

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.

lex: Lexical Analyzer Generator <strong>XENIX</strong> Programming<br />

If any of these characters are to be used literally, they must be quoted individually with<br />

a backslash (\) or as a group within quotation marks ("). Whatever is contained between<br />

a pair of quotation marks is to be taken as text characters. Thus<br />

xyz" + +<br />

ma<strong>tc</strong>hes the string xyz++ when it appears. Note that a part of a string may be quoted.<br />

It is harmless but unnecessary to quote an ordinary text character; the expression<br />

"xyz + +<br />

is the same as the one above. Thus by quoting every nonalphanumeric character being<br />

used as a text character, you need not memorize the above list of current operator<br />

characters.<br />

An operator character may also be turned into a text character by preceding it with a<br />

backslash (\) as in<br />

xyz\ + \ +<br />

which is another, less readable, equivalent of the above expressions. The quoting<br />

mechanism can also be used to get a blank into an expression; normally, as explained<br />

above, blanks or tabs end a rule. Any blank character not contained within brackets<br />

must be quoted. Several normal C escapes with the backslash (\) are recognized:<br />

\n newline<br />

\t tab<br />

\b backspace<br />

\\ backslash<br />

Since newline is illegal in an expression, \n must be used; it is not required to escape tab<br />

and backspace. Every character but blank, tab, newline, backspace, and backslash is<br />

always a text character.<br />

Invoking lex<br />

There are two steps in compiling a lex source program. First, the lex source must be<br />

turned into a generated C program. Then this program must be compiled and loaded,<br />

usually with a library of lex subroutines. The generated program is in a file named<br />

lex.yy.c. The lex 1/0 library is defined in terms of the C standard library.<br />

9-4

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

Saved successfully!

Ooh no, something went wrong!