DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
lex

Running lex

If lex.l is the file containing the lex specification, the C source for the lexical analyzer is produced by running lex with the following command:

lex lex.l

lex produces a C file called lex.yy.c.

Options

There are several options available with the lex command. If you use one or more of them, place them between the command name lex and the filename argument.

The -t option sends lex's output to the standard output rather than to the file lex.yy.c.

The -v option prints out a small set of statistics describing the so-called finite automata that lex produces with the C program lex.yy.c. (For a detailed account of finite automata and their importance to lex, see the Aho, Sethi, and Ullman book, Compilers: Principles, Techniques, and Tools, Addison-Wesley, 1986.)

lex uses a table (a two-dimensional array in C) to represent its finite automaton. The maximum number of states that the finite automaton requires is set by default to 4000. If your lex source has a large number of rules or the rules are very complex, this default value may be too small. You can enlarge the value by placing the following entry in the definitions section of your lex source:

   %n 6000
This entry tells lex to make the table large enough to handle as many as 6000 states. (The -v option indicates how large a number you should choose.) If you have need to increase the maximum number of state transitions beyond 16000, the designated parameter is a, for example:
   %a 20000
See lex(CP) for a concise description of the command and a list of all the options available.
Next topic: Compiling a lexical analyzer
Previous topic: Using lex under UNIX systems

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003