Next: , Previous: , Up: Top   [Contents][Index]


9 Invoking Bison

The usual way to invoke Bison is as follows:

bison infile

Here infile is the grammar file name, which usually ends in ‘.y’. The parser implementation file’s name is made by replacing the ‘.y’ with ‘.tab.c’ and removing any leading directory. Thus, the ‘bison foo.y’ file name yields foo.tab.c, and the ‘bison hack/foo.y’ file name yields foo.tab.c. It’s also possible, in case you are writing C++ code instead of C in your grammar file, to name it foo.ypp or foo.y++. Then, the output files will take an extension like the given one as input (respectively foo.tab.cpp and foo.tab.c++). This feature takes effect with all options that manipulate file names like ‘-o’ or ‘-d’.

For example :

bison -d infile.yxx

will produce infile.tab.cxx and infile.tab.hxx, and

bison -d -o output.c++ infile.y

will produce output.c++ and outfile.h++.

For compatibility with POSIX, the standard Bison distribution also contains a shell script called yacc that invokes Bison with the -y option.