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 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 %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 Bison Declaration Summary). Currently supported languages include C, C++, and Java. language is case-insensitive.

--locations

Pretend that %locations was specified. See Decl Summary.

-p prefix
--name-prefix=prefix

Pretend that %name-prefix "prefix" was specified (see Decl Summary). Obsoleted by -Dapi.prefix=prefix. See 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 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 Decl Summary.

-y
--yacc

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 y.tab.c, and the other outputs are called y.output and y.tab.h. Also, if generating a deterministic parser in C, generate #define statements in addition to an enum to associate token numbers with token 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. If your grammar uses Bison extensions like ‘%glr-parser’, Bison might not be Yacc-compatible even if this option is specified.


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