3 # C++ skeleton for Bison
5 # Copyright (C) 2002, 2003, 2004, 2005, 2006 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.
31 [@output @output_header_name@
32 b4_copyright([Skeleton interface
for Bison
LALR(1) parsers in C
++],
33 [2002, 2003, 2004, 2005, 2006])
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
45 namespace ]b4_namespace
[
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_flag[
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_flag[
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; \
97 namespace ]b4_namespace
[
101 class ]b4_parser_class_name
[
104 /// Symbol semantic values.
106 ]m4_ifdef([b4_stype
],
107 [ union semantic_type
109 /* Line __line__ of lalr1.cc. */
110 b4_syncline([@oline@
], [@ofile@
])
112 [ typedef int semantic_type
;])[
114 typedef YYSTYPE semantic_type
;
116 /// Symbol locations.
117 typedef ]b4_location_type
[ location_type
;
121 ]b4_token_enums(b4_tokens
)[
124 typedef token::yytokentype token_type
;
126 /// Build a parser object.
127 ]b4_parser_class_name
[ (]b4_parse_param_decl
[);
128 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 value on the debug stream.
160 /// \param yytype The token type.
161 /// \param yyvaluep Its semantic value.
162 /// \param yylocationp Its location.
163 virtual void yy_symbol_value_print_ (int yytype
,
164 const semantic_type
* yyvaluep
,
165 const location_type
* yylocationp
);
166 /// \brief Report a symbol on the debug stream.
167 /// \param yytype The token type.
168 /// \param yyvaluep Its semantic value.
169 /// \param yylocationp Its location.
170 virtual void yy_symbol_print_ (int yytype
,
171 const semantic_type
* yyvaluep
,
172 const location_type
* yylocationp
);
173 #endif /* ! YYDEBUG */
177 typedef int state_type
;
178 /// State stack type.
179 typedef stack
<state_type
> state_stack_type
;
180 /// Semantic value stack type.
181 typedef stack
<semantic_type
> semantic_stack_type
;
182 /// location stack type.
183 typedef stack
<location_type
> location_stack_type
;
186 state_stack_type yystate_stack_
;
187 /// The semantic value stack.
188 semantic_stack_type yysemantic_stack_
;
189 /// The location stack.
190 location_stack_type yylocation_stack_
;
192 /// Internal symbol numbers.
193 typedef ]b4_int_type_for([b4_translate
])[ token_number_type
;
195 /// For a state, the index in \a yytable_ of its portion.
196 static const ]b4_int_type_for([b4_pact
])[ yypact_
[];
197 static const ]b4_int_type(b4_pact_ninf
, b4_pact_ninf
)[ yypact_ninf_
;
199 /// For a state, default rule to reduce.
200 /// Unless\a yytable_ specifies something else to do.
201 /// Zero means the default is an error.
202 static const ]b4_int_type_for([b4_defact
])[ yydefact_
[];
204 static const ]b4_int_type_for([b4_pgoto
])[ yypgoto_
[];
205 static const ]b4_int_type_for([b4_defgoto
])[ yydefgoto_
[];
207 /// What to do in a state.
208 /// \a yytable_[yypact_[s]]: what to do in state \a s.
209 /// - if positive, shift that token.
210 /// - if negative, reduce the rule which number is the opposite.
211 /// - if zero, do what YYDEFACT says.
212 static const ]b4_int_type_for([b4_table
])[ yytable_
[];
213 static const ]b4_int_type(b4_table_ninf
, b4_table_ninf
)[ yytable_ninf_
;
215 static const ]b4_int_type_for([b4_check
])[ yycheck_
[];
217 /// For a state, its accessing symbol.
218 static const ]b4_int_type_for([b4_stos
])[ yystos_
[];
220 /// For a rule, its LHS.
221 static const ]b4_int_type_for([b4_r1
])[ yyr1_
[];
222 /// For a rule, its RHS length.
223 static const ]b4_int_type_for([b4_r2
])[ yyr2_
[];
225 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
226 /// For a symbol, its name in clear.
227 static const char* const yytname_
[];
231 /// Convert the symbol name \a n to a form suitable for a diagnostic.
232 virtual std::string
yytnamerr_ (const char *n
);
236 /// A type to store symbol numbers and -1.
237 typedef ]b4_int_type_for([b4_rhs
])[ rhs_number_type
;
238 /// A `-1'-separated list of the rules' RHS.
239 static const rhs_number_type yyrhs_
[];
240 /// For each rule, the index of the first RHS symbol in \a yyrhs_.
241 static const ]b4_int_type_for([b4_prhs
])[ yyprhs_
[];
242 /// For each rule, its source line number.
243 static const ]b4_int_type_for([b4_rline
])[ yyrline_
[];
244 /// For each scanner token number, its symbol number.
245 static const ]b4_int_type_for([b4_toknum
])[ yytoken_number_
[];
246 /// Report on the debug stream that the rule \a r is going to be reduced.
247 virtual void yy_reduce_print_ (int r
);
248 /// Print the state stack on the debug stream.
249 virtual void yystack_print_ ();
252 /// Convert a scanner token number \a t to a symbol number.
253 token_number_type
yytranslate_ (int t
);
255 /// \brief Reclaim the memory associated to a symbol.
256 /// \param yymsg Why this token is reclaimed.
257 /// \param yytype The symbol type.
258 /// \param yyvaluep Its semantic value.
259 /// \param yylocationp Its location.
260 inline void yydestruct_ (const char* yymsg
,
262 semantic_type
* yyvaluep
,
263 location_type
* yylocationp
);
265 /// Pop \a n symbols the three stacks.
266 inline void yypop_ (unsigned int n
= 1);
269 static const int yyeof_
;
270 /* LAST_ -- Last index in TABLE_. */
271 static const int yylast_
;
272 static const int yynnts_
;
273 static const int yyempty_
;
274 static const int yyfinal_
;
275 static const int yyterror_
;
276 static const int yyerrcode_
;
277 static const int yyntokens_
;
278 static const unsigned int yyuser_token_number_max_
;
279 static const token_number_type yyundef_token_
;
283 std::ostream
* yycdebug_
;
285 ]b4_parse_param_vars
[
289 ]m4_ifset([b4_global_tokens_and_yystype
],
290 [b4_token_defines(b4_tokens
)
293 /* Redirection for backward compatibility. */
294 # define YYSTYPE b4_namespace::b4_parser_class_name::semantic_type
297 #endif /* ! defined PARSER_HEADER_H */]
299 @output @output_parser_name@
300 b4_copyright([Skeleton implementation
for Bison
LALR(1) parsers in C
++],
301 [2002, 2003, 2004, 2005, 2006])
302 m4_if(b4_prefix
, [yy
], [],
304 // Take the name prefix into account.
305 #define yylex b4_prefix[]lex])
307 #include @output_header_name@])[
309 /* User implementation prologue. */
312 ]/* Line __line__ of lalr1.cc. */
313 b4_syncline([@oline@
], [@ofile@
])[
318 # include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */
319 # define YY_(msgid) dgettext ("bison-runtime", msgid)
323 # define YY_(msgid) msgid
327 /* Suppress unused-variable warnings by "using" E. */
328 #define YYUSE(e) ((void) (e))
330 /* A pseudo ostream that takes yydebug_ into account. */
332 for (bool yydebugcond_ = yydebug_; yydebugcond_; yydebugcond_ = false) \
335 /* Enable debugging if requested. */
338 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
342 *yycdebug_ << Title << ' '; \
343 yy_symbol_print_ ((Type), (Value), (Location)); \
344 *yycdebug_ << std::endl; \
348 # define YY_REDUCE_PRINT(Rule) \
351 yy_reduce_print_ (Rule); \
354 # define YY_STACK_PRINT() \
362 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
363 # define YY_REDUCE_PRINT(Rule)
364 # define YY_STACK_PRINT()
366 #endif /* !YYDEBUG */
368 #define YYACCEPT goto yyacceptlab
369 #define YYABORT goto yyabortlab
370 #define YYERROR goto yyerrorlab
372 namespace ]b4_namespace
[
376 /* Return YYSTR after stripping away unnecessary quotes and
377 backslashes, so that it's suitable for yyerror. The heuristic is
378 that double-quoting is unnecessary unless the string contains an
379 apostrophe, a comma, or backslash (other than backslash-backslash).
380 YYSTR is taken from yytname. */
382 ]b4_parser_class_name
[::yytnamerr_ (const char *yystr
)
386 std::string yyr
= "";
387 char const *yyp
= yystr
;
394 goto do_not_strip_quotes
;
398 goto do_not_strip_quotes
;
407 do_not_strip_quotes
: ;
415 /// Build a parser object.
416 ]b4_parser_class_name::b4_parser_class_name
[ (]b4_parse_param_decl
[)
418 yycdebug_ (&std::cerr
)]b4_parse_param_cons
[
422 ]b4_parser_class_name::~b4_parser_class_name
[ ()
427 /*--------------------------------.
428 | Print this symbol on YYOUTPUT. |
429 `--------------------------------*/
432 ]b4_parser_class_name
[::yy_symbol_value_print_ (int yytype
,
433 const semantic_type
* yyvaluep
, const location_type
* yylocationp
)
439 ]m4_map([b4_symbol_actions
], m4_defn([b4_symbol_printers
]))dnl
447 ]b4_parser_class_name
[::yy_symbol_print_ (int yytype
,
448 const semantic_type
* yyvaluep
, const location_type
* yylocationp
)
450 *yycdebug_
<< (yytype
< yyntokens_
? "token" : "nterm")
451 << ' ' << yytname_
[yytype
] << " ("
452 << *yylocationp
<< ": ";
453 yy_symbol_value_print_ (yytype
, yyvaluep
, yylocationp
);
456 #endif /* ! YYDEBUG */
459 ]b4_parser_class_name
[::yydestruct_ (const char* yymsg
,
460 int yytype
, semantic_type
* yyvaluep
, location_type
* yylocationp
)
466 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
470 ]m4_map([b4_symbol_actions
], m4_defn([b4_symbol_destructors
]))[
477 ]b4_parser_class_name
[::yypop_ (unsigned int n
)
479 yystate_stack_
.pop (n
);
480 yysemantic_stack_
.pop (n
);
481 yylocation_stack_
.pop (n
);
485 ]b4_parser_class_name
[::debug_stream () const
491 ]b4_parser_class_name
[::set_debug_stream (std::ostream
& o
)
497 ]b4_parser_class_name
[::debug_level_type
498 ]b4_parser_class_name
[::debug_level () const
504 ]b4_parser_class_name
[::set_debug_level (debug_level_type l
)
511 ]b4_parser_class_name
[::parse ()
513 /// Look-ahead and look-ahead in internal form.
514 int yychar
= yyempty_
;
522 /* Error handling. */
524 int yyerrstatus_
= 0;
526 /// Semantic value of the look-ahead.
527 semantic_type yylval
;
528 /// Location of the look-ahead.
529 location_type yylloc
;
530 /// The locations where the error started and ended.
531 location yyerror_range
[2];
540 YYCDEBUG
<< "Starting parse" << std::endl
;
542 ]m4_ifdef([b4_initial_action
], [
543 m4_pushdef([b4_at_dollar
], [yylloc
])dnl
544 m4_pushdef([b4_dollar_dollar
], [yylval
])dnl
545 /* User initialization code. */
547 m4_popdef([b4_dollar_dollar
])dnl
548 m4_popdef([b4_at_dollar
])dnl
549 /* Line __line__ of yacc.c. */
550 b4_syncline([@oline@
], [@ofile@
])])dnl
552 [ /* Initialize the stacks. The initial state will be pushed in
553 yynewstate, since the latter expects the semantical and the
554 location values to have been already stored, initialize these
555 stacks with a primary value. */
556 yystate_stack_
= state_stack_type (0);
557 yysemantic_stack_
= semantic_stack_type (0);
558 yylocation_stack_
= location_stack_type (0);
559 yysemantic_stack_
.push (yylval
);
560 yylocation_stack_
.push (yylloc
);
564 yystate_stack_
.push (yystate
);
565 YYCDEBUG
<< "Entering state " << yystate
<< std::endl
;
571 /* Try to take a decision without look-ahead. */
572 yyn
= yypact_
[yystate
];
573 if (yyn
== yypact_ninf_
)
576 /* Read a look-ahead token. */
577 if (yychar
== yyempty_
)
579 YYCDEBUG
<< "Reading a token: ";
580 yychar
= ]b4_c_function_call([yylex
], [int],
581 [[YYSTYPE
*], [&yylval
]][]dnl
582 b4_locations_if([, [[location
*], [&yylloc
]]])dnl
583 m4_ifdef([b4_lex_param
], [, ]b4_lex_param
))[;
587 /* Convert token to internal form. */
588 if (yychar
<= yyeof_
)
590 yychar
= yytoken
= yyeof_
;
591 YYCDEBUG
<< "Now at end of input." << std::endl
;
595 yytoken
= yytranslate_ (yychar
);
596 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
599 /* If the proper action on seeing token YYTOKEN is to reduce or to
600 detect an error, take that action. */
602 if (yyn
< 0 || yylast_
< yyn
|| yycheck_
[yyn
] != yytoken
)
605 /* Reduce or error. */
609 if (yyn
== 0 || yyn
== yytable_ninf_
)
619 /* Shift the look-ahead token. */
620 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
622 /* Discard the token being shifted unless it is eof. */
623 if (yychar
!= yyeof_
)
626 yysemantic_stack_
.push (yylval
);
627 yylocation_stack_
.push (yylloc
);
629 /* Count tokens shifted since error; after three, turn off error
637 /*-----------------------------------------------------------.
638 | yydefault -- do the default action for the current state. |
639 `-----------------------------------------------------------*/
641 yyn
= yydefact_
[yystate
];
646 /*-----------------------------.
647 | yyreduce -- Do a reduction. |
648 `-----------------------------*/
651 /* If YYLEN is nonzero, implement the default value of the action:
652 `$$ = $1'. Otherwise, use the top of the stack.
654 Otherwise, the following line sets YYVAL to garbage.
655 This behavior is undocumented and Bison
656 users should not rely upon it. */
658 yyval
= yysemantic_stack_
[yylen
- 1];
660 yyval
= yysemantic_stack_
[0];
663 slice
<location_type
, location_stack_type
> slice (yylocation_stack_
, yylen
);
664 YYLLOC_DEFAULT (yyloc
, slice
, yylen
);
666 YY_REDUCE_PRINT (yyn
);
670 /* Line __line__ of lalr1.cc. */
671 b4_syncline([@oline@
], [@ofile@
])[
674 YY_SYMBOL_PRINT ("-> $$ =", yyr1_
[yyn
], &yyval
, &yyloc
);
680 yysemantic_stack_
.push (yyval
);
681 yylocation_stack_
.push (yyloc
);
683 /* Shift the result of the reduction. */
685 yystate
= yypgoto_
[yyn
- yyntokens_
] + yystate_stack_
[0];
686 if (0 <= yystate
&& yystate
<= yylast_
687 && yycheck_
[yystate
] == yystate_stack_
[0])
688 yystate
= yytable_
[yystate
];
690 yystate
= yydefgoto_
[yyn
- yyntokens_
];
693 /*------------------------------------.
694 | yyerrlab -- here on detecting error |
695 `------------------------------------*/
697 /* If not already recovering from an error, report this error. */
701 error (yylloc
, yysyntax_error_ (yystate
]dnl
702 b4_error_verbose_if([, yytoken
])[));
705 yyerror_range
[0] = yylloc
;
706 if (yyerrstatus_
== 3)
708 /* If just tried and failed to reuse look-ahead token after an
709 error, discard it. */
711 if (yychar
<= yyeof_
)
713 /* Return failure if at end of input. */
714 if (yychar
== yyeof_
)
719 yydestruct_ ("Error: discarding", yytoken
, &yylval
, &yylloc
);
724 /* Else will try to reuse look-ahead token after shifting the error
729 /*---------------------------------------------------.
730 | yyerrorlab -- error raised explicitly by YYERROR. |
731 `---------------------------------------------------*/
734 /* Pacify compilers like GCC when the user code never invokes
735 YYERROR and the label yyerrorlab therefore never appears in user
740 yyerror_range
[0] = yylocation_stack_
[yylen
- 1];
741 /* Do not reclaim the symbols of the rule which action triggered
745 yystate
= yystate_stack_
[0];
748 /*-------------------------------------------------------------.
749 | yyerrlab1 -- common code for both syntax error and YYERROR. |
750 `-------------------------------------------------------------*/
752 yyerrstatus_
= 3; /* Each real token shifted decrements this. */
756 yyn
= yypact_
[yystate
];
757 if (yyn
!= yypact_ninf_
)
760 if (0 <= yyn
&& yyn
<= yylast_
&& yycheck_
[yyn
] == yyterror_
)
768 /* Pop the current state because it cannot handle the error token. */
769 if (yystate_stack_
.height () == 1)
772 yyerror_range
[0] = yylocation_stack_
[0];
773 yydestruct_ ("Error: popping",
775 &yysemantic_stack_
[0], &yylocation_stack_
[0]);
777 yystate
= yystate_stack_
[0];
784 yyerror_range
[1] = yylloc
;
785 // Using YYLLOC is tempting, but would change the location of
786 // the look-ahead. YYLOC is available though.
787 YYLLOC_DEFAULT (yyloc
, (yyerror_range
- 1), 2);
788 yysemantic_stack_
.push (yylval
);
789 yylocation_stack_
.push (yyloc
);
791 /* Shift the error token. */
792 YY_SYMBOL_PRINT ("Shifting", yystos_
[yyn
],
793 &yysemantic_stack_
[0], &yylocation_stack_
[0]);
809 if (yychar
!= yyeof_
&& yychar
!= yyempty_
)
810 yydestruct_ ("Cleanup: discarding lookahead", yytoken
, &yylval
, &yylloc
);
812 /* Do not reclaim the symbols of the rule which action triggered
813 this YYABORT or YYACCEPT. */
815 while (yystate_stack_
.height () != 1)
817 yydestruct_ ("Cleanup: popping",
818 yystos_
[yystate_stack_
[0]],
819 &yysemantic_stack_
[0],
820 &yylocation_stack_
[0]);
827 // Generate an error message.
829 ]b4_parser_class_name
[::yysyntax_error_ (int yystate
]dnl
830 b4_error_verbose_if([, int tok
])[)
835 int yyn
= yypact_
[yystate
];
836 if (yypact_ninf_
< yyn
&& yyn
< yylast_
)
838 /* Start YYX at -YYN if negative to avoid negative indexes in
840 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
842 /* Stay within bounds of both yycheck and yytname. */
843 int yychecklim
= yylast_
- yyn
;
844 int yyxend
= yychecklim
< yyntokens_
? yychecklim
: yyntokens_
;
846 for (int x
= yyxbegin
; x
< yyxend
; ++x
)
847 if (yycheck_
[x
+ yyn
] == x
&& x
!= yyterror_
)
850 // FIXME: This method of building the message is not compatible
851 // with internationalization. It should work like yacc.c does it.
852 // That is, first build a string that looks like this:
853 // "syntax error, unexpected %s or %s or %s"
854 // Then, invoke YY_ on this string.
855 // Finally, use the string as a format to output
856 // yytname_[tok], etc.
857 // Until this gets fixed, this message appears in English only.
858 res
= "syntax error, unexpected ";
859 res
+= yytnamerr_ (yytname_
[tok
]);
863 for (int x
= yyxbegin
; x
< yyxend
; ++x
)
864 if (yycheck_
[x
+ yyn
] == x
&& x
!= yyterror_
)
866 res
+= (!count
++) ? ", expecting " : " or ";
867 res
+= yytnamerr_ (yytname_
[x
]);
873 res
= YY_("syntax error");
878 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
880 const ]b4_int_type(b4_pact_ninf
, b4_pact_ninf
) b4_parser_class_name::yypact_ninf_
= b4_pact_ninf
[;
881 const ]b4_int_type_for([b4_pact
])[
882 ]b4_parser_class_name
[::yypact_
[] =
887 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
888 doesn't specify something else to do. Zero means the default is an
890 const ]b4_int_type_for([b4_defact
])[
891 ]b4_parser_class_name
[::yydefact_
[] =
896 /* YYPGOTO[NTERM-NUM]. */
897 const ]b4_int_type_for([b4_pgoto
])[
898 ]b4_parser_class_name
[::yypgoto_
[] =
903 /* YYDEFGOTO[NTERM-NUM]. */
904 const ]b4_int_type_for([b4_defgoto
])[
905 ]b4_parser_class_name
[::yydefgoto_
[] =
910 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
911 positive, shift that token. If negative, reduce the rule which
912 number is the opposite. If zero, do what YYDEFACT says. */
913 const ]b4_int_type(b4_table_ninf
, b4_table_ninf
) b4_parser_class_name::yytable_ninf_
= b4_table_ninf
[;
914 const ]b4_int_type_for([b4_table
])[
915 ]b4_parser_class_name
[::yytable_
[] =
921 const ]b4_int_type_for([b4_check
])[
922 ]b4_parser_class_name
[::yycheck_
[] =
927 /* STOS_[STATE-NUM] -- The (internal number of the) accessing
928 symbol of state STATE-NUM. */
929 const ]b4_int_type_for([b4_stos
])[
930 ]b4_parser_class_name
[::yystos_
[] =
936 /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
938 const ]b4_int_type_for([b4_toknum
])[
939 ]b4_parser_class_name
[::yytoken_number_
[] =
945 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
946 const ]b4_int_type_for([b4_r1
])[
947 ]b4_parser_class_name
[::yyr1_
[] =
952 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
953 const ]b4_int_type_for([b4_r2
])[
954 ]b4_parser_class_name
[::yyr2_
[] =
959 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
960 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
961 First, the terminals, then, starting at \a yyntokens_, nonterminals. */
963 const ]b4_parser_class_name
[::yytname_
[] =
970 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
971 const ]b4_parser_class_name
[::rhs_number_type
972 ]b4_parser_class_name
[::yyrhs_
[] =
977 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
979 const ]b4_int_type_for([b4_prhs
])[
980 ]b4_parser_class_name
[::yyprhs_
[] =
985 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
986 const ]b4_int_type_for([b4_rline
])[
987 ]b4_parser_class_name
[::yyrline_
[] =
992 // Print the state stack on the debug stream.
994 ]b4_parser_class_name
[::yystack_print_ ()
996 *yycdebug_
<< "Stack now";
997 for (state_stack_type::const_iterator i
= yystate_stack_
.begin ();
998 i
!= yystate_stack_
.end (); ++i
)
999 *yycdebug_
<< ' ' << *i
;
1000 *yycdebug_
<< std::endl
;
1003 // Report on the debug stream that the rule \a yyrule is going to be reduced.
1005 ]b4_parser_class_name
[::yy_reduce_print_ (int yyrule
)
1007 unsigned int yylno
= yyrline_
[yyrule
];
1008 int yynrhs
= yyr2_
[yyrule
];
1009 /* Print the symbols being reduced, and their result. */
1010 *yycdebug_
<< "Reducing stack by rule " << yyrule
- 1
1011 << " (line " << yylno
<< "), ";
1012 /* The symbols being reduced. */
1013 for (int yyi
= 0; yyi
< yynrhs
; yyi
++)
1014 YY_SYMBOL_PRINT (" $" << yyi
+ 1 << " =",
1015 yyrhs_
[yyprhs_
[yyrule
] + yyi
],
1016 &]b4_rhs_value(yynrhs
, yyi
+ 1)[,
1017 &]b4_rhs_location(yynrhs
, yyi
+ 1)[);
1021 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1022 ]b4_parser_class_name
[::token_number_type
1023 ]b4_parser_class_name
[::yytranslate_ (int t
)
1026 const token_number_type
1031 if ((unsigned int) t
<= yyuser_token_number_max_
)
1032 return translate_table
[t
];
1034 return yyundef_token_
;
1037 const int ]b4_parser_class_name
[::yyeof_
= 0;
1038 const int ]b4_parser_class_name
[::yylast_
= ]b4_last
[;
1039 const int ]b4_parser_class_name
[::yynnts_
= ]b4_nterms_number
[;
1040 const int ]b4_parser_class_name
[::yyempty_
= -2;
1041 const int ]b4_parser_class_name
[::yyfinal_
= ]b4_final_state_number
[;
1042 const int ]b4_parser_class_name
[::yyterror_
= 1;
1043 const int ]b4_parser_class_name
[::yyerrcode_
= 256;
1044 const int ]b4_parser_class_name
[::yyntokens_
= ]b4_tokens_number
[;
1046 const unsigned int ]b4_parser_class_name
[::yyuser_token_number_max_
= ]b4_user_token_number_max
[;
1047 const ]b4_parser_class_name
[::token_number_type
]b4_parser_class_name
[::yyundef_token_
= ]b4_undef_token_number
[;
1049 } // namespace ]b4_namespace[
1053 @output b4_dir_prefix
[]stack
.hh
1054 b4_copyright([Stack handling
for Bison parsers in C
++],
1055 [2002, 2003, 2004, 2005, 2006])[
1057 #ifndef BISON_STACK_HH
1058 # define BISON_STACK_HH
1062 namespace ]b4_namespace
[
1064 template <class T
, class S
= std::deque
<T
> >
1069 // Hide our reversed order.
1070 typedef typename
S::reverse_iterator iterator
;
1071 typedef typename
S::const_reverse_iterator const_iterator
;
1077 stack (unsigned int n
) : seq_ (n
)
1083 operator [] (unsigned int i
)
1090 operator [] (unsigned int i
) const
1099 seq_
.push_front (t
);
1104 pop (unsigned int n
= 1)
1114 return seq_
.size ();
1117 inline const_iterator
begin () const { return seq_
.rbegin (); }
1118 inline const_iterator
end () const { return seq_
.rend (); }
1125 /// Present a slice of the top of a stack.
1126 template <class T
, class S
= stack
<T
> >
1131 slice (const S
& stack
,
1132 unsigned int range
) : stack_ (stack
),
1139 operator [] (unsigned int i
) const
1141 return stack_
[range_
- i
];
1147 unsigned int range_
;
1151 #endif // not BISON_STACK_HH]