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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
The following private members can be used by members of parser classes
generated by b(). All data members are actually protected
members inherited from the parser's base class.
itemization(
it() bf(size_t d_acceptedTokens_):nl()
Counts the number of accepted tokens since the start of the tt(parse())
function or since the last detected syntactic error. It is initialized
to tt(d_requiredTokens_) to allow an early error to be detected as
well.
it() bf(bool d_actionCases_):nl()
When the bf(debug) option has been specified, this variable (bf(false)
by default) determines whether the numbers of the case-entries that
are about to be executed by the parser's tt(executeAction) member are
displayed to the standard output stream.
it() bf(bool d_debug_):nl()
When the bf(debug) option has been specified, this variable (bf(true)
by default) determines whether debug information is actually
displayed.
it() bf(LTYPE_ d_loc_):nl()
The location type value associated with a terminal token. It can be
used by, e.g., lexical scanners to pass location information of a
matched token to the parser in parallel with a returned token. It is
available only when bf(%lsp-needed, %ltype) or bf(%locationstruct) has
been defined. nl()
Lexical scanners may be offered the facility to assign a value to this
variable in parallel with a returned token. In order to allow a
scanner access to bf(d_loc_), bf(d_loc_)'s address should be passed
to the scanner. This can be realized, for example, by defining a
member bf(void setLoc(LTYPE_ *loc)) in the lexical scanner, which is
then called from the parser's constructor as follows:
verb(
d_scanner.setSLoc(&d_loc_);
)
Subsequently, the lexical scanner may assign a value to the parser's
bf(d_loc_) variable through the pointer to bf(d_loc_) stored inside
the lexical scanner.
it() bf(size_t d_nErrors_):nl()
The number of errors counted by tt(parse()). It is initialized by the
parser's base class initializer, and is updated while tt(parse())
executes. When tt(parse()) has returned it contains the total number
of errors counted by tt(parse()). Errors are not counted if suppressed
(i.e., if tt(d_acceptedTokens_) is less than tt(d_requiredTokens_)).
it() bf(size_t d_requiredTokens_):nl()
Defines the minimum number of accepted tokens that the tt(parse())
function must have processed before a syntactic error can be
generated.
it() label(DVAL) bf(STYPE_ d_val_):nl()
The semantic value of a returned token or nonterminal symbol. With
nonterminal tokens it is assigned a value through the action rule's
symbol bf($$). Lexical scanners may be offered the facility to assign
a semantic value to this variable in parallel with a returned
token. To allow a scanner access to bf(d_val_),
bf(d_val_)'s address should be passed to the scanner. This can be
realized, for example, by defining a member bf(void setSval(STYPE_
*)) in the lexical scanner, which is then called from the parser's
constructor as follows:
verb(
d_scanner.setSval(&d_val_);
)
Subsequently, the lexical scanner may assign a value to the parser's
bf(d_val_) variable through the pointer to bf(d_val_) stored inside
the lexical scanner.
Note that in some cases this approach em(must) be used to make
available the correct semantic value to the parser. In particular,
when a grammar state defines multiple reductions, depending on the
next token, the reduction's action only takes place following the
retrieval of the next token, thus losing the initially matched token
text. As an example, consider the following little grammar:
verb(
expr:
name
|
ident '(' ')'
|
NR
;
name:
IDENT
;
ident: IDENT ;
)
Having recognized tt(IDENT) two reductions are possible: to tt(name)
and to tt(ident). The reduction to tt(ident) is appropriate when the
next token is tt(CHAR(40)), otherwise the reduction to tt(name) is
performed. So, the parser asks for the next token, thereby
destroying the text matching tt(IDENT) before tt(ident) or tt(name)'s
actions are able to save the text themselves. To enure the
availability of the text matching tt(IDENT) is situations like these
the em(scanner) must assign the proper semantic value when it
recognizes a token. Consequently the parser's tt(d_val_) data member
must be made available to the scanner.
If tt(STYPE_) is a wrapper type for polymorphic semantic values, then
direct assignment of values to tt(d_val_) is is only possible from
values of the defined polymorphic data types. More complex assignments
are also possible, using em(tagged assignments)+IFDEF(MANUAL)(, as
explained in section ref(POLYTYPE))().
)
|