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

Compiling a lexical analyzer

The file lex.yy.c may be compiled and linked in the same way as any C program. The -ll option is used to link the object file created from this C source with lex library:

cc lex.yy.c -ll

The lex library provides a default main() program that calls the lexical analyzer under the name yylex(), so you do not have to supply your own main().

If you have the lex specification spread across several files, you can run lex on each of them individually, but be sure to rename or move each lex.yy.c file before you run lex on the next one. Otherwise, each file overwrites the previous one. Once you have generated all the C files, you can compile all of them in one command line.

To compile and link the output files produced by lex and yacc, run:

cc lex.yy.c y.tab.c -ly -ll

Note that the yacc library is linked (with the -ly option) before the lex library (with the -ll option) to ensure that the main() program supplied will call the yacc parser.


Next topic: Running the lexical analyzer
Previous topic: Options

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