| 1 |
The input file for b() is a grammar file. Different from Bison++ and Bison |
| 2 |
grammar files, b() grammar file consist of just two sections. The general form |
| 3 |
of a b() grammar file looks like this: |
| 4 |
verb( |
| 5 |
Bisonc++ directives |
| 6 |
%% |
| 7 |
Grammar rules |
| 8 |
) |
| 9 |
Readers familiar with Bison may note that there is no em(C declaration |
| 10 |
section) and no section to define em(Additional C code). With b() these |
| 11 |
sections are superfluous since, due to the fact that a b() parser is defined |
| 12 |
as a bf(C++) class, all additional code required for the parser's |
| 13 |
implementation can be incorporated into the parser class itself. Also, bf(C++) |
| 14 |
classes normally only require declarations that can be defined in the classes' |
| 15 |
header files, so also the `additional C code' section was omitted from |
| 16 |
b()'s grammar file. |
| 17 |
|
| 18 |
The `%%' is a separator that appears in every b() grammar file |
| 19 |
separating the two sections. |
| 20 |
|
| 21 |
The directives section is used to declare the names of the terminal and |
| 22 |
nonterminal symbols, and may also describe operator precedence and the data |
| 23 |
types of semantic values of various symbols. Additional directives are used to |
| 24 |
define, e.g., the name of the generated parser class and a namespace in which |
| 25 |
the parser class is defined. All b() directives are covered in section |
| 26 |
ref(DIRECTIVES). |
| 27 |
|
| 28 |
Grammar rules define how to construct em(nonterminal symbols). The grammar |
| 29 |
rules section defines one or more b() grammar rules. See |
| 30 |
section ref(RULES), covering the syntax of grammar rules. |
| 31 |
|
| 32 |
The `%%' separator must always be specified, even if the directives section is |
| 33 |
empty. |
| 34 |
|
| 35 |
B()'s grammar file may be split into several files. Each file may be given a |
| 36 |
suggestive name. This allows quick identification of where a particular |
| 37 |
section or rule is found, and improves readability of the designed |
| 38 |
grammar. The link(%include)(INCLUDE)-directive (see section ref(INCLUDE)) can |
| 39 |
be used to include a partial grammar specification file into another |
| 40 |
specification file. |