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 # Backward compatibility.
24 m4_define([b4_location_constructors
])
25 m4_include(b4_pkgdatadir
/[location
.cc
])
27 # We do want M4 expansion after # for CPP macros.
30 m4_if(b4_defines_flag
, 0, [],
31 [@output @output_header_name@
32 b4_copyright([C
++ Skeleton parser
for LALR(1) parsing with Bison
],
33 [2002, 2003, 2004, 2005])
34 dnl FIXME
: This is wrong
, we want computed header guards
.
36 /* C++ LALR(1) parser skeleton written by Akim Demaille. */
38 #ifndef PARSER_HEADER_H
39 # define PARSER_HEADER_H
51 /* First part of user declarations. */
54 ]/* Line __line__ of lalr1.cc. */
55 b4_syncline([@oline@
], [@ofile@
])[
57 ]dnl Include location
.hh here
: it might depend on headers included above
.
58 [#include "location.hh"
60 /* Enabling traces. */
62 # define YYDEBUG ]b4_debug[
65 /* Enabling verbose error messages. */
66 #ifdef YYERROR_VERBOSE
67 # undef YYERROR_VERBOSE
68 # define YYERROR_VERBOSE 1
70 # define YYERROR_VERBOSE ]b4_error_verbose[
73 /* Enabling the token table. */
75 # define YYTOKEN_TABLE ]b4_token_table[
78 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
79 If N is 0, then set CURRENT to the empty location which ends
80 the previous symbol: RHS[0] (always defined). */
82 #ifndef YYLLOC_DEFAULT
83 # define YYLLOC_DEFAULT(Current, Rhs, N) \
87 (Current).begin = (Rhs)[1].begin; \
88 (Current).end = (Rhs)[N].end; \
92 (Current).begin = (Current).end = (Rhs)[0].end; \
101 class ]b4_parser_class_name
[
104 /// Symbol semantic values.
105 #if ! defined (YYSTYPE)
106 ]m4_ifdef([b4_stype
],
107 [b4_syncline([b4_stype_line
], [b4_file_name
])
108 union semantic_type b4_stype
;
109 /* Line __line__ of lalr1.cc. */
110 b4_syncline([@oline@
], [@ofile@
])],
111 [ typedef int semantic_type
;])[
113 typedef YYSTYPE semantic_type
;
115 /// Symbol locations.
116 typedef ]b4_location_type
[ location_type
;
120 ]b4_token_enums(b4_tokens
)[
123 /// Build a parser object.
124 ]b4_parser_class_name
[ (]b4_parse_param_decl
[);
125 virtual ~]b4_parser_class_name
[ ();
128 /// \returns 0 iff parsing succeeded.
129 virtual int parse ();
131 /// The current debugging stream.
132 std::ostream
& debug_stream () const;
133 /// Set the current debugging stream.
134 void set_debug_stream (std::ostream
&);
136 /// Type for debugging levels.
137 typedef int debug_level_type
;
138 /// The current debugging level.
139 debug_level_type
debug_level () const;
140 /// Set the current debugging level.
141 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 look-ahead token.
152 virtual std::string
yysyntax_error_ (int yystate
]dnl
153 b4_error_verbose_if([, int tok
])[);
156 /// \brief Report a symbol on the debug stream.
157 /// \param yytype The token type.
158 /// \param yyvaluep Its semantic value.
159 /// \param yylocationp Its location.
160 virtual void yysymprint_ (int yytype
,
161 const semantic_type
* yyvaluep
,
162 const location_type
* yylocationp
);
163 #endif /* ! YYDEBUG */
167 typedef int state_type
;
168 /// State stack type.
169 typedef stack
<state_type
> state_stack_type
;
170 /// Semantic value stack type.
171 typedef stack
<semantic_type
> semantic_stack_type
;
172 /// location stack type.
173 typedef stack
<location_type
> location_stack_type
;
176 state_stack_type yystate_stack_
;
177 /// The semantic value stack.
178 semantic_stack_type yysemantic_stack_
;
179 /// The location stack.
180 location_stack_type yylocation_stack_
;
182 /// Internal symbol numbers.
183 typedef ]b4_int_type_for([b4_translate
])[ token_number_type
;
185 /// For a state, the index in \a yytable_ of its portion.
186 static const ]b4_int_type_for([b4_pact
])[ yypact_
[];
187 static const ]b4_int_type(b4_pact_ninf
, b4_pact_ninf
)[ yypact_ninf_
;
189 /// For a state, default rule to reduce.
190 /// Unless\a yytable_ specifies something else to do.
191 /// Zero means the default is an error.
192 static const ]b4_int_type_for([b4_defact
])[ yydefact_
[];
194 static const ]b4_int_type_for([b4_pgoto
])[ yypgoto_
[];
195 static const ]b4_int_type_for([b4_defgoto
])[ yydefgoto_
[];
197 /// What to do in a state.
198 /// \a yytable_[yypact_[s]]: what to do in state \a s.
199 /// - if positive, shift that token.
200 /// - if negative, reduce the rule which number is the opposite.
201 /// - if zero, do what YYDEFACT says.
202 static const ]b4_int_type_for([b4_table
])[ yytable_
[];
203 static const ]b4_int_type(b4_table_ninf
, b4_table_ninf
)[ yytable_ninf_
;
205 static const ]b4_int_type_for([b4_check
])[ yycheck_
[];
207 /// For a state, its accessing symbol.
208 static const ]b4_int_type_for([b4_stos
])[ yystos_
[];
210 /// For a rule, its LHS.
211 static const ]b4_int_type_for([b4_r1
])[ yyr1_
[];
212 /// For a rule, its RHS length.
213 static const ]b4_int_type_for([b4_r2
])[ yyr2_
[];
215 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
216 /// For a symbol, its name in clear.
217 static const char* const yytname_
[];
221 /// Convert the symbol name \a n to a form suitable for a diagnostic.
222 virtual std::string
yytnamerr_ (const char *n
);
226 /// A type to store symbol numbers and -1.
227 typedef ]b4_int_type_for([b4_rhs
])[ rhs_number_type
;
228 /// A `-1'-separated list of the rules' RHS.
229 static const rhs_number_type yyrhs_
[];
230 /// For each rule, the index of the first RHS symbol in \a yyrhs_.
231 static const ]b4_int_type_for([b4_prhs
])[ yyprhs_
[];
232 /// For each rule, its source line number.
233 static const ]b4_int_type_for([b4_rline
])[ yyrline_
[];
234 /// For each scanner token number, its symbol number.
235 static const ]b4_int_type_for([b4_toknum
])[ yytoken_number_
[];
236 /// Report on the debug stream that the rule \a r is going to be reduced.
237 virtual void yy_reduce_print_ (int r
);
238 /// Print the state stack on the debug stream.
239 virtual void yystack_print_ ();
242 /// Convert a scanner token number to a symbol number.
243 inline token_number_type
yytranslate_ (int token
);
245 /// \brief Reclaim the memory associated to a symbol.
246 /// \param yymsg Why this token is reclaimed.
247 /// \param yytype The symbol type.
248 /// \param yyvaluep Its semantic value.
249 /// \param yylocationp Its location.
250 inline void yydestruct_ (const char* yymsg
,
252 semantic_type
* yyvaluep
,
253 location_type
* yylocationp
);
255 /// Pop \a n symbols the three stacks.
256 inline void yypop_ (unsigned int n
= 1);
259 static const int yyeof_
;
260 /* LAST_ -- Last index in TABLE_. */
261 static const int yylast_
;
262 static const int yynnts_
;
263 static const int yyempty_
;
264 static const int yyfinal_
;
265 static const int yyterror_
;
266 static const int yyerrcode_
;
267 static const int yyntokens_
;
268 static const unsigned int yyuser_token_number_max_
;
269 static const token_number_type yyundef_token_
;
273 std::ostream
* yycdebug_
;
275 ]b4_parse_param_vars
[
279 ]m4_ifset([b4_global_tokens_and_yystype
],
280 [b4_token_defines(b4_tokens
)
283 /* Redirection for backward compatibility. */
284 # define YYSTYPE yy::b4_parser_class_name::semantic_type
287 #endif /* ! defined PARSER_HEADER_H */]
289 @output @output_parser_name@
290 b4_copyright([C
++ Skeleton parser
for LALR(1) parsing with Bison
],
291 [2002, 2003, 2004, 2005])
292 m4_if(b4_prefix
[], [yy
], [],
294 // Take the name prefix into account.
295 #define yylex b4_prefix[]lex])
296 m4_if(b4_defines_flag
, 0, [],
298 #include @output_header_name@])[
300 /* User implementation prologue. */
303 ]/* Line __line__ of lalr1.cc. */
304 b4_syncline([@oline@
], [@ofile@
])[
309 # include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */
310 # define YY_(msgid) dgettext ("bison-runtime", msgid)
314 # define YY_(msgid) msgid
318 /* Suppress unused-variable warnings by "using" E. */
319 #define YYUSE(e) ((void) (e))
321 /* A pseudo ostream that takes yydebug_ into account. */
323 for (bool yydebugcond_ = yydebug_; yydebugcond_; yydebugcond_ = false) \
326 /* Enable debugging if requested. */
329 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
333 *yycdebug_ << Title << ' '; \
334 yysymprint_ ((Type), (Value), (Location)); \
335 *yycdebug_ << std::endl; \
339 # define YY_REDUCE_PRINT(Rule) \
342 yy_reduce_print_ (Rule); \
345 # define YY_STACK_PRINT() \
353 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
354 # define YY_REDUCE_PRINT(Rule)
355 # define YY_STACK_PRINT()
357 #endif /* !YYDEBUG */
359 #define YYACCEPT goto yyacceptlab
360 #define YYABORT goto yyabortlab
361 #define YYERROR goto yyerrorlab
365 /* Return YYSTR after stripping away unnecessary quotes and
366 backslashes, so that it's suitable for yyerror. The heuristic is
367 that double-quoting is unnecessary unless the string contains an
368 apostrophe, a comma, or backslash (other than backslash-backslash).
369 YYSTR is taken from yytname. */
371 yy::]b4_parser_class_name
[::yytnamerr_ (const char *yystr
)
375 std::string yyr
= "";
376 char const *yyp
= yystr
;
383 goto do_not_strip_quotes
;
387 goto do_not_strip_quotes
;
396 do_not_strip_quotes
: ;
406 /// Build a parser object.
407 ]b4_parser_class_name::b4_parser_class_name
[ (]b4_parse_param_decl
[)
409 yycdebug_ (&std::cerr
)]b4_parse_param_cons
[
413 ]b4_parser_class_name::~b4_parser_class_name
[ ()
418 /*--------------------------------.
419 | Print this symbol on YYOUTPUT. |
420 `--------------------------------*/
423 ]b4_parser_class_name
[::yysymprint_ (int yytype
,
424 const semantic_type
* yyvaluep
, const location_type
* yylocationp
)
426 /* Backward compatibility, but should be removed eventually. */
427 std::ostream
& cdebug_
= *yycdebug_
;
433 *yycdebug_
<< (yytype
< yyntokens_
? "token" : "nterm")
434 << ' ' << yytname_
[yytype
] << " ("
435 << *yylocationp
<< ": ";
438 ]m4_map([b4_symbol_actions
], m4_defn([b4_symbol_printers
]))dnl
444 #endif /* ! YYDEBUG */
447 ]b4_parser_class_name
[::yydestruct_ (const char* yymsg
,
448 int yytype
, semantic_type
* yyvaluep
, location_type
* yylocationp
)
454 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
458 ]m4_map([b4_symbol_actions
], m4_defn([b4_symbol_destructors
]))[
465 ]b4_parser_class_name
[::yypop_ (unsigned int n
)
467 yystate_stack_
.pop (n
);
468 yysemantic_stack_
.pop (n
);
469 yylocation_stack_
.pop (n
);
473 ]b4_parser_class_name
[::debug_stream () const
479 ]b4_parser_class_name
[::set_debug_stream (std::ostream
& o
)
485 ]b4_parser_class_name
[::debug_level_type
486 ]b4_parser_class_name
[::debug_level () const
492 ]b4_parser_class_name
[::set_debug_level (debug_level_type l
)
499 ]b4_parser_class_name
[::parse ()
501 /// Look-ahead and look-ahead in internal form.
502 int yychar
= yyempty_
;
510 /* Error handling. */
512 int yyerrstatus_
= 0;
514 /// Semantic value of the look-ahead.
515 semantic_type yylval
;
516 /// Location of the look-ahead.
517 location_type yylloc
;
518 /// The locations where the error started and ended.
519 location yyerror_range
[2];
528 YYCDEBUG
<< "Starting parse" << std::endl
;
530 ]m4_ifdef([b4_initial_action
], [
531 m4_pushdef([b4_at_dollar
], [yylloc
])dnl
532 m4_pushdef([b4_dollar_dollar
], [yylval
])dnl
533 /* User initialization code. */
535 m4_popdef([b4_dollar_dollar
])dnl
536 m4_popdef([b4_at_dollar
])dnl
537 /* Line __line__ of yacc.c. */
538 b4_syncline([@oline@
], [@ofile@
])])dnl
540 [ /* Initialize the stacks. The initial state will be pushed in
541 yynewstate, since the latter expects the semantical and the
542 location values to have been already stored, initialize these
543 stacks with a primary value. */
544 yystate_stack_
= state_stack_type (0);
545 yysemantic_stack_
= semantic_stack_type (0);
546 yylocation_stack_
= location_stack_type (0);
547 yysemantic_stack_
.push (yylval
);
548 yylocation_stack_
.push (yylloc
);
552 yystate_stack_
.push (yystate
);
553 YYCDEBUG
<< "Entering state " << yystate
<< std::endl
;
559 /* Try to take a decision without look-ahead. */
560 yyn
= yypact_
[yystate
];
561 if (yyn
== yypact_ninf_
)
564 /* Read a look-ahead token. */
565 if (yychar
== yyempty_
)
567 YYCDEBUG
<< "Reading a token: ";
568 yychar
= ]b4_c_function_call([yylex
], [int],
569 [[YYSTYPE
*], [&yylval
]][]dnl
570 b4_location_if([, [[location
*], [&yylloc
]]])dnl
571 m4_ifdef([b4_lex_param
], [, ]b4_lex_param
))[;
575 /* Convert token to internal form. */
576 if (yychar
<= yyeof_
)
578 yychar
= yytoken
= yyeof_
;
579 YYCDEBUG
<< "Now at end of input." << std::endl
;
583 yytoken
= yytranslate_ (yychar
);
584 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
587 /* If the proper action on seeing token YYTOKEN is to reduce or to
588 detect an error, take that action. */
590 if (yyn
< 0 || yylast_
< yyn
|| yycheck_
[yyn
] != yytoken
)
593 /* Reduce or error. */
597 if (yyn
== 0 || yyn
== yytable_ninf_
)
607 /* Shift the look-ahead token. */
608 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
610 /* Discard the token being shifted unless it is eof. */
611 if (yychar
!= yyeof_
)
614 yysemantic_stack_
.push (yylval
);
615 yylocation_stack_
.push (yylloc
);
617 /* Count tokens shifted since error; after three, turn off error
625 /*-----------------------------------------------------------.
626 | yydefault -- do the default action for the current state. |
627 `-----------------------------------------------------------*/
629 yyn
= yydefact_
[yystate
];
634 /*-----------------------------.
635 | yyreduce -- Do a reduction. |
636 `-----------------------------*/
639 /* If YYLEN is nonzero, implement the default value of the action:
640 `$$ = $1'. Otherwise, use the top of the stack.
642 Otherwise, the following line sets YYVAL to garbage.
643 This behavior is undocumented and Bison
644 users should not rely upon it. */
646 yyval
= yysemantic_stack_
[yylen
- 1];
648 yyval
= yysemantic_stack_
[0];
651 slice
<location_type
, location_stack_type
> slice (yylocation_stack_
, yylen
);
652 YYLLOC_DEFAULT (yyloc
, slice
, yylen
);
654 YY_REDUCE_PRINT (yyn
);
658 /* Line __line__ of lalr1.cc. */
659 b4_syncline([@oline@
], [@ofile@
])[
662 YY_SYMBOL_PRINT ("-> $$ =", yyr1_
[yyn
], &yyval
, &yyloc
);
668 yysemantic_stack_
.push (yyval
);
669 yylocation_stack_
.push (yyloc
);
671 /* Shift the result of the reduction. */
673 yystate
= yypgoto_
[yyn
- yyntokens_
] + yystate_stack_
[0];
674 if (0 <= yystate
&& yystate
<= yylast_
675 && yycheck_
[yystate
] == yystate_stack_
[0])
676 yystate
= yytable_
[yystate
];
678 yystate
= yydefgoto_
[yyn
- yyntokens_
];
681 /*------------------------------------.
682 | yyerrlab -- here on detecting error |
683 `------------------------------------*/
685 /* If not already recovering from an error, report this error. */
689 error (yylloc
, yysyntax_error_ (yystate
]dnl
690 b4_error_verbose_if([, yytoken
])[));
693 yyerror_range
[0] = yylloc
;
694 if (yyerrstatus_
== 3)
696 /* If just tried and failed to reuse look-ahead token after an
697 error, discard it. */
699 if (yychar
<= yyeof_
)
701 /* Return failure if at end of input. */
702 if (yychar
== yyeof_
)
707 yydestruct_ ("Error: discarding", yytoken
, &yylval
, &yylloc
);
712 /* Else will try to reuse look-ahead token after shifting the error
717 /*---------------------------------------------------.
718 | yyerrorlab -- error raised explicitly by YYERROR. |
719 `---------------------------------------------------*/
722 /* Pacify compilers like GCC when the user code never invokes
723 YYERROR and the label yyerrorlab therefore never appears in user
728 yyerror_range
[0] = yylocation_stack_
[yylen
- 1];
729 /* Do not reclaim the symbols of the rule which action triggered
733 yystate
= yystate_stack_
[0];
736 /*-------------------------------------------------------------.
737 | yyerrlab1 -- common code for both syntax error and YYERROR. |
738 `-------------------------------------------------------------*/
740 yyerrstatus_
= 3; /* Each real token shifted decrements this. */
744 yyn
= yypact_
[yystate
];
745 if (yyn
!= yypact_ninf_
)
748 if (0 <= yyn
&& yyn
<= yylast_
&& yycheck_
[yyn
] == yyterror_
)
756 /* Pop the current state because it cannot handle the error token. */
757 if (yystate_stack_
.height () == 1)
760 yyerror_range
[0] = yylocation_stack_
[0];
761 yydestruct_ ("Error: popping",
763 &yysemantic_stack_
[0], &yylocation_stack_
[0]);
765 yystate
= yystate_stack_
[0];
772 yyerror_range
[1] = yylloc
;
773 // Using YYLLOC is tempting, but would change the location of
774 // the look-ahead. YYLOC is available though.
775 YYLLOC_DEFAULT (yyloc
, yyerror_range
- 1, 2);
776 yysemantic_stack_
.push (yylval
);
777 yylocation_stack_
.push (yyloc
);
779 /* Shift the error token. */
780 YY_SYMBOL_PRINT ("Shifting", yystos_
[yyn
],
781 &yysemantic_stack_
[0], &yylocation_stack_
[0]);
797 if (yychar
!= yyeof_
&& yychar
!= yyempty_
)
798 yydestruct_ ("Cleanup: discarding lookahead", yytoken
, &yylval
, &yylloc
);
800 /* Do not reclaim the symbols of the rule which action triggered
801 this YYABORT or YYACCEPT. */
803 while (yystate_stack_
.height () != 1)
805 yydestruct_ ("Cleanup: popping",
806 yystos_
[yystate_stack_
[0]],
807 &yysemantic_stack_
[0],
808 &yylocation_stack_
[0]);
815 // Generate an error message.
817 ]b4_parser_class_name
[::yysyntax_error_ (int yystate
]dnl
818 b4_error_verbose_if([, int tok
])[)
822 int yyn
= yypact_
[yystate
];
823 if (yypact_ninf_
< yyn
&& yyn
< yylast_
)
825 /* Start YYX at -YYN if negative to avoid negative indexes in
827 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
829 /* Stay within bounds of both yycheck and yytname. */
830 int yychecklim
= yylast_
- yyn
;
831 int yyxend
= yychecklim
< yyntokens_
? yychecklim
: yyntokens_
;
833 for (int x
= yyxbegin
; x
< yyxend
; ++x
)
834 if (yycheck_
[x
+ yyn
] == x
&& x
!= yyterror_
)
837 // FIXME: This method of building the message is not compatible
838 // with internationalization. It should work like yacc.c does it.
839 // That is, first build a string that looks like this:
840 // "syntax error, unexpected %s or %s or %s"
841 // Then, invoke YY_ on this string.
842 // Finally, use the string as a format to output
843 // yytname_[tok], etc.
844 // Until this gets fixed, this message appears in English only.
845 res
= "syntax error, unexpected ";
846 res
+= yytnamerr_ (yytname_
[tok
]);
850 for (int x
= yyxbegin
; x
< yyxend
; ++x
)
851 if (yycheck_
[x
+ yyn
] == x
&& x
!= yyterror_
)
853 res
+= (!count
++) ? ", expecting " : " or ";
854 res
+= yytnamerr_ (yytname_
[x
]);
860 res
= YY_("syntax error");
865 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
867 const ]b4_int_type(b4_pact_ninf
, b4_pact_ninf
) b4_parser_class_name::yypact_ninf_
= b4_pact_ninf
[;
868 const ]b4_int_type_for([b4_pact
])[
869 ]b4_parser_class_name
[::yypact_
[] =
874 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
875 doesn't specify something else to do. Zero means the default is an
877 const ]b4_int_type_for([b4_defact
])[
878 ]b4_parser_class_name
[::yydefact_
[] =
883 /* YYPGOTO[NTERM-NUM]. */
884 const ]b4_int_type_for([b4_pgoto
])[
885 ]b4_parser_class_name
[::yypgoto_
[] =
890 /* YYDEFGOTO[NTERM-NUM]. */
891 const ]b4_int_type_for([b4_defgoto
])[
892 ]b4_parser_class_name
[::yydefgoto_
[] =
897 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
898 positive, shift that token. If negative, reduce the rule which
899 number is the opposite. If zero, do what YYDEFACT says. */
900 const ]b4_int_type(b4_table_ninf
, b4_table_ninf
) b4_parser_class_name::yytable_ninf_
= b4_table_ninf
[;
901 const ]b4_int_type_for([b4_table
])[
902 ]b4_parser_class_name
[::yytable_
[] =
908 const ]b4_int_type_for([b4_check
])[
909 ]b4_parser_class_name
[::yycheck_
[] =
914 /* STOS_[STATE-NUM] -- The (internal number of the) accessing
915 symbol of state STATE-NUM. */
916 const ]b4_int_type_for([b4_stos
])[
917 ]b4_parser_class_name
[::yystos_
[] =
923 /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
925 const ]b4_int_type_for([b4_toknum
])[
926 ]b4_parser_class_name
[::yytoken_number_
[] =
932 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
933 const ]b4_int_type_for([b4_r1
])[
934 ]b4_parser_class_name
[::yyr1_
[] =
939 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
940 const ]b4_int_type_for([b4_r2
])[
941 ]b4_parser_class_name
[::yyr2_
[] =
946 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
947 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
948 First, the terminals, then, starting at \a yyntokens_, nonterminals. */
950 const ]b4_parser_class_name
[::yytname_
[] =
957 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
958 const ]b4_parser_class_name
[::rhs_number_type
959 ]b4_parser_class_name
[::yyrhs_
[] =
964 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
966 const ]b4_int_type_for([b4_prhs
])[
967 ]b4_parser_class_name
[::yyprhs_
[] =
972 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
973 const ]b4_int_type_for([b4_rline
])[
974 ]b4_parser_class_name
[::yyrline_
[] =
979 // Print the state stack on the debug stream.
981 ]b4_parser_class_name
[::yystack_print_ ()
983 *yycdebug_
<< "Stack now";
984 for (state_stack_type::const_iterator i
= yystate_stack_
.begin ();
985 i
!= yystate_stack_
.end (); ++i
)
986 *yycdebug_
<< ' ' << *i
;
987 *yycdebug_
<< std::endl
;
990 // Report on the debug stream that the rule \a yyrule is going to be reduced.
992 ]b4_parser_class_name
[::yy_reduce_print_ (int yyrule
)
994 unsigned int yylno
= yyrline_
[yyrule
];
995 int yynrhs
= yyr2_
[yyrule
];
996 /* Print the symbols being reduced, and their result. */
997 *yycdebug_
<< "Reducing stack by rule " << yyrule
- 1
998 << " (line " << yylno
<< "), ";
999 /* The symbols being reduced. */
1000 for (int yyi
= 0; yyi
< yynrhs
; yyi
++)
1001 YY_SYMBOL_PRINT (" $" << yyi
+ 1 << " =",
1002 yyrhs_
[yyprhs_
[yyrule
] + yyi
],
1003 &]b4_rhs_value(yynrhs
, yyi
+ 1)[,
1004 &]b4_rhs_location(yynrhs
, yyi
+ 1)[);
1008 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1009 ]b4_parser_class_name
[::token_number_type
1010 ]b4_parser_class_name
[::yytranslate_ (int token
)
1013 const token_number_type
1018 if ((unsigned int) token
<= yyuser_token_number_max_
)
1019 return translate_table
[token
];
1021 return yyundef_token_
;
1024 const int ]b4_parser_class_name
[::yyeof_
= 0;
1025 const int ]b4_parser_class_name
[::yylast_
= ]b4_last
[;
1026 const int ]b4_parser_class_name
[::yynnts_
= ]b4_nterms_number
[;
1027 const int ]b4_parser_class_name
[::yyempty_
= -2;
1028 const int ]b4_parser_class_name
[::yyfinal_
= ]b4_final_state_number
[;
1029 const int ]b4_parser_class_name
[::yyterror_
= 1;
1030 const int ]b4_parser_class_name
[::yyerrcode_
= 256;
1031 const int ]b4_parser_class_name
[::yyntokens_
= ]b4_tokens_number
[;
1033 const unsigned int ]b4_parser_class_name
[::yyuser_token_number_max_
= ]b4_user_token_number_max
[;
1034 const ]b4_parser_class_name
[::token_number_type
]b4_parser_class_name
[::yyundef_token_
= ]b4_undef_token_number
[;
1040 @output b4_dir_prefix
[]stack
.hh
1041 b4_copyright([stack handling
for Bison C
++ parsers
], [2002, 2003, 2004, 2005])[
1043 #ifndef BISON_STACK_HH
1044 # define BISON_STACK_HH
1050 template <class T
, class S
= std::deque
<T
> >
1055 // Hide our reversed order.
1056 typedef typename
S::reverse_iterator iterator
;
1057 typedef typename
S::const_reverse_iterator const_iterator
;
1063 stack (unsigned int n
) : seq_ (n
)
1069 operator [] (unsigned int i
)
1076 operator [] (unsigned int i
) const
1085 seq_
.push_front (t
);
1090 pop (unsigned int n
= 1)
1100 return seq_
.size ();
1103 inline const_iterator
begin () const { return seq_
.rbegin (); }
1104 inline const_iterator
end () const { return seq_
.rend (); }
1111 /// Present a slice of the top of a stack.
1112 template <class T
, class S
= stack
<T
> >
1117 slice (const S
& stack
,
1118 unsigned int range
) : stack_ (stack
),
1125 operator [] (unsigned int i
) const
1127 return stack_
[range_
- i
];
1133 unsigned int range_
;
1137 #endif // not BISON_STACK_HH]