]> git.saurik.com Git - bison.git/blame - data/lalr1.cc
Make yyparser::error public.
[bison.git] / data / lalr1.cc
CommitLineData
60491a94 1# C++ skeleton for Bison
b4721715 2
cf98343c
AD
3# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008
4# Free Software Foundation, Inc.
60491a94 5
f16b0819 6# This program is free software: you can redistribute it and/or modify
60491a94 7# it under the terms of the GNU General Public License as published by
f16b0819 8# the Free Software Foundation, either version 3 of the License, or
60491a94 9# (at your option) any later version.
f16b0819 10#
60491a94
AD
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
f16b0819 15#
60491a94 16# You should have received a copy of the GNU General Public License
f16b0819 17# along with this program. If not, see <http://www.gnu.org/licenses/>.
60491a94 18
cf147260 19m4_include(b4_pkgdatadir/[c++.m4])
7eb8a0bc 20
2ea7730c 21
ba206cf4
AD
22# b4_integral_parser_table_declare(TABLE-NAME, CONTENT, COMMENT)
23# --------------------------------------------------------------
0fddb3d5 24# Declare "parser::yy<TABLE-NAME>_" which contents is CONTENT.
ba206cf4 25m4_define([b4_integral_parser_table_declare],
6ab1adbe
AD
26[m4_ifval([$3], [b4_c_comment([$3], [ ])
27])dnl
28 static const b4_int_type_for([$2]) yy$1_[[]];dnl
0fddb3d5
AD
29])
30
ba206cf4 31# b4_integral_parser_table_define(TABLE-NAME, CONTENT, COMMENT)
0fddb3d5 32# ---------------------------------------------
8901f32e 33# Define "parser::yy<TABLE-NAME>_" which contents is CONTENT.
ba206cf4 34m4_define([b4_integral_parser_table_define],
6ab1adbe 35[ const b4_int_type_for([$2])
8901f32e
AD
36 b4_parser_class_name::yy$1_[[]] =
37 {
38 $2
6ab1adbe
AD
39 };dnl
40])
41
a9ce3f54 42
5de9c593
AD
43# b4_symbol_value_template(VAL, [TYPE])
44# -------------------------------------
507aa0e2
AD
45# Same as b4_symbol_value, but used in a template method. It makes
46# a difference when using variants.
5de9c593
AD
47m4_copy([b4_symbol_value], [b4_symbol_value_template])
48
5ab8c47b 49
09277875
AD
50# b4_lex_symbol_if([IF-YYLEX-RETURNS-A-COMPLETE-SYMBOL], [IF-NOT])
51# ----------------------------------------------------------------
52m4_define([b4_lex_symbol_if],
53[b4_percent_define_ifdef([[lex_symbol]], [$1], [$2])])
54
55
8901f32e 56# b4_assert_if([IF-ASSERTIONS-ARE-USED], [IF-NOT])
5de9c593 57# ------------------------------------------------
8901f32e
AD
58m4_define([b4_assert_if],
59[b4_percent_define_ifdef([[assert]], [$1], [$2])])
60
61
e1f93869
AD
62# b4_lhs_value([TYPE])
63# --------------------
64# Expansion of $<TYPE>$.
65m4_define([b4_lhs_value],
507aa0e2 66 [b4_symbol_value([yylhs.value], [$1])])
e1f93869
AD
67
68
69# b4_lhs_location()
70# -----------------
71# Expansion of @$.
72m4_define([b4_lhs_location],
507aa0e2 73 [yylhs.location])
e1f93869
AD
74
75
33c195cc
AD
76# b4_rhs_data(RULE-LENGTH, NUM)
77# -----------------------------
78# Return the data corresponding to the symbol #NUM, where the current
79# rule has RULE-LENGTH symbols on RHS.
80m4_define([b4_rhs_data],
3204049e 81 [yystack_@{b4_subtract($@)@}])
33c195cc
AD
82
83
84# b4_rhs_state(RULE-LENGTH, NUM)
51bacae6 85# ------------------------------
33c195cc
AD
86# The state corresponding to the symbol #NUM, where the current
87# rule has RULE-LENGTH symbols on RHS.
88m4_define([b4_rhs_state],
89 [b4_rhs_data([$1], [$2]).state])
90
91
8901f32e
AD
92# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
93# --------------------------------------
94# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
95# symbols on RHS.
96m4_define([b4_rhs_value],
33c195cc
AD
97 [b4_symbol_value([b4_rhs_data([$1], [$2]).value], [$3])])
98
8901f32e
AD
99
100# b4_rhs_location(RULE-LENGTH, NUM)
101# ---------------------------------
102# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
103# on RHS.
104m4_define([b4_rhs_location],
33c195cc 105 [b4_rhs_data([$1], [$2]).location])
8901f32e 106
507aa0e2 107
2bde9113
AD
108# b4_symbol_action(SYMBOL-NUM, KIND)
109# ----------------------------------
110# Run the action KIND (destructor or printer) for SYMBOL-NUM.
c4585f1e 111# Same as in C, but using references instead of pointers.
2bde9113
AD
112m4_define([b4_symbol_action],
113[b4_symbol_if([$1], [has_$2],
c4585f1e 114[m4_pushdef([b4_dollar_dollar],
2bde9113
AD
115 [b4_symbol_value_template([yysym.value],
116 b4_symbol_if([$1], [has_type],
117 [b4_symbol([$1], [type])]))])dnl
1f7d007b 118m4_pushdef([b4_at_dollar], [yysym.location])dnl
fb7c5b1f 119 b4_symbol_case_([$1])
2bde9113
AD
120b4_syncline([b4_symbol([$1], [$2_line])], ["b4_symbol([$1], [$2_file])"])
121 b4_symbol([$1], [$2])
c4585f1e
AD
122b4_syncline([@oline@], [@ofile@])
123 break;
2bde9113 124
c4585f1e
AD
125m4_popdef([b4_at_dollar])dnl
126m4_popdef([b4_dollar_dollar])dnl
2bde9113
AD
127])])
128
fe1b448a
AD
129# b4_symbol_constructor_declaration_(SYMBOL-NUMBER)
130# -------------------------------------------------
2873fdf8
AD
131# Declare the overloaded version of make_symbol for the (common) type of
132# these SYMBOL-NUMBERS. Use at class-level.
133m4_define([b4_symbol_constructor_declaration_],
aea10ef4 134[b4_symbol_if([$1], [is_token], [b4_symbol_if([$1], [has_id],
fe1b448a
AD
135[ static inline
136 symbol_type
137 make_[]b4_symbol_([$1], [id]) (dnl
6659366c
AD
138b4_args(b4_symbol_if([$1], [has_type],
139 [const b4_symbol([$1], [type])& v]),
c1e6c88c 140 b4_locations_if([const location_type& l])));
1c4af381 141
2873fdf8
AD
142])])])
143
fe1b448a
AD
144
145# b4_symbol_constructor_declarations
146# ----------------------------------
147# Declare symbol constructors for all the value types.
148# Use at class-level.
149m4_define([b4_symbol_constructor_declarations],
2873fdf8 150[b4_variant_if([
fe1b448a 151 // Symbol constructors declarations.
e3c52a63 152b4_symbol_foreach([b4_symbol_constructor_declaration_])])])
2873fdf8
AD
153
154
155
156# b4_symbol_constructor_definition_(SYMBOL-NUMBER)
157# ------------------------------------------------
fe1b448a 158# Define symbol constructor for this SYMBOL-NUMBER.
2873fdf8 159m4_define([b4_symbol_constructor_definition_],
aea10ef4 160[b4_symbol_if([$1], [is_token], [b4_symbol_if([$1], [has_id],
fe1b448a
AD
161[ b4_parser_class_name::symbol_type
162 b4_parser_class_name::make_[]b4_symbol_([$1], [id]) (dnl
6659366c
AD
163b4_args(b4_symbol_if([$1], [has_type],
164 [const b4_symbol([$1], [type])& v]),
2ea7730c 165 b4_locations_if([const location_type& l])))
2873fdf8 166 {
aea10ef4 167 return symbol_type (b4_args([yytranslate_ (token::b4_symbol([$1], [id]))],
6659366c 168 b4_symbol_if([$1], [has_type], [v]),
2ea7730c 169 b4_locations_if([l])));
2873fdf8
AD
170 }
171
172])])])
173
174
e51b0a82 175# b4_symbol_constructor_definitions
2873fdf8
AD
176# ----------------------------------
177# Define the overloaded versions of make_symbol for all the value types.
178m4_define([b4_symbol_constructor_definitions],
e51b0a82
AD
179[[ // symbol_base_type.
180 template <typename Exact>
181 ]b4_parser_class_name[::symbol_base_type<Exact>::symbol_base_type ()
182 : value()]b4_locations_if([
183 , location()])[
184 {
185 }]b4_locations_if([[
186
187 template <typename Exact>
188 ]b4_parser_class_name[::symbol_base_type<Exact>::symbol_base_type (const location_type& l)
189 : value()
190 , location(l)
191 {
192 }]])[
193
194 template <typename Exact>
195 ]b4_parser_class_name[::symbol_base_type<Exact>::symbol_base_type (]b4_args(
196 [const semantic_type& v],
197 b4_locations_if([const location_type& l]))[)
198 : value(v)]b4_locations_if([
199 , location(l)])[
200 {
201 }
202
203 template <typename Exact>
204 const Exact&
205 ]b4_parser_class_name[::symbol_base_type<Exact>::self () const
206 {
207 return static_cast<const Exact&>(*this);
208 }
209
210 template <typename Exact>
211 Exact&
212 ]b4_parser_class_name[::symbol_base_type<Exact>::self ()
213 {
214 return static_cast<Exact&>(*this);
215 }
216
217 template <typename Exact>
218 int
219 ]b4_parser_class_name[::symbol_base_type<Exact>::type_get () const
220 {
221 return self ().type_get_ ();
222 }
223
224 // symbol_type.
225 ]b4_parser_class_name[::symbol_type::symbol_type ()
226 : super_type ()
227 , type ()
228 {
229 }
230
231 ]b4_parser_class_name[::symbol_type::symbol_type (]b4_args(
232 [int t],
233 b4_locations_if([const location_type& l]))[)
234 : super_type (]b4_locations_if([l])[)
235 , type (t)
236 {
237 }
238
239 ]b4_parser_class_name[::symbol_type::symbol_type (]b4_args(
240 [int t],
241 [const semantic_type& v],
242 b4_locations_if([const location_type& l]))[)
243 : super_type (v]b4_locations_if([, l])[)
244 , type (t)
245 {
246 }
247
248 int
249 ]b4_parser_class_name[::symbol_type::type_get_ () const
250 {
251 return type;
252 }
202598d3
AD
253]b4_lex_symbol_if([[
254 ]b4_parser_class_name[::token_type
255 ]b4_parser_class_name[::symbol_type::token () const
256 {
257 // YYTOKNUM[NUM] -- (External) token number corresponding to the
258 // (internal) symbol number NUM (which must be that of a token). */
259 static
260 const ]b4_int_type_for([b4_toknum])[
261 yytoken_number_[] =
262 {
263 ]b4_toknum[
264 };
265 return static_cast<token_type> (yytoken_number_[type]);
266 }
267]])[
e51b0a82
AD
268
269]b4_variant_if(
2873fdf8 270[ // Implementation of make_symbol for each symbol type.
e3c52a63 271b4_symbol_foreach([b4_symbol_constructor_definition_])])])
2873fdf8
AD
272
273
78835571
AD
274# b4_yytranslate_definition
275# -------------------------
276# Define yytranslate_. Sometimes we want it in the header file,
277# sometimes the cc file suffices.
278m4_define([b4_yytranslate_definition],
cb0b136a 279[[ // Symbol number corresponding to token number t.
78835571
AD
280 ]b4_parser_class_name[::token_number_type
281 ]b4_parser_class_name[::yytranslate_ (]b4_lex_symbol_if([token_type],
282 [int])[ t)
283 {
284 static
285 const token_number_type
286 translate_table[] =
287 {
288]b4_translate[
289 };
290 const unsigned int user_token_number_max_ = ]b4_user_token_number_max[;
291 const token_number_type undef_token_ = ]b4_undef_token_number[;
292
293 if (static_cast<int>(t) <= yyeof_)
294 return yyeof_;
295 else if (static_cast<unsigned int> (t) <= user_token_number_max_)
296 return translate_table[t];
297 else
298 return undef_token_;
299 }
300]])
301
302
8901f32e
AD
303m4_pushdef([b4_copyright_years],
304 [2002, 2003, 2004, 2005, 2006, 2007, 2008])
305
6afc30cc 306m4_define([b4_parser_class_name],
a4e25e1d 307 [b4_percent_define_get([[parser_class_name]])])
34376418
AD
308
309# The header is mandatory.
310b4_defines_if([],
5f340b48 311 [b4_fatal([b4_skeleton[: using %%defines is mandatory]])])
34376418 312
2ea7730c
AD
313b4_locations_if(
314[# Backward compatibility.
4626a15d 315m4_define([b4_location_constructors])
2ea7730c 316m4_include(b4_pkgdatadir/[location.cc])])
51bacae6 317m4_include(b4_pkgdatadir/[stack.hh])
507aa0e2 318b4_variant_if([m4_include(b4_pkgdatadir/[variant.hh])])
a5eb1ed2 319
b526ee61
AD
320# We do want M4 expansion after # for CPP macros.
321m4_changecom()
08af01c2 322m4_divert_push(0)dnl
c944f7f2 323@output(b4_spec_defines_file@)@
a9ce3f54 324b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++])
fb9712a9 325dnl FIXME: This is wrong, we want computed header guards.
8bb4c753 326[
af3412cd
PE
327/* C++ LALR(1) parser skeleton written by Akim Demaille. */
328
c5e3e510
AD
329#ifndef PARSER_HEADER_H
330# define PARSER_HEADER_H
2b548aa6 331
a4e25e1d 332]b4_percent_code_get([[requires]])[
aef3da86 333
8901f32e 334]b4_assert_if([#include <cassert>])[
8d69a1a3 335#include <string>
717be197 336#include <iostream>
fb9712a9 337#include "stack.hh"
50997c6e 338
793fbca5 339]b4_namespace_open[
2ea7730c
AD
340]b4_locations_if([ class position;
341 class location;])[
507aa0e2 342]b4_variant_if([b4_variant_definition])[
793fbca5 343]b4_namespace_close[
4162fa07 344
2ea7730c 345]b4_locations_if([#include "location.hh"])[
fc695704 346
69e2658b
RA
347/* Enabling traces. */
348#ifndef YYDEBUG
327afc7c 349# define YYDEBUG ]b4_debug_flag[
69e2658b
RA
350#endif
351
141f5793
PE
352/* Enabling verbose error messages. */
353#ifdef YYERROR_VERBOSE
354# undef YYERROR_VERBOSE
355# define YYERROR_VERBOSE 1
356#else
327afc7c 357# define YYERROR_VERBOSE ]b4_error_verbose_flag[
69e2658b
RA
358#endif
359
141f5793
PE
360/* Enabling the token table. */
361#ifndef YYTOKEN_TABLE
362# define YYTOKEN_TABLE ]b4_token_table[
363#endif
364
2ea7730c
AD
365]b4_locations_if([dnl
366[/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
b4a20338
AD
367 If N is 0, then set CURRENT to the empty location which ends
368 the previous symbol: RHS[0] (always defined). */
3fc16193 369
374f5a14 370#ifndef YYLLOC_DEFAULT
8901f32e
AD
371# define YYLLOC_DEFAULT(Current, Rhs, N) \
372do { \
373 if (N) \
374 { \
375 (Current).begin = (Rhs)[1].location.begin; \
376 (Current).end = (Rhs)[N].location.end; \
377 } \
378 else \
379 { \
380 (Current).begin = (Current).end = (Rhs)[0].location.end; \
381 } \
2a4647a3 382} while (false)
2ea7730c 383#endif]])[
374f5a14 384
793fbca5 385]b4_namespace_open[
3f3eed27 386
efeed023 387 /// A Bison parser.
07fed891 388 class ]b4_parser_class_name[
2b548aa6 389 {
fb9712a9 390 public:
02650b7f 391#ifndef YYSTYPE
5ab8c47b
AD
392]b4_variant_if(
393[ /// An auxiliary type to compute the largest semantic type.
394 union union_type
e3c52a63 395 {]b4_type_foreach([b4_char_sizeof])[};
5ab8c47b
AD
396
397 /// Symbol semantic values.
398 typedef variant<sizeof(union_type)> semantic_type;],
399[ /// Symbol semantic values.
400m4_ifdef([b4_stype],
1221b78a 401[ union semantic_type
5ab8c47b 402 {b4_user_stype
7ecec4dd 403 };],
ddc8ede1
PE
404[m4_if(b4_tag_seen_flag, 0,
405[[ typedef int semantic_type;]],
5ab8c47b 406[[ typedef YYSTYPE semantic_type;]])])])[
fb9712a9 407#else
f479c6c6 408 typedef YYSTYPE semantic_type;
2ea7730c 409#endif]b4_locations_if([
617a8f12 410 /// Symbol locations.
2ea7730c 411 typedef b4_percent_define_get([[location_type]]) location_type;])[
fb9712a9
AD
412 /// Tokens.
413 struct token
414 {
415 ]b4_token_enums(b4_tokens)[
416 };
c095d689
AD
417 /// Token type.
418 typedef token::yytokentype token_type;
2b548aa6 419
efeed023 420 /// Build a parser object.
98ae9643
AD
421 ]b4_parser_class_name[ (]b4_parse_param_decl[);
422 virtual ~]b4_parser_class_name[ ();
2b548aa6 423
f69a4142
AD
424 /// Parse.
425 /// \returns 0 iff parsing succeeded.
e019c247 426 virtual int parse ();
2b548aa6 427
52cbbe84 428#if YYDEBUG
f69a4142 429 /// The current debugging stream.
9a1e9989
AD
430 std::ostream& debug_stream () const;
431 /// Set the current debugging stream.
432 void set_debug_stream (std::ostream &);
433
a3cb6248
AD
434 /// Type for debugging levels.
435 typedef int debug_level_type;
436 /// The current debugging level.
437 debug_level_type debug_level () const;
438 /// Set the current debugging level.
439 void set_debug_level (debug_level_type l);
52cbbe84 440#endif
a3cb6248 441
2ea7730c
AD
442 /// Report a syntax error.]b4_locations_if([
443 /// \param loc where the syntax error is found.])[
efeed023 444 /// \param msg a description of the syntax error.
2ea7730c 445 virtual void error (]b4_locations_if([const location_type& loc, ])[const std::string& msg);
efeed023 446
49572920 447 private:
dbcdae2d 448 /// Generate an error message.
d4fb5e3c 449 /// \param state the state where the error occurred.
742e4900 450 /// \param tok the lookahead token.
8901f32e 451 virtual std::string yysyntax_error_ (int yystate, int tok);
efeed023 452
e019c247 453 /// State numbers.
f479c6c6 454 typedef int state_type;
2b548aa6 455
e019c247 456 /// Internal symbol numbers.
f479c6c6 457 typedef ]b4_int_type_for([b4_translate])[ token_number_type;
617a8f12 458 static const ]b4_int_type(b4_pact_ninf, b4_pact_ninf)[ yypact_ninf_;
617a8f12 459 static const ]b4_int_type(b4_table_ninf, b4_table_ninf)[ yytable_ninf_;
efeed023 460
0fddb3d5 461 /* Tables. */
ba206cf4 462]b4_parser_tables_declare[
69e2658b 463
141f5793 464#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
efeed023 465 /// For a symbol, its name in clear.
9e0876fb 466 static const char* const yytname_[];
422c18f4 467#endif]b4_error_verbose_if([
9e0876fb 468
9e0876fb 469 /// Convert the symbol name \a n to a form suitable for a diagnostic.
422c18f4 470 static std::string yytnamerr_ (const char *n);])[
2b548aa6 471
69e2658b 472#if YYDEBUG
ba206cf4
AD
473]b4_integral_parser_table_declare([rline], [b4_rline],
474 [YYRLINE[YYN] -- Source line where rule number YYN was defined.])[
efeed023 475 /// Report on the debug stream that the rule \a r is going to be reduced.
d1ff7a7c 476 virtual void yy_reduce_print_ (int r);
efeed023 477 /// Print the state stack on the debug stream.
f69a4142 478 virtual void yystack_print_ ();
fa7b79c0
PE
479
480 /* Debugging. */
481 int yydebug_;
482 std::ostream* yycdebug_;
69e2658b 483#endif
2b548aa6 484
32c96bd7 485 /// Convert a scanner token number \a t to a symbol number.
1c4af381 486 static inline token_number_type yytranslate_ (]b4_lex_symbol_if([token_type], [int])[ t);
f69a4142 487
1f7d007b 488 /// A complete symbol, with its type.
5de9c593 489 template <typename Exact>
1f7d007b 490 struct symbol_base_type
8901f32e
AD
491 {
492 /// Default constructor.
d3be4f6d 493 inline symbol_base_type ();
8901f32e 494
2ea7730c
AD
495 /// Constructor.]b4_locations_if([
496 inline symbol_base_type (const location_type& l)])[;
497 inline symbol_base_type (]b4_args(
498 [const semantic_type& v],
499 b4_locations_if([const location_type& l]))[);
8901f32e 500
5de9c593
AD
501 /// Return this with its exact type.
502 const Exact& self () const;
503 Exact& self ();
504
1f7d007b 505 /// Return the type of this symbol.
5de9c593 506 int type_get () const;
8901f32e
AD
507
508 /// The semantic value.
2ea7730c 509 semantic_type value;]b4_locations_if([
8901f32e
AD
510
511 /// The location.
2ea7730c 512 location_type location;])[
8901f32e
AD
513 };
514
57295d14 515#if YYDEBUG
1f7d007b
AD
516 /// \brief Display a symbol type, value and location.
517 /// \param yyo The output stream.
518 /// \param yysym The symbol.
5de9c593
AD
519 template <typename Exact>
520 void yy_print_ (std::ostream& yyo,
521 const symbol_base_type<Exact>& yysym) const;
57295d14
AD
522#endif
523
1f7d007b
AD
524 /// \brief Reclaim the memory associated to a symbol.
525 /// \param yymsg Why this token is reclaimed.
526 /// If null, print nothing.
527 /// \param s The symbol.
5de9c593
AD
528 template <typename Exact>
529 inline void yy_destroy_ (const char* yymsg,
530 symbol_base_type<Exact>& yysym) const;
1f7d007b 531
2873fdf8 532 public:
1f7d007b 533 /// Element of the stack: a state and its attributes.
5de9c593 534 struct symbol_type : symbol_base_type<symbol_type>
1f7d007b 535 {
5de9c593
AD
536 /// The parent class.
537 typedef symbol_base_type<symbol_type> super_type;
538
1f7d007b 539 /// Default constructor.
d3be4f6d 540 inline symbol_type ();
1f7d007b
AD
541
542 /// Constructor.
2ea7730c
AD
543 inline symbol_type (]b4_args([int t],
544 [const semantic_type& v],
545 b4_locations_if([const location_type& l]))[);
1f7d007b 546
2ea7730c
AD
547 inline symbol_type (]b4_args([int t],
548 b4_locations_if([const location_type& l]))[);
2873fdf8 549
1f7d007b
AD
550 /// The symbol type.
551 int type;
552
553 /// Return the type corresponding to this state.
5de9c593 554 inline int type_get_ () const;
202598d3
AD
555
556 /// Its token.
557 inline token_type token () const;
1f7d007b
AD
558 };
559
2873fdf8
AD
560]b4_symbol_constructor_declarations[
561
562 private:
1f7d007b 563 /// Element of the stack: a state and its attributes.
5de9c593 564 struct stack_symbol_type : symbol_base_type<stack_symbol_type>
1f7d007b 565 {
5de9c593
AD
566 /// The parent class.
567 typedef symbol_base_type<stack_symbol_type> super_type;
568
1f7d007b 569 /// Default constructor.
d3be4f6d 570 inline stack_symbol_type ();
1f7d007b
AD
571
572 /// Constructor.
2ea7730c
AD
573 inline stack_symbol_type (]b4_args([state_type s],
574 [const semantic_type& v],
575 b4_locations_if([const location_type& l]))[);
1f7d007b
AD
576
577 /// The state.
578 state_type state;
57295d14 579
1f7d007b 580 /// Return the type corresponding to this state.
5de9c593 581 inline int type_get_ () const;
1f7d007b 582 };
57295d14 583
8901f32e 584 /// Stack type.
bc0b0477 585 typedef stack<stack_symbol_type> stack_type;
8901f32e
AD
586
587 /// The stack.
588 stack_type yystack_;
589
7dedf26e 590 /// Push a new state on the stack.
9380cfd0
AD
591 /// \param m a debug message to display
592 /// if null, no trace is output.
e9b0834e
AD
593 /// \param s the symbol
594 /// \warning the contents of \a s.value is stolen.
bc0b0477 595 inline void yypush_ (const char* m, stack_symbol_type& s);
7dedf26e 596
1f7d007b
AD
597 /// Push a new look ahead token on the state on the stack.
598 /// \param m a debug message to display
599 /// if null, no trace is output.
600 /// \param s the state
601 /// \param sym the symbol (for its value and location).
602 /// \warning the contents of \a s.value is stolen.
603 inline void yypush_ (const char* m, state_type s, symbol_type& sym);
604
52d5733f 605 /// Pop \a n symbols the three stacks.
f69a4142 606 inline void yypop_ (unsigned int n = 1);
52d5733f 607
762a801e 608 /* Constants. */
914202bd
AD
609 enum
610 {
611 yyeof_ = 0,
612 yylast_ = ]b4_last[, //< Last index in yytable_.
613 yynnts_ = ]b4_nterms_number[, //< Number of nonterminal symbols.
614 yyempty_ = -2,
615 yyfinal_ = ]b4_final_state_number[, //< Termination state number.
616 yyterror_ = 1,
617 yyerrcode_ = 256,
618 yyntokens_ = ]b4_tokens_number[, //< Number of tokens.
619 };
620
caf37a36 621]b4_parse_param_vars[
2b548aa6 622 };
1c4af381
AD
623
624]b4_lex_symbol_if([b4_yytranslate_definition])[
2c086d29 625]b4_lex_symbol_if([b4_symbol_constructor_definitions])[
793fbca5 626]b4_namespace_close[
2b548aa6 627
592d0b1e 628]b4_percent_define_flag_if([[global_tokens_and_yystype]],
fb9712a9
AD
629[b4_token_defines(b4_tokens)
630
631#ifndef YYSTYPE
9d9b8b70 632 /* Redirection for backward compatibility. */
793fbca5 633# define YYSTYPE b4_namespace_ref::b4_parser_class_name::semantic_type
fb9712a9 634#endif
9bc0dd67 635])
a4e25e1d 636b4_percent_code_get([[provides]])[]dnl
9bc0dd67
JD
637
638[#endif /* ! defined PARSER_HEADER_H */]
a0d4650a 639@output(b4_parser_file_name@)@
a9ce3f54 640b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++])
a4e25e1d 641b4_percent_code_get([[top]])[]dnl
aa08666d 642m4_if(b4_prefix, [yy], [],
c5b95ccf
AD
643[
644// Take the name prefix into account.
9bc0dd67
JD
645#define yylex b4_prefix[]lex])[
646
647/* First part of user declarations. */
c944f7f2 648]b4_user_pre_prologue[
9bc0dd67 649
c944f7f2 650#include "@basename(]b4_spec_defines_file[@)"
50997c6e 651
fb9712a9 652/* User implementation prologue. */
8e0a5e9e 653]b4_user_post_prologue
a4e25e1d 654b4_percent_code_get[]dnl
fb9712a9 655
8e0a5e9e 656[#ifndef YY_
30757c8c
PE
657# if YYENABLE_NLS
658# if ENABLE_NLS
659# include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */
660# define YY_(msgid) dgettext ("bison-runtime", msgid)
661# endif
662# endif
663# ifndef YY_
664# define YY_(msgid) msgid
665# endif
989b5b8e
AD
666#endif
667
2a4647a3 668/* Suppress unused-variable warnings by "using" E. */
12ce2df6 669#define YYUSE(e) ((void) (e))
2a4647a3 670
2b548aa6 671/* Enable debugging if requested. */
50997c6e 672#if YYDEBUG
284acc8b 673
fa7b79c0
PE
674/* A pseudo ostream that takes yydebug_ into account. */
675# define YYCDEBUG if (yydebug_) (*yycdebug_)
676
1f7d007b 677# define YY_SYMBOL_PRINT(Title, Symbol) \
57295d14
AD
678 do { \
679 if (yydebug_) \
680 { \
681 *yycdebug_ << Title << ' '; \
1f7d007b 682 yy_print_ (*yycdebug_, Symbol); \
57295d14
AD
683 *yycdebug_ << std::endl; \
684 } \
8901f32e 685 } while (false)
284acc8b 686
5348bfbe 687# define YY_REDUCE_PRINT(Rule) \
8901f32e
AD
688 do { \
689 if (yydebug_) \
690 yy_reduce_print_ (Rule); \
691 } while (false)
284acc8b 692
25f66e1a 693# define YY_STACK_PRINT() \
8901f32e
AD
694 do { \
695 if (yydebug_) \
696 yystack_print_ (); \
697 } while (false)
284acc8b 698
2b548aa6 699#else /* !YYDEBUG */
284acc8b 700
a36b333c 701# define YYCDEBUG if (false) std::cerr
1f7d007b
AD
702# define YY_SYMBOL_PRINT(Title, Symbol) static_cast<void>(0)
703# define YY_REDUCE_PRINT(Rule) static_cast<void>(0)
704# define YY_STACK_PRINT() static_cast<void>(0)
284acc8b 705
2b548aa6
RA
706#endif /* !YYDEBUG */
707
39be9022
AD
708#define yyerrok (yyerrstatus_ = 0)
709#define yyclearin (yyempty = true)
98e26a92 710
39be9022
AD
711#define YYACCEPT goto yyacceptlab
712#define YYABORT goto yyabortlab
713#define YYERROR goto yyerrorlab
98e26a92 714#define YYRECOVERING() (!!yyerrstatus_)
60a777aa 715
422c18f4 716]b4_namespace_open[]b4_error_verbose_if([[
9e0876fb 717
aa08666d
AD
718 /* Return YYSTR after stripping away unnecessary quotes and
719 backslashes, so that it's suitable for yyerror. The heuristic is
720 that double-quoting is unnecessary unless the string contains an
721 apostrophe, a comma, or backslash (other than backslash-backslash).
722 YYSTR is taken from yytname. */
723 std::string
724 ]b4_parser_class_name[::yytnamerr_ (const char *yystr)
725 {
726 if (*yystr == '"')
727 {
728 std::string yyr = "";
729 char const *yyp = yystr;
193d7c70 730
aa08666d
AD
731 for (;;)
732 switch (*++yyp)
733 {
734 case '\'':
735 case ',':
736 goto do_not_strip_quotes;
193d7c70 737
aa08666d
AD
738 case '\\':
739 if (*++yyp != '\\')
740 goto do_not_strip_quotes;
741 /* Fall through. */
742 default:
743 yyr += *yyp;
744 break;
193d7c70 745
aa08666d
AD
746 case '"':
747 return yyr;
748 }
749 do_not_strip_quotes: ;
750 }
193d7c70 751
aa08666d
AD
752 return yystr;
753 }
422c18f4 754]])[
9e0876fb 755
98ae9643 756 /// Build a parser object.
fa7b79c0
PE
757 ]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [
758 :])[
759#if YYDEBUG
760 ]m4_ifset([b4_parse_param], [ ], [ :])[yydebug_ (false),
761 yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[
762#endif]b4_parse_param_cons[
98ae9643
AD
763 {
764 }
a0e68930 765
98ae9643
AD
766 ]b4_parser_class_name::~b4_parser_class_name[ ()
767 {
768 }
a0e68930 769
a0e68930 770
1f7d007b
AD
771 /*---------------.
772 | Symbol types. |
773 `---------------*/
774
2c086d29 775]b4_lex_symbol_if([], [b4_symbol_constructor_definitions])[
2873fdf8 776
1f7d007b
AD
777 // stack_symbol_type.
778 ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type ()
5de9c593
AD
779 : super_type ()
780 , state ()
1f7d007b
AD
781 {
782 }
783
2ea7730c
AD
784 ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (]b4_args(
785 [state_type s],
786 [const semantic_type& v],
787 b4_locations_if([const location_type& l]))[)
788 : super_type (v]b4_locations_if([, l])[)
5de9c593 789 , state (s)
1f7d007b
AD
790 {
791 }
792
793 int
5de9c593 794 ]b4_parser_class_name[::stack_symbol_type::type_get_ () const
1f7d007b
AD
795 {
796 return yystos_[state];
797 }
798
799
5de9c593 800 template <typename Exact>
98ae9643 801 void
5de9c593
AD
802 ]b4_parser_class_name[::yy_destroy_ (const char* yymsg,
803 symbol_base_type<Exact>& yysym) const
98ae9643 804 {
1f7d007b 805 int yytype = yysym.type_get ();
98ae9643 806 YYUSE (yymsg);
8901f32e 807 if (yymsg)
1f7d007b 808 YY_SYMBOL_PRINT (yymsg, yysym);
98ae9643 809
8901f32e 810 // User destructor.
98ae9643
AD
811 switch (yytype)
812 {
e3c52a63 813]b4_symbol_foreach([b4_symbol_destructor])dnl
2bde9113
AD
814[ default:
815 break;
8901f32e
AD
816 }]b4_variant_if([
817
818 // Type destructor.
4c3cc7da 819 b4_symbol_variant([[yytype]], [[yysym.value]], [[template destroy]])])[
8901f32e
AD
820 }
821
1f7d007b 822#if YYDEBUG
5de9c593 823 template <typename Exact>
1f7d007b 824 void
5de9c593
AD
825 ]b4_parser_class_name[::yy_print_ (std::ostream& yyo,
826 const symbol_base_type<Exact>& yysym) const
8901f32e 827 {
1f7d007b
AD
828 int yytype = yysym.type_get ();
829 yyo << (yytype < yyntokens_ ? "token" : "nterm")
2ea7730c
AD
830 << ' ' << yytname_[yytype] << " ("]b4_locations_if([
831 << yysym.location << ": "])[;
1f7d007b
AD
832 switch (yytype)
833 {
e3c52a63 834]b4_symbol_foreach([b4_symbol_printer])dnl
2bde9113 835[ default:
1f7d007b
AD
836 break;
837 }
838 yyo << ')';
8901f32e 839 }
1f7d007b 840#endif
8901f32e 841
1f7d007b
AD
842 void
843 ]b4_parser_class_name[::yypush_ (const char* m, state_type s,
844 symbol_type& sym)
8901f32e 845 {
1f7d007b
AD
846 if (m)
847 YY_SYMBOL_PRINT (m, sym);
848]b4_variant_if(
2ea7730c
AD
849[[ yystack_.push (stack_symbol_type (]b4_args(
850 [s],
851 [semantic_type()],
852 b4_locations_if([sym.location]))[));
1f7d007b
AD
853 ]b4_symbol_variant([[yystos_[s]]], [[yystack_[0].value]],
854 [build], [sym.value])],
2ea7730c
AD
855[[ yystack_.push (stack_symbol_type (]b4_args(
856 [s],
857 [sym.value],
858 b4_locations_if([sym.location]))[));]])[
98ae9643 859 }
60a777aa 860
7dedf26e 861 void
bc0b0477 862 ]b4_parser_class_name[::yypush_ (const char* m, stack_symbol_type& s)
7dedf26e 863 {
9380cfd0 864 if (m)
1f7d007b 865 YY_SYMBOL_PRINT (m, s);
8901f32e 866]b4_variant_if(
2ea7730c
AD
867[[ yystack_.push (stack_symbol_type (]b4_args(
868 [s.state],
869 [semantic_type()],
870 b4_locations_if([s.location]))[));
1f7d007b 871 ]b4_symbol_variant([[yystos_[s.state]]], [[yystack_[0].value]],
e9b0834e
AD
872 [build], [s.value])],
873[ yystack_.push (s);])[
7dedf26e
AD
874 }
875
98ae9643
AD
876 void
877 ]b4_parser_class_name[::yypop_ (unsigned int n)
878 {
8901f32e 879 yystack_.pop (n);
98ae9643 880 }
52d5733f 881
fa7b79c0 882#if YYDEBUG
98ae9643
AD
883 std::ostream&
884 ]b4_parser_class_name[::debug_stream () const
885 {
886 return *yycdebug_;
887 }
9a1e9989 888
98ae9643
AD
889 void
890 ]b4_parser_class_name[::set_debug_stream (std::ostream& o)
891 {
892 yycdebug_ = &o;
893 }
9a1e9989
AD
894
895
98ae9643
AD
896 ]b4_parser_class_name[::debug_level_type
897 ]b4_parser_class_name[::debug_level () const
898 {
899 return yydebug_;
900 }
a3cb6248 901
98ae9643
AD
902 void
903 ]b4_parser_class_name[::set_debug_level (debug_level_type l)
904 {
905 yydebug_ = l;
906 }
fa7b79c0 907#endif
a3cb6248 908
98ae9643
AD
909 int
910 ]b4_parser_class_name[::parse ()
911 {
39be9022
AD
912 /// Whether yyla contains a lookahead.
913 bool yyempty = true;
d4fb5e3c 914
98ae9643
AD
915 /* State. */
916 int yyn;
a85284cf 917 int yylen = 0;
98ae9643 918 int yystate = 0;
d4fb5e3c 919
9d9b8b70 920 /* Error handling. */
98ae9643
AD
921 int yynerrs_ = 0;
922 int yyerrstatus_ = 0;
dbcdae2d 923
6082531a 924 /// The lookahead symbol.
2ea7730c 925 symbol_type yyla;]b4_locations_if([[
6082531a 926
98ae9643 927 /// The locations where the error started and ended.
2ea7730c 928 stack_symbol_type yyerror_range[2];]])[
dbcdae2d 929
e1f93869 930 /// $$ and @@$.
bc0b0477 931 stack_symbol_type yylhs;
dbcdae2d 932
e1f93869 933 /// The return value of parse().
98ae9643 934 int yyresult;
ad745863 935
98ae9643 936 YYCDEBUG << "Starting parse" << std::endl;
451364ed 937
451364ed 938]m4_ifdef([b4_initial_action], [
6082531a
AD
939m4_pushdef([b4_at_dollar], [yyla.location])dnl
940m4_pushdef([b4_dollar_dollar], [yyla.value])dnl
9d9b8b70 941 /* User initialization code. */
8ec0a172 942 b4_user_initial_action
451364ed 943m4_popdef([b4_dollar_dollar])dnl
8ec0a172 944m4_popdef([b4_at_dollar])])dnl
451364ed 945
8901f32e 946 [ /* Initialize the stack. The initial state will be set in
98ae9643
AD
947 yynewstate, since the latter expects the semantical and the
948 location values to have been already stored, initialize these
949 stacks with a primary value. */
8901f32e 950 yystack_ = stack_type (0);
1f7d007b 951 yypush_ (0, 0, yyla);
98ae9643 952
7dedf26e
AD
953 // A new state was pushed on the stack.
954 // Invariant: yystate == yystack_[0].state, i.e.,
955 // yystate was just pushed onto the state stack.
98ae9643 956 yynewstate:
98ae9643 957 YYCDEBUG << "Entering state " << yystate << std::endl;
868d2d96
JD
958
959 /* Accept? */
960 if (yystate == yyfinal_)
961 goto yyacceptlab;
962
98ae9643
AD
963 goto yybackup;
964
965 /* Backup. */
966 yybackup:
967
742e4900 968 /* Try to take a decision without lookahead. */
98ae9643
AD
969 yyn = yypact_[yystate];
970 if (yyn == yypact_ninf_)
971 goto yydefault;
972
742e4900 973 /* Read a lookahead token. */
39be9022 974 if (yyempty)
98ae9643 975 {
09277875
AD
976 YYCDEBUG << "Reading a token: ";
977]b4_lex_symbol_if(
dd735e4e
AD
978[ yyla = b4_c_function_call([yylex], [symbol_type],
979 m4_ifdef([b4_lex_param], b4_lex_param));],
09277875 980[ yyla.type = yytranslate_ (b4_c_function_call([yylex], [int],
6082531a
AD
981 [[YYSTYPE*], [&yyla.value]][]dnl
982b4_locations_if([, [[location*], [&yyla.location]]])dnl
09277875 983m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
39be9022 984 yyempty = false;
98ae9643 985 }
aba12ad1 986 YY_SYMBOL_PRINT ("Next token is", yyla);
98ae9643 987
1f7d007b
AD
988 /* If the proper action on seeing token YYLA.TYPE is to reduce or
989 to detect an error, take that action. */
990 yyn += yyla.type;
991 if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.type)
98ae9643
AD
992 goto yydefault;
993
994 /* Reduce or error. */
995 yyn = yytable_[yyn];
996 if (yyn <= 0)
997 {
02650b7f 998 if (yyn == 0 || yyn == yytable_ninf_)
6082531a 999 goto yyerrlab;
02650b7f
PE
1000 yyn = -yyn;
1001 goto yyreduce;
98ae9643
AD
1002 }
1003
868d2d96 1004 /* Discard the token being shifted. */
39be9022 1005 yyempty = true;
98ae9643
AD
1006
1007 /* Count tokens shifted since error; after three, turn off error
1008 status. */
1009 if (yyerrstatus_)
1010 --yyerrstatus_;
1011
9380cfd0 1012 /* Shift the lookahead token. */
1f7d007b
AD
1013 yystate = yyn;
1014 yypush_ ("Shifting", yystate, yyla);
98ae9643
AD
1015 goto yynewstate;
1016
1017 /*-----------------------------------------------------------.
1018 | yydefault -- do the default action for the current state. |
1019 `-----------------------------------------------------------*/
1020 yydefault:
1021 yyn = yydefact_[yystate];
1022 if (yyn == 0)
1023 goto yyerrlab;
1024 goto yyreduce;
1025
1026 /*-----------------------------.
1027 | yyreduce -- Do a reduction. |
1028 `-----------------------------*/
1029 yyreduce:
5ab8c47b
AD
1030 yylen = yyr2_[yyn];]b4_variant_if([
1031 /* Variants are always initialized to an empty instance of the
1032 correct type. The default $$=$1 rule is NOT applied when using
1033 variants */
507aa0e2 1034 ]b4_symbol_variant([[yyr1_@{yyn@}]], [yylhs.value], [build]),[
a85284cf 1035 /* If YYLEN is nonzero, implement the default value of the action:
98ae9643
AD
1036 `$$ = $1'. Otherwise, use the top of the stack.
1037
e1f93869 1038 Otherwise, the following line sets YYLHS.VALUE to garbage.
98ae9643
AD
1039 This behavior is undocumented and Bison
1040 users should not rely upon it. */
1041 if (yylen)
e1f93869 1042 yylhs.value = yystack_@{yylen - 1@}.value;
98ae9643 1043 else
e1f93869 1044 yylhs.value = yystack_@{0@}.value;])[
2ea7730c
AD
1045]b4_locations_if([dnl
1046[
8901f32e 1047 // Compute the default @@$.
2b548aa6 1048 {
bc0b0477 1049 slice<stack_symbol_type, stack_type> slice (yystack_, yylen);
e1f93869 1050 YYLLOC_DEFAULT (yylhs.location, slice, yylen);
2ea7730c 1051 }]])[
8901f32e
AD
1052
1053 // Perform the reduction.
98ae9643
AD
1054 YY_REDUCE_PRINT (yyn);
1055 switch (yyn)
1056 {
30bb2edc 1057]b4_user_actions[
cf98343c
AD
1058 default:
1059 break;
98ae9643 1060 }
e1f93869
AD
1061 // Compute post-reduction state.
1062 yyn = yyr1_[yyn];
1063 yystate = yypgoto_[yyn - yyntokens_] + yystack_[yylen].state;
1064 if (0 <= yystate && yystate <= yylast_
1065 && yycheck_[yystate] == yystack_[yylen].state)
1066 yystate = yytable_[yystate];
1067 else
1068 yystate = yydefgoto_[yyn - yyntokens_];
1069 yylhs.state = yystate;
1f7d007b 1070 YY_SYMBOL_PRINT ("-> $$ =", yylhs);
8901f32e 1071]b4_variant_if([[
9c6a8966 1072 // Destroy the rhs symbols.
8901f32e 1073 for (int i = 0; i < yylen; ++i)
9c6a8966
AD
1074 // Destroy a variant which value may have been swapped with
1075 // yylhs.value (for instance if the action was "std::swap($$,
1076 // $1)"). The value of yylhs.value (hence possibly one of these
1077 // rhs symbols) depends on the default contruction for this
1078 // type. In the case of pointers for instance, no
1079 // initialization is done, so the value is junk. Therefore do
1080 // not try to report the value of symbols about to be destroyed
1081 // in the debug trace, it's possibly junk. Hence yymsg = 0.
1082 // Besides, that keeps exactly the same traces as with the other
1083 // Bison skeletons.
1f7d007b 1084 yy_destroy_ (0, yystack_[i]);]])[
98ae9643
AD
1085
1086 yypop_ (yylen);
a85284cf 1087 yylen = 0;
98ae9643 1088 YY_STACK_PRINT ();
98ae9643
AD
1089
1090 /* Shift the result of the reduction. */
e9b0834e 1091 yypush_ (0, yylhs);
98ae9643
AD
1092 goto yynewstate;
1093
9c6a8966
AD
1094 /*--------------------------------------.
1095 | yyerrlab -- here on detecting error. |
1096 `--------------------------------------*/
98ae9643
AD
1097 yyerrlab:
1098 /* If not already recovering from an error, report this error. */
1099 if (!yyerrstatus_)
1100 {
02650b7f 1101 ++yynerrs_;
2ea7730c
AD
1102 error (]b4_args(b4_locations_if([yyla.location]),
1103 [yysyntax_error_ (yystate, yyla.type)])[);
98ae9643
AD
1104 }
1105
2ea7730c
AD
1106]b4_locations_if([[
1107 yyerror_range[0].location = yyla.location;]])[
98ae9643
AD
1108 if (yyerrstatus_ == 3)
1109 {
742e4900 1110 /* If just tried and failed to reuse lookahead token after an
27cb5b59
AD
1111 error, discard it. */
1112
1113 /* Return failure if at end of input. */
aba12ad1 1114 if (yyla.type == yyeof_)
27cb5b59
AD
1115 YYABORT;
1116 else
39be9022 1117 {
27cb5b59 1118 yy_destroy_ ("Error: discarding", yyla);
39be9022 1119 yyempty = true;
02650b7f 1120 }
98ae9643
AD
1121 }
1122
742e4900 1123 /* Else will try to reuse lookahead token after shifting the error
98ae9643
AD
1124 token. */
1125 goto yyerrlab1;
1126
1127
1128 /*---------------------------------------------------.
1129 | yyerrorlab -- error raised explicitly by YYERROR. |
1130 `---------------------------------------------------*/
1131 yyerrorlab:
1132
1133 /* Pacify compilers like GCC when the user code never invokes
1134 YYERROR and the label yyerrorlab therefore never appears in user
1135 code. */
1136 if (false)
1137 goto yyerrorlab;
1138
2ea7730c
AD
1139]b4_locations_if([[
1140 yyerror_range[0].location = yystack_[yylen - 1].location;]])[
a85284cf 1141 /* Do not reclaim the symbols of the rule which action triggered
9d9b8b70 1142 this YYERROR. */
98ae9643 1143 yypop_ (yylen);
a85284cf 1144 yylen = 0;
8901f32e 1145 yystate = yystack_[0].state;
98ae9643
AD
1146 goto yyerrlab1;
1147
1148 /*-------------------------------------------------------------.
1149 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1150 `-------------------------------------------------------------*/
1151 yyerrlab1:
1152 yyerrstatus_ = 3; /* Each real token shifted decrements this. */
e1f93869 1153 {
bc0b0477 1154 stack_symbol_type error_token;
e1f93869
AD
1155 for (;;)
1156 {
1157 yyn = yypact_[yystate];
1158 if (yyn != yypact_ninf_)
1159 {
1160 yyn += yyterror_;
1161 if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
1162 {
1163 yyn = yytable_[yyn];
1164 if (0 < yyn)
1165 break;
1166 }
1167 }
98ae9643 1168
e1f93869
AD
1169 // Pop the current state because it cannot handle the error token.
1170 if (yystack_.size () == 1)
1171 YYABORT;
2ea7730c
AD
1172]b4_locations_if([[
1173 yyerror_range[0].location = yystack_[0].location;]])[
1f7d007b 1174 yy_destroy_ ("Error: popping", yystack_[0]);
e1f93869
AD
1175 yypop_ ();
1176 yystate = yystack_[0].state;
1177 YY_STACK_PRINT ();
1178 }
2ea7730c 1179]b4_locations_if([[
6082531a 1180 yyerror_range[1].location = yyla.location;
2ea7730c 1181 YYLLOC_DEFAULT (error_token.location, (yyerror_range - 1), 2);]])[
e1f93869
AD
1182
1183 /* Shift the error token. */
e9b0834e
AD
1184 error_token.state = yystate = yyn;
1185 yypush_ ("Shifting", error_token);
e1f93869 1186 }
98ae9643
AD
1187 goto yynewstate;
1188
1189 /* Accept. */
1190 yyacceptlab:
1191 yyresult = 0;
1192 goto yyreturn;
1193
1194 /* Abort. */
1195 yyabortlab:
1196 yyresult = 1;
1197 goto yyreturn;
1198
1199 yyreturn:
39be9022 1200 if (!yyempty)
1f7d007b 1201 yy_destroy_ ("Cleanup: discarding lookahead", yyla);
98ae9643 1202
a85284cf 1203 /* Do not reclaim the symbols of the rule which action triggered
9d9b8b70 1204 this YYABORT or YYACCEPT. */
a85284cf 1205 yypop_ (yylen);
8901f32e 1206 while (yystack_.size () != 1)
98ae9643 1207 {
1f7d007b 1208 yy_destroy_ ("Cleanup: popping", yystack_[0]);
02650b7f 1209 yypop_ ();
98ae9643
AD
1210 }
1211
1212 return yyresult;
1213 }
2b548aa6 1214
98ae9643
AD
1215 // Generate an error message.
1216 std::string
422c18f4
AD
1217 ]b4_parser_class_name[::yysyntax_error_ (]dnl
1218b4_error_verbose_if([int yystate, int yytoken],
1219 [int, int])[)
98ae9643 1220 {
422c18f4 1221 std::string yyres;]b4_error_verbose_if([[
98ae9643 1222 int yyn = yypact_[yystate];
d6645148 1223 if (yypact_ninf_ < yyn && yyn <= yylast_)
98ae9643 1224 {
02650b7f
PE
1225 /* Start YYX at -YYN if negative to avoid negative indexes in
1226 YYCHECK. */
1227 int yyxbegin = yyn < 0 ? -yyn : 0;
1228
1229 /* Stay within bounds of both yycheck and yytname. */
d6645148 1230 int yychecklim = yylast_ - yyn + 1;
02650b7f 1231 int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
a0ffc175 1232
eeb29422
AD
1233 // Number of reported tokens (one for the "unexpected", one per
1234 // "expected").
a0ffc175
AD
1235 size_t yycount = 0;
1236 // Its maximum.
1237 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1238 // Arguments of yyformat.
1239 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1240 yyarg[yycount++] = yytname_[yytoken];
1241 for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
1242 if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_)
1243 {
1244 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1245 {
1246 yycount = 1;
1247 break;
1248 }
1249 else
1250 yyarg[yycount++] = yytname_[yyx];
1251 }
1252
1253 char const* yyformat = 0;
1254 switch (yycount)
1255 {
1256#define YYCASE_(N, S) \
1257 case N: \
1258 yyformat = S; \
1259 break
1260 YYCASE_(1, YY_("syntax error, unexpected %s"));
1261 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1262 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1263 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1264 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1265#undef YYCASE_
1266 }
1267 // Argument number.
1268 size_t yyi = 0;
1269 for (char const* yyp = yyformat; *yyp; ++yyp)
1270 if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
1271 {
1272 yyres += yytnamerr_ (yyarg[yyi++]);
1273 ++yyp;
1274 }
1275 else
1276 yyres += *yyp;
98ae9643
AD
1277 }
1278 else
422c18f4
AD
1279 ]])dnl
1280[ yyres = YY_("syntax error");
a0ffc175 1281 return yyres;
98ae9643 1282 }
a08460b0 1283
5348bfbe 1284
98ae9643 1285 const ]b4_int_type(b4_pact_ninf, b4_pact_ninf) b4_parser_class_name::yypact_ninf_ = b4_pact_ninf[;
2b548aa6 1286
0fddb3d5
AD
1287 const ]b4_int_type(b4_table_ninf, b4_table_ninf) b4_parser_class_name::yytable_ninf_ = b4_table_ninf[;
1288
ba206cf4 1289]b4_parser_tables_define[
2b548aa6 1290
141f5793 1291#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
98ae9643 1292 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
9d9b8b70 1293 First, the terminals, then, starting at \a yyntokens_, nonterminals. */
98ae9643
AD
1294 const char*
1295 const ]b4_parser_class_name[::yytname_[] =
1296 {
8901f32e 1297 ]b4_tname[
98ae9643 1298 };
69e2658b 1299#endif
2b548aa6 1300
69e2658b 1301#if YYDEBUG
ba206cf4 1302]b4_integral_parser_table_define([rline], [b4_rline])[
5348bfbe 1303
98ae9643
AD
1304 // Print the state stack on the debug stream.
1305 void
1306 ]b4_parser_class_name[::yystack_print_ ()
1307 {
1308 *yycdebug_ << "Stack now";
8901f32e
AD
1309 for (stack_type::const_iterator
1310 i = yystack_.begin (),
1311 i_end = yystack_.end ();
1312 i != i_end; ++i)
1313 *yycdebug_ << ' ' << i->state;
98ae9643
AD
1314 *yycdebug_ << std::endl;
1315 }
25f66e1a 1316
98ae9643
AD
1317 // Report on the debug stream that the rule \a yyrule is going to be reduced.
1318 void
d1ff7a7c 1319 ]b4_parser_class_name[::yy_reduce_print_ (int yyrule)
98ae9643
AD
1320 {
1321 unsigned int yylno = yyrline_[yyrule];
d1ff7a7c 1322 int yynrhs = yyr2_[yyrule];
98ae9643
AD
1323 /* Print the symbols being reduced, and their result. */
1324 *yycdebug_ << "Reducing stack by rule " << yyrule - 1
7cff04b5 1325 << " (line " << yylno << "):" << std::endl;
d1ff7a7c
AD
1326 /* The symbols being reduced. */
1327 for (int yyi = 0; yyi < yynrhs; yyi++)
1328 YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",
1f7d007b 1329 ]b4_rhs_data(yynrhs, yyi + 1)[);
98ae9643 1330 }
5348bfbe 1331#endif // YYDEBUG
69e2658b 1332
1c4af381 1333]b4_lex_symbol_if([], [b4_yytranslate_definition])[
793fbca5 1334]b4_namespace_close[
8901f32e 1335]b4_epilogue[]dnl
08af01c2 1336m4_divert_pop(0)
a9ce3f54 1337m4_popdef([b4_copyright_years])dnl