Debian Codegraph @

documentation/manual/class/privmembers.yo

raw
1 The following members can be used by members of parser classes generated
2 by bic(). When prefixed by tt(Base::) they are actually protected members
3 inherited from the parser's base class. These members are shown
4 below. Following the description of those members several more are listed:
5 those members are used during the parsing process, andshould not be modified
6 or masked by user-defined code.
7
8 itemization(
9 it() bf(void Base::ABORT() const throw(Return_)):nl()
10 This member can be called from any member function (called from any of
11 the parser's action blocks) to indicate a failure while parsing thus
12 terminating the parsing function with an error value 1. Note that this
13 offers a marked extension and improvement of the macro tt(YYABORT)
14 defined by bf(bison++) in that tt(YYABORT) could not be called from
15 outside of the parsing member function.
16
17 it() bf(void Base::ACCEPT() const throw(Return_)):nl()
18 This member can be called from any member function (called from any of
19 the parser's action blocks) to indicate successful parsing and thus
20 terminating the parsing function. Note that this offers a marked
21 extension and improvement of the macro tt(YYACCEPT) defined by
22 bf(bison++) in that tt(YYACCEPT) could not be called from outside of
23 the parsing member function.
24
25 it() bf(void Base::ERROR+nop()() const throw(ErrorRecovery_)):nl()
26 This member can be called from any member function (called from any of
27 the parser's action blocks) to generate an error, and results in the
28 parser executing its error recovery code. Note that this offers a
29 marked extension and improvement of the macro tt(YYERROR) defined by
30 bf(bison++) in that tt(YYERROR) could not be called from outside of
31 the parsing member function.
32
33 it() bf(void error()):nl()
34 By default implemented inline in the tt(parser.ih) internal header file,
35 it writes a simple message to the standard error stream. It is called
36 when a syntactic error is encountered, and its default implementation
37 may safely be altered.
38
39 it() bf(void exceptionHandler(std::exception const &exc)):nl()
40 This member's default implementation is provided inline in the
41 tt(parser.ih) internal header file. It consists of a mere tt(throw)
42 statement, rethrowing a caught exception.
43
44 The tt(parse) member function's body essentially consists of a
45 tt(while) statement, in which the next token is obtained via the
46 parser's tt(lex) member. This token is then processed according to the
47 current state of the parsing process. This may result in executing
48 actions over which the parsing process has no control and which may
49 result in exceptions being thrown.
50
51 Such exceptions do not necessarily have to terminate the parsing
52 process: they could be thrown by code, linked to the parser, that
53 simply checks for semantic errors (like divisions by zero)
54 throwing exceptions if such errors are observed.
55
56 The member tt(exceptionHandler) receives and may handle such
57 exceptions without necessarily ending the parsing process. It receives
58 any tt(std::exception) thrown by the parser's actions, as though the
59 action block itself was surrounded by a tt(try ... catch) statement.
60 It is of course still possible to use an explicit tt(try ... catch)
61 statement within action blocks. However, tt(exceptionHandler) can
62 be used to factor out code that is common to various action blocks.
63
64 The next example shows an explicit implementation of
65 tt(exceptionHandler): any tt(std::exception) thrown by the parser's
66 action blocks is caught, showing the exception's message, and
67 increasing the parser's error count. After this parsing continues as
68 if no exception had been thrown:
69 verb(
70 void Parser::exceptionHandler(std::exception const &exc)
71 {
72 std::cout << exc.what() << '\n';
73 ++d_nErrors_;
74 }
75 )
76
77 it() bf(int lex()):nl()
78 By default implemented inline in the tt(parser.ih) internal header file,
79 it can be pre-implemented by bic() using the tt(scanner) option or
80 directive (see above); alternatively it em(must) be implemented by the
81 programmer. It interfaces to the lexical scanner, and should return the
82 next token produced by the lexical scanner, either as a plain character
83 or as one of the symbolic tokens defined in the tt(Parser::Tokens_)
84 enumeration. Zero or negative token values are interpreted as `end of
85 input'.
86
87 it() bf(void print()):nl()
88 By default implemented inline in the tt(parser.ih) internal header file,
89 this member calls tt(print_) to display the last received token and
90 corresponding matched text. The tt(print_) member is only implemented
91 if the tt(--print-tokens) option or tt(%print-tokens) directive was
92 used when the parsing function was generated. Calling tt(print_) from
93 tt(print) is unconditional, but can easily be controlled by the using
94 program, by defining, e.g., a command-line option.
95
96 it() bf(size_t stackSize_+nop()() const):nl()
97 Returns the current number of elements in the parser's state-stack.
98
99 it() bf(size_t state_+nop()() const):nl()
100 Returns the current parsing-state.
101
102 it() bf(bool Base::recovery_+nop()() const):nl()
103 Returns tt(true) while recovering from a syntax error.
104
105 it() bf(int Base::token_+nop()() const):nl()
106 Returns the currently considered token.
107 )
108
109 The following members are required during the parsing process. They should not
110 be modified or masked by user-defined code:
111
112 itemization(
113 it() bf(Base::ParserBase())
114 it() bf(void Base::clearin_+nop()()())
115 it() bf(void errorRecovery_+nop()())
116 it() bf(void Base::errorVerbose_+nop()())
117 it() bf(void executeAction_+nop()(int))
118 it() bf(int lex_(int token))
119 it() bf(int Base::lookup+nop()())
120 it() bf(LTYPE_ const &lsp_(int) const)nl()
121 (only available when tt(%lsp-needed, %ltype) or
122 tt(%locationstruct) was specified).
123 it() bf(void nextCycle_+nop()())
124 it() bf(void nextToken_+nop()())
125 it() bf(void Base::pop_+nop()())
126 it() bf(void Base::popToken_+nop()())
127 it() bf(void print_()())
128 it() bf(void Base::push_+nop()())
129 it() bf(void Base::pushToken_+nop()())
130 it() bf(void Base::shift_+nop()(int state))
131 it() bf(void Base::redoToken_+nop()(int rule))
132 it() bf(void Base::reduce_+nop()(int rule))
133 it() bf(void Base::savedToken_+nop()())
134 it() bf(void Base::symbol_+nop()())
135 it() bf(void Base::startRecovert_+nop()())
136 it() bf(void Base::top_+nop()())
137 it() bf(int Base::token_+nop()() const)
138 it() bf(void Base::vs_+nop()(int idx))
139 )
140
141
142
143