Debian Codegraph @

documentation/manual/class/privdata.yo

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