Next: , Previous: , Up: Declarations   [Contents][Index]


3.7.13 %define Summary

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:

Directive: %define variable
Directive: %define variable value
Directive: %define variable {value}
Directive: %define variable "value"

Define variable to value.

The type of the values depend on the syntax. Braces denote value in the target language (e.g., a namespace, a type, etc.). Keyword values (no delimiters) denote finite choice (e.g., a variation of a feature). String values denote remaining cases (e.g., a file name).

It is an error if a variable is defined by %define multiple 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:

  1. value is true
  2. value is omitted (or "" is specified). This is equivalent to true.
  3. value is false.
  4. variable is never defined. In this case, Bison selects a default value.

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 described below.

Directive: %define api.namespace {namespace}
Directive: %define api.location.type {type}
Directive: %define api.prefix {prefix}
Directive: %define api.pure purity
Directive: %define api.push-pull kind
Directive: %define api.token.constructor
Directive: %define api.token.prefix {prefix}
Directive: %define api.value.type support
Directive: %define api.value.type {type}
Directive: %define api.value.union.name name
Directive: %define location_type

Obsoleted by api.location.type since Bison 2.7.

Directive: %define lr.default-reduction when
Directive: %define lr.keep-unreachable-state
Directive: %define lr.type type
Directive: %define namespace {namespace}

Obsoleted by api.namespace

Directive: %define parse.assert
Directive: %define parse.error verbosity
Directive: %define parse.lac when
Directive: %define parse.trace

Next: , Previous: , Up: Declarations   [Contents][Index]