There are many features of Bison's behavior that can be controlled by
assigning the feature a single value. For historical reasons, some
such features are assigned values by dedicated directives, such as
%start, which assigns the start symbol. However, newer such
features are associated with variables, which are assigned by the
%define directive:
Define variable to value.
value must be placed in quotation marks if it contains any character other than a letter, underscore, period, or non-initial dash or digit. Omitting
"value"entirely is always equivalent to specifying"".It is an error if a variable is defined by
%definemultiple times, but see -D name[=value].
The rest of this section summarizes variables and values that
%define accepts.
Some variables take Boolean values. In this case, Bison will complain if the variable definition does not meet one of the following four conditions:
true
"" is specified).
This is equivalent to true.
false.
What variables are accepted, as well as their meanings and default values, depend on the selected target language and/or the parser skeleton (see %language, see %skeleton). Unaccepted variables produce an error. Some of the accepted variables are:
false
pull, push, both
pull
most, consistent, accepting
accepting if lr.type is canonical-lr.
most otherwise.
false
lalr, ielr, canonical-lr
lalr
%define namespace "foo::bar"
Bison uses foo::bar verbatim in references such as:
foo::bar::parser::semantic_type
However, to open a namespace, Bison removes any leading :: and then
splits on any remaining occurrences:
namespace foo { namespace bar {
class position;
class location;
} }
"::".
For example, "foo" or "::foo::bar".
%name-prefix, which defaults
to yy.
This usage of %name-prefix is for backward compatibility and can be
confusing since %name-prefix also specifies the textual prefix for the
lexical analyzer function.
Thus, if you specify %name-prefix, it is best to also specify
%define namespace so that %name-prefix only affects the
lexical analyzer function.
For example, if you specify:
%define namespace "foo"
%name-prefix "bar::"
The parser namespace is foo and yylex is referenced as
bar::lex.
none, full
none