| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 file's name is made by replacing the `.y' with `.tab.c'. Thus, the `bison foo.y' filename yields `foo.tab.c', and the `bison hack/foo.y' filename yields `hack/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 filenames 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.
| 9.1 Bison Options | All the options described in detail, in alphabetical order by short options. | |
| 9.2 Option Cross Key | Alphabetical list of long options. | |
| 9.3 Yacc Library | Yacc-compatible yylex and main.
|
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Bison supports both traditional single-letter options and mnemonic long option names. Long option names are indicated with `--' instead of `-'. Abbreviations for option names are allowed as long as they are unique. When a long option takes an argument, like `--file-prefix', connect the option name and the argument with `='.
Here is a list of options that can be used with Bison, alphabetized by short option. It is followed by a cross key alphabetized by long option.
Operations modes:
Print a summary of the command-line options to Bison and exit.
Print the version number of Bison and exit.
Equivalent to `-o y.tab.c'; the parser output file is called `y.tab.c', and the other outputs are called `y.output' and `y.tab.h'. The purpose of this option is to imitate Yacc's output file name conventions. Thus, the following shell script can substitute for Yacc, and the Bison distribution contains such a script for compatibility with POSIX:
#! /bin/sh bison -y "$" |
Tuning the parser:
Specify the skeleton to use. You probably don't need this option unless you are developing Bison.
In the parser file, define the macro YYDEBUG to 1 if it is not
already defined, so that the debugging facilities are compiled.
See section Tracing Your Parser.
Pretend that %locations was specified. See section Bison Declaration Summary.
Pretend that %name-prefix="prefix" was specified.
See section Bison Declaration Summary.
Don't put any #line preprocessor commands in the parser file.
Ordinarily Bison puts them in the parser file so that the C compiler
and debuggers will associate errors with your source file, the
grammar file. This option causes them to associate errors with the
parser file, treating it as an independent source file in its own right.
Pretend that %no-parser was specified. See section Bison Declaration Summary.
Pretend that %token-table was specified. See section Bison Declaration Summary.
Adjust the output:
Pretend that %defines was specified, i.e., write an extra output
file containing macro definitions for the token type names defined in
the grammar and the semantic value type YYSTYPE, as well as a few
extern variable declarations. See section Bison Declaration Summary.
Same as above, but save in the file defines-file.
Pretend that %verbose was specified, i.e, specify prefix to use
for all Bison output file names. See section Bison Declaration Summary.
Write an extra output file containing verbose description of the comma separated list of things among:
stateDescription of the grammar, conflicts (resolved and unresolved), and LALR automaton.
lookaheadImplies state and augments the description of the automaton with
each rule's lookahead set.
itemsetImplies state and augments the description of the automaton with
the full set of items for each state, instead of its core only.
For instance, on the following grammar
Pretend that %verbose was specified, i.e, write an extra output
file containing verbose descriptions of the grammar and
parser. See section Bison Declaration Summary.
Specify the filename for the parser file.
The other output files' names are constructed from filename as described under the `-v' and `-d' options.
Output a VCG definition of the LALR(1) grammar automaton computed by Bison. If the grammar file is `foo.y', the VCG output file will be `foo.vcg'.
The behavior of -graph is the same than `-g'. The only difference is that it has an optional argument which is the name of the output graph filename.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Here is a list of options, alphabetized by long option, to help you find the corresponding short option.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The Yacc library contains default implementations of the
yyerror and main functions. These default
implementations are normally not useful, but POSIX requires
them. To use the Yacc library, link your program with the
`-ly' option. Note that Bison's implementation of the Yacc
library is distributed under the terms of the GNU General
Public License (see section GNU GENERAL PUBLIC LICENSE).
If you use the Yacc library's yyerror function, you should
declare yyerror as follows:
int yyerror (char const *); |
Bison ignores the int value returned by this yyerror.
If you use the Yacc library's main function, your
yyparse function should have the following type signature:
int yyparse (void); |
| [ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated
using texi2html 1.76.