]>
Commit | Line | Data |
---|---|---|
a75c057f | 1 | m4_divert(-1) |
b4721715 | 2 | |
60491a94 | 3 | # C++ skeleton for Bison |
b4721715 | 4 | |
1221b78a | 5 | # Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. |
60491a94 AD |
6 | |
7 | # This program is free software; you can redistribute it and/or modify | |
8 | # it under the terms of the GNU General Public License as published by | |
9 | # the Free Software Foundation; either version 2 of the License, or | |
10 | # (at your option) any later version. | |
11 | ||
12 | # This program is distributed in the hope that it will be useful, | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | # GNU General Public License for more details. | |
16 | ||
17 | # You should have received a copy of the GNU General Public License | |
18 | # along with this program; if not, write to the Free Software | |
0fb669f9 PE |
19 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
20 | # 02110-1301 USA | |
60491a94 | 21 | |
cf147260 | 22 | m4_include(b4_pkgdatadir/[c++.m4]) |
4626a15d AD |
23 | # Backward compatibility. |
24 | m4_define([b4_location_constructors]) | |
fc695704 | 25 | m4_include(b4_pkgdatadir/[location.cc]) |
a5eb1ed2 | 26 | |
b526ee61 AD |
27 | # We do want M4 expansion after # for CPP macros. |
28 | m4_changecom() | |
98254360 | 29 | m4_divert(0)dnl |
b61c6978 PE |
30 | m4_if(b4_defines_flag, 0, [], |
31 | [@output @output_header_name@ | |
fb8135fa | 32 | b4_copyright([C++ Skeleton parser for LALR(1) parsing with Bison], |
02650b7f | 33 | [2002, 2003, 2004, 2005, 2006]) |
fb9712a9 | 34 | dnl FIXME: This is wrong, we want computed header guards. |
8bb4c753 | 35 | [ |
af3412cd PE |
36 | /* C++ LALR(1) parser skeleton written by Akim Demaille. */ |
37 | ||
c5e3e510 AD |
38 | #ifndef PARSER_HEADER_H |
39 | # define PARSER_HEADER_H | |
2b548aa6 | 40 | |
8d69a1a3 | 41 | #include <string> |
717be197 | 42 | #include <iostream> |
fb9712a9 | 43 | #include "stack.hh" |
50997c6e | 44 | |
fc695704 AD |
45 | namespace yy |
46 | { | |
47 | class position; | |
48 | class location; | |
49 | } | |
4162fa07 | 50 | |
fb9712a9 | 51 | /* First part of user declarations. */ |
c5e3e510 | 52 | ]b4_pre_prologue[ |
4162fa07 | 53 | |
996b1c7e | 54 | ]/* Line __line__ of lalr1.cc. */ |
c5e3e510 | 55 | b4_syncline([@oline@], [@ofile@])[ |
e96c9728 | 56 | |
fc695704 AD |
57 | ]dnl Include location.hh here: it might depend on headers included above. |
58 | [#include "location.hh" | |
59 | ||
69e2658b RA |
60 | /* Enabling traces. */ |
61 | #ifndef YYDEBUG | |
c5e3e510 | 62 | # define YYDEBUG ]b4_debug[ |
69e2658b RA |
63 | #endif |
64 | ||
141f5793 PE |
65 | /* Enabling verbose error messages. */ |
66 | #ifdef YYERROR_VERBOSE | |
67 | # undef YYERROR_VERBOSE | |
68 | # define YYERROR_VERBOSE 1 | |
69 | #else | |
c5e3e510 | 70 | # define YYERROR_VERBOSE ]b4_error_verbose[ |
69e2658b RA |
71 | #endif |
72 | ||
141f5793 PE |
73 | /* Enabling the token table. */ |
74 | #ifndef YYTOKEN_TABLE | |
75 | # define YYTOKEN_TABLE ]b4_token_table[ | |
76 | #endif | |
77 | ||
b4a20338 AD |
78 | /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. |
79 | If N is 0, then set CURRENT to the empty location which ends | |
80 | the previous symbol: RHS[0] (always defined). */ | |
3fc16193 | 81 | |
374f5a14 | 82 | #ifndef YYLLOC_DEFAULT |
b4a20338 AD |
83 | # define YYLLOC_DEFAULT(Current, Rhs, N) \ |
84 | do { \ | |
85 | if (N) \ | |
86 | { \ | |
87 | (Current).begin = (Rhs)[1].begin; \ | |
88 | (Current).end = (Rhs)[N].end; \ | |
89 | } \ | |
90 | else \ | |
91 | { \ | |
92 | (Current).begin = (Current).end = (Rhs)[0].end; \ | |
93 | } \ | |
2a4647a3 | 94 | } while (false) |
374f5a14 RA |
95 | #endif |
96 | ||
2b548aa6 RA |
97 | namespace yy |
98 | { | |
3f3eed27 | 99 | |
efeed023 | 100 | /// A Bison parser. |
07fed891 | 101 | class ]b4_parser_class_name[ |
2b548aa6 | 102 | { |
fb9712a9 | 103 | public: |
617a8f12 | 104 | /// Symbol semantic values. |
02650b7f | 105 | #ifndef YYSTYPE |
fb9712a9 | 106 | ]m4_ifdef([b4_stype], |
1221b78a PE |
107 | [ union semantic_type |
108 | b4_stype | |
fb9712a9 | 109 | /* Line __line__ of lalr1.cc. */ |
1221b78a PE |
110 | b4_syncline([@oline@], [@ofile@]) |
111 | ;], | |
fb9712a9 AD |
112 | [ typedef int semantic_type;])[ |
113 | #else | |
f479c6c6 | 114 | typedef YYSTYPE semantic_type; |
fb9712a9 | 115 | #endif |
617a8f12 | 116 | /// Symbol locations. |
f479c6c6 | 117 | typedef ]b4_location_type[ location_type; |
fb9712a9 AD |
118 | /// Tokens. |
119 | struct token | |
120 | { | |
121 | ]b4_token_enums(b4_tokens)[ | |
122 | }; | |
c095d689 AD |
123 | /// Token type. |
124 | typedef token::yytokentype token_type; | |
2b548aa6 | 125 | |
efeed023 | 126 | /// Build a parser object. |
98ae9643 AD |
127 | ]b4_parser_class_name[ (]b4_parse_param_decl[); |
128 | virtual ~]b4_parser_class_name[ (); | |
2b548aa6 | 129 | |
f69a4142 AD |
130 | /// Parse. |
131 | /// \returns 0 iff parsing succeeded. | |
e019c247 | 132 | virtual int parse (); |
2b548aa6 | 133 | |
f69a4142 | 134 | /// The current debugging stream. |
9a1e9989 AD |
135 | std::ostream& debug_stream () const; |
136 | /// Set the current debugging stream. | |
137 | void set_debug_stream (std::ostream &); | |
138 | ||
a3cb6248 AD |
139 | /// Type for debugging levels. |
140 | typedef int debug_level_type; | |
141 | /// The current debugging level. | |
142 | debug_level_type debug_level () const; | |
143 | /// Set the current debugging level. | |
144 | void set_debug_level (debug_level_type l); | |
145 | ||
2b548aa6 | 146 | private: |
efeed023 AD |
147 | /// Report a syntax error. |
148 | /// \param loc where the syntax error is found. | |
149 | /// \param msg a description of the syntax error. | |
99880de5 | 150 | virtual void error (const location_type& loc, const std::string& msg); |
efeed023 | 151 | |
dbcdae2d | 152 | /// Generate an error message. |
d4fb5e3c AD |
153 | /// \param state the state where the error occurred. |
154 | /// \param tok the look-ahead token. | |
155 | virtual std::string yysyntax_error_ (int yystate]dnl | |
156 | b4_error_verbose_if([, int tok])[); | |
efeed023 | 157 | |
a5eb1ed2 | 158 | #if YYDEBUG |
a0af42fc AD |
159 | /// \brief Report a symbol value on the debug stream. |
160 | /// \param yytype The token type. | |
161 | /// \param yyvaluep Its semantic value. | |
162 | /// \param yylocationp Its location. | |
163 | virtual void yy_symbol_value_print_ (int yytype, | |
02650b7f PE |
164 | const semantic_type* yyvaluep, |
165 | const location_type* yylocationp); | |
f69a4142 AD |
166 | /// \brief Report a symbol on the debug stream. |
167 | /// \param yytype The token type. | |
168 | /// \param yyvaluep Its semantic value. | |
169 | /// \param yylocationp Its location. | |
a0af42fc | 170 | virtual void yy_symbol_print_ (int yytype, |
02650b7f PE |
171 | const semantic_type* yyvaluep, |
172 | const location_type* yylocationp); | |
a5eb1ed2 AD |
173 | #endif /* ! YYDEBUG */ |
174 | ||
4bb2bc3f | 175 | |
e019c247 | 176 | /// State numbers. |
f479c6c6 | 177 | typedef int state_type; |
e019c247 AD |
178 | /// State stack type. |
179 | typedef stack<state_type> state_stack_type; | |
180 | /// Semantic value stack type. | |
181 | typedef stack<semantic_type> semantic_stack_type; | |
182 | /// location stack type. | |
183 | typedef stack<location_type> location_stack_type; | |
184 | ||
f69a4142 | 185 | /// The state stack. |
e019c247 | 186 | state_stack_type yystate_stack_; |
f69a4142 | 187 | /// The semantic value stack. |
e019c247 | 188 | semantic_stack_type yysemantic_stack_; |
f69a4142 | 189 | /// The location stack. |
e019c247 | 190 | location_stack_type yylocation_stack_; |
2b548aa6 | 191 | |
e019c247 | 192 | /// Internal symbol numbers. |
f479c6c6 | 193 | typedef ]b4_int_type_for([b4_translate])[ token_number_type; |
2b548aa6 | 194 | /* Tables. */ |
efeed023 | 195 | /// For a state, the index in \a yytable_ of its portion. |
617a8f12 AD |
196 | static const ]b4_int_type_for([b4_pact])[ yypact_[]; |
197 | static const ]b4_int_type(b4_pact_ninf, b4_pact_ninf)[ yypact_ninf_; | |
efeed023 AD |
198 | |
199 | /// For a state, default rule to reduce. | |
200 | /// Unless\a yytable_ specifies something else to do. | |
201 | /// Zero means the default is an error. | |
617a8f12 | 202 | static const ]b4_int_type_for([b4_defact])[ yydefact_[]; |
efeed023 | 203 | |
617a8f12 AD |
204 | static const ]b4_int_type_for([b4_pgoto])[ yypgoto_[]; |
205 | static const ]b4_int_type_for([b4_defgoto])[ yydefgoto_[]; | |
efeed023 AD |
206 | |
207 | /// What to do in a state. | |
208 | /// \a yytable_[yypact_[s]]: what to do in state \a s. | |
209 | /// - if positive, shift that token. | |
210 | /// - if negative, reduce the rule which number is the opposite. | |
211 | /// - if zero, do what YYDEFACT says. | |
617a8f12 AD |
212 | static const ]b4_int_type_for([b4_table])[ yytable_[]; |
213 | static const ]b4_int_type(b4_table_ninf, b4_table_ninf)[ yytable_ninf_; | |
efeed023 | 214 | |
617a8f12 | 215 | static const ]b4_int_type_for([b4_check])[ yycheck_[]; |
efeed023 AD |
216 | |
217 | /// For a state, its accessing symbol. | |
617a8f12 | 218 | static const ]b4_int_type_for([b4_stos])[ yystos_[]; |
efeed023 AD |
219 | |
220 | /// For a rule, its LHS. | |
617a8f12 | 221 | static const ]b4_int_type_for([b4_r1])[ yyr1_[]; |
efeed023 | 222 | /// For a rule, its RHS length. |
617a8f12 | 223 | static const ]b4_int_type_for([b4_r2])[ yyr2_[]; |
69e2658b | 224 | |
141f5793 | 225 | #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE |
efeed023 | 226 | /// For a symbol, its name in clear. |
9e0876fb PE |
227 | static const char* const yytname_[]; |
228 | #endif | |
229 | ||
230 | #if YYERROR_VERBOSE | |
231 | /// Convert the symbol name \a n to a form suitable for a diagnostic. | |
232 | virtual std::string yytnamerr_ (const char *n); | |
69e2658b | 233 | #endif |
2b548aa6 | 234 | |
69e2658b | 235 | #if YYDEBUG |
e019c247 | 236 | /// A type to store symbol numbers and -1. |
f479c6c6 | 237 | typedef ]b4_int_type_for([b4_rhs])[ rhs_number_type; |
617a8f12 | 238 | /// A `-1'-separated list of the rules' RHS. |
99880de5 | 239 | static const rhs_number_type yyrhs_[]; |
617a8f12 AD |
240 | /// For each rule, the index of the first RHS symbol in \a yyrhs_. |
241 | static const ]b4_int_type_for([b4_prhs])[ yyprhs_[]; | |
242 | /// For each rule, its source line number. | |
243 | static const ]b4_int_type_for([b4_rline])[ yyrline_[]; | |
244 | /// For each scanner token number, its symbol number. | |
245 | static const ]b4_int_type_for([b4_toknum])[ yytoken_number_[]; | |
efeed023 | 246 | /// Report on the debug stream that the rule \a r is going to be reduced. |
d1ff7a7c | 247 | virtual void yy_reduce_print_ (int r); |
efeed023 | 248 | /// Print the state stack on the debug stream. |
f69a4142 | 249 | virtual void yystack_print_ (); |
69e2658b | 250 | #endif |
2b548aa6 | 251 | |
f69a4142 | 252 | /// Convert a scanner token number to a symbol number. |
de35dd59 | 253 | token_number_type yytranslate_ (int token); |
f69a4142 AD |
254 | |
255 | /// \brief Reclaim the memory associated to a symbol. | |
256 | /// \param yymsg Why this token is reclaimed. | |
257 | /// \param yytype The symbol type. | |
258 | /// \param yyvaluep Its semantic value. | |
259 | /// \param yylocationp Its location. | |
260 | inline void yydestruct_ (const char* yymsg, | |
02650b7f PE |
261 | int yytype, |
262 | semantic_type* yyvaluep, | |
263 | location_type* yylocationp); | |
2b548aa6 | 264 | |
52d5733f | 265 | /// Pop \a n symbols the three stacks. |
f69a4142 | 266 | inline void yypop_ (unsigned int n = 1); |
52d5733f | 267 | |
762a801e | 268 | /* Constants. */ |
617a8f12 | 269 | static const int yyeof_; |
39912f52 | 270 | /* LAST_ -- Last index in TABLE_. */ |
617a8f12 AD |
271 | static const int yylast_; |
272 | static const int yynnts_; | |
273 | static const int yyempty_; | |
274 | static const int yyfinal_; | |
275 | static const int yyterror_; | |
276 | static const int yyerrcode_; | |
277 | static const int yyntokens_; | |
278 | static const unsigned int yyuser_token_number_max_; | |
99880de5 | 279 | static const token_number_type yyundef_token_; |
2b548aa6 | 280 | |
717be197 | 281 | /* Debugging. */ |
a3cb6248 | 282 | int yydebug_; |
9a1e9989 | 283 | std::ostream* yycdebug_; |
717be197 | 284 | |
caf37a36 | 285 | ]b4_parse_param_vars[ |
2b548aa6 RA |
286 | }; |
287 | } | |
288 | ||
fb9712a9 AD |
289 | ]m4_ifset([b4_global_tokens_and_yystype], |
290 | [b4_token_defines(b4_tokens) | |
291 | ||
292 | #ifndef YYSTYPE | |
9d9b8b70 | 293 | /* Redirection for backward compatibility. */ |
fb9712a9 AD |
294 | # define YYSTYPE yy::b4_parser_class_name::semantic_type |
295 | #endif | |
296 | ])[ | |
c5e3e510 | 297 | #endif /* ! defined PARSER_HEADER_H */] |
b61c6978 | 298 | ])dnl |
6ad762a8 | 299 | @output @output_parser_name@ |
fb8135fa | 300 | b4_copyright([C++ Skeleton parser for LALR(1) parsing with Bison], |
02650b7f | 301 | [2002, 2003, 2004, 2005, 2006]) |
c5b95ccf AD |
302 | m4_if(b4_prefix[], [yy], [], |
303 | [ | |
304 | // Take the name prefix into account. | |
305 | #define yylex b4_prefix[]lex]) | |
306 | m4_if(b4_defines_flag, 0, [], | |
307 | [ | |
308 | #include @output_header_name@])[ | |
50997c6e | 309 | |
fb9712a9 AD |
310 | /* User implementation prologue. */ |
311 | ]b4_post_prologue[ | |
312 | ||
313 | ]/* Line __line__ of lalr1.cc. */ | |
314 | b4_syncline([@oline@], [@ofile@])[ | |
315 | ||
30757c8c PE |
316 | #ifndef YY_ |
317 | # if YYENABLE_NLS | |
318 | # if ENABLE_NLS | |
319 | # include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */ | |
320 | # define YY_(msgid) dgettext ("bison-runtime", msgid) | |
321 | # endif | |
322 | # endif | |
323 | # ifndef YY_ | |
324 | # define YY_(msgid) msgid | |
325 | # endif | |
989b5b8e AD |
326 | #endif |
327 | ||
2a4647a3 | 328 | /* Suppress unused-variable warnings by "using" E. */ |
12ce2df6 | 329 | #define YYUSE(e) ((void) (e)) |
2a4647a3 | 330 | |
9d9b8b70 | 331 | /* A pseudo ostream that takes yydebug_ into account. */ |
9a1e9989 | 332 | # define YYCDEBUG \ |
a3cb6248 | 333 | for (bool yydebugcond_ = yydebug_; yydebugcond_; yydebugcond_ = false) \ |
9a1e9989 AD |
334 | (*yycdebug_) |
335 | ||
2b548aa6 | 336 | /* Enable debugging if requested. */ |
50997c6e | 337 | #if YYDEBUG |
284acc8b | 338 | |
284acc8b AD |
339 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ |
340 | do { \ | |
a3cb6248 | 341 | if (yydebug_) \ |
284acc8b | 342 | { \ |
d1ff7a7c | 343 | *yycdebug_ << Title << ' '; \ |
a0af42fc | 344 | yy_symbol_print_ ((Type), (Value), (Location)); \ |
9a1e9989 | 345 | *yycdebug_ << std::endl; \ |
284acc8b | 346 | } \ |
2a4647a3 | 347 | } while (false) |
284acc8b | 348 | |
5348bfbe AD |
349 | # define YY_REDUCE_PRINT(Rule) \ |
350 | do { \ | |
a3cb6248 | 351 | if (yydebug_) \ |
d1ff7a7c | 352 | yy_reduce_print_ (Rule); \ |
2a4647a3 | 353 | } while (false) |
284acc8b | 354 | |
25f66e1a AD |
355 | # define YY_STACK_PRINT() \ |
356 | do { \ | |
a3cb6248 | 357 | if (yydebug_) \ |
f69a4142 | 358 | yystack_print_ (); \ |
2a4647a3 | 359 | } while (false) |
284acc8b | 360 | |
2b548aa6 | 361 | #else /* !YYDEBUG */ |
284acc8b | 362 | |
284acc8b | 363 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) |
5348bfbe | 364 | # define YY_REDUCE_PRINT(Rule) |
25f66e1a | 365 | # define YY_STACK_PRINT() |
284acc8b | 366 | |
2b548aa6 RA |
367 | #endif /* !YYDEBUG */ |
368 | ||
60a777aa AD |
369 | #define YYACCEPT goto yyacceptlab |
370 | #define YYABORT goto yyabortlab | |
47301314 | 371 | #define YYERROR goto yyerrorlab |
60a777aa | 372 | |
9e0876fb PE |
373 | #if YYERROR_VERBOSE |
374 | ||
375 | /* Return YYSTR after stripping away unnecessary quotes and | |
376 | backslashes, so that it's suitable for yyerror. The heuristic is | |
377 | that double-quoting is unnecessary unless the string contains an | |
378 | apostrophe, a comma, or backslash (other than backslash-backslash). | |
379 | YYSTR is taken from yytname. */ | |
380 | std::string | |
381 | yy::]b4_parser_class_name[::yytnamerr_ (const char *yystr) | |
382 | { | |
383 | if (*yystr == '"') | |
384 | { | |
385 | std::string yyr = ""; | |
386 | char const *yyp = yystr; | |
387 | ||
388 | for (;;) | |
389 | switch (*++yyp) | |
390 | { | |
391 | case '\'': | |
392 | case ',': | |
393 | goto do_not_strip_quotes; | |
394 | ||
395 | case '\\': | |
396 | if (*++yyp != '\\') | |
397 | goto do_not_strip_quotes; | |
398 | /* Fall through. */ | |
399 | default: | |
400 | yyr += *yyp; | |
401 | break; | |
402 | ||
403 | case '"': | |
404 | return yyr; | |
405 | } | |
406 | do_not_strip_quotes: ; | |
407 | } | |
408 | ||
409 | return yystr; | |
410 | } | |
411 | ||
412 | #endif | |
413 | ||
98ae9643 | 414 | namespace yy |
a0e68930 | 415 | { |
98ae9643 AD |
416 | /// Build a parser object. |
417 | ]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[) | |
418 | : yydebug_ (false), | |
419 | yycdebug_ (&std::cerr)]b4_parse_param_cons[ | |
420 | { | |
421 | } | |
a0e68930 | 422 | |
98ae9643 AD |
423 | ]b4_parser_class_name::~b4_parser_class_name[ () |
424 | { | |
425 | } | |
a0e68930 | 426 | |
98ae9643 AD |
427 | #if YYDEBUG |
428 | /*--------------------------------. | |
429 | | Print this symbol on YYOUTPUT. | | |
430 | `--------------------------------*/ | |
a0e68930 | 431 | |
a0af42fc AD |
432 | inline void |
433 | ]b4_parser_class_name[::yy_symbol_value_print_ (int yytype, | |
02650b7f | 434 | const semantic_type* yyvaluep, const location_type* yylocationp) |
98ae9643 | 435 | { |
98ae9643 AD |
436 | YYUSE (yylocationp); |
437 | YYUSE (yyvaluep); | |
98ae9643 AD |
438 | switch (yytype) |
439 | { | |
440 | ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl | |
441 | [ default: | |
02650b7f | 442 | break; |
98ae9643 | 443 | } |
a0af42fc AD |
444 | } |
445 | ||
446 | ||
447 | void | |
448 | ]b4_parser_class_name[::yy_symbol_print_ (int yytype, | |
02650b7f | 449 | const semantic_type* yyvaluep, const location_type* yylocationp) |
a0af42fc AD |
450 | { |
451 | *yycdebug_ << (yytype < yyntokens_ ? "token" : "nterm") | |
02650b7f PE |
452 | << ' ' << yytname_[yytype] << " (" |
453 | << *yylocationp << ": "; | |
a0af42fc | 454 | yy_symbol_value_print_ (yytype, yyvaluep, yylocationp); |
98ae9643 AD |
455 | *yycdebug_ << ')'; |
456 | } | |
457 | #endif /* ! YYDEBUG */ | |
a0e68930 | 458 | |
98ae9643 AD |
459 | void |
460 | ]b4_parser_class_name[::yydestruct_ (const char* yymsg, | |
02650b7f | 461 | int yytype, semantic_type* yyvaluep, location_type* yylocationp) |
98ae9643 AD |
462 | { |
463 | YYUSE (yylocationp); | |
464 | YYUSE (yymsg); | |
465 | YYUSE (yyvaluep); | |
466 | ||
467 | YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); | |
468 | ||
469 | switch (yytype) | |
470 | { | |
471 | ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))[ | |
02650b7f PE |
472 | default: |
473 | break; | |
98ae9643 AD |
474 | } |
475 | } | |
60a777aa | 476 | |
98ae9643 AD |
477 | void |
478 | ]b4_parser_class_name[::yypop_ (unsigned int n) | |
479 | { | |
480 | yystate_stack_.pop (n); | |
481 | yysemantic_stack_.pop (n); | |
482 | yylocation_stack_.pop (n); | |
483 | } | |
52d5733f | 484 | |
98ae9643 AD |
485 | std::ostream& |
486 | ]b4_parser_class_name[::debug_stream () const | |
487 | { | |
488 | return *yycdebug_; | |
489 | } | |
9a1e9989 | 490 | |
98ae9643 AD |
491 | void |
492 | ]b4_parser_class_name[::set_debug_stream (std::ostream& o) | |
493 | { | |
494 | yycdebug_ = &o; | |
495 | } | |
9a1e9989 AD |
496 | |
497 | ||
98ae9643 AD |
498 | ]b4_parser_class_name[::debug_level_type |
499 | ]b4_parser_class_name[::debug_level () const | |
500 | { | |
501 | return yydebug_; | |
502 | } | |
a3cb6248 | 503 | |
98ae9643 AD |
504 | void |
505 | ]b4_parser_class_name[::set_debug_level (debug_level_type l) | |
506 | { | |
507 | yydebug_ = l; | |
508 | } | |
a3cb6248 AD |
509 | |
510 | ||
98ae9643 AD |
511 | int |
512 | ]b4_parser_class_name[::parse () | |
513 | { | |
514 | /// Look-ahead and look-ahead in internal form. | |
515 | int yychar = yyempty_; | |
516 | int yytoken = 0; | |
d4fb5e3c | 517 | |
98ae9643 AD |
518 | /* State. */ |
519 | int yyn; | |
a85284cf | 520 | int yylen = 0; |
98ae9643 | 521 | int yystate = 0; |
d4fb5e3c | 522 | |
9d9b8b70 | 523 | /* Error handling. */ |
98ae9643 AD |
524 | int yynerrs_ = 0; |
525 | int yyerrstatus_ = 0; | |
dbcdae2d | 526 | |
98ae9643 AD |
527 | /// Semantic value of the look-ahead. |
528 | semantic_type yylval; | |
529 | /// Location of the look-ahead. | |
530 | location_type yylloc; | |
531 | /// The locations where the error started and ended. | |
532 | location yyerror_range[2]; | |
dbcdae2d | 533 | |
98ae9643 AD |
534 | /// $$. |
535 | semantic_type yyval; | |
536 | /// @@$. | |
537 | location_type yyloc; | |
dbcdae2d | 538 | |
98ae9643 | 539 | int yyresult; |
ad745863 | 540 | |
98ae9643 | 541 | YYCDEBUG << "Starting parse" << std::endl; |
451364ed | 542 | |
451364ed | 543 | ]m4_ifdef([b4_initial_action], [ |
99880de5 AD |
544 | m4_pushdef([b4_at_dollar], [yylloc])dnl |
545 | m4_pushdef([b4_dollar_dollar], [yylval])dnl | |
9d9b8b70 | 546 | /* User initialization code. */ |
98ae9643 | 547 | b4_initial_action |
451364ed AD |
548 | m4_popdef([b4_dollar_dollar])dnl |
549 | m4_popdef([b4_at_dollar])dnl | |
98ae9643 | 550 | /* Line __line__ of yacc.c. */ |
451364ed AD |
551 | b4_syncline([@oline@], [@ofile@])])dnl |
552 | ||
98ae9643 AD |
553 | [ /* Initialize the stacks. The initial state will be pushed in |
554 | yynewstate, since the latter expects the semantical and the | |
555 | location values to have been already stored, initialize these | |
556 | stacks with a primary value. */ | |
557 | yystate_stack_ = state_stack_type (0); | |
558 | yysemantic_stack_ = semantic_stack_type (0); | |
559 | yylocation_stack_ = location_stack_type (0); | |
560 | yysemantic_stack_.push (yylval); | |
561 | yylocation_stack_.push (yylloc); | |
562 | ||
563 | /* New state. */ | |
564 | yynewstate: | |
565 | yystate_stack_.push (yystate); | |
566 | YYCDEBUG << "Entering state " << yystate << std::endl; | |
567 | goto yybackup; | |
568 | ||
569 | /* Backup. */ | |
570 | yybackup: | |
571 | ||
572 | /* Try to take a decision without look-ahead. */ | |
573 | yyn = yypact_[yystate]; | |
574 | if (yyn == yypact_ninf_) | |
575 | goto yydefault; | |
576 | ||
577 | /* Read a look-ahead token. */ | |
578 | if (yychar == yyempty_) | |
579 | { | |
02650b7f PE |
580 | YYCDEBUG << "Reading a token: "; |
581 | yychar = ]b4_c_function_call([yylex], [int], | |
582 | [[YYSTYPE*], [&yylval]][]dnl | |
dbcdae2d AD |
583 | b4_location_if([, [[location*], [&yylloc]]])dnl |
584 | m4_ifdef([b4_lex_param], [, ]b4_lex_param))[; | |
98ae9643 AD |
585 | } |
586 | ||
587 | ||
588 | /* Convert token to internal form. */ | |
589 | if (yychar <= yyeof_) | |
590 | { | |
02650b7f PE |
591 | yychar = yytoken = yyeof_; |
592 | YYCDEBUG << "Now at end of input." << std::endl; | |
98ae9643 AD |
593 | } |
594 | else | |
595 | { | |
02650b7f PE |
596 | yytoken = yytranslate_ (yychar); |
597 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); | |
98ae9643 AD |
598 | } |
599 | ||
600 | /* If the proper action on seeing token YYTOKEN is to reduce or to | |
601 | detect an error, take that action. */ | |
602 | yyn += yytoken; | |
603 | if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken) | |
604 | goto yydefault; | |
605 | ||
606 | /* Reduce or error. */ | |
607 | yyn = yytable_[yyn]; | |
608 | if (yyn <= 0) | |
609 | { | |
02650b7f PE |
610 | if (yyn == 0 || yyn == yytable_ninf_) |
611 | goto yyerrlab; | |
612 | yyn = -yyn; | |
613 | goto yyreduce; | |
98ae9643 AD |
614 | } |
615 | ||
616 | /* Accept? */ | |
617 | if (yyn == yyfinal_) | |
618 | goto yyacceptlab; | |
619 | ||
620 | /* Shift the look-ahead token. */ | |
621 | YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); | |
622 | ||
623 | /* Discard the token being shifted unless it is eof. */ | |
624 | if (yychar != yyeof_) | |
625 | yychar = yyempty_; | |
626 | ||
627 | yysemantic_stack_.push (yylval); | |
628 | yylocation_stack_.push (yylloc); | |
629 | ||
630 | /* Count tokens shifted since error; after three, turn off error | |
631 | status. */ | |
632 | if (yyerrstatus_) | |
633 | --yyerrstatus_; | |
634 | ||
635 | yystate = yyn; | |
636 | goto yynewstate; | |
637 | ||
638 | /*-----------------------------------------------------------. | |
639 | | yydefault -- do the default action for the current state. | | |
640 | `-----------------------------------------------------------*/ | |
641 | yydefault: | |
642 | yyn = yydefact_[yystate]; | |
643 | if (yyn == 0) | |
644 | goto yyerrlab; | |
645 | goto yyreduce; | |
646 | ||
647 | /*-----------------------------. | |
648 | | yyreduce -- Do a reduction. | | |
649 | `-----------------------------*/ | |
650 | yyreduce: | |
651 | yylen = yyr2_[yyn]; | |
a85284cf | 652 | /* If YYLEN is nonzero, implement the default value of the action: |
98ae9643 AD |
653 | `$$ = $1'. Otherwise, use the top of the stack. |
654 | ||
655 | Otherwise, the following line sets YYVAL to garbage. | |
656 | This behavior is undocumented and Bison | |
657 | users should not rely upon it. */ | |
658 | if (yylen) | |
659 | yyval = yysemantic_stack_[yylen - 1]; | |
660 | else | |
661 | yyval = yysemantic_stack_[0]; | |
2b548aa6 | 662 | |
2b548aa6 | 663 | { |
98ae9643 AD |
664 | slice<location_type, location_stack_type> slice (yylocation_stack_, yylen); |
665 | YYLLOC_DEFAULT (yyloc, slice, yylen); | |
2b548aa6 | 666 | } |
98ae9643 AD |
667 | YY_REDUCE_PRINT (yyn); |
668 | switch (yyn) | |
669 | { | |
02650b7f | 670 | ]b4_actions |
a85284cf AD |
671 | /* Line __line__ of lalr1.cc. */ |
672 | b4_syncline([@oline@], [@ofile@])[ | |
02650b7f | 673 | default: break; |
98ae9643 | 674 | } |
d1ff7a7c | 675 | YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc); |
98ae9643 AD |
676 | |
677 | yypop_ (yylen); | |
a85284cf | 678 | yylen = 0; |
98ae9643 AD |
679 | YY_STACK_PRINT (); |
680 | ||
681 | yysemantic_stack_.push (yyval); | |
682 | yylocation_stack_.push (yyloc); | |
683 | ||
684 | /* Shift the result of the reduction. */ | |
685 | yyn = yyr1_[yyn]; | |
686 | yystate = yypgoto_[yyn - yyntokens_] + yystate_stack_[0]; | |
687 | if (0 <= yystate && yystate <= yylast_ | |
02650b7f | 688 | && yycheck_[yystate] == yystate_stack_[0]) |
98ae9643 AD |
689 | yystate = yytable_[yystate]; |
690 | else | |
691 | yystate = yydefgoto_[yyn - yyntokens_]; | |
692 | goto yynewstate; | |
693 | ||
694 | /*------------------------------------. | |
695 | | yyerrlab -- here on detecting error | | |
696 | `------------------------------------*/ | |
697 | yyerrlab: | |
698 | /* If not already recovering from an error, report this error. */ | |
699 | if (!yyerrstatus_) | |
700 | { | |
02650b7f PE |
701 | ++yynerrs_; |
702 | error (yylloc, yysyntax_error_ (yystate]dnl | |
d4fb5e3c | 703 | b4_error_verbose_if([, yytoken])[)); |
98ae9643 AD |
704 | } |
705 | ||
706 | yyerror_range[0] = yylloc; | |
707 | if (yyerrstatus_ == 3) | |
708 | { | |
02650b7f PE |
709 | /* If just tried and failed to reuse look-ahead token after an |
710 | error, discard it. */ | |
711 | ||
712 | if (yychar <= yyeof_) | |
713 | { | |
714 | /* Return failure if at end of input. */ | |
715 | if (yychar == yyeof_) | |
716 | YYABORT; | |
717 | } | |
718 | else | |
719 | { | |
720 | yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc); | |
721 | yychar = yyempty_; | |
722 | } | |
98ae9643 AD |
723 | } |
724 | ||
725 | /* Else will try to reuse look-ahead token after shifting the error | |
726 | token. */ | |
727 | goto yyerrlab1; | |
728 | ||
729 | ||
730 | /*---------------------------------------------------. | |
731 | | yyerrorlab -- error raised explicitly by YYERROR. | | |
732 | `---------------------------------------------------*/ | |
733 | yyerrorlab: | |
734 | ||
735 | /* Pacify compilers like GCC when the user code never invokes | |
736 | YYERROR and the label yyerrorlab therefore never appears in user | |
737 | code. */ | |
738 | if (false) | |
739 | goto yyerrorlab; | |
740 | ||
741 | yyerror_range[0] = yylocation_stack_[yylen - 1]; | |
a85284cf | 742 | /* Do not reclaim the symbols of the rule which action triggered |
9d9b8b70 | 743 | this YYERROR. */ |
98ae9643 | 744 | yypop_ (yylen); |
a85284cf | 745 | yylen = 0; |
98ae9643 AD |
746 | yystate = yystate_stack_[0]; |
747 | goto yyerrlab1; | |
748 | ||
749 | /*-------------------------------------------------------------. | |
750 | | yyerrlab1 -- common code for both syntax error and YYERROR. | | |
751 | `-------------------------------------------------------------*/ | |
752 | yyerrlab1: | |
753 | yyerrstatus_ = 3; /* Each real token shifted decrements this. */ | |
754 | ||
755 | for (;;) | |
756 | { | |
02650b7f PE |
757 | yyn = yypact_[yystate]; |
758 | if (yyn != yypact_ninf_) | |
759 | { | |
760 | yyn += yyterror_; | |
761 | if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_) | |
762 | { | |
763 | yyn = yytable_[yyn]; | |
764 | if (0 < yyn) | |
765 | break; | |
766 | } | |
767 | } | |
768 | ||
769 | /* Pop the current state because it cannot handle the error token. */ | |
770 | if (yystate_stack_.height () == 1) | |
771 | YYABORT; | |
772 | ||
773 | yyerror_range[0] = yylocation_stack_[0]; | |
774 | yydestruct_ ("Error: popping", | |
775 | yystos_[yystate], | |
776 | &yysemantic_stack_[0], &yylocation_stack_[0]); | |
777 | yypop_ (); | |
778 | yystate = yystate_stack_[0]; | |
779 | YY_STACK_PRINT (); | |
98ae9643 AD |
780 | } |
781 | ||
782 | if (yyn == yyfinal_) | |
783 | goto yyacceptlab; | |
784 | ||
785 | yyerror_range[1] = yylloc; | |
786 | // Using YYLLOC is tempting, but would change the location of | |
787 | // the look-ahead. YYLOC is available though. | |
401aace6 | 788 | YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); |
98ae9643 AD |
789 | yysemantic_stack_.push (yylval); |
790 | yylocation_stack_.push (yyloc); | |
791 | ||
9d9b8b70 | 792 | /* Shift the error token. */ |
98ae9643 | 793 | YY_SYMBOL_PRINT ("Shifting", yystos_[yyn], |
02650b7f | 794 | &yysemantic_stack_[0], &yylocation_stack_[0]); |
98ae9643 AD |
795 | |
796 | yystate = yyn; | |
797 | goto yynewstate; | |
798 | ||
799 | /* Accept. */ | |
800 | yyacceptlab: | |
801 | yyresult = 0; | |
802 | goto yyreturn; | |
803 | ||
804 | /* Abort. */ | |
805 | yyabortlab: | |
806 | yyresult = 1; | |
807 | goto yyreturn; | |
808 | ||
809 | yyreturn: | |
810 | if (yychar != yyeof_ && yychar != yyempty_) | |
811 | yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc); | |
812 | ||
a85284cf | 813 | /* Do not reclaim the symbols of the rule which action triggered |
9d9b8b70 | 814 | this YYABORT or YYACCEPT. */ |
a85284cf | 815 | yypop_ (yylen); |
98ae9643 AD |
816 | while (yystate_stack_.height () != 1) |
817 | { | |
02650b7f PE |
818 | yydestruct_ ("Cleanup: popping", |
819 | yystos_[yystate_stack_[0]], | |
820 | &yysemantic_stack_[0], | |
821 | &yylocation_stack_[0]); | |
822 | yypop_ (); | |
98ae9643 AD |
823 | } |
824 | ||
825 | return yyresult; | |
826 | } | |
2b548aa6 | 827 | |
98ae9643 AD |
828 | // Generate an error message. |
829 | std::string | |
830 | ]b4_parser_class_name[::yysyntax_error_ (int yystate]dnl | |
fb9712a9 | 831 | b4_error_verbose_if([, int tok])[) |
98ae9643 AD |
832 | { |
833 | std::string res; | |
c66dfadd | 834 | YYUSE (yystate); |
a08460b0 | 835 | #if YYERROR_VERBOSE |
98ae9643 AD |
836 | int yyn = yypact_[yystate]; |
837 | if (yypact_ninf_ < yyn && yyn < yylast_) | |
838 | { | |
02650b7f PE |
839 | /* Start YYX at -YYN if negative to avoid negative indexes in |
840 | YYCHECK. */ | |
841 | int yyxbegin = yyn < 0 ? -yyn : 0; | |
842 | ||
843 | /* Stay within bounds of both yycheck and yytname. */ | |
844 | int yychecklim = yylast_ - yyn; | |
845 | int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; | |
846 | int count = 0; | |
847 | for (int x = yyxbegin; x < yyxend; ++x) | |
848 | if (yycheck_[x + yyn] == x && x != yyterror_) | |
849 | ++count; | |
850 | ||
851 | // FIXME: This method of building the message is not compatible | |
852 | // with internationalization. It should work like yacc.c does it. | |
853 | // That is, first build a string that looks like this: | |
854 | // "syntax error, unexpected %s or %s or %s" | |
855 | // Then, invoke YY_ on this string. | |
856 | // Finally, use the string as a format to output | |
857 | // yytname_[tok], etc. | |
858 | // Until this gets fixed, this message appears in English only. | |
859 | res = "syntax error, unexpected "; | |
860 | res += yytnamerr_ (yytname_[tok]); | |
861 | if (count < 5) | |
862 | { | |
863 | count = 0; | |
864 | for (int x = yyxbegin; x < yyxend; ++x) | |
865 | if (yycheck_[x + yyn] == x && x != yyterror_) | |
866 | { | |
867 | res += (!count++) ? ", expecting " : " or "; | |
868 | res += yytnamerr_ (yytname_[x]); | |
869 | } | |
870 | } | |
98ae9643 AD |
871 | } |
872 | else | |
dbcdae2d | 873 | #endif |
98ae9643 AD |
874 | res = YY_("syntax error"); |
875 | return res; | |
876 | } | |
a08460b0 | 877 | |
5348bfbe | 878 | |
98ae9643 AD |
879 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing |
880 | STATE-NUM. */ | |
881 | const ]b4_int_type(b4_pact_ninf, b4_pact_ninf) b4_parser_class_name::yypact_ninf_ = b4_pact_ninf[; | |
882 | const ]b4_int_type_for([b4_pact])[ | |
883 | ]b4_parser_class_name[::yypact_[] = | |
884 | { | |
885 | ]b4_pact[ | |
886 | }; | |
2b548aa6 | 887 | |
98ae9643 AD |
888 | /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE |
889 | doesn't specify something else to do. Zero means the default is an | |
890 | error. */ | |
891 | const ]b4_int_type_for([b4_defact])[ | |
892 | ]b4_parser_class_name[::yydefact_[] = | |
893 | { | |
894 | ]b4_defact[ | |
895 | }; | |
2b548aa6 | 896 | |
98ae9643 AD |
897 | /* YYPGOTO[NTERM-NUM]. */ |
898 | const ]b4_int_type_for([b4_pgoto])[ | |
899 | ]b4_parser_class_name[::yypgoto_[] = | |
900 | { | |
901 | ]b4_pgoto[ | |
902 | }; | |
2b548aa6 | 903 | |
98ae9643 AD |
904 | /* YYDEFGOTO[NTERM-NUM]. */ |
905 | const ]b4_int_type_for([b4_defgoto])[ | |
906 | ]b4_parser_class_name[::yydefgoto_[] = | |
907 | { | |
908 | ]b4_defgoto[ | |
909 | }; | |
2b548aa6 | 910 | |
98ae9643 AD |
911 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If |
912 | positive, shift that token. If negative, reduce the rule which | |
913 | number is the opposite. If zero, do what YYDEFACT says. */ | |
914 | const ]b4_int_type(b4_table_ninf, b4_table_ninf) b4_parser_class_name::yytable_ninf_ = b4_table_ninf[; | |
915 | const ]b4_int_type_for([b4_table])[ | |
916 | ]b4_parser_class_name[::yytable_[] = | |
917 | { | |
918 | ]b4_table[ | |
919 | }; | |
920 | ||
921 | /* YYCHECK. */ | |
922 | const ]b4_int_type_for([b4_check])[ | |
923 | ]b4_parser_class_name[::yycheck_[] = | |
924 | { | |
925 | ]b4_check[ | |
926 | }; | |
927 | ||
928 | /* STOS_[STATE-NUM] -- The (internal number of the) accessing | |
929 | symbol of state STATE-NUM. */ | |
930 | const ]b4_int_type_for([b4_stos])[ | |
931 | ]b4_parser_class_name[::yystos_[] = | |
932 | { | |
933 | ]b4_stos[ | |
934 | }; | |
769b430f | 935 | |
45d5982f | 936 | #if YYDEBUG |
98ae9643 AD |
937 | /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding |
938 | to YYLEX-NUM. */ | |
939 | const ]b4_int_type_for([b4_toknum])[ | |
940 | ]b4_parser_class_name[::yytoken_number_[] = | |
941 | { | |
942 | ]b4_toknum[ | |
943 | }; | |
769b430f AD |
944 | #endif |
945 | ||
98ae9643 AD |
946 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ |
947 | const ]b4_int_type_for([b4_r1])[ | |
948 | ]b4_parser_class_name[::yyr1_[] = | |
949 | { | |
950 | ]b4_r1[ | |
951 | }; | |
2b548aa6 | 952 | |
98ae9643 AD |
953 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ |
954 | const ]b4_int_type_for([b4_r2])[ | |
955 | ]b4_parser_class_name[::yyr2_[] = | |
956 | { | |
957 | ]b4_r2[ | |
958 | }; | |
2b548aa6 | 959 | |
141f5793 | 960 | #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE |
98ae9643 | 961 | /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. |
9d9b8b70 | 962 | First, the terminals, then, starting at \a yyntokens_, nonterminals. */ |
98ae9643 AD |
963 | const char* |
964 | const ]b4_parser_class_name[::yytname_[] = | |
965 | { | |
966 | ]b4_tname[ | |
967 | }; | |
69e2658b | 968 | #endif |
2b548aa6 | 969 | |
69e2658b | 970 | #if YYDEBUG |
9d9b8b70 | 971 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ |
98ae9643 AD |
972 | const ]b4_parser_class_name[::rhs_number_type |
973 | ]b4_parser_class_name[::yyrhs_[] = | |
974 | { | |
975 | ]b4_rhs[ | |
976 | }; | |
2b548aa6 | 977 | |
98ae9643 AD |
978 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in |
979 | YYRHS. */ | |
980 | const ]b4_int_type_for([b4_prhs])[ | |
981 | ]b4_parser_class_name[::yyprhs_[] = | |
982 | { | |
983 | ]b4_prhs[ | |
984 | }; | |
2b548aa6 | 985 | |
98ae9643 AD |
986 | /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ |
987 | const ]b4_int_type_for([b4_rline])[ | |
988 | ]b4_parser_class_name[::yyrline_[] = | |
989 | { | |
990 | ]b4_rline[ | |
991 | }; | |
5348bfbe | 992 | |
98ae9643 AD |
993 | // Print the state stack on the debug stream. |
994 | void | |
995 | ]b4_parser_class_name[::yystack_print_ () | |
996 | { | |
997 | *yycdebug_ << "Stack now"; | |
998 | for (state_stack_type::const_iterator i = yystate_stack_.begin (); | |
02650b7f | 999 | i != yystate_stack_.end (); ++i) |
98ae9643 AD |
1000 | *yycdebug_ << ' ' << *i; |
1001 | *yycdebug_ << std::endl; | |
1002 | } | |
25f66e1a | 1003 | |
98ae9643 AD |
1004 | // Report on the debug stream that the rule \a yyrule is going to be reduced. |
1005 | void | |
d1ff7a7c | 1006 | ]b4_parser_class_name[::yy_reduce_print_ (int yyrule) |
98ae9643 AD |
1007 | { |
1008 | unsigned int yylno = yyrline_[yyrule]; | |
d1ff7a7c | 1009 | int yynrhs = yyr2_[yyrule]; |
98ae9643 AD |
1010 | /* Print the symbols being reduced, and their result. */ |
1011 | *yycdebug_ << "Reducing stack by rule " << yyrule - 1 | |
02650b7f | 1012 | << " (line " << yylno << "), "; |
d1ff7a7c AD |
1013 | /* The symbols being reduced. */ |
1014 | for (int yyi = 0; yyi < yynrhs; yyi++) | |
1015 | YY_SYMBOL_PRINT (" $" << yyi + 1 << " =", | |
02650b7f PE |
1016 | yyrhs_[yyprhs_[yyrule] + yyi], |
1017 | &]b4_rhs_value(yynrhs, yyi + 1)[, | |
1018 | &]b4_rhs_location(yynrhs, yyi + 1)[); | |
98ae9643 | 1019 | } |
5348bfbe | 1020 | #endif // YYDEBUG |
69e2658b | 1021 | |
98ae9643 AD |
1022 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ |
1023 | ]b4_parser_class_name[::token_number_type | |
1024 | ]b4_parser_class_name[::yytranslate_ (int token) | |
2b548aa6 | 1025 | { |
98ae9643 AD |
1026 | static |
1027 | const token_number_type | |
1028 | translate_table[] = | |
1029 | { | |
1030 | ]b4_translate[ | |
1031 | }; | |
1032 | if ((unsigned int) token <= yyuser_token_number_max_) | |
1033 | return translate_table[token]; | |
1034 | else | |
1035 | return yyundef_token_; | |
1036 | } | |
1037 | ||
1038 | const int ]b4_parser_class_name[::yyeof_ = 0; | |
1039 | const int ]b4_parser_class_name[::yylast_ = ]b4_last[; | |
1040 | const int ]b4_parser_class_name[::yynnts_ = ]b4_nterms_number[; | |
1041 | const int ]b4_parser_class_name[::yyempty_ = -2; | |
1042 | const int ]b4_parser_class_name[::yyfinal_ = ]b4_final_state_number[; | |
1043 | const int ]b4_parser_class_name[::yyterror_ = 1; | |
1044 | const int ]b4_parser_class_name[::yyerrcode_ = 256; | |
1045 | const int ]b4_parser_class_name[::yyntokens_ = ]b4_tokens_number[; | |
1046 | ||
1047 | const unsigned int ]b4_parser_class_name[::yyuser_token_number_max_ = ]b4_user_token_number_max[; | |
1048 | const ]b4_parser_class_name[::token_number_type ]b4_parser_class_name[::yyundef_token_ = ]b4_undef_token_number[; | |
2b548aa6 | 1049 | |
98ae9643 | 1050 | } // namespace yy |
2b548aa6 | 1051 | |
c5e3e510 | 1052 | ]b4_epilogue |
21846f69 | 1053 | dnl |
2b81e969 | 1054 | @output b4_dir_prefix[]stack.hh |
1221b78a PE |
1055 | b4_copyright([stack handling for Bison C++ parsers], |
1056 | [2002, 2003, 2004, 2005, 2006])[ | |
98254360 | 1057 | |
2b548aa6 RA |
1058 | #ifndef BISON_STACK_HH |
1059 | # define BISON_STACK_HH | |
1060 | ||
45119f04 | 1061 | #include <deque> |
2b548aa6 RA |
1062 | |
1063 | namespace yy | |
1064 | { | |
f85a5e6f | 1065 | template <class T, class S = std::deque<T> > |
99880de5 | 1066 | class stack |
2b548aa6 RA |
1067 | { |
1068 | public: | |
1069 | ||
ecfe33e7 AD |
1070 | // Hide our reversed order. |
1071 | typedef typename S::reverse_iterator iterator; | |
1072 | typedef typename S::const_reverse_iterator const_iterator; | |
2b548aa6 | 1073 | |
99880de5 | 1074 | stack () : seq_ () |
2b548aa6 RA |
1075 | { |
1076 | } | |
1077 | ||
99880de5 | 1078 | stack (unsigned int n) : seq_ (n) |
2b548aa6 RA |
1079 | { |
1080 | } | |
1081 | ||
1082 | inline | |
1083 | T& | |
779e7ceb | 1084 | operator [] (unsigned int i) |
2b548aa6 | 1085 | { |
1d4055aa | 1086 | return seq_[i]; |
2b548aa6 RA |
1087 | } |
1088 | ||
1089 | inline | |
1090 | const T& | |
779e7ceb | 1091 | operator [] (unsigned int i) const |
2b548aa6 | 1092 | { |
1d4055aa | 1093 | return seq_[i]; |
2b548aa6 RA |
1094 | } |
1095 | ||
1096 | inline | |
1097 | void | |
1098 | push (const T& t) | |
1099 | { | |
45119f04 | 1100 | seq_.push_front (t); |
2b548aa6 RA |
1101 | } |
1102 | ||
1103 | inline | |
1104 | void | |
779e7ceb | 1105 | pop (unsigned int n = 1) |
2b548aa6 RA |
1106 | { |
1107 | for (; n; --n) | |
45119f04 | 1108 | seq_.pop_front (); |
2b548aa6 RA |
1109 | } |
1110 | ||
762a801e | 1111 | inline |
779e7ceb | 1112 | unsigned int |
762a801e RA |
1113 | height () const |
1114 | { | |
1115 | return seq_.size (); | |
1116 | } | |
1117 | ||
ecfe33e7 AD |
1118 | inline const_iterator begin () const { return seq_.rbegin (); } |
1119 | inline const_iterator end () const { return seq_.rend (); } | |
2b548aa6 RA |
1120 | |
1121 | private: | |
1122 | ||
1123 | S seq_; | |
1124 | }; | |
374f5a14 | 1125 | |
e019c247 | 1126 | /// Present a slice of the top of a stack. |
99880de5 AD |
1127 | template <class T, class S = stack<T> > |
1128 | class slice | |
374f5a14 RA |
1129 | { |
1130 | public: | |
1131 | ||
99880de5 | 1132 | slice (const S& stack, |
779e7ceb PE |
1133 | unsigned int range) : stack_ (stack), |
1134 | range_ (range) | |
374f5a14 RA |
1135 | { |
1136 | } | |
1137 | ||
1138 | inline | |
1139 | const T& | |
779e7ceb | 1140 | operator [] (unsigned int i) const |
374f5a14 | 1141 | { |
1d4055aa | 1142 | return stack_[range_ - i]; |
374f5a14 RA |
1143 | } |
1144 | ||
1145 | private: | |
1146 | ||
1147 | const S& stack_; | |
779e7ceb | 1148 | unsigned int range_; |
374f5a14 | 1149 | }; |
2b548aa6 RA |
1150 | } |
1151 | ||
c5e3e510 | 1152 | #endif // not BISON_STACK_HH] |
fc695704 | 1153 | m4_divert(-1) |