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


9 Invoking Bison

The usual way to invoke Bison is as follows:

$ bison file

Here file 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 file.yxx

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

$ bison -d -o output.c++ file.y

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

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


The exit status of bison is:

0 (success)

when there were no errors. Warnings, which are diagnostics about dubious constructs, do not change the exit status, unless they are turned into errors (see -Werror).

1 (failure)

when there were errors. No file was generated (except the reports generated by --verbose, etc.). In particular, the output files that possibly existed were not changed.

63 (mismatch)

when bison does not meet the version requirements of the grammar file. See section Require a Version of Bison. No file was generated or changed.


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