Next: Output Files, Previous: Diagnostics, Up: Bison Options [Contents][Index]
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 Tracing Your Parser.
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:
%define
definition
for name.
%define
definitions for name.
%define
definitions for name.
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.
Specify the programming language for the generated parser, as if
%language
was specified (see Bison Declaration Summary). Currently supported
languages include C, C++, D and Java. language is case-insensitive.
Pretend that %locations
was specified. See Bison Declaration Summary.
Pretend that %name-prefix "prefix"
was specified (see 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 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.
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.
Pretend that %token-table
was specified. See Bison Declaration Summary.
Act more like the traditional yacc
command:
#define
statements in addition to an enum
to
associate token codes with token kind names.
POSIXLY_CORRECT
environment variable is defined, generate
prototypes for yyerror
and yylex
6 (since Bison
3.8):
int yylex (void); void yyerror (const char *);
As a Bison extension, additional arguments required by %pure-parser
,
%locations
, %lex-param
and %parse-param
are taken into
account. You may disable yyerror
’s prototype with ‘#define
yyerror yyerror’ (as specified by POSIX), or with ‘#define
YYERROR_IS_DECLARED’ (a Bison extension). Likewise for yylex
.
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 "$@"
Next: Output Files, Previous: Diagnostics, Up: Bison Options [Contents][Index]