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
])
24 # The header is mandatory.
26 [m4_fatal(b4_skeleton
[: using %defines is mandatory
])])
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 @output_header_name@
37 b4_copyright([Skeleton interface
for Bison
LALR(1) parsers in C
++],
38 [2002, 2003, 2004, 2005, 2006])
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
50 namespace ]b4_namespace
[
56 ]m4_ifdef([b4_before_definitions
],
57 [[/* Copy the %before-definitions blocks. */
58 ]b4_before_definitions
])[]dnl
60 [/* Line __line__ of lalr1.cc. */
61 ]b4_syncline([@oline@
], [@ofile@
])[
63 ]dnl Include location
.hh here
: it might depend on headers included above
.
64 [#include "location.hh"
66 /* Enabling traces. */
68 # define YYDEBUG ]b4_debug_flag[
71 /* Enabling verbose error messages. */
72 #ifdef YYERROR_VERBOSE
73 # undef YYERROR_VERBOSE
74 # define YYERROR_VERBOSE 1
76 # define YYERROR_VERBOSE ]b4_error_verbose_flag[
79 /* Enabling the token table. */
81 # define YYTOKEN_TABLE ]b4_token_table[
84 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
85 If N is 0, then set CURRENT to the empty location which ends
86 the previous symbol: RHS[0] (always defined). */
88 #ifndef YYLLOC_DEFAULT
89 # define YYLLOC_DEFAULT(Current, Rhs, N) \
93 (Current).begin = (Rhs)[1].begin; \
94 (Current).end = (Rhs)[N].end; \
98 (Current).begin = (Current).end = (Rhs)[0].end; \
103 namespace ]b4_namespace
[
107 class ]b4_parser_class_name
[
110 /// Symbol semantic values.
112 ]m4_ifdef([b4_stype
],
113 [ union semantic_type
115 /* Line __line__ of lalr1.cc. */
116 b4_syncline([@oline@
], [@ofile@
])
118 [ typedef int semantic_type
;])[
120 typedef YYSTYPE semantic_type
;
122 /// Symbol locations.
123 typedef ]b4_location_type
[ location_type
;
127 ]b4_token_enums(b4_tokens
)[
130 typedef token::yytokentype token_type
;
132 /// Build a parser object.
133 ]b4_parser_class_name
[ (]b4_parse_param_decl
[);
134 virtual ~]b4_parser_class_name
[ ();
137 /// \returns 0 iff parsing succeeded.
138 virtual int parse ();
140 /// The current debugging stream.
141 std::ostream
& debug_stream () const;
142 /// Set the current debugging stream.
143 void set_debug_stream (std::ostream
&);
145 /// Type for debugging levels.
146 typedef int debug_level_type
;
147 /// The current debugging level.
148 debug_level_type
debug_level () const;
149 /// Set the current debugging level.
150 void set_debug_level (debug_level_type l
);
153 /// Report a syntax error.
154 /// \param loc where the syntax error is found.
155 /// \param msg a description of the syntax error.
156 virtual void error (const location_type
& loc
, const std::string
& msg
);
158 /// Generate an error message.
159 /// \param state the state where the error occurred.
160 /// \param tok the lookahead token.
161 virtual std::string
yysyntax_error_ (int yystate
]dnl
162 b4_error_verbose_if([, int tok
])[);
165 /// \brief Report a symbol value on the debug stream.
166 /// \param yytype The token type.
167 /// \param yyvaluep Its semantic value.
168 /// \param yylocationp Its location.
169 virtual void yy_symbol_value_print_ (int yytype
,
170 const semantic_type
* yyvaluep
,
171 const location_type
* yylocationp
);
172 /// \brief Report a symbol on the debug stream.
173 /// \param yytype The token type.
174 /// \param yyvaluep Its semantic value.
175 /// \param yylocationp Its location.
176 virtual void yy_symbol_print_ (int yytype
,
177 const semantic_type
* yyvaluep
,
178 const location_type
* yylocationp
);
179 #endif /* ! YYDEBUG */
183 typedef int state_type
;
184 /// State stack type.
185 typedef stack
<state_type
> state_stack_type
;
186 /// Semantic value stack type.
187 typedef stack
<semantic_type
> semantic_stack_type
;
188 /// location stack type.
189 typedef stack
<location_type
> location_stack_type
;
192 state_stack_type yystate_stack_
;
193 /// The semantic value stack.
194 semantic_stack_type yysemantic_stack_
;
195 /// The location stack.
196 location_stack_type yylocation_stack_
;
198 /// Internal symbol numbers.
199 typedef ]b4_int_type_for([b4_translate
])[ token_number_type
;
201 /// For a state, the index in \a yytable_ of its portion.
202 static const ]b4_int_type_for([b4_pact
])[ yypact_
[];
203 static const ]b4_int_type(b4_pact_ninf
, b4_pact_ninf
)[ yypact_ninf_
;
205 /// For a state, default rule to reduce.
206 /// Unless\a yytable_ specifies something else to do.
207 /// Zero means the default is an error.
208 static const ]b4_int_type_for([b4_defact
])[ yydefact_
[];
210 static const ]b4_int_type_for([b4_pgoto
])[ yypgoto_
[];
211 static const ]b4_int_type_for([b4_defgoto
])[ yydefgoto_
[];
213 /// What to do in a state.
214 /// \a yytable_[yypact_[s]]: what to do in state \a s.
215 /// - if positive, shift that token.
216 /// - if negative, reduce the rule which number is the opposite.
217 /// - if zero, do what YYDEFACT says.
218 static const ]b4_int_type_for([b4_table
])[ yytable_
[];
219 static const ]b4_int_type(b4_table_ninf
, b4_table_ninf
)[ yytable_ninf_
;
221 static const ]b4_int_type_for([b4_check
])[ yycheck_
[];
223 /// For a state, its accessing symbol.
224 static const ]b4_int_type_for([b4_stos
])[ yystos_
[];
226 /// For a rule, its LHS.
227 static const ]b4_int_type_for([b4_r1
])[ yyr1_
[];
228 /// For a rule, its RHS length.
229 static const ]b4_int_type_for([b4_r2
])[ yyr2_
[];
231 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
232 /// For a symbol, its name in clear.
233 static const char* const yytname_
[];
237 /// Convert the symbol name \a n to a form suitable for a diagnostic.
238 virtual std::string
yytnamerr_ (const char *n
);
242 /// A type to store symbol numbers and -1.
243 typedef ]b4_int_type_for([b4_rhs
])[ rhs_number_type
;
244 /// A `-1'-separated list of the rules' RHS.
245 static const rhs_number_type yyrhs_
[];
246 /// For each rule, the index of the first RHS symbol in \a yyrhs_.
247 static const ]b4_int_type_for([b4_prhs
])[ yyprhs_
[];
248 /// For each rule, its source line number.
249 static const ]b4_int_type_for([b4_rline
])[ yyrline_
[];
250 /// For each scanner token number, its symbol number.
251 static const ]b4_int_type_for([b4_toknum
])[ yytoken_number_
[];
252 /// Report on the debug stream that the rule \a r is going to be reduced.
253 virtual void yy_reduce_print_ (int r
);
254 /// Print the state stack on the debug stream.
255 virtual void yystack_print_ ();
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_
;
289 std::ostream
* yycdebug_
;
291 ]b4_parse_param_vars
[
295 ]m4_ifset([b4_global_tokens_and_yystype
],
296 [b4_token_defines(b4_tokens
)
299 /* Redirection for backward compatibility. */
300 # define YYSTYPE b4_namespace::b4_parser_class_name::semantic_type
303 m4_ifdef([b4_after_definitions
],
304 [[/* Copy the %after-definitions blocks. */
305 ]b4_after_definitions
])[]dnl
307 [#endif /* ! defined PARSER_HEADER_H */]
309 @output @output_parser_name@
310 b4_copyright([Skeleton implementation
for Bison
LALR(1) parsers in C
++],
311 [2002, 2003, 2004, 2005, 2006])
312 m4_if(b4_prefix
, [yy
], [],
314 // Take the name prefix into account.
315 #define yylex b4_prefix[]lex])[
317 /* First part of user declarations. */
321 #include @output_header_name@])[
323 /* User implementation prologue. */
326 ]/* Line __line__ of lalr1.cc. */
327 b4_syncline([@oline@
], [@ofile@
])[
332 # include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */
333 # define YY_(msgid) dgettext ("bison-runtime", msgid)
337 # define YY_(msgid) msgid
341 /* Suppress unused-variable warnings by "using" E. */
342 #define YYUSE(e) ((void) (e))
344 /* A pseudo ostream that takes yydebug_ into account. */
346 for (bool yydebugcond_ = yydebug_; yydebugcond_; yydebugcond_ = false) \
349 /* Enable debugging if requested. */
352 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
356 *yycdebug_ << Title << ' '; \
357 yy_symbol_print_ ((Type), (Value), (Location)); \
358 *yycdebug_ << std::endl; \
362 # define YY_REDUCE_PRINT(Rule) \
365 yy_reduce_print_ (Rule); \
368 # define YY_STACK_PRINT() \
376 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
377 # define YY_REDUCE_PRINT(Rule)
378 # define YY_STACK_PRINT()
380 #endif /* !YYDEBUG */
382 #define YYACCEPT goto yyacceptlab
383 #define YYABORT goto yyabortlab
384 #define YYERROR goto yyerrorlab
386 namespace ]b4_namespace
[
390 /* Return YYSTR after stripping away unnecessary quotes and
391 backslashes, so that it's suitable for yyerror. The heuristic is
392 that double-quoting is unnecessary unless the string contains an
393 apostrophe, a comma, or backslash (other than backslash-backslash).
394 YYSTR is taken from yytname. */
396 ]b4_parser_class_name
[::yytnamerr_ (const char *yystr
)
400 std::string yyr
= "";
401 char const *yyp
= yystr
;
408 goto do_not_strip_quotes
;
412 goto do_not_strip_quotes
;
421 do_not_strip_quotes
: ;
429 /// Build a parser object.
430 ]b4_parser_class_name::b4_parser_class_name
[ (]b4_parse_param_decl
[)
432 yycdebug_ (&std::cerr
)]b4_parse_param_cons
[
436 ]b4_parser_class_name::~b4_parser_class_name
[ ()
441 /*--------------------------------.
442 | Print this symbol on YYOUTPUT. |
443 `--------------------------------*/
446 ]b4_parser_class_name
[::yy_symbol_value_print_ (int yytype
,
447 const semantic_type
* yyvaluep
, const location_type
* yylocationp
)
453 ]m4_map([b4_symbol_actions
], m4_defn([b4_symbol_printers
]))dnl
461 ]b4_parser_class_name
[::yy_symbol_print_ (int yytype
,
462 const semantic_type
* yyvaluep
, const location_type
* yylocationp
)
464 *yycdebug_
<< (yytype
< yyntokens_
? "token" : "nterm")
465 << ' ' << yytname_
[yytype
] << " ("
466 << *yylocationp
<< ": ";
467 yy_symbol_value_print_ (yytype
, yyvaluep
, yylocationp
);
470 #endif /* ! YYDEBUG */
473 ]b4_parser_class_name
[::yydestruct_ (const char* yymsg
,
474 int yytype
, semantic_type
* yyvaluep
, location_type
* yylocationp
)
480 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
484 ]m4_map([b4_symbol_actions
], m4_defn([b4_symbol_destructors
]))[
491 ]b4_parser_class_name
[::yypop_ (unsigned int n
)
493 yystate_stack_
.pop (n
);
494 yysemantic_stack_
.pop (n
);
495 yylocation_stack_
.pop (n
);
499 ]b4_parser_class_name
[::debug_stream () const
505 ]b4_parser_class_name
[::set_debug_stream (std::ostream
& o
)
511 ]b4_parser_class_name
[::debug_level_type
512 ]b4_parser_class_name
[::debug_level () const
518 ]b4_parser_class_name
[::set_debug_level (debug_level_type l
)
525 ]b4_parser_class_name
[::parse ()
527 /// Lookahead and lookahead in internal form.
528 int yychar
= yyempty_
;
536 /* Error handling. */
538 int yyerrstatus_
= 0;
540 /// Semantic value of the lookahead.
541 semantic_type yylval
;
542 /// Location of the lookahead.
543 location_type yylloc
;
544 /// The locations where the error started and ended.
545 location yyerror_range
[2];
554 YYCDEBUG
<< "Starting parse" << std::endl
;
556 ]m4_ifdef([b4_initial_action
], [
557 m4_pushdef([b4_at_dollar
], [yylloc
])dnl
558 m4_pushdef([b4_dollar_dollar
], [yylval
])dnl
559 /* User initialization code. */
561 m4_popdef([b4_dollar_dollar
])dnl
562 m4_popdef([b4_at_dollar
])dnl
563 /* Line __line__ of yacc.c. */
564 b4_syncline([@oline@
], [@ofile@
])])dnl
566 [ /* Initialize the stacks. The initial state will be pushed in
567 yynewstate, since the latter expects the semantical and the
568 location values to have been already stored, initialize these
569 stacks with a primary value. */
570 yystate_stack_
= state_stack_type (0);
571 yysemantic_stack_
= semantic_stack_type (0);
572 yylocation_stack_
= location_stack_type (0);
573 yysemantic_stack_
.push (yylval
);
574 yylocation_stack_
.push (yylloc
);
578 yystate_stack_
.push (yystate
);
579 YYCDEBUG
<< "Entering state " << yystate
<< std::endl
;
585 /* Try to take a decision without lookahead. */
586 yyn
= yypact_
[yystate
];
587 if (yyn
== yypact_ninf_
)
590 /* Read a lookahead token. */
591 if (yychar
== yyempty_
)
593 YYCDEBUG
<< "Reading a token: ";
594 yychar
= ]b4_c_function_call([yylex
], [int],
595 [[YYSTYPE
*], [&yylval
]][]dnl
596 b4_locations_if([, [[location
*], [&yylloc
]]])dnl
597 m4_ifdef([b4_lex_param
], [, ]b4_lex_param
))[;
601 /* Convert token to internal form. */
602 if (yychar
<= yyeof_
)
604 yychar
= yytoken
= yyeof_
;
605 YYCDEBUG
<< "Now at end of input." << std::endl
;
609 yytoken
= yytranslate_ (yychar
);
610 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
613 /* If the proper action on seeing token YYTOKEN is to reduce or to
614 detect an error, take that action. */
616 if (yyn
< 0 || yylast_
< yyn
|| yycheck_
[yyn
] != yytoken
)
619 /* Reduce or error. */
623 if (yyn
== 0 || yyn
== yytable_ninf_
)
633 /* Shift the lookahead token. */
634 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
636 /* Discard the token being shifted unless it is eof. */
637 if (yychar
!= yyeof_
)
640 yysemantic_stack_
.push (yylval
);
641 yylocation_stack_
.push (yylloc
);
643 /* Count tokens shifted since error; after three, turn off error
651 /*-----------------------------------------------------------.
652 | yydefault -- do the default action for the current state. |
653 `-----------------------------------------------------------*/
655 yyn
= yydefact_
[yystate
];
660 /*-----------------------------.
661 | yyreduce -- Do a reduction. |
662 `-----------------------------*/
665 /* If YYLEN is nonzero, implement the default value of the action:
666 `$$ = $1'. Otherwise, use the top of the stack.
668 Otherwise, the following line sets YYVAL to garbage.
669 This behavior is undocumented and Bison
670 users should not rely upon it. */
672 yyval
= yysemantic_stack_
[yylen
- 1];
674 yyval
= yysemantic_stack_
[0];
677 slice
<location_type
, location_stack_type
> slice (yylocation_stack_
, yylen
);
678 YYLLOC_DEFAULT (yyloc
, slice
, yylen
);
680 YY_REDUCE_PRINT (yyn
);
684 /* Line __line__ of lalr1.cc. */
685 b4_syncline([@oline@
], [@ofile@
])[
688 YY_SYMBOL_PRINT ("-> $$ =", yyr1_
[yyn
], &yyval
, &yyloc
);
694 yysemantic_stack_
.push (yyval
);
695 yylocation_stack_
.push (yyloc
);
697 /* Shift the result of the reduction. */
699 yystate
= yypgoto_
[yyn
- yyntokens_
] + yystate_stack_
[0];
700 if (0 <= yystate
&& yystate
<= yylast_
701 && yycheck_
[yystate
] == yystate_stack_
[0])
702 yystate
= yytable_
[yystate
];
704 yystate
= yydefgoto_
[yyn
- yyntokens_
];
707 /*------------------------------------.
708 | yyerrlab -- here on detecting error |
709 `------------------------------------*/
711 /* If not already recovering from an error, report this error. */
715 error (yylloc
, yysyntax_error_ (yystate
]dnl
716 b4_error_verbose_if([, yytoken
])[));
719 yyerror_range
[0] = yylloc
;
720 if (yyerrstatus_
== 3)
722 /* If just tried and failed to reuse lookahead token after an
723 error, discard it. */
725 if (yychar
<= yyeof_
)
727 /* Return failure if at end of input. */
728 if (yychar
== yyeof_
)
733 yydestruct_ ("Error: discarding", yytoken
, &yylval
, &yylloc
);
738 /* Else will try to reuse lookahead token after shifting the error
743 /*---------------------------------------------------.
744 | yyerrorlab -- error raised explicitly by YYERROR. |
745 `---------------------------------------------------*/
748 /* Pacify compilers like GCC when the user code never invokes
749 YYERROR and the label yyerrorlab therefore never appears in user
754 yyerror_range
[0] = yylocation_stack_
[yylen
- 1];
755 /* Do not reclaim the symbols of the rule which action triggered
759 yystate
= yystate_stack_
[0];
762 /*-------------------------------------------------------------.
763 | yyerrlab1 -- common code for both syntax error and YYERROR. |
764 `-------------------------------------------------------------*/
766 yyerrstatus_
= 3; /* Each real token shifted decrements this. */
770 yyn
= yypact_
[yystate
];
771 if (yyn
!= yypact_ninf_
)
774 if (0 <= yyn
&& yyn
<= yylast_
&& yycheck_
[yyn
] == yyterror_
)
782 /* Pop the current state because it cannot handle the error token. */
783 if (yystate_stack_
.height () == 1)
786 yyerror_range
[0] = yylocation_stack_
[0];
787 yydestruct_ ("Error: popping",
789 &yysemantic_stack_
[0], &yylocation_stack_
[0]);
791 yystate
= yystate_stack_
[0];
798 yyerror_range
[1] = yylloc
;
799 // Using YYLLOC is tempting, but would change the location of
800 // the lookahead. YYLOC is available though.
801 YYLLOC_DEFAULT (yyloc
, (yyerror_range
- 1), 2);
802 yysemantic_stack_
.push (yylval
);
803 yylocation_stack_
.push (yyloc
);
805 /* Shift the error token. */
806 YY_SYMBOL_PRINT ("Shifting", yystos_
[yyn
],
807 &yysemantic_stack_
[0], &yylocation_stack_
[0]);
823 if (yychar
!= yyeof_
&& yychar
!= yyempty_
)
824 yydestruct_ ("Cleanup: discarding lookahead", yytoken
, &yylval
, &yylloc
);
826 /* Do not reclaim the symbols of the rule which action triggered
827 this YYABORT or YYACCEPT. */
829 while (yystate_stack_
.height () != 1)
831 yydestruct_ ("Cleanup: popping",
832 yystos_
[yystate_stack_
[0]],
833 &yysemantic_stack_
[0],
834 &yylocation_stack_
[0]);
841 // Generate an error message.
843 ]b4_parser_class_name
[::yysyntax_error_ (int yystate
]dnl
844 b4_error_verbose_if([, int tok
])[)
849 int yyn
= yypact_
[yystate
];
850 if (yypact_ninf_
< yyn
&& yyn
<= yylast_
)
852 /* Start YYX at -YYN if negative to avoid negative indexes in
854 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
856 /* Stay within bounds of both yycheck and yytname. */
857 int yychecklim
= yylast_
- yyn
+ 1;
858 int yyxend
= yychecklim
< yyntokens_
? yychecklim
: yyntokens_
;
860 for (int x
= yyxbegin
; x
< yyxend
; ++x
)
861 if (yycheck_
[x
+ yyn
] == x
&& x
!= yyterror_
)
864 // FIXME: This method of building the message is not compatible
865 // with internationalization. It should work like yacc.c does it.
866 // That is, first build a string that looks like this:
867 // "syntax error, unexpected %s or %s or %s"
868 // Then, invoke YY_ on this string.
869 // Finally, use the string as a format to output
870 // yytname_[tok], etc.
871 // Until this gets fixed, this message appears in English only.
872 res
= "syntax error, unexpected ";
873 res
+= yytnamerr_ (yytname_
[tok
]);
877 for (int x
= yyxbegin
; x
< yyxend
; ++x
)
878 if (yycheck_
[x
+ yyn
] == x
&& x
!= yyterror_
)
880 res
+= (!count
++) ? ", expecting " : " or ";
881 res
+= yytnamerr_ (yytname_
[x
]);
887 res
= YY_("syntax error");
892 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
894 const ]b4_int_type(b4_pact_ninf
, b4_pact_ninf
) b4_parser_class_name::yypact_ninf_
= b4_pact_ninf
[;
895 const ]b4_int_type_for([b4_pact
])[
896 ]b4_parser_class_name
[::yypact_
[] =
901 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
902 doesn't specify something else to do. Zero means the default is an
904 const ]b4_int_type_for([b4_defact
])[
905 ]b4_parser_class_name
[::yydefact_
[] =
910 /* YYPGOTO[NTERM-NUM]. */
911 const ]b4_int_type_for([b4_pgoto
])[
912 ]b4_parser_class_name
[::yypgoto_
[] =
917 /* YYDEFGOTO[NTERM-NUM]. */
918 const ]b4_int_type_for([b4_defgoto
])[
919 ]b4_parser_class_name
[::yydefgoto_
[] =
924 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
925 positive, shift that token. If negative, reduce the rule which
926 number is the opposite. If zero, do what YYDEFACT says. */
927 const ]b4_int_type(b4_table_ninf
, b4_table_ninf
) b4_parser_class_name::yytable_ninf_
= b4_table_ninf
[;
928 const ]b4_int_type_for([b4_table
])[
929 ]b4_parser_class_name
[::yytable_
[] =
935 const ]b4_int_type_for([b4_check
])[
936 ]b4_parser_class_name
[::yycheck_
[] =
941 /* STOS_[STATE-NUM] -- The (internal number of the) accessing
942 symbol of state STATE-NUM. */
943 const ]b4_int_type_for([b4_stos
])[
944 ]b4_parser_class_name
[::yystos_
[] =
950 /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
952 const ]b4_int_type_for([b4_toknum
])[
953 ]b4_parser_class_name
[::yytoken_number_
[] =
959 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
960 const ]b4_int_type_for([b4_r1
])[
961 ]b4_parser_class_name
[::yyr1_
[] =
966 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
967 const ]b4_int_type_for([b4_r2
])[
968 ]b4_parser_class_name
[::yyr2_
[] =
973 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
974 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
975 First, the terminals, then, starting at \a yyntokens_, nonterminals. */
977 const ]b4_parser_class_name
[::yytname_
[] =
984 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
985 const ]b4_parser_class_name
[::rhs_number_type
986 ]b4_parser_class_name
[::yyrhs_
[] =
991 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
993 const ]b4_int_type_for([b4_prhs
])[
994 ]b4_parser_class_name
[::yyprhs_
[] =
999 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
1000 const ]b4_int_type_for([b4_rline
])[
1001 ]b4_parser_class_name
[::yyrline_
[] =
1006 // Print the state stack on the debug stream.
1008 ]b4_parser_class_name
[::yystack_print_ ()
1010 *yycdebug_
<< "Stack now";
1011 for (state_stack_type::const_iterator i
= yystate_stack_
.begin ();
1012 i
!= yystate_stack_
.end (); ++i
)
1013 *yycdebug_
<< ' ' << *i
;
1014 *yycdebug_
<< std::endl
;
1017 // Report on the debug stream that the rule \a yyrule is going to be reduced.
1019 ]b4_parser_class_name
[::yy_reduce_print_ (int yyrule
)
1021 unsigned int yylno
= yyrline_
[yyrule
];
1022 int yynrhs
= yyr2_
[yyrule
];
1023 /* Print the symbols being reduced, and their result. */
1024 *yycdebug_
<< "Reducing stack by rule " << yyrule
- 1
1025 << " (line " << yylno
<< "), ";
1026 /* The symbols being reduced. */
1027 for (int yyi
= 0; yyi
< yynrhs
; yyi
++)
1028 YY_SYMBOL_PRINT (" $" << yyi
+ 1 << " =",
1029 yyrhs_
[yyprhs_
[yyrule
] + yyi
],
1030 &]b4_rhs_value(yynrhs
, yyi
+ 1)[,
1031 &]b4_rhs_location(yynrhs
, yyi
+ 1)[);
1035 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1036 ]b4_parser_class_name
[::token_number_type
1037 ]b4_parser_class_name
[::yytranslate_ (int t
)
1040 const token_number_type
1045 if ((unsigned int) t
<= yyuser_token_number_max_
)
1046 return translate_table
[t
];
1048 return yyundef_token_
;
1051 const int ]b4_parser_class_name
[::yyeof_
= 0;
1052 const int ]b4_parser_class_name
[::yylast_
= ]b4_last
[;
1053 const int ]b4_parser_class_name
[::yynnts_
= ]b4_nterms_number
[;
1054 const int ]b4_parser_class_name
[::yyempty_
= -2;
1055 const int ]b4_parser_class_name
[::yyfinal_
= ]b4_final_state_number
[;
1056 const int ]b4_parser_class_name
[::yyterror_
= 1;
1057 const int ]b4_parser_class_name
[::yyerrcode_
= 256;
1058 const int ]b4_parser_class_name
[::yyntokens_
= ]b4_tokens_number
[;
1060 const unsigned int ]b4_parser_class_name
[::yyuser_token_number_max_
= ]b4_user_token_number_max
[;
1061 const ]b4_parser_class_name
[::token_number_type
]b4_parser_class_name
[::yyundef_token_
= ]b4_undef_token_number
[;
1063 } // namespace ]b4_namespace[
1067 @output b4_dir_prefix
[]stack
.hh
1068 b4_copyright([Stack handling
for Bison parsers in C
++],
1069 [2002, 2003, 2004, 2005, 2006])[
1071 #ifndef BISON_STACK_HH
1072 # define BISON_STACK_HH
1076 namespace ]b4_namespace
[
1078 template <class T
, class S
= std::deque
<T
> >
1083 // Hide our reversed order.
1084 typedef typename
S::reverse_iterator iterator
;
1085 typedef typename
S::const_reverse_iterator const_iterator
;
1091 stack (unsigned int n
) : seq_ (n
)
1097 operator [] (unsigned int i
)
1104 operator [] (unsigned int i
) const
1113 seq_
.push_front (t
);
1118 pop (unsigned int n
= 1)
1128 return seq_
.size ();
1131 inline const_iterator
begin () const { return seq_
.rbegin (); }
1132 inline const_iterator
end () const { return seq_
.rend (); }
1139 /// Present a slice of the top of a stack.
1140 template <class T
, class S
= stack
<T
> >
1145 slice (const S
& stack
,
1146 unsigned int range
) : stack_ (stack
),
1153 operator [] (unsigned int i
) const
1155 return stack_
[range_
- i
];
1161 unsigned int range_
;
1165 #endif // not BISON_STACK_HH]