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

Compiling

The file y.tab.c produced by yacc can be compiled with cc as follows:

cc y.tab.c -ly

The -ly option causes the object file generated to be linked with the yacc library. If you supply your own versions of main() and yyerror(), link the module containing these routines before the library.

A routine named yylex() must be provided to do lexical analysis and return tokens to the parser. This routine can be supplied by the user or generated from a lex specification. A lexical analyzer generated lex can be linked to the parser using the following command line:

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

lex.yy.c is the C file that lex produces. If you are using the library version of main(), the -ly option must appear before -ll, so that the version in the yacc library is used.

Using make

The make facility can be used to help maintain the parser code. make interprets files with the extension .y as yacc source files. Suppose a list of dependencies in a makefile contains a filename x.o, and there exists a file x.y. If x.y has been modified later than x.o, or if x.o does not exist, then make will cause yacc to be run on x.y, and cause the object file x.o to be created from the resulting y.tab.c.


Next topic: Running the parser
Previous topic: Parsing

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