1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
B() processes a file containing a grammar definition. Different
from Bison++ and Bison grammar files, b()'s grammar file consists of only
two sections. The general form of a b() grammar file is as follows:
verb(
Bisonc++ directives
%%
Grammar rules
)
Readers familiar with Bison may note that there is no em(C declaration
section) and no section to define em(Additional C code). With b() these
sections are superfluous since, due to the fact that a b() parser is a class,
all additionally required code can be incorporated into the parser class
itself. Also, bf(C++) classes normally only require declarations that can be
provided in the classes' header files, so also the `additional C code' section
was omitted from the grammar file.
The `%%' is a punctuation that appears in every b() grammar file to
separate the two sections.
The b() directives section contains all necessary directive specifications,
like directives declaring the names of the terminal and nonterminal symbols,
and directives describing operator precedence, and the data types of semantic
values of various symbols.
The file's second section (grammar rules) is used to define how to construct
each nonterminal symbol from its parts.
One special directive is availble that may be used in both the directives
section and in the grammar rules section. This directive is tt(%include),
allowing you to split long grammar specifications into smaller, more
comprehensible and accessible chunks. The tt(%include) directive is discussed
in more detail in section ref(INCLUDE).
|