| 1 |
The declaration section of a grammar file defines the symbols used in |
| 2 |
formulating the production rules and the data types of semantic values. See |
| 3 |
section ref(SYMBOLS). |
| 4 |
|
| 5 |
All token names (except for single-character literal tokens such as '+' and |
| 6 |
'*') must be declared. If data types must be associated with semantic values |
| 7 |
of symbols (see sections ref(SEMANTICS)) then those symbols must also be |
| 8 |
declared. |
| 9 |
|
| 10 |
By default the first rule in the rule section specifies the grammar's em(start |
| 11 |
symbol). The tt(%start) directive can be used to specify another rule (see |
| 12 |
section ref(LANGUAGES)). |
| 13 |
|
| 14 |
This section covers all of b()'s declarations. Some have already been |
| 15 |
mentioned, but several more are available. Some define how the grammar parses |
| 16 |
its input (like tt(%left, %right)); other directives define, e.g., the name of |
| 17 |
the parsing function, or the name(s) of the files b() generates. |
| 18 |
|
| 19 |
In particular readers familiar with Bison (or Bison++) should read this |
| 20 |
section thoroughly, since b()'s directives are more extensive and different |
| 21 |
from the `declarations' offered by Bison, and the macros defined by Bison++. |
| 22 |
|
| 23 |
Several directives expect file- or pathname arguments. File- or pathnames must |
| 24 |
be provided on the same line as the directive itself, starting at the first |
| 25 |
non-blank character after the directive. File- or pathnames may contain escape |
| 26 |
sequences (e.g., if you must: use `tt(\ )' to include a blank in a filename), |
| 27 |
and continue until encountering the next blank character. Alternatively, file- |
| 28 |
or pathnames may be surrounded by double quotes (tt("...")) or pointed |
| 29 |
brackets (tt(<...>)). Pointed brackets surrounding file- or path-names merely |
| 30 |
function to delimit filenames. They do not refer to, e.g., bf(C++)'s include |
| 31 |
path. No escape sequences are required for blanks within delimited file- or |
| 32 |
path-names. |
| 33 |
|
| 34 |
Directives accepting a `filename' do not accept path names, i.e., they cannot |
| 35 |
contain directory separators (tt(/)); directives accepting a 'pathname' may |
| 36 |
contain directory separators. |
| 37 |
|
| 38 |
|
| 39 |
Sometimes directives have analogous command-line options. In those cases |
| 40 |
command-line options take priority over directives. |
| 41 |
|
| 42 |
Some directives may generate errors. This happens when a directive |
| 43 |
conflicts with the contents of a file bic() cannot modify (e.g., a |
| 44 |
parser class header file exists, but doesn't define a namespace, but a |
| 45 |
tt(%namespace) directive was provided). |
| 46 |
|
| 47 |
To solve such errore the offending directive could be omitted, the existing |
| 48 |
file could be removed, or the existing file could be hand-edited according to |
| 49 |
the directive's specification. |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|