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


9.1.3 Tuning the Parser

Options changing the generated parsers.

-t
--debug

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]
--define=name[=value]
-F name[=value]
--force-define=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
--language=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++, D and Java. language is case-insensitive.

--locations

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

-p prefix
--name-prefix=prefix

Pretend that %name-prefix "prefix" was specified (see section Bison Declaration Summary). The option -p is specified by POSIX. When POSIX compatibility is not a requirement, -Dapi.prefix=prefix is a better option (see section Multiple Parsers in the Same Program).

-l
--no-lines

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
--skeleton=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.

-k
--token-table

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

-y
--yacc

Act more like the traditional yacc command:

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.

Thus, the following shell script can substitute for Yacc, and the Bison distribution contains such a yacc script for compatibility with POSIX:

#! /bin/sh
bison -y "$@"

Footnotes

(6)

See https://austingroupbugs.net/view.php?id=1388#c5220.


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