Next: , Previous: , Up: Bison Options   [Contents][Index]

9.1.3 Tuning the Parser

Options changing the generated parsers.


In the parser implementation 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.

-D name[=value]
-F name[=value]

Each of these is equivalent to ‘%define name value’ (see section %define Summary). Note that the delimiters are part of value: -Dapi.value.type=union, -Dapi.value.type={union} and -Dapi.value.type="union" correspond to ‘%define api.value.type union’, ‘%define api.value.type {union}’ and ‘%define api.value.type "union"’.

Bison processes multiple definitions for the same name as follows:

You should avoid using -F and --force-define in your make files unless you are confident that it is safe to quietly ignore any conflicting %define that may be added to the grammar file.

-L language

Specify the programming language for the generated parser, as if %language was specified (see section Bison Declaration Summary). Currently supported languages include C, C++, and Java. language is case-insensitive.


Pretend that %locations was specified. See section Bison Declaration Summary.

-p prefix

Pretend that %name-prefix "prefix" was specified (see section Bison Declaration Summary). Obsoleted by -Dapi.prefix=prefix. See section Multiple Parsers in the Same Program.


Don’t put any #line preprocessor commands in the parser implementation file. Ordinarily Bison puts them in the parser implementation 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 implementation file, treating it as an independent source file in its own right.

-S file

Specify the skeleton to use, similar to %skeleton (see section Bison Declaration Summary).

If file does not contain a /, file is the name of a skeleton file in the Bison installation directory. If it does, file is an absolute file name or a file name relative to the current working directory. This is similar to how most shells resolve commands.


Pretend that %token-table was specified. See section Bison Declaration Summary.


Act more like the traditional yacc command. This can cause different diagnostics to be generated (it implies -Wyacc), and may change behavior in other minor ways. Most importantly, imitate Yacc’s output file name conventions, so that the parser implementation file is called, and the other outputs are called y.output and Also, generate #define statements in addition to an enum to associate token codes with token kind names. 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 "$@"

The -y/--yacc option is intended for use with traditional Yacc grammars. This option only makes sense for the default C skeleton, yacc.c. If your grammar uses Bison extensions Bison cannot be Yacc-compatible, even if this option is specified.

Next: , Previous: , Up: Bison Options   [Contents][Index]