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.
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, 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[
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; \
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 to a symbol number.
253 token_number_type
yytranslate_ (int token
);
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([C
++ Skeleton parser
for LALR(1) parsing with Bison
],
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])
306 m4_if(b4_defines_flag
, 0, [],
308 #include @output_header_name@])[
310 /* User implementation prologue. */
313 ]/* Line __line__ of lalr1.cc. */
314 b4_syncline([@oline@
], [@ofile@
])[
319 # include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */
320 # define YY_(msgid) dgettext ("bison-runtime", msgid)
324 # define YY_(msgid) msgid
328 /* Suppress unused-variable warnings by "using" E. */
329 #define YYUSE(e) ((void) (e))
331 /* A pseudo ostream that takes yydebug_ into account. */
333 for (bool yydebugcond_ = yydebug_; yydebugcond_; yydebugcond_ = false) \
336 /* Enable debugging if requested. */
339 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
343 *yycdebug_ << Title << ' '; \
344 yy_symbol_print_ ((Type), (Value), (Location)); \
345 *yycdebug_ << std::endl; \
349 # define YY_REDUCE_PRINT(Rule) \
352 yy_reduce_print_ (Rule); \
355 # define YY_STACK_PRINT() \
363 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
364 # define YY_REDUCE_PRINT(Rule)
365 # define YY_STACK_PRINT()
367 #endif /* !YYDEBUG */
369 #define YYACCEPT goto yyacceptlab
370 #define YYABORT goto yyabortlab
371 #define YYERROR goto yyerrorlab
373 namespace ]b4_namespace
[
377 /* Return YYSTR after stripping away unnecessary quotes and
378 backslashes, so that it's suitable for yyerror. The heuristic is
379 that double-quoting is unnecessary unless the string contains an
380 apostrophe, a comma, or backslash (other than backslash-backslash).
381 YYSTR is taken from yytname. */
383 ]b4_parser_class_name
[::yytnamerr_ (const char *yystr
)
387 std::string yyr
= "";
388 char const *yyp
= yystr
;
395 goto do_not_strip_quotes
;
399 goto do_not_strip_quotes
;
408 do_not_strip_quotes
: ;
416 /// Build a parser object.
417 ]b4_parser_class_name::b4_parser_class_name
[ (]b4_parse_param_decl
[)
419 yycdebug_ (&std::cerr
)]b4_parse_param_cons
[
423 ]b4_parser_class_name::~b4_parser_class_name
[ ()
428 /*--------------------------------.
429 | Print this symbol on YYOUTPUT. |
430 `--------------------------------*/
433 ]b4_parser_class_name
[::yy_symbol_value_print_ (int yytype
,
434 const semantic_type
* yyvaluep
, const location_type
* yylocationp
)
440 ]m4_map([b4_symbol_actions
], m4_defn([b4_symbol_printers
]))dnl
448 ]b4_parser_class_name
[::yy_symbol_print_ (int yytype
,
449 const semantic_type
* yyvaluep
, const location_type
* yylocationp
)
451 *yycdebug_
<< (yytype
< yyntokens_
? "token" : "nterm")
452 << ' ' << yytname_
[yytype
] << " ("
453 << *yylocationp
<< ": ";
454 yy_symbol_value_print_ (yytype
, yyvaluep
, yylocationp
);
457 #endif /* ! YYDEBUG */
460 ]b4_parser_class_name
[::yydestruct_ (const char* yymsg
,
461 int yytype
, semantic_type
* yyvaluep
, location_type
* yylocationp
)
467 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
471 ]m4_map([b4_symbol_actions
], m4_defn([b4_symbol_destructors
]))[
478 ]b4_parser_class_name
[::yypop_ (unsigned int n
)
480 yystate_stack_
.pop (n
);
481 yysemantic_stack_
.pop (n
);
482 yylocation_stack_
.pop (n
);
486 ]b4_parser_class_name
[::debug_stream () const
492 ]b4_parser_class_name
[::set_debug_stream (std::ostream
& o
)
498 ]b4_parser_class_name
[::debug_level_type
499 ]b4_parser_class_name
[::debug_level () const
505 ]b4_parser_class_name
[::set_debug_level (debug_level_type l
)
512 ]b4_parser_class_name
[::parse ()
514 /// Look-ahead and look-ahead in internal form.
515 int yychar
= yyempty_
;
523 /* Error handling. */
525 int yyerrstatus_
= 0;
527 /// Semantic value of the look-ahead.
528 semantic_type yylval
;
529 /// Location of the look-ahead.
530 location_type yylloc
;
531 /// The locations where the error started and ended.
532 location yyerror_range
[2];
541 YYCDEBUG
<< "Starting parse" << std::endl
;
543 ]m4_ifdef([b4_initial_action
], [
544 m4_pushdef([b4_at_dollar
], [yylloc
])dnl
545 m4_pushdef([b4_dollar_dollar
], [yylval
])dnl
546 /* User initialization code. */
548 m4_popdef([b4_dollar_dollar
])dnl
549 m4_popdef([b4_at_dollar
])dnl
550 /* Line __line__ of yacc.c. */
551 b4_syncline([@oline@
], [@ofile@
])])dnl
553 [ /* Initialize the stacks. The initial state will be pushed in
554 yynewstate, since the latter expects the semantical and the
555 location values to have been already stored, initialize these
556 stacks with a primary value. */
557 yystate_stack_
= state_stack_type (0);
558 yysemantic_stack_
= semantic_stack_type (0);
559 yylocation_stack_
= location_stack_type (0);
560 yysemantic_stack_
.push (yylval
);
561 yylocation_stack_
.push (yylloc
);
565 yystate_stack_
.push (yystate
);
566 YYCDEBUG
<< "Entering state " << yystate
<< std::endl
;
572 /* Try to take a decision without look-ahead. */
573 yyn
= yypact_
[yystate
];
574 if (yyn
== yypact_ninf_
)
577 /* Read a look-ahead token. */
578 if (yychar
== yyempty_
)
580 YYCDEBUG
<< "Reading a token: ";
581 yychar
= ]b4_c_function_call([yylex
], [int],
582 [[YYSTYPE
*], [&yylval
]][]dnl
583 b4_location_if([, [[location
*], [&yylloc
]]])dnl
584 m4_ifdef([b4_lex_param
], [, ]b4_lex_param
))[;
588 /* Convert token to internal form. */
589 if (yychar
<= yyeof_
)
591 yychar
= yytoken
= yyeof_
;
592 YYCDEBUG
<< "Now at end of input." << std::endl
;
596 yytoken
= yytranslate_ (yychar
);
597 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
600 /* If the proper action on seeing token YYTOKEN is to reduce or to
601 detect an error, take that action. */
603 if (yyn
< 0 || yylast_
< yyn
|| yycheck_
[yyn
] != yytoken
)
606 /* Reduce or error. */
610 if (yyn
== 0 || yyn
== yytable_ninf_
)
620 /* Shift the look-ahead token. */
621 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
623 /* Discard the token being shifted unless it is eof. */
624 if (yychar
!= yyeof_
)
627 yysemantic_stack_
.push (yylval
);
628 yylocation_stack_
.push (yylloc
);
630 /* Count tokens shifted since error; after three, turn off error
638 /*-----------------------------------------------------------.
639 | yydefault -- do the default action for the current state. |
640 `-----------------------------------------------------------*/
642 yyn
= yydefact_
[yystate
];
647 /*-----------------------------.
648 | yyreduce -- Do a reduction. |
649 `-----------------------------*/
652 /* If YYLEN is nonzero, implement the default value of the action:
653 `$$ = $1'. Otherwise, use the top of the stack.
655 Otherwise, the following line sets YYVAL to garbage.
656 This behavior is undocumented and Bison
657 users should not rely upon it. */
659 yyval
= yysemantic_stack_
[yylen
- 1];
661 yyval
= yysemantic_stack_
[0];
664 slice
<location_type
, location_stack_type
> slice (yylocation_stack_
, yylen
);
665 YYLLOC_DEFAULT (yyloc
, slice
, yylen
);
667 YY_REDUCE_PRINT (yyn
);
671 /* Line __line__ of lalr1.cc. */
672 b4_syncline([@oline@
], [@ofile@
])[
675 YY_SYMBOL_PRINT ("-> $$ =", yyr1_
[yyn
], &yyval
, &yyloc
);
681 yysemantic_stack_
.push (yyval
);
682 yylocation_stack_
.push (yyloc
);
684 /* Shift the result of the reduction. */
686 yystate
= yypgoto_
[yyn
- yyntokens_
] + yystate_stack_
[0];
687 if (0 <= yystate
&& yystate
<= yylast_
688 && yycheck_
[yystate
] == yystate_stack_
[0])
689 yystate
= yytable_
[yystate
];
691 yystate
= yydefgoto_
[yyn
- yyntokens_
];
694 /*------------------------------------.
695 | yyerrlab -- here on detecting error |
696 `------------------------------------*/
698 /* If not already recovering from an error, report this error. */
702 error (yylloc
, yysyntax_error_ (yystate
]dnl
703 b4_error_verbose_if([, yytoken
])[));
706 yyerror_range
[0] = yylloc
;
707 if (yyerrstatus_
== 3)
709 /* If just tried and failed to reuse look-ahead token after an
710 error, discard it. */
712 if (yychar
<= yyeof_
)
714 /* Return failure if at end of input. */
715 if (yychar
== yyeof_
)
720 yydestruct_ ("Error: discarding", yytoken
, &yylval
, &yylloc
);
725 /* Else will try to reuse look-ahead token after shifting the error
730 /*---------------------------------------------------.
731 | yyerrorlab -- error raised explicitly by YYERROR. |
732 `---------------------------------------------------*/
735 /* Pacify compilers like GCC when the user code never invokes
736 YYERROR and the label yyerrorlab therefore never appears in user
741 yyerror_range
[0] = yylocation_stack_
[yylen
- 1];
742 /* Do not reclaim the symbols of the rule which action triggered
746 yystate
= yystate_stack_
[0];
749 /*-------------------------------------------------------------.
750 | yyerrlab1 -- common code for both syntax error and YYERROR. |
751 `-------------------------------------------------------------*/
753 yyerrstatus_
= 3; /* Each real token shifted decrements this. */
757 yyn
= yypact_
[yystate
];
758 if (yyn
!= yypact_ninf_
)
761 if (0 <= yyn
&& yyn
<= yylast_
&& yycheck_
[yyn
] == yyterror_
)
769 /* Pop the current state because it cannot handle the error token. */
770 if (yystate_stack_
.height () == 1)
773 yyerror_range
[0] = yylocation_stack_
[0];
774 yydestruct_ ("Error: popping",
776 &yysemantic_stack_
[0], &yylocation_stack_
[0]);
778 yystate
= yystate_stack_
[0];
785 yyerror_range
[1] = yylloc
;
786 // Using YYLLOC is tempting, but would change the location of
787 // the look-ahead. YYLOC is available though.
788 YYLLOC_DEFAULT (yyloc
, (yyerror_range
- 1), 2);
789 yysemantic_stack_
.push (yylval
);
790 yylocation_stack_
.push (yyloc
);
792 /* Shift the error token. */
793 YY_SYMBOL_PRINT ("Shifting", yystos_
[yyn
],
794 &yysemantic_stack_
[0], &yylocation_stack_
[0]);
810 if (yychar
!= yyeof_
&& yychar
!= yyempty_
)
811 yydestruct_ ("Cleanup: discarding lookahead", yytoken
, &yylval
, &yylloc
);
813 /* Do not reclaim the symbols of the rule which action triggered
814 this YYABORT or YYACCEPT. */
816 while (yystate_stack_
.height () != 1)
818 yydestruct_ ("Cleanup: popping",
819 yystos_
[yystate_stack_
[0]],
820 &yysemantic_stack_
[0],
821 &yylocation_stack_
[0]);
828 // Generate an error message.
830 ]b4_parser_class_name
[::yysyntax_error_ (int yystate
]dnl
831 b4_error_verbose_if([, int tok
])[)
836 int yyn
= yypact_
[yystate
];
837 if (yypact_ninf_
< yyn
&& yyn
< yylast_
)
839 /* Start YYX at -YYN if negative to avoid negative indexes in
841 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
843 /* Stay within bounds of both yycheck and yytname. */
844 int yychecklim
= yylast_
- yyn
;
845 int yyxend
= yychecklim
< yyntokens_
? yychecklim
: yyntokens_
;
847 for (int x
= yyxbegin
; x
< yyxend
; ++x
)
848 if (yycheck_
[x
+ yyn
] == x
&& x
!= yyterror_
)
851 // FIXME: This method of building the message is not compatible
852 // with internationalization. It should work like yacc.c does it.
853 // That is, first build a string that looks like this:
854 // "syntax error, unexpected %s or %s or %s"
855 // Then, invoke YY_ on this string.
856 // Finally, use the string as a format to output
857 // yytname_[tok], etc.
858 // Until this gets fixed, this message appears in English only.
859 res
= "syntax error, unexpected ";
860 res
+= yytnamerr_ (yytname_
[tok
]);
864 for (int x
= yyxbegin
; x
< yyxend
; ++x
)
865 if (yycheck_
[x
+ yyn
] == x
&& x
!= yyterror_
)
867 res
+= (!count
++) ? ", expecting " : " or ";
868 res
+= yytnamerr_ (yytname_
[x
]);
874 res
= YY_("syntax error");
879 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
881 const ]b4_int_type(b4_pact_ninf
, b4_pact_ninf
) b4_parser_class_name::yypact_ninf_
= b4_pact_ninf
[;
882 const ]b4_int_type_for([b4_pact
])[
883 ]b4_parser_class_name
[::yypact_
[] =
888 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
889 doesn't specify something else to do. Zero means the default is an
891 const ]b4_int_type_for([b4_defact
])[
892 ]b4_parser_class_name
[::yydefact_
[] =
897 /* YYPGOTO[NTERM-NUM]. */
898 const ]b4_int_type_for([b4_pgoto
])[
899 ]b4_parser_class_name
[::yypgoto_
[] =
904 /* YYDEFGOTO[NTERM-NUM]. */
905 const ]b4_int_type_for([b4_defgoto
])[
906 ]b4_parser_class_name
[::yydefgoto_
[] =
911 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
912 positive, shift that token. If negative, reduce the rule which
913 number is the opposite. If zero, do what YYDEFACT says. */
914 const ]b4_int_type(b4_table_ninf
, b4_table_ninf
) b4_parser_class_name::yytable_ninf_
= b4_table_ninf
[;
915 const ]b4_int_type_for([b4_table
])[
916 ]b4_parser_class_name
[::yytable_
[] =
922 const ]b4_int_type_for([b4_check
])[
923 ]b4_parser_class_name
[::yycheck_
[] =
928 /* STOS_[STATE-NUM] -- The (internal number of the) accessing
929 symbol of state STATE-NUM. */
930 const ]b4_int_type_for([b4_stos
])[
931 ]b4_parser_class_name
[::yystos_
[] =
937 /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
939 const ]b4_int_type_for([b4_toknum
])[
940 ]b4_parser_class_name
[::yytoken_number_
[] =
946 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
947 const ]b4_int_type_for([b4_r1
])[
948 ]b4_parser_class_name
[::yyr1_
[] =
953 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
954 const ]b4_int_type_for([b4_r2
])[
955 ]b4_parser_class_name
[::yyr2_
[] =
960 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
961 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
962 First, the terminals, then, starting at \a yyntokens_, nonterminals. */
964 const ]b4_parser_class_name
[::yytname_
[] =
971 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
972 const ]b4_parser_class_name
[::rhs_number_type
973 ]b4_parser_class_name
[::yyrhs_
[] =
978 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
980 const ]b4_int_type_for([b4_prhs
])[
981 ]b4_parser_class_name
[::yyprhs_
[] =
986 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
987 const ]b4_int_type_for([b4_rline
])[
988 ]b4_parser_class_name
[::yyrline_
[] =
993 // Print the state stack on the debug stream.
995 ]b4_parser_class_name
[::yystack_print_ ()
997 *yycdebug_
<< "Stack now";
998 for (state_stack_type::const_iterator i
= yystate_stack_
.begin ();
999 i
!= yystate_stack_
.end (); ++i
)
1000 *yycdebug_
<< ' ' << *i
;
1001 *yycdebug_
<< std::endl
;
1004 // Report on the debug stream that the rule \a yyrule is going to be reduced.
1006 ]b4_parser_class_name
[::yy_reduce_print_ (int yyrule
)
1008 unsigned int yylno
= yyrline_
[yyrule
];
1009 int yynrhs
= yyr2_
[yyrule
];
1010 /* Print the symbols being reduced, and their result. */
1011 *yycdebug_
<< "Reducing stack by rule " << yyrule
- 1
1012 << " (line " << yylno
<< "), ";
1013 /* The symbols being reduced. */
1014 for (int yyi
= 0; yyi
< yynrhs
; yyi
++)
1015 YY_SYMBOL_PRINT (" $" << yyi
+ 1 << " =",
1016 yyrhs_
[yyprhs_
[yyrule
] + yyi
],
1017 &]b4_rhs_value(yynrhs
, yyi
+ 1)[,
1018 &]b4_rhs_location(yynrhs
, yyi
+ 1)[);
1022 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1023 ]b4_parser_class_name
[::token_number_type
1024 ]b4_parser_class_name
[::yytranslate_ (int token
)
1027 const token_number_type
1032 if ((unsigned int) token
<= yyuser_token_number_max_
)
1033 return translate_table
[token
];
1035 return yyundef_token_
;
1038 const int ]b4_parser_class_name
[::yyeof_
= 0;
1039 const int ]b4_parser_class_name
[::yylast_
= ]b4_last
[;
1040 const int ]b4_parser_class_name
[::yynnts_
= ]b4_nterms_number
[;
1041 const int ]b4_parser_class_name
[::yyempty_
= -2;
1042 const int ]b4_parser_class_name
[::yyfinal_
= ]b4_final_state_number
[;
1043 const int ]b4_parser_class_name
[::yyterror_
= 1;
1044 const int ]b4_parser_class_name
[::yyerrcode_
= 256;
1045 const int ]b4_parser_class_name
[::yyntokens_
= ]b4_tokens_number
[;
1047 const unsigned int ]b4_parser_class_name
[::yyuser_token_number_max_
= ]b4_user_token_number_max
[;
1048 const ]b4_parser_class_name
[::token_number_type
]b4_parser_class_name
[::yyundef_token_
= ]b4_undef_token_number
[;
1050 } // namespace ]b4_namespace[
1054 @output b4_dir_prefix
[]stack
.hh
1055 b4_copyright([stack handling
for Bison C
++ parsers
],
1056 [2002, 2003, 2004, 2005, 2006])[
1058 #ifndef BISON_STACK_HH
1059 # define BISON_STACK_HH
1063 namespace ]b4_namespace
[
1065 template <class T
, class S
= std::deque
<T
> >
1070 // Hide our reversed order.
1071 typedef typename
S::reverse_iterator iterator
;
1072 typedef typename
S::const_reverse_iterator const_iterator
;
1078 stack (unsigned int n
) : seq_ (n
)
1084 operator [] (unsigned int i
)
1091 operator [] (unsigned int i
) const
1100 seq_
.push_front (t
);
1105 pop (unsigned int n
= 1)
1115 return seq_
.size ();
1118 inline const_iterator
begin () const { return seq_
.rbegin (); }
1119 inline const_iterator
end () const { return seq_
.rend (); }
1126 /// Present a slice of the top of a stack.
1127 template <class T
, class S
= stack
<T
> >
1132 slice (const S
& stack
,
1133 unsigned int range
) : stack_ (stack
),
1140 operator [] (unsigned int i
) const
1142 return stack_
[range_
- i
];
1148 unsigned int range_
;
1152 #endif // not BISON_STACK_HH]