3 # C++ skeleton for Bison
5 # Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
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.
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.
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
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 m4_include(b4_pkgdatadir
/[c
++.m4
])
23 m4_include(b4_pkgdatadir
/[location
.cc
])
25 # We do want M4 expansion after # for CPP macros.
28 m4_if(b4_defines_flag
, 0, [],
29 [@output @output_header_name@
30 b4_copyright([C
++ Skeleton parser
for LALR(1) parsing with Bison
],
31 [2002, 2003, 2004, 2005])
32 dnl FIXME
: This is wrong
, we want computed header guards
.
34 #ifndef PARSER_HEADER_H
35 # define PARSER_HEADER_H
47 /* First part of user declarations. */
50 ]/* Line __line__ of lalr1.cc. */
51 b4_syncline([@oline@
], [@ofile@
])[
53 ]dnl Include location
.hh here
: it might depend on headers included above
.
54 [#include "location.hh"
56 /* Enabling traces. */
58 # define YYDEBUG ]b4_debug[
61 /* Enabling verbose error messages. */
62 #ifdef YYERROR_VERBOSE
63 # undef YYERROR_VERBOSE
64 # define YYERROR_VERBOSE 1
66 # define YYERROR_VERBOSE ]b4_error_verbose[
69 /* Enabling the token table. */
71 # define YYTOKEN_TABLE ]b4_token_table[
74 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
75 If N is 0, then set CURRENT to the empty location which ends
76 the previous symbol: RHS[0] (always defined). */
78 #ifndef YYLLOC_DEFAULT
79 # define YYLLOC_DEFAULT(Current, Rhs, N) \
83 (Current).begin = (Rhs)[1].begin; \
84 (Current).end = (Rhs)[N].end; \
88 (Current).begin = (Current).end = (Rhs)[0].end; \
97 class ]b4_parser_class_name
[
100 /// Symbol semantic values.
101 #if ! defined (YYSTYPE)
102 ]m4_ifdef([b4_stype
],
103 [b4_syncline([b4_stype_line
], [b4_file_name
])
104 union semantic_type b4_stype
;
105 /* Line __line__ of lalr1.cc. */
106 b4_syncline([@oline@
], [@ofile@
])],
107 [ typedef int semantic_type
;])[
109 typedef YYSTYPE semantic_type
;
111 /// Symbol locations.
112 typedef ]b4_location_type
[ location_type
;
116 ]b4_token_enums(b4_tokens
)[
119 /// Build a parser object.
120 ]b4_parser_class_name
[ (]b4_parse_param_decl
[) :
122 yycdebug_ (&std::cerr
)]b4_parse_param_cons
[
126 virtual ~]b4_parser_class_name
[ ()
131 /// \returns 0 iff parsing succeeded.
132 virtual int parse ();
134 /// The current debugging stream.
135 std::ostream
& debug_stream () const;
136 /// Set the current debugging stream.
137 void set_debug_stream (std::ostream
&);
139 /// Type for debugging levels.
140 typedef int debug_level_type
;
141 /// The current debugging level.
142 debug_level_type
debug_level () const;
143 /// Set the current debugging level.
144 void set_debug_level (debug_level_type l
);
147 /// Report a syntax error.
148 /// \param loc where the syntax error is found.
149 /// \param msg a description of the syntax error.
150 virtual void error (const location_type
& loc
, const std::string
& msg
);
152 /// Generate an error message.
153 /// \param state the state where the error occurred.
154 /// \param tok the look-ahead token.
155 virtual std::string
yysyntax_error_ (int yystate
]dnl
156 b4_error_verbose_if([, int tok
])[);
159 /// \brief Report a symbol on the debug stream.
160 /// \param yytype The token type.
161 /// \param yyvaluep Its semantic value.
162 /// \param yylocationp Its location.
163 virtual void yysymprint_ (int yytype
,
164 const semantic_type
* yyvaluep
,
165 const location_type
* yylocationp
);
166 #endif /* ! YYDEBUG */
170 typedef int state_type
;
171 /// State stack type.
172 typedef stack
<state_type
> state_stack_type
;
173 /// Semantic value stack type.
174 typedef stack
<semantic_type
> semantic_stack_type
;
175 /// location stack type.
176 typedef stack
<location_type
> location_stack_type
;
179 state_stack_type yystate_stack_
;
180 /// The semantic value stack.
181 semantic_stack_type yysemantic_stack_
;
182 /// The location stack.
183 location_stack_type yylocation_stack_
;
185 /// Internal symbol numbers.
186 typedef ]b4_int_type_for([b4_translate
])[ token_number_type
;
188 /// For a state, the index in \a yytable_ of its portion.
189 static const ]b4_int_type_for([b4_pact
])[ yypact_
[];
190 static const ]b4_int_type(b4_pact_ninf
, b4_pact_ninf
)[ yypact_ninf_
;
192 /// For a state, default rule to reduce.
193 /// Unless\a yytable_ specifies something else to do.
194 /// Zero means the default is an error.
195 static const ]b4_int_type_for([b4_defact
])[ yydefact_
[];
197 static const ]b4_int_type_for([b4_pgoto
])[ yypgoto_
[];
198 static const ]b4_int_type_for([b4_defgoto
])[ yydefgoto_
[];
200 /// What to do in a state.
201 /// \a yytable_[yypact_[s]]: what to do in state \a s.
202 /// - if positive, shift that token.
203 /// - if negative, reduce the rule which number is the opposite.
204 /// - if zero, do what YYDEFACT says.
205 static const ]b4_int_type_for([b4_table
])[ yytable_
[];
206 static const ]b4_int_type(b4_table_ninf
, b4_table_ninf
)[ yytable_ninf_
;
208 static const ]b4_int_type_for([b4_check
])[ yycheck_
[];
210 /// For a state, its accessing symbol.
211 static const ]b4_int_type_for([b4_stos
])[ yystos_
[];
213 /// For a rule, its LHS.
214 static const ]b4_int_type_for([b4_r1
])[ yyr1_
[];
215 /// For a rule, its RHS length.
216 static const ]b4_int_type_for([b4_r2
])[ yyr2_
[];
218 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
219 /// For a symbol, its name in clear.
220 static const char* const yytname_
[];
224 /// Convert the symbol name \a n to a form suitable for a diagnostic.
225 virtual std::string
yytnamerr_ (const char *n
);
229 /// A type to store symbol numbers and -1.
230 typedef ]b4_int_type_for([b4_rhs
])[ rhs_number_type
;
231 /// A `-1'-separated list of the rules' RHS.
232 static const rhs_number_type yyrhs_
[];
233 /// For each rule, the index of the first RHS symbol in \a yyrhs_.
234 static const ]b4_int_type_for([b4_prhs
])[ yyprhs_
[];
235 /// For each rule, its source line number.
236 static const ]b4_int_type_for([b4_rline
])[ yyrline_
[];
237 /// For each scanner token number, its symbol number.
238 static const ]b4_int_type_for([b4_toknum
])[ yytoken_number_
[];
239 /// Report on the debug stream that the rule \a r is going to be reduced.
240 virtual void yyreduce_print_ (int r
);
241 /// Print the state stack on the debug stream.
242 virtual void yystack_print_ ();
245 /// Convert a scanner token number to a symbol number.
246 inline token_number_type
yytranslate_ (int token
);
248 /// \brief Reclaim the memory associated to a symbol.
249 /// \param yymsg Why this token is reclaimed.
250 /// \param yytype The symbol type.
251 /// \param yyvaluep Its semantic value.
252 /// \param yylocationp Its location.
253 inline void yydestruct_ (const char* yymsg
,
255 semantic_type
* yyvaluep
,
256 location_type
* yylocationp
);
258 /// Pop \a n symbols the three stacks.
259 inline void yypop_ (unsigned int n
= 1);
262 static const int yyeof_
;
263 /* LAST_ -- Last index in TABLE_. */
264 static const int yylast_
;
265 static const int yynnts_
;
266 static const int yyempty_
;
267 static const int yyfinal_
;
268 static const int yyterror_
;
269 static const int yyerrcode_
;
270 static const int yyntokens_
;
271 static const unsigned int yyuser_token_number_max_
;
272 static const token_number_type yyundef_token_
;
276 std::ostream
* yycdebug_
;
278 ]b4_parse_param_vars
[
282 ]m4_ifset([b4_global_tokens_and_yystype
],
283 [b4_token_defines(b4_tokens
)
286 /* Redirection for backward compatibility. */
287 # define YYSTYPE yy::b4_parser_class_name::semantic_type
290 #endif /* ! defined PARSER_HEADER_H */]
292 @output @output_parser_name@
293 b4_copyright([C
++ Skeleton parser
for LALR(1) parsing with Bison
],
294 [2002, 2003, 2004, 2005])
295 m4_if(b4_prefix
[], [yy
], [],
297 // Take the name prefix into account.
298 #define yylex b4_prefix[]lex])
299 m4_if(b4_defines_flag
, 0, [],
301 #include @output_header_name@])[
303 /* User implementation prologue. */
306 ]/* Line __line__ of lalr1.cc. */
307 b4_syncline([@oline@
], [@ofile@
])[
312 # include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */
313 # define YY_(msgid) dgettext ("bison-runtime", msgid)
317 # define YY_(msgid) msgid
321 /* Suppress unused-variable warnings by "using" E. */
322 #define YYUSE(e) do {;} while (false && (e))
324 /* A pseudo ostream that takes yydebug_ into account. */
326 for (bool yydebugcond_ = yydebug_; yydebugcond_; yydebugcond_ = false) \
329 /* Enable debugging if requested. */
332 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
336 *yycdebug_ << (Title) << ' '; \
337 yysymprint_ ((Type), (Value), (Location)); \
338 *yycdebug_ << std::endl; \
342 # define YY_REDUCE_PRINT(Rule) \
345 yyreduce_print_ (Rule); \
348 # define YY_STACK_PRINT() \
356 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
357 # define YY_REDUCE_PRINT(Rule)
358 # define YY_STACK_PRINT()
360 #endif /* !YYDEBUG */
362 #define YYACCEPT goto yyacceptlab
363 #define YYABORT goto yyabortlab
364 #define YYERROR goto yyerrorlab
368 /* Return YYSTR after stripping away unnecessary quotes and
369 backslashes, so that it's suitable for yyerror. The heuristic is
370 that double-quoting is unnecessary unless the string contains an
371 apostrophe, a comma, or backslash (other than backslash-backslash).
372 YYSTR is taken from yytname. */
374 yy::]b4_parser_class_name
[::yytnamerr_ (const char *yystr
)
378 std::string yyr
= "";
379 char const *yyp
= yystr
;
386 goto do_not_strip_quotes
;
390 goto do_not_strip_quotes
;
399 do_not_strip_quotes
: ;
408 /*--------------------------------.
409 | Print this symbol on YYOUTPUT. |
410 `--------------------------------*/
413 yy::]b4_parser_class_name
[::yysymprint_ (int yytype
,
414 const semantic_type
* yyvaluep
, const location_type
* yylocationp
)
416 /* Backward compatibility, but should be removed eventually. */
417 std::ostream
& cdebug_
= *yycdebug_
;
423 *yycdebug_
<< (yytype
< yyntokens_
? "token" : "nterm")
424 << ' ' << yytname_
[yytype
] << " ("
425 << *yylocationp
<< ": ";
428 ]m4_map([b4_symbol_actions
], m4_defn([b4_symbol_printers
]))dnl
434 #endif /* ! YYDEBUG */
437 yy::]b4_parser_class_name
[::yydestruct_ (const char* yymsg
,
438 int yytype
, semantic_type
* yyvaluep
, location_type
* yylocationp
)
444 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
448 ]m4_map([b4_symbol_actions
], m4_defn([b4_symbol_destructors
]))[
455 yy::]b4_parser_class_name
[::yypop_ (unsigned int n
)
457 yystate_stack_
.pop (n
);
458 yysemantic_stack_
.pop (n
);
459 yylocation_stack_
.pop (n
);
463 yy::]b4_parser_class_name
[::debug_stream () const
469 yy::]b4_parser_class_name
[::set_debug_stream (std::ostream
& o
)
475 yy::]b4_parser_class_name
[::debug_level_type
476 yy::]b4_parser_class_name
[::debug_level () const
482 yy::]b4_parser_class_name
[::set_debug_level (debug_level_type l
)
489 yy::]b4_parser_class_name
[::parse ()
491 /// Look-ahead and look-ahead in internal form.
492 int yychar
= yyempty_
;
500 /* Error handling. */
502 int yyerrstatus_
= 0;
504 /// Semantic value of the look-ahead.
505 semantic_type yylval
;
506 /// Location of the look-ahead.
507 location_type yylloc
;
508 /// The locations where the error started and ended.
509 location yyerror_range
[2];
518 YYCDEBUG
<< "Starting parse" << std::endl
;
520 ]m4_ifdef([b4_initial_action
], [
521 m4_pushdef([b4_at_dollar
], [yylloc
])dnl
522 m4_pushdef([b4_dollar_dollar
], [yylval
])dnl
523 /* User initialization code. */
525 m4_popdef([b4_dollar_dollar
])dnl
526 m4_popdef([b4_at_dollar
])dnl
527 /* Line __line__ of yacc.c. */
528 b4_syncline([@oline@
], [@ofile@
])])dnl
530 [ /* Initialize the stacks. The initial state will be pushed in
531 yynewstate, since the latter expects the semantical and the
532 location values to have been already stored, initialize these
533 stacks with a primary value. */
534 yystate_stack_
= state_stack_type (0);
535 yysemantic_stack_
= semantic_stack_type (0);
536 yylocation_stack_
= location_stack_type (0);
537 yysemantic_stack_
.push (yylval
);
538 yylocation_stack_
.push (yylloc
);
542 yystate_stack_
.push (yystate
);
543 YYCDEBUG
<< "Entering state " << yystate
<< std::endl
;
549 /* Try to take a decision without look-ahead. */
550 yyn
= yypact_
[yystate
];
551 if (yyn
== yypact_ninf_
)
554 /* Read a look-ahead token. */
555 if (yychar
== yyempty_
)
557 YYCDEBUG
<< "Reading a token: ";
558 yychar
= ]b4_c_function_call([yylex
], [int],
559 [[YYSTYPE
*], [&yylval
]][]dnl
560 b4_location_if([, [[location
*], [&yylloc
]]])dnl
561 m4_ifdef([b4_lex_param
], [, ]b4_lex_param
))[;
565 /* Convert token to internal form. */
566 if (yychar
<= yyeof_
)
568 yychar
= yytoken
= yyeof_
;
569 YYCDEBUG
<< "Now at end of input." << std::endl
;
573 yytoken
= yytranslate_ (yychar
);
574 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
577 /* If the proper action on seeing token YYTOKEN is to reduce or to
578 detect an error, take that action. */
580 if (yyn
< 0 || yylast_
< yyn
|| yycheck_
[yyn
] != yytoken
)
583 /* Reduce or error. */
587 if (yyn
== 0 || yyn
== yytable_ninf_
)
597 /* Shift the look-ahead token. */
598 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
600 /* Discard the token being shifted unless it is eof. */
601 if (yychar
!= yyeof_
)
604 yysemantic_stack_
.push (yylval
);
605 yylocation_stack_
.push (yylloc
);
607 /* Count tokens shifted since error; after three, turn off error
615 /*-----------------------------------------------------------.
616 | yydefault -- do the default action for the current state. |
617 `-----------------------------------------------------------*/
619 yyn
= yydefact_
[yystate
];
624 /*-----------------------------.
625 | yyreduce -- Do a reduction. |
626 `-----------------------------*/
629 /* If LEN_ is nonzero, implement the default value of the action:
630 `$$ = $1'. Otherwise, use the top of the stack.
632 Otherwise, the following line sets YYVAL to garbage.
633 This behavior is undocumented and Bison
634 users should not rely upon it. */
636 yyval
= yysemantic_stack_
[yylen
- 1];
638 yyval
= yysemantic_stack_
[0];
641 slice
<location_type
, location_stack_type
> slice (yylocation_stack_
, yylen
);
642 YYLLOC_DEFAULT (yyloc
, slice
, yylen
);
644 YY_REDUCE_PRINT (yyn
);
651 ]/* Line __line__ of lalr1.cc. */
652 b4_syncline([@oline@
], [@ofile@
])[
658 yysemantic_stack_
.push (yyval
);
659 yylocation_stack_
.push (yyloc
);
661 /* Shift the result of the reduction. */
663 yystate
= yypgoto_
[yyn
- yyntokens_
] + yystate_stack_
[0];
664 if (0 <= yystate
&& yystate
<= yylast_
665 && yycheck_
[yystate
] == yystate_stack_
[0])
666 yystate
= yytable_
[yystate
];
668 yystate
= yydefgoto_
[yyn
- yyntokens_
];
671 /*------------------------------------.
672 | yyerrlab -- here on detecting error |
673 `------------------------------------*/
675 /* If not already recovering from an error, report this error. */
679 error (yylloc
, yysyntax_error_ (yystate
]dnl
680 b4_error_verbose_if([, yytoken
])[));
683 yyerror_range
[0] = yylloc
;
684 if (yyerrstatus_
== 3)
686 /* If just tried and failed to reuse look-ahead token after an
687 error, discard it. */
689 if (yychar
<= yyeof_
)
691 /* Return failure if at end of input. */
692 if (yychar
== yyeof_
)
697 yydestruct_ ("Error: discarding", yytoken
, &yylval
, &yylloc
);
702 /* Else will try to reuse look-ahead token after shifting the error
707 /*---------------------------------------------------.
708 | yyerrorlab -- error raised explicitly by YYERROR. |
709 `---------------------------------------------------*/
712 /* Pacify compilers like GCC when the user code never invokes
713 YYERROR and the label yyerrorlab therefore never appears in user
718 yyerror_range
[0] = yylocation_stack_
[yylen
- 1];
720 yystate
= yystate_stack_
[0];
723 /*-------------------------------------------------------------.
724 | yyerrlab1 -- common code for both syntax error and YYERROR. |
725 `-------------------------------------------------------------*/
727 yyerrstatus_
= 3; /* Each real token shifted decrements this. */
731 yyn
= yypact_
[yystate
];
732 if (yyn
!= yypact_ninf_
)
735 if (0 <= yyn
&& yyn
<= yylast_
&& yycheck_
[yyn
] == yyterror_
)
743 /* Pop the current state because it cannot handle the error token. */
744 if (yystate_stack_
.height () == 1)
747 yyerror_range
[0] = yylocation_stack_
[0];
748 yydestruct_ ("Error: popping",
750 &yysemantic_stack_
[0], &yylocation_stack_
[0]);
752 yystate
= yystate_stack_
[0];
759 yyerror_range
[1] = yylloc
;
760 // Using YYLLOC is tempting, but would change the location of
761 // the look-ahead. YYLOC is available though.
762 YYLLOC_DEFAULT (yyloc
, yyerror_range
- 1, 2);
763 yysemantic_stack_
.push (yylval
);
764 yylocation_stack_
.push (yyloc
);
766 /* Shift the error token. */
767 YY_SYMBOL_PRINT ("Shifting", yystos_
[yyn
],
768 &yysemantic_stack_
[0], &yylocation_stack_
[0]);
784 if (yychar
!= yyeof_
&& yychar
!= yyempty_
)
785 yydestruct_ ("Cleanup: discarding lookahead", yytoken
, &yylval
, &yylloc
);
787 while (yystate_stack_
.height () != 1)
789 yydestruct_ ("Cleanup: popping",
790 yystos_
[yystate_stack_
[0]],
791 &yysemantic_stack_
[0],
792 &yylocation_stack_
[0]);
799 // Generate an error message.
801 yy::]b4_parser_class_name
[::yysyntax_error_ (int yystate
]dnl
802 b4_error_verbose_if([, int tok
])[)
806 int yyn
= yypact_
[yystate
];
807 if (yypact_ninf_
< yyn
&& yyn
< yylast_
)
809 /* Start YYX at -YYN if negative to avoid negative indexes in
811 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
813 /* Stay within bounds of both yycheck and yytname. */
814 int yychecklim
= yylast_
- yyn
;
815 int yyxend
= yychecklim
< yyntokens_
? yychecklim
: yyntokens_
;
817 for (int x
= yyxbegin
; x
< yyxend
; ++x
)
818 if (yycheck_
[x
+ yyn
] == x
&& x
!= yyterror_
)
821 // FIXME: This method of building the message is not compatible
822 // with internationalization. It should work like yacc.c does it.
823 // That is, first build a string that looks like this:
824 // "syntax error, unexpected %s or %s or %s"
825 // Then, invoke YY_ on this string.
826 // Finally, use the string as a format to output
827 // yytname_[tok], etc.
828 // Until this gets fixed, this message appears in English only.
829 res
= "syntax error, unexpected ";
830 res
+= yytnamerr_ (yytname_
[tok
]);
834 for (int x
= yyxbegin
; x
< yyxend
; ++x
)
835 if (yycheck_
[x
+ yyn
] == x
&& x
!= yyterror_
)
837 res
+= (!count
++) ? ", expecting " : " or ";
838 res
+= yytnamerr_ (yytname_
[x
]);
844 res
= YY_("syntax error");
849 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
851 const ]b4_int_type(b4_pact_ninf
, b4_pact_ninf
) yy::b4_parser_class_name::yypact_ninf_
= b4_pact_ninf
[;
852 const ]b4_int_type_for([b4_pact
])[
853 yy::]b4_parser_class_name
[::yypact_
[] =
858 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
859 doesn't specify something else to do. Zero means the default is an
861 const ]b4_int_type_for([b4_defact
])[
862 yy::]b4_parser_class_name
[::yydefact_
[] =
867 /* YYPGOTO[NTERM-NUM]. */
868 const ]b4_int_type_for([b4_pgoto
])[
869 yy::]b4_parser_class_name
[::yypgoto_
[] =
874 /* YYDEFGOTO[NTERM-NUM]. */
875 const ]b4_int_type_for([b4_defgoto
])[
876 yy::]b4_parser_class_name
[::yydefgoto_
[] =
881 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
882 positive, shift that token. If negative, reduce the rule which
883 number is the opposite. If zero, do what YYDEFACT says. */
884 const ]b4_int_type(b4_table_ninf
, b4_table_ninf
) yy::b4_parser_class_name::yytable_ninf_
= b4_table_ninf
[;
885 const ]b4_int_type_for([b4_table
])[
886 yy::]b4_parser_class_name
[::yytable_
[] =
892 const ]b4_int_type_for([b4_check
])[
893 yy::]b4_parser_class_name
[::yycheck_
[] =
898 /* STOS_[STATE-NUM] -- The (internal number of the) accessing
899 symbol of state STATE-NUM. */
900 const ]b4_int_type_for([b4_stos
])[
901 yy::]b4_parser_class_name
[::yystos_
[] =
907 /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
909 const ]b4_int_type_for([b4_toknum
])[
910 yy::]b4_parser_class_name
[::yytoken_number_
[] =
916 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
917 const ]b4_int_type_for([b4_r1
])[
918 yy::]b4_parser_class_name
[::yyr1_
[] =
923 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
924 const ]b4_int_type_for([b4_r2
])[
925 yy::]b4_parser_class_name
[::yyr2_
[] =
930 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
931 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
932 First, the terminals, then, starting at \a yyntokens_, nonterminals. */
934 const yy::]b4_parser_class_name
[::yytname_
[] =
941 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
942 const yy::]b4_parser_class_name
[::rhs_number_type
943 yy::]b4_parser_class_name
[::yyrhs_
[] =
948 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
950 const ]b4_int_type_for([b4_prhs
])[
951 yy::]b4_parser_class_name
[::yyprhs_
[] =
956 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
957 const ]b4_int_type_for([b4_rline
])[
958 yy::]b4_parser_class_name
[::yyrline_
[] =
963 // Print the state stack on the debug stream.
965 yy::]b4_parser_class_name
[::yystack_print_ ()
967 *yycdebug_
<< "Stack now";
968 for (state_stack_type::const_iterator i
= yystate_stack_
.begin ();
969 i
!= yystate_stack_
.end (); ++i
)
970 *yycdebug_
<< ' ' << *i
;
971 *yycdebug_
<< std::endl
;
974 // Report on the debug stream that the rule \a yyrule is going to be reduced.
976 yy::]b4_parser_class_name
[::yyreduce_print_ (int yyrule
)
978 unsigned int yylno
= yyrline_
[yyrule
];
979 /* Print the symbols being reduced, and their result. */
980 *yycdebug_
<< "Reducing stack by rule " << yyrule
- 1
981 << " (line " << yylno
<< "), ";
982 for (]b4_int_type_for([b4_prhs
])[ i
= yyprhs_
[yyrule
];
984 *yycdebug_
<< yytname_
[yyrhs_
[i
]] << ' ';
985 *yycdebug_
<< "-> " << yytname_
[yyr1_
[yyrule
]] << std::endl
;
989 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
990 yy::]b4_parser_class_name
[::token_number_type
991 yy::]b4_parser_class_name
[::yytranslate_ (int token
)
994 const token_number_type
999 if ((unsigned int) token
<= yyuser_token_number_max_
)
1000 return translate_table
[token
];
1002 return yyundef_token_
;
1005 const int yy::]b4_parser_class_name
[::yyeof_
= 0;
1006 const int yy::]b4_parser_class_name
[::yylast_
= ]b4_last
[;
1007 const int yy::]b4_parser_class_name
[::yynnts_
= ]b4_nterms_number
[;
1008 const int yy::]b4_parser_class_name
[::yyempty_
= -2;
1009 const int yy::]b4_parser_class_name
[::yyfinal_
= ]b4_final_state_number
[;
1010 const int yy::]b4_parser_class_name
[::yyterror_
= 1;
1011 const int yy::]b4_parser_class_name
[::yyerrcode_
= 256;
1012 const int yy::]b4_parser_class_name
[::yyntokens_
= ]b4_tokens_number
[;
1014 const unsigned int yy::]b4_parser_class_name
[::yyuser_token_number_max_
= ]b4_user_token_number_max
[;
1015 const yy::]b4_parser_class_name
[::token_number_type
yy::]b4_parser_class_name
[::yyundef_token_
= ]b4_undef_token_number
[;
1019 @output b4_dir_prefix
[]stack
.hh
1020 b4_copyright([stack handling
for Bison C
++ parsers
], [2002, 2003, 2004, 2005])[
1022 #ifndef BISON_STACK_HH
1023 # define BISON_STACK_HH
1029 template <class T
, class S
= std::deque
<T
> >
1034 // Hide our reversed order.
1035 typedef typename
S::reverse_iterator iterator
;
1036 typedef typename
S::const_reverse_iterator const_iterator
;
1042 stack (unsigned int n
) : seq_ (n
)
1048 operator [] (unsigned int i
)
1055 operator [] (unsigned int i
) const
1064 seq_
.push_front (t
);
1069 pop (unsigned int n
= 1)
1079 return seq_
.size ();
1082 inline const_iterator
begin () const { return seq_
.rbegin (); }
1083 inline const_iterator
end () const { return seq_
.rend (); }
1090 /// Present a slice of the top of a stack.
1091 template <class T
, class S
= stack
<T
> >
1096 slice (const S
& stack
,
1097 unsigned int range
) : stack_ (stack
),
1104 operator [] (unsigned int i
) const
1106 return stack_
[range_
- i
];
1112 unsigned int range_
;
1116 #endif // not BISON_STACK_HH]