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