1 # C++ skeleton for Bison
3 # Copyright (C) 2002-2010 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 m4_include(b4_pkgdatadir
/[c
++.m4
])
20 m4_define([b4_parser_class_name
],
21 [b4_percent_define_get([[parser_class_name]])])
23 # The header is mandatory.
25 [b4_fatal([b4_skeleton
[: using %%defines is mandatory
]])])
27 b4_percent_define_ifdef([[location_type]], [],
28 [# Backward compatibility.
29 m4_define([b4_location_constructors
])
30 m4_include(b4_pkgdatadir
/[location
.cc
])])
32 # We do want M4 expansion after # for CPP macros.
36 [@
output(b4_spec_defines_file@
)@
37 b4_copyright([Skeleton interface
for Bison
LALR(1) parsers in C
++],
39 dnl FIXME
: This is wrong
, we want computed header guards
.
41 /* C++ LALR(1) parser skeleton written by Akim Demaille. */
43 #ifndef PARSER_HEADER_H
44 # define PARSER_HEADER_H
46 ]b4_percent_code_get([[requires]])[
51 ]b4_percent_define_ifdef([[location_type]], [],
52 [[#include "location.hh"]])[
54 /* Enabling traces. */
56 # define YYDEBUG ]b4_debug_flag[
59 /* Enabling verbose error messages. */
60 #ifdef YYERROR_VERBOSE
61 # undef YYERROR_VERBOSE
62 # define YYERROR_VERBOSE 1
64 # define YYERROR_VERBOSE ]b4_error_verbose_flag[
67 /* Enabling the token table. */
69 # define YYTOKEN_TABLE ]b4_token_table[
72 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
73 If N is 0, then set CURRENT to the empty location which ends
74 the previous symbol: RHS[0] (always defined). */
76 #ifndef YYLLOC_DEFAULT
77 # define YYLLOC_DEFAULT(Current, Rhs, N) \
81 (Current).begin = (Rhs)[1].begin; \
82 (Current).end = (Rhs)[N].end; \
86 (Current).begin = (Current).end = (Rhs)[0].end; \
94 class ]b4_parser_class_name
[
97 /// Symbol semantic values.
100 [ union semantic_type
104 [m4_if(b4_tag_seen_flag
, 0,
105 [[ typedef int semantic_type
;]],
106 [[ typedef YYSTYPE semantic_type
;]])])[
108 typedef YYSTYPE semantic_type
;
110 /// Symbol locations.
111 typedef ]b4_percent_define_get([[location_type]],
112 [[location]])[ location_type
;
116 ]b4_token_enums(b4_tokens
)[
119 typedef token::yytokentype token_type
;
121 /// Build a parser object.
122 ]b4_parser_class_name
[ (]b4_parse_param_decl
[);
123 virtual ~]b4_parser_class_name
[ ();
126 /// \returns 0 iff parsing succeeded.
127 virtual int parse ();
130 /// The current debugging stream.
131 std::ostream
& debug_stream () const;
132 /// Set the current debugging stream.
133 void set_debug_stream (std::ostream
&);
135 /// Type for debugging levels.
136 typedef int debug_level_type
;
137 /// The current debugging level.
138 debug_level_type
debug_level () const;
139 /// Set the current debugging level.
140 void set_debug_level (debug_level_type l
);
144 /// Report a syntax error.
145 /// \param loc where the syntax error is found.
146 /// \param msg a description of the syntax error.
147 virtual void error (const location_type
& loc
, const std::string
& msg
);
149 /// Generate an error message.
150 /// \param state the state where the error occurred.
151 /// \param tok the lookahead token.
152 virtual std::string
yysyntax_error_ (int yystate
, int tok
);
155 /// \brief Report a symbol value on the debug stream.
156 /// \param yytype The token type.
157 /// \param yyvaluep Its semantic value.
158 /// \param yylocationp Its location.
159 virtual void yy_symbol_value_print_ (int yytype
,
160 const semantic_type
* yyvaluep
,
161 const location_type
* yylocationp
);
162 /// \brief Report a symbol on the debug stream.
163 /// \param yytype The token type.
164 /// \param yyvaluep Its semantic value.
165 /// \param yylocationp Its location.
166 virtual void yy_symbol_print_ (int yytype
,
167 const semantic_type
* yyvaluep
,
168 const location_type
* yylocationp
);
173 typedef int state_type
;
174 /// State stack type.
175 typedef stack
<state_type
> state_stack_type
;
176 /// Semantic value stack type.
177 typedef stack
<semantic_type
> semantic_stack_type
;
178 /// location stack type.
179 typedef stack
<location_type
> location_stack_type
;
182 state_stack_type yystate_stack_
;
183 /// The semantic value stack.
184 semantic_stack_type yysemantic_stack_
;
185 /// The location stack.
186 location_stack_type yylocation_stack_
;
188 /// Whether the given \c yypact_ value indicates a defaulted state.
189 /// \param yyvalue the value to check
190 static bool yy_pact_value_is_default_ (int yyvalue
);
192 /// Whether the given \c yytable_ value indicates a syntax error.
193 /// \param yyvalue the value to check
194 static bool yy_table_value_is_error_ (int yyvalue
);
196 /// Internal symbol numbers.
197 typedef ]b4_int_type_for([b4_translate
])[ token_number_type
;
199 /// For a state, the index in \a yytable_ of its portion.
200 static const ]b4_int_type_for([b4_pact
])[ yypact_
[];
201 static const ]b4_int_type(b4_pact_ninf
, b4_pact_ninf
)[ yypact_ninf_
;
203 /// For a state, default reduction number.
204 /// Unless\a yytable_ specifies something else to do.
205 /// Zero means the default is an error.
206 static const ]b4_int_type_for([b4_defact
])[ yydefact_
[];
208 static const ]b4_int_type_for([b4_pgoto
])[ yypgoto_
[];
209 static const ]b4_int_type_for([b4_defgoto
])[ yydefgoto_
[];
211 /// What to do in a state.
212 /// \a yytable_[yypact_[s]]: what to do in state \a s.
213 /// - if positive, shift that token.
214 /// - if negative, reduce the rule which number is the opposite.
215 /// - if zero, do what YYDEFACT says.
216 static const ]b4_int_type_for([b4_table
])[ yytable_
[];
217 static const ]b4_int_type(b4_table_ninf
, b4_table_ninf
)[ yytable_ninf_
;
219 static const ]b4_int_type_for([b4_check
])[ yycheck_
[];
221 /// For a state, its accessing symbol.
222 static const ]b4_int_type_for([b4_stos
])[ yystos_
[];
224 /// For a rule, its LHS.
225 static const ]b4_int_type_for([b4_r1
])[ yyr1_
[];
226 /// For a rule, its RHS length.
227 static const ]b4_int_type_for([b4_r2
])[ yyr2_
[];
229 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
230 /// For a symbol, its name in clear.
231 static const char* const yytname_
[];
232 #endif]b4_error_verbose_if([
234 /// Convert the symbol name \a n to a form suitable for a diagnostic.
235 static std::string
yytnamerr_ (const char *n
);])[
238 /// A type to store symbol numbers and -1.
239 typedef ]b4_int_type_for([b4_rhs
])[ rhs_number_type
;
240 /// A `-1'-separated list of the rules' RHS.
241 static const rhs_number_type yyrhs_
[];
242 /// For each rule, the index of the first RHS symbol in \a yyrhs_.
243 static const ]b4_int_type_for([b4_prhs
])[ yyprhs_
[];
244 /// For each rule, its source line number.
245 static const ]b4_int_type_for([b4_rline
])[ yyrline_
[];
246 /// For each scanner token number, its symbol number.
247 static const ]b4_int_type_for([b4_toknum
])[ yytoken_number_
[];
248 /// Report on the debug stream that the rule \a r is going to be reduced.
249 virtual void yy_reduce_print_ (int r
);
250 /// Print the state stack on the debug stream.
251 virtual void yystack_print_ ();
255 std::ostream
* yycdebug_
;
258 /// Convert a scanner token number \a t to a symbol number.
259 token_number_type
yytranslate_ (int t
);
261 /// \brief Reclaim the memory associated to a symbol.
262 /// \param yymsg Why this token is reclaimed.
263 /// \param yytype The symbol type.
264 /// \param yyvaluep Its semantic value.
265 /// \param yylocationp Its location.
266 inline void yydestruct_ (const char* yymsg
,
268 semantic_type
* yyvaluep
,
269 location_type
* yylocationp
);
271 /// Pop \a n symbols the three stacks.
272 inline void yypop_ (unsigned int n
= 1);
275 static const int yyeof_
;
276 /* LAST_ -- Last index in TABLE_. */
277 static const int yylast_
;
278 static const int yynnts_
;
279 static const int yyempty_
;
280 static const int yyfinal_
;
281 static const int yyterror_
;
282 static const int yyerrcode_
;
283 static const int yyntokens_
;
284 static const unsigned int yyuser_token_number_max_
;
285 static const token_number_type yyundef_token_
;
286 ]b4_parse_param_vars
[
290 ]b4_percent_define_flag_if([[global_tokens_and_yystype]],
291 [b4_token_defines(b4_tokens
)
294 /* Redirection for backward compatibility. */
295 # define YYSTYPE b4_namespace_ref::b4_parser_class_name::semantic_type
298 b4_percent_code_get([[provides]])[]dnl
300 [#endif /* ! defined PARSER_HEADER_H */]
302 @
output(b4_parser_file_name@
)@
303 b4_copyright([Skeleton implementation
for Bison
LALR(1) parsers in C
++],
305 b4_percent_code_get([[top]])[]dnl
306 m4_if(b4_prefix
, [yy
], [],
308 // Take the name prefix into account.
309 #define yylex b4_prefix[]lex])[
311 /* First part of user declarations. */
312 ]b4_user_pre_prologue
315 #include "@basename(]b4_spec_defines_file[@)"]])[
317 /* User implementation prologue. */
318 ]b4_user_post_prologue
319 b4_percent_code_get
[]dnl
322 # if defined YYENABLE_NLS && YYENABLE_NLS
324 # include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */
325 # define YY_(msgid) dgettext ("bison-runtime", msgid)
329 # define YY_(msgid) msgid
333 /* Suppress unused-variable warnings by "using" E. */
334 #define YYUSE(e) ((void) (e))
336 /* Enable debugging if requested. */
339 /* A pseudo ostream that takes yydebug_ into account. */
340 # define YYCDEBUG if (yydebug_) (*yycdebug_)
342 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
346 *yycdebug_ << Title << ' '; \
347 yy_symbol_print_ ((Type), (Value), (Location)); \
348 *yycdebug_ << std::endl; \
352 # define YY_REDUCE_PRINT(Rule) \
355 yy_reduce_print_ (Rule); \
358 # define YY_STACK_PRINT() \
366 # define YYCDEBUG if (false) std::cerr
367 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
368 # define YY_REDUCE_PRINT(Rule)
369 # define YY_STACK_PRINT()
371 #endif /* !YYDEBUG */
373 #define yyerrok (yyerrstatus_ = 0)
374 #define yyclearin (yychar = yyempty_)
376 #define YYACCEPT goto yyacceptlab
377 #define YYABORT goto yyabortlab
378 #define YYERROR goto yyerrorlab
379 #define YYRECOVERING() (!!yyerrstatus_)
381 ]b4_namespace_open
[]b4_error_verbose_if([[
383 /* Return YYSTR after stripping away unnecessary quotes and
384 backslashes, so that it's suitable for yyerror. The heuristic is
385 that double-quoting is unnecessary unless the string contains an
386 apostrophe, a comma, or backslash (other than backslash-backslash).
387 YYSTR is taken from yytname. */
389 ]b4_parser_class_name
[::yytnamerr_ (const char *yystr
)
393 std::string yyr
= "";
394 char const *yyp
= yystr
;
401 goto do_not_strip_quotes
;
405 goto do_not_strip_quotes
;
414 do_not_strip_quotes
: ;
421 /// Build a parser object.
422 ]b4_parser_class_name::b4_parser_class_name
[ (]b4_parse_param_decl
[)]m4_ifset([b4_parse_param
], [
425 ]m4_ifset([b4_parse_param
], [ ], [ :])[yydebug_ (false),
426 yycdebug_ (&std::cerr
)]m4_ifset([b4_parse_param
], [,])[
427 #endif]b4_parse_param_cons[
431 ]b4_parser_class_name::~b4_parser_class_name
[ ()
436 /*--------------------------------.
437 | Print this symbol on YYOUTPUT. |
438 `--------------------------------*/
441 ]b4_parser_class_name
[::yy_symbol_value_print_ (int yytype
,
442 const semantic_type
* yyvaluep
, const location_type
* yylocationp
)
448 ]m4_map([b4_symbol_actions
], m4_defn([b4_symbol_printers
]))dnl
456 ]b4_parser_class_name
[::yy_symbol_print_ (int yytype
,
457 const semantic_type
* yyvaluep
, const location_type
* yylocationp
)
459 *yycdebug_
<< (yytype
< yyntokens_
? "token" : "nterm")
460 << ' ' << yytname_
[yytype
] << " ("
461 << *yylocationp
<< ": ";
462 yy_symbol_value_print_ (yytype
, yyvaluep
, yylocationp
);
468 ]b4_parser_class_name
[::yydestruct_ (const char* yymsg
,
469 int yytype
, semantic_type
* yyvaluep
, location_type
* yylocationp
)
475 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
479 ]m4_map([b4_symbol_actions
], m4_defn([b4_symbol_destructors
]))[
486 ]b4_parser_class_name
[::yypop_ (unsigned int n
)
488 yystate_stack_
.pop (n
);
489 yysemantic_stack_
.pop (n
);
490 yylocation_stack_
.pop (n
);
495 ]b4_parser_class_name
[::debug_stream () const
501 ]b4_parser_class_name
[::set_debug_stream (std::ostream
& o
)
507 ]b4_parser_class_name
[::debug_level_type
508 ]b4_parser_class_name
[::debug_level () const
514 ]b4_parser_class_name
[::set_debug_level (debug_level_type l
)
521 ]b4_parser_class_name
[::yy_pact_value_is_default_ (int yyvalue
)
523 return yyvalue
== yypact_ninf_
;
527 ]b4_parser_class_name
[::yy_table_value_is_error_ (int yyvalue
)
529 return yyvalue
== yytable_ninf_
;
533 ]b4_parser_class_name
[::parse ()
535 /// Lookahead and lookahead in internal form.
536 int yychar
= yyempty_
;
544 /* Error handling. */
546 int yyerrstatus_
= 0;
548 /// Semantic value of the lookahead.
549 semantic_type yylval
;
550 /// Location of the lookahead.
551 location_type yylloc
;
552 /// The locations where the error started and ended.
553 location_type yyerror_range
[3];
562 YYCDEBUG
<< "Starting parse" << std::endl
;
564 ]m4_ifdef([b4_initial_action
], [
565 m4_pushdef([b4_at_dollar
], [yylloc
])dnl
566 m4_pushdef([b4_dollar_dollar
], [yylval
])dnl
567 /* User initialization code. */
568 b4_user_initial_action
569 m4_popdef([b4_dollar_dollar
])dnl
570 m4_popdef([b4_at_dollar
])])dnl
572 [ /* Initialize the stacks. The initial state will be pushed in
573 yynewstate, since the latter expects the semantical and the
574 location values to have been already stored, initialize these
575 stacks with a primary value. */
576 yystate_stack_
= state_stack_type (0);
577 yysemantic_stack_
= semantic_stack_type (0);
578 yylocation_stack_
= location_stack_type (0);
579 yysemantic_stack_
.push (yylval
);
580 yylocation_stack_
.push (yylloc
);
584 yystate_stack_
.push (yystate
);
585 YYCDEBUG
<< "Entering state " << yystate
<< std::endl
;
588 if (yystate
== yyfinal_
)
596 /* Try to take a decision without lookahead. */
597 yyn
= yypact_
[yystate
];
598 if (yy_pact_value_is_default_ (yyn
))
601 /* Read a lookahead token. */
602 if (yychar
== yyempty_
)
604 YYCDEBUG
<< "Reading a token: ";
605 yychar
= ]b4_c_function_call([yylex
], [int],
606 [[YYSTYPE
*], [&yylval
]][]dnl
607 b4_locations_if([, [[location
*], [&yylloc
]]])dnl
608 m4_ifdef([b4_lex_param
], [, ]b4_lex_param
))[;
612 /* Convert token to internal form. */
613 if (yychar
<= yyeof_
)
615 yychar
= yytoken
= yyeof_
;
616 YYCDEBUG
<< "Now at end of input." << std::endl
;
620 yytoken
= yytranslate_ (yychar
);
621 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
624 /* If the proper action on seeing token YYTOKEN is to reduce or to
625 detect an error, take that action. */
627 if (yyn
< 0 || yylast_
< yyn
|| yycheck_
[yyn
] != yytoken
)
630 /* Reduce or error. */
634 if (yy_table_value_is_error_ (yyn
))
640 /* Shift the lookahead token. */
641 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
643 /* Discard the token being shifted. */
646 yysemantic_stack_
.push (yylval
);
647 yylocation_stack_
.push (yylloc
);
649 /* Count tokens shifted since error; after three, turn off error
657 /*-----------------------------------------------------------.
658 | yydefault -- do the default action for the current state. |
659 `-----------------------------------------------------------*/
661 yyn
= yydefact_
[yystate
];
666 /*-----------------------------.
667 | yyreduce -- Do a reduction. |
668 `-----------------------------*/
671 /* If YYLEN is nonzero, implement the default value of the action:
672 `$$ = $1'. Otherwise, use the top of the stack.
674 Otherwise, the following line sets YYVAL to garbage.
675 This behavior is undocumented and Bison
676 users should not rely upon it. */
678 yyval
= yysemantic_stack_
[yylen
- 1];
680 yyval
= yysemantic_stack_
[0];
683 slice
<location_type
, location_stack_type
> slice (yylocation_stack_
, yylen
);
684 YYLLOC_DEFAULT (yyloc
, slice
, yylen
);
686 YY_REDUCE_PRINT (yyn
);
693 YY_SYMBOL_PRINT ("-> $$ =", yyr1_
[yyn
], &yyval
, &yyloc
);
699 yysemantic_stack_
.push (yyval
);
700 yylocation_stack_
.push (yyloc
);
702 /* Shift the result of the reduction. */
704 yystate
= yypgoto_
[yyn
- yyntokens_
] + yystate_stack_
[0];
705 if (0 <= yystate
&& yystate
<= yylast_
706 && yycheck_
[yystate
] == yystate_stack_
[0])
707 yystate
= yytable_
[yystate
];
709 yystate
= yydefgoto_
[yyn
- yyntokens_
];
712 /*------------------------------------.
713 | yyerrlab -- here on detecting error |
714 `------------------------------------*/
716 /* If not already recovering from an error, report this error. */
720 error (yylloc
, yysyntax_error_ (yystate
, yytoken
));
723 yyerror_range
[1] = yylloc
;
724 if (yyerrstatus_
== 3)
726 /* If just tried and failed to reuse lookahead token after an
727 error, discard it. */
729 if (yychar
<= yyeof_
)
731 /* Return failure if at end of input. */
732 if (yychar
== yyeof_
)
737 yydestruct_ ("Error: discarding", yytoken
, &yylval
, &yylloc
);
742 /* Else will try to reuse lookahead token after shifting the error
747 /*---------------------------------------------------.
748 | yyerrorlab -- error raised explicitly by YYERROR. |
749 `---------------------------------------------------*/
752 /* Pacify compilers like GCC when the user code never invokes
753 YYERROR and the label yyerrorlab therefore never appears in user
758 yyerror_range
[1] = yylocation_stack_
[yylen
- 1];
759 /* Do not reclaim the symbols of the rule which action triggered
763 yystate
= yystate_stack_
[0];
766 /*-------------------------------------------------------------.
767 | yyerrlab1 -- common code for both syntax error and YYERROR. |
768 `-------------------------------------------------------------*/
770 yyerrstatus_
= 3; /* Each real token shifted decrements this. */
774 yyn
= yypact_
[yystate
];
775 if (!yy_pact_value_is_default_ (yyn
))
778 if (0 <= yyn
&& yyn
<= yylast_
&& yycheck_
[yyn
] == yyterror_
)
786 /* Pop the current state because it cannot handle the error token. */
787 if (yystate_stack_
.height () == 1)
790 yyerror_range
[1] = yylocation_stack_
[0];
791 yydestruct_ ("Error: popping",
793 &yysemantic_stack_
[0], &yylocation_stack_
[0]);
795 yystate
= yystate_stack_
[0];
799 yyerror_range
[2] = yylloc
;
800 // Using YYLLOC is tempting, but would change the location of
801 // the lookahead. YYLOC is available though.
802 YYLLOC_DEFAULT (yyloc
, yyerror_range
, 2);
803 yysemantic_stack_
.push (yylval
);
804 yylocation_stack_
.push (yyloc
);
806 /* Shift the error token. */
807 YY_SYMBOL_PRINT ("Shifting", yystos_
[yyn
],
808 &yysemantic_stack_
[0], &yylocation_stack_
[0]);
824 if (yychar
!= yyempty_
)
825 yydestruct_ ("Cleanup: discarding lookahead", yytoken
, &yylval
, &yylloc
);
827 /* Do not reclaim the symbols of the rule which action triggered
828 this YYABORT or YYACCEPT. */
830 while (yystate_stack_
.height () != 1)
832 yydestruct_ ("Cleanup: popping",
833 yystos_
[yystate_stack_
[0]],
834 &yysemantic_stack_
[0],
835 &yylocation_stack_
[0]);
842 // Generate an error message.
844 ]b4_parser_class_name
[::yysyntax_error_ (]dnl
845 b4_error_verbose_if([int yystate
, int yytoken
],
848 std::string yyres
;]b4_error_verbose_if([[
849 int yyn
= yypact_
[yystate
];
850 if (yypact_ninf_
< yyn
&& yyn
<= yylast_
)
852 /* Start YYX at -YYN if negative to avoid negative indexes in
853 YYCHECK. In other words, skip the first -YYN actions for this
854 state because they are default actions. */
855 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
857 /* Stay within bounds of both yycheck and yytname. */
858 int yychecklim
= yylast_
- yyn
+ 1;
859 int yyxend
= yychecklim
< yyntokens_
? yychecklim
: yyntokens_
;
861 // Number of reported tokens (one for the "unexpected", one per
865 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
866 // Arguments of yyformat.
867 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
868 yyarg
[yycount
++] = yytname_
[yytoken
];
869 for (int yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
870 if (yycheck_
[yyx
+ yyn
] == yyx
&& yyx
!= yyterror_
871 && !yy_table_value_is_error_ (yytable_
[yyx
+ yyn
]))
873 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
879 yyarg
[yycount
++] = yytname_
[yyx
];
882 char const* yyformat
= 0;
885 #define YYCASE_(N, S) \
889 YYCASE_(1, YY_("syntax error, unexpected %s"));
890 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
891 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
892 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
893 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
898 for (char const* yyp
= yyformat
; *yyp
; ++yyp
)
899 if (yyp
[0] == '%' && yyp
[1] == 's' && yyi
< yycount
)
901 yyres
+= yytnamerr_ (yyarg
[yyi
++]);
909 [ yyres
= YY_("syntax error");
914 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
916 const ]b4_int_type(b4_pact_ninf
, b4_pact_ninf
) b4_parser_class_name::yypact_ninf_
= b4_pact_ninf
[;
917 const ]b4_int_type_for([b4_pact
])[
918 ]b4_parser_class_name
[::yypact_
[] =
923 /* YYDEFACT[S] -- default reduction number in state S. Performed when
924 YYTABLE doesn't specify something else to do. Zero means the
925 default is an error. */
926 const ]b4_int_type_for([b4_defact
])[
927 ]b4_parser_class_name
[::yydefact_
[] =
932 /* YYPGOTO[NTERM-NUM]. */
933 const ]b4_int_type_for([b4_pgoto
])[
934 ]b4_parser_class_name
[::yypgoto_
[] =
939 /* YYDEFGOTO[NTERM-NUM]. */
940 const ]b4_int_type_for([b4_defgoto
])[
941 ]b4_parser_class_name
[::yydefgoto_
[] =
946 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
947 positive, shift that token. If negative, reduce the rule which
948 number is the opposite. If YYTABLE_NINF_, syntax error. */
949 const ]b4_int_type(b4_table_ninf
, b4_table_ninf
) b4_parser_class_name::yytable_ninf_
= b4_table_ninf
[;
950 const ]b4_int_type_for([b4_table
])[
951 ]b4_parser_class_name
[::yytable_
[] =
957 const ]b4_int_type_for([b4_check
])[
958 ]b4_parser_class_name
[::yycheck_
[] =
963 /* STOS_[STATE-NUM] -- The (internal number of the) accessing
964 symbol of state STATE-NUM. */
965 const ]b4_int_type_for([b4_stos
])[
966 ]b4_parser_class_name
[::yystos_
[] =
972 /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
974 const ]b4_int_type_for([b4_toknum
])[
975 ]b4_parser_class_name
[::yytoken_number_
[] =
981 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
982 const ]b4_int_type_for([b4_r1
])[
983 ]b4_parser_class_name
[::yyr1_
[] =
988 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
989 const ]b4_int_type_for([b4_r2
])[
990 ]b4_parser_class_name
[::yyr2_
[] =
995 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
996 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
997 First, the terminals, then, starting at \a yyntokens_, nonterminals. */
999 const ]b4_parser_class_name
[::yytname_
[] =
1006 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
1007 const ]b4_parser_class_name
[::rhs_number_type
1008 ]b4_parser_class_name
[::yyrhs_
[] =
1013 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1015 const ]b4_int_type_for([b4_prhs
])[
1016 ]b4_parser_class_name
[::yyprhs_
[] =
1021 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
1022 const ]b4_int_type_for([b4_rline
])[
1023 ]b4_parser_class_name
[::yyrline_
[] =
1028 // Print the state stack on the debug stream.
1030 ]b4_parser_class_name
[::yystack_print_ ()
1032 *yycdebug_
<< "Stack now";
1033 for (state_stack_type::const_iterator i
= yystate_stack_
.begin ();
1034 i
!= yystate_stack_
.end (); ++i
)
1035 *yycdebug_
<< ' ' << *i
;
1036 *yycdebug_
<< std::endl
;
1039 // Report on the debug stream that the rule \a yyrule is going to be reduced.
1041 ]b4_parser_class_name
[::yy_reduce_print_ (int yyrule
)
1043 unsigned int yylno
= yyrline_
[yyrule
];
1044 int yynrhs
= yyr2_
[yyrule
];
1045 /* Print the symbols being reduced, and their result. */
1046 *yycdebug_
<< "Reducing stack by rule " << yyrule
- 1
1047 << " (line " << yylno
<< "):" << std::endl
;
1048 /* The symbols being reduced. */
1049 for (int yyi
= 0; yyi
< yynrhs
; yyi
++)
1050 YY_SYMBOL_PRINT (" $" << yyi
+ 1 << " =",
1051 yyrhs_
[yyprhs_
[yyrule
] + yyi
],
1052 &]b4_rhs_value(yynrhs
, yyi
+ 1)[,
1053 &]b4_rhs_location(yynrhs
, yyi
+ 1)[);
1057 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1058 ]b4_parser_class_name
[::token_number_type
1059 ]b4_parser_class_name
[::yytranslate_ (int t
)
1062 const token_number_type
1067 if ((unsigned int) t
<= yyuser_token_number_max_
)
1068 return translate_table
[t
];
1070 return yyundef_token_
;
1073 const int ]b4_parser_class_name
[::yyeof_
= 0;
1074 const int ]b4_parser_class_name
[::yylast_
= ]b4_last
[;
1075 const int ]b4_parser_class_name
[::yynnts_
= ]b4_nterms_number
[;
1076 const int ]b4_parser_class_name
[::yyempty_
= -2;
1077 const int ]b4_parser_class_name
[::yyfinal_
= ]b4_final_state_number
[;
1078 const int ]b4_parser_class_name
[::yyterror_
= 1;
1079 const int ]b4_parser_class_name
[::yyerrcode_
= 256;
1080 const int ]b4_parser_class_name
[::yyntokens_
= ]b4_tokens_number
[;
1082 const unsigned int ]b4_parser_class_name
[::yyuser_token_number_max_
= ]b4_user_token_number_max
[;
1083 const ]b4_parser_class_name
[::token_number_type
]b4_parser_class_name
[::yyundef_token_
= ]b4_undef_token_number
[;
1085 ]b4_namespace_close
[
1089 @
output(b4_dir_prefix
[]stack
.hh@
)@
1090 b4_copyright([Stack handling
for Bison parsers in C
++],
1093 #ifndef BISON_STACK_HH
1094 # define BISON_STACK_HH
1099 template <class T
, class S
= std::deque
<T
> >
1104 // Hide our reversed order.
1105 typedef typename
S::reverse_iterator iterator
;
1106 typedef typename
S::const_reverse_iterator const_iterator
;
1112 stack (unsigned int n
) : seq_ (n
)
1118 operator [] (unsigned int i
)
1125 operator [] (unsigned int i
) const
1134 seq_
.push_front (t
);
1139 pop (unsigned int n
= 1)
1149 return seq_
.size ();
1152 inline const_iterator
begin () const { return seq_
.rbegin (); }
1153 inline const_iterator
end () const { return seq_
.rend (); }
1160 /// Present a slice of the top of a stack.
1161 template <class T
, class S
= stack
<T
> >
1166 slice (const S
& stack
,
1167 unsigned int range
) : stack_ (stack
),
1174 operator [] (unsigned int i
) const
1176 return stack_
[range_
- i
];
1182 unsigned int range_
;
1184 ]b4_namespace_close
[
1186 #endif // not BISON_STACK_HH[]dnl