| 1 |
B() generates a bf(C++) parser em(class), rather than a parsing em(function), |
| 2 |
like Bison. B()'s class is a plain bf(C++) class and not a fairly complex |
| 3 |
macro-based class as generated by Bison++. |
| 4 |
|
| 5 |
The bf(C++) class generated by b() does not require em(virtual) members |
| 6 |
(when polymorphic semantic values are used (cf. section ref(POLYMORPHIC) a |
| 7 |
polymorphic base class em(is) used, but that class has no further implications |
| 8 |
for the parser class generated by bic()); in this case polymorphism is merely |
| 9 |
used internally, inaccessible to bic()'s user, to define a common interface |
| 10 |
for the various polymorphic data types). |
| 11 |
|
| 12 |
The generated parser class's essential member (the member tt(parse)) is |
| 13 |
generated from the grammar specification and so the software engineer will |
| 14 |
therefore hardly ever feel the need to modify that function. All but a few of |
| 15 |
the remaining predefined members have very clear definitions and meanings as |
| 16 |
well, making it unlikely that they should ever require overriding. |
| 17 |
|
| 18 |
It is likely that members like tt(lex) and/or tt(error) need dedicated |
| 19 |
definitions with different parsers generated by bic(); but then again: while |
| 20 |
defining the grammar the definition of the associated support members is a |
| 21 |
natural extension of defining the grammar, and can be realized em(in parallel) |
| 22 |
with defining the grammar, in practice not requiring any virtual members. By |
| 23 |
not requiring virtual members the parser's class organization is simplified, |
| 24 |
and calling non-virtual members will be just a trifle faster than calling |
| 25 |
these member functions as virtual functions. |
| 26 |
|
| 27 |
In this chapter all available members and features of the generated parser |
| 28 |
class are discussed. Having read this chapter you should be able to use the |
| 29 |
generated parser class in your program (using its public members) and to use |
| 30 |
its facilities in the actions defined for the various production rules and/or |
| 31 |
use these facilities in additional class members that you might have defined |
| 32 |
yourself. |
| 33 |
|
| 34 |
In the remainder of this chapter the class's public members are first |
| 35 |
discussed, to be followed by the class's private members. While constructing |
| 36 |
the grammar all private members are available in the action parts of the |
| 37 |
grammar's production rules. Furthermore, any member (and so not just from the |
| 38 |
action blocks) may generate errors (thus initiating error recovery procedures) |
| 39 |
and may flag the (un)successful parsing of the information given to the parser |
| 40 |
(terminating the parsing function tt(parse)). |
| 41 |
|
| 42 |
Symbols defined in the generated parser and parser base class usually end in |
| 43 |
an underscore character. Such symbols should not be masked or |
| 44 |
redefined. Some members have names not ending in an underscore |
| 45 |
character. Those names have either historically been used (like tt(parse) and |
| 46 |
tt(ERROR)) or they can be redefined by the user (like tt(int lex()) and |
| 47 |
tt(void print())). Their specific requirements are documented below. |