3 # C++ skeleton for Bison
5 # Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 m4_include(b4_pkgdatadir
/[c
++.m4
])
23 m4_include(b4_pkgdatadir
/[location
.cc
])
25 # We do want M4 expansion after # for CPP macros.
28 m4_if(b4_defines_flag
, 0, [],
29 [@output @output_header_name@
30 b4_copyright([C
++ Skeleton parser
for LALR(1) parsing with Bison
],
31 [2002, 2003, 2004, 2005])
32 dnl FIXME
: This is wrong
, we want computed header guards
.
33 dnl FIXME
: I
do not know why the macros are missing now
. :(
35 #ifndef PARSER_HEADER_H
36 # define PARSER_HEADER_H
48 /* First part of user declarations. */
51 ]/* Line __line__ of lalr1.cc. */
52 b4_syncline([@oline@
], [@ofile@
])[
54 ]dnl Include location
.hh here
: it might depend on headers included above
.
55 [#include "location.hh"
57 /* Enabling traces. */
59 # define YYDEBUG ]b4_debug[
62 /* Enabling verbose error messages. */
63 #ifdef YYERROR_VERBOSE
64 # undef YYERROR_VERBOSE
65 # define YYERROR_VERBOSE 1
67 # define YYERROR_VERBOSE ]b4_error_verbose[
70 /* Enabling the token table. */
72 # define YYTOKEN_TABLE ]b4_token_table[
75 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
76 If N is 0, then set CURRENT to the empty location which ends
77 the previous symbol: RHS[0] (always defined). */
79 #ifndef YYLLOC_DEFAULT
80 # define YYLLOC_DEFAULT(Current, Rhs, N) \
84 (Current).begin = (Rhs)[1].begin; \
85 (Current).end = (Rhs)[N].end; \
89 (Current).begin = (Current).end = (Rhs)[0].end; \
98 class ]b4_parser_class_name
[
101 /// Symbol semantic values.
102 #if ! defined (YYSTYPE)
103 ]m4_ifdef([b4_stype
],
104 [b4_syncline([b4_stype_line
], [b4_file_name
])
105 union semantic_type b4_stype
;
106 /* Line __line__ of lalr1.cc. */
107 b4_syncline([@oline@
], [@ofile@
])],
108 [ typedef int semantic_type
;])[
110 typedef YYSTYPE semantic_type
;
112 /// Symbol locations.
113 typedef ]b4_location_type
[ location_type
;
117 ]b4_token_enums(b4_tokens
)[
120 /// Build a parser object.
121 ]b4_parser_class_name
[ (]b4_parse_param_decl
[) :
123 yycdebug_ (&std::cerr
)]b4_parse_param_cons
[
127 virtual ~]b4_parser_class_name
[ ()
132 /// \returns 0 iff parsing succeeded.
133 virtual int parse ();
135 /// The current debugging stream.
136 std::ostream
& debug_stream () const;
137 /// Set the current debugging stream.
138 void set_debug_stream (std::ostream
&);
140 /// Type for debugging levels.
141 typedef int debug_level_type
;
142 /// The current debugging level.
143 debug_level_type
debug_level () const;
144 /// Set the current debugging level.
145 void set_debug_level (debug_level_type l
);
148 /// Report a syntax error.
149 /// \param loc where the syntax error is found.
150 /// \param msg a description of the syntax error.
151 virtual void error (const location_type
& loc
, const std::string
& msg
);
153 /// Generate an error message.
154 /// \param state the state where the error occurred.
155 /// \param tok the look-ahead token.
156 virtual std::string
yysyntax_error_ (int yystate
]dnl
157 b4_error_verbose_if([, int tok
])[);
160 /// \brief Report a symbol on the debug stream.
161 /// \param yytype The token type.
162 /// \param yyvaluep Its semantic value.
163 /// \param yylocationp Its location.
164 virtual void yysymprint_ (int yytype
,
165 const semantic_type
* yyvaluep
,
166 const location_type
* yylocationp
);
167 #endif /* ! YYDEBUG */
171 typedef int state_type
;
172 /// State stack type.
173 typedef stack
<state_type
> state_stack_type
;
174 /// Semantic value stack type.
175 typedef stack
<semantic_type
> semantic_stack_type
;
176 /// location stack type.
177 typedef stack
<location_type
> location_stack_type
;
180 state_stack_type yystate_stack_
;
181 /// The semantic value stack.
182 semantic_stack_type yysemantic_stack_
;
183 /// The location stack.
184 location_stack_type yylocation_stack_
;
186 /// Internal symbol numbers.
187 typedef ]b4_int_type_for([b4_translate
])[ token_number_type
;
189 /// For a state, the index in \a yytable_ of its portion.
190 static const ]b4_int_type_for([b4_pact
])[ yypact_
[];
191 static const ]b4_int_type(b4_pact_ninf
, b4_pact_ninf
)[ yypact_ninf_
;
193 /// For a state, default rule to reduce.
194 /// Unless\a yytable_ specifies something else to do.
195 /// Zero means the default is an error.
196 static const ]b4_int_type_for([b4_defact
])[ yydefact_
[];
198 static const ]b4_int_type_for([b4_pgoto
])[ yypgoto_
[];
199 static const ]b4_int_type_for([b4_defgoto
])[ yydefgoto_
[];
201 /// What to do in a state.
202 /// \a yytable_[yypact_[s]]: what to do in state \a s.
203 /// - if positive, shift that token.
204 /// - if negative, reduce the rule which number is the opposite.
205 /// - if zero, do what YYDEFACT says.
206 static const ]b4_int_type_for([b4_table
])[ yytable_
[];
207 static const ]b4_int_type(b4_table_ninf
, b4_table_ninf
)[ yytable_ninf_
;
209 static const ]b4_int_type_for([b4_check
])[ yycheck_
[];
211 /// For a state, its accessing symbol.
212 static const ]b4_int_type_for([b4_stos
])[ yystos_
[];
214 /// For a rule, its LHS.
215 static const ]b4_int_type_for([b4_r1
])[ yyr1_
[];
216 /// For a rule, its RHS length.
217 static const ]b4_int_type_for([b4_r2
])[ yyr2_
[];
219 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
220 /// For a symbol, its name in clear.
221 static const char* const yytname_
[];
225 /// Convert the symbol name \a n to a form suitable for a diagnostic.
226 virtual std::string
yytnamerr_ (const char *n
);
230 /// A type to store symbol numbers and -1.
231 typedef ]b4_int_type_for([b4_rhs
])[ rhs_number_type
;
232 /// A `-1'-separated list of the rules' RHS.
233 static const rhs_number_type yyrhs_
[];
234 /// For each rule, the index of the first RHS symbol in \a yyrhs_.
235 static const ]b4_int_type_for([b4_prhs
])[ yyprhs_
[];
236 /// For each rule, its source line number.
237 static const ]b4_int_type_for([b4_rline
])[ yyrline_
[];
238 /// For each scanner token number, its symbol number.
239 static const ]b4_int_type_for([b4_toknum
])[ yytoken_number_
[];
240 /// Report on the debug stream that the rule \a r is going to be reduced.
241 virtual void yyreduce_print_ (int r
);
242 /// Print the state stack on the debug stream.
243 virtual void yystack_print_ ();
246 /// Convert a scanner token number to a symbol number.
247 inline token_number_type
yytranslate_ (int token
);
249 /// \brief Reclaim the memory associated to a symbol.
250 /// \param yymsg Why this token is reclaimed.
251 /// \param yytype The symbol type.
252 /// \param yyvaluep Its semantic value.
253 /// \param yylocationp Its location.
254 inline void yydestruct_ (const char* yymsg
,
256 semantic_type
* yyvaluep
,
257 location_type
* yylocationp
);
259 /// Pop \a n symbols the three stacks.
260 inline void yypop_ (unsigned int n
= 1);
263 static const int yyeof_
;
264 /* LAST_ -- Last index in TABLE_. */
265 static const int yylast_
;
266 static const int yynnts_
;
267 static const int yyempty_
;
268 static const int yyfinal_
;
269 static const int yyterror_
;
270 static const int yyerrcode_
;
271 static const int yyntokens_
;
272 static const unsigned int yyuser_token_number_max_
;
273 static const token_number_type yyundef_token_
;
277 std::ostream
* yycdebug_
;
279 ]b4_parse_param_vars
[
283 ]m4_ifset([b4_global_tokens_and_yystype
],
284 [b4_token_defines(b4_tokens
)
287 /* Redirection for backward compatibility. */
288 # define YYSTYPE yy::b4_parser_class_name::semantic_type
291 #endif /* ! defined PARSER_HEADER_H */]
293 @output @output_parser_name@
294 b4_copyright([C
++ Skeleton parser
for LALR(1) parsing with Bison
],
295 [2002, 2003, 2004, 2005])
296 m4_if(b4_prefix
[], [yy
], [],
298 // Take the name prefix into account.
299 #define yylex b4_prefix[]lex])
300 m4_if(b4_defines_flag
, 0, [],
302 #include @output_header_name@])[
304 /* User implementation prologue. */
307 ]/* Line __line__ of lalr1.cc. */
308 b4_syncline([@oline@
], [@ofile@
])[
313 # include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */
314 # define YY_(msgid) dgettext ("bison-runtime", msgid)
318 # define YY_(msgid) msgid
322 /* A pseudo ostream that takes yydebug_ into account. */
324 for (bool yydebugcond_ = yydebug_; yydebugcond_; yydebugcond_ = false) \
327 /* Enable debugging if requested. */
330 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
334 *yycdebug_ << (Title) << ' '; \
335 yysymprint_ ((Type), (Value), (Location)); \
336 *yycdebug_ << std::endl; \
340 # define YY_REDUCE_PRINT(Rule) \
343 yyreduce_print_ (Rule); \
346 # define YY_STACK_PRINT() \
354 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
355 # define YY_REDUCE_PRINT(Rule)
356 # define YY_STACK_PRINT()
358 #endif /* !YYDEBUG */
360 #define YYACCEPT goto yyacceptlab
361 #define YYABORT goto yyabortlab
362 #define YYERROR goto yyerrorlab
366 /* Return YYSTR after stripping away unnecessary quotes and
367 backslashes, so that it's suitable for yyerror. The heuristic is
368 that double-quoting is unnecessary unless the string contains an
369 apostrophe, a comma, or backslash (other than backslash-backslash).
370 YYSTR is taken from yytname. */
372 yy::]b4_parser_class_name
[::yytnamerr_ (const char *yystr
)
376 std::string yyr
= "";
377 char const *yyp
= yystr
;
384 goto do_not_strip_quotes
;
388 goto do_not_strip_quotes
;
397 do_not_strip_quotes
: ;
406 /*--------------------------------.
407 | Print this symbol on YYOUTPUT. |
408 `--------------------------------*/
411 yy::]b4_parser_class_name
[::yysymprint_ (int yytype
,
412 const semantic_type
* yyvaluep
, const location_type
* yylocationp
)
414 /* Backward compatibility, but should be removed eventually. */
415 std::ostream
& cdebug_
= *yycdebug_
;
417 /* Suppress unused-variable warnings. */
419 yysymprint_ (yytype
+ !&cdebug_
, yyvaluep
, yylocationp
);
421 *yycdebug_
<< (yytype
< yyntokens_
? "token" : "nterm")
422 << ' ' << yytname_
[yytype
] << " ("
423 << *yylocationp
<< ": ";
426 ]m4_map([b4_symbol_actions
], m4_defn([b4_symbol_printers
]))dnl
432 #endif /* ! YYDEBUG */
435 yy::]b4_parser_class_name
[::yydestruct_ (const char* yymsg
,
436 int yytype
, semantic_type
* yyvaluep
, location_type
* yylocationp
)
438 /* Suppress unused-variable warnings. */
440 yydestruct_ (yymsg
, yytype
, yyvaluep
, yylocationp
);
442 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
446 ]m4_map([b4_symbol_actions
], m4_defn([b4_symbol_destructors
]))[
453 yy::]b4_parser_class_name
[::yypop_ (unsigned int n
)
455 yystate_stack_
.pop (n
);
456 yysemantic_stack_
.pop (n
);
457 yylocation_stack_
.pop (n
);
461 yy::]b4_parser_class_name
[::debug_stream () const
467 yy::]b4_parser_class_name
[::set_debug_stream (std::ostream
& o
)
473 yy::]b4_parser_class_name
[::debug_level_type
474 yy::]b4_parser_class_name
[::debug_level () const
480 yy::]b4_parser_class_name
[::set_debug_level (debug_level_type l
)
487 yy::]b4_parser_class_name
[::parse ()
489 /// Look-ahead and look-ahead in internal form.
490 int yychar
= yyempty_
;
498 /* Error handling. */
500 int yyerrstatus_
= 0;
502 /// Semantic value of the look-ahead.
503 semantic_type yylval
;
504 /// Location of the look-ahead.
505 location_type yylloc
;
506 /// The locations where the error started and ended.
507 location yyerror_range
[2];
516 YYCDEBUG
<< "Starting parse" << std::endl
;
518 ]m4_ifdef([b4_initial_action
], [
519 m4_pushdef([b4_at_dollar
], [yylloc
])dnl
520 m4_pushdef([b4_dollar_dollar
], [yylval
])dnl
521 /* User initialization code. */
523 m4_popdef([b4_dollar_dollar
])dnl
524 m4_popdef([b4_at_dollar
])dnl
525 /* Line __line__ of yacc.c. */
526 b4_syncline([@oline@
], [@ofile@
])])dnl
528 [ /* Initialize the stacks. The initial state will be pushed in
529 yynewstate, since the latter expects the semantical and the
530 location values to have been already stored, initialize these
531 stacks with a primary value. */
532 yystate_stack_
= state_stack_type (0);
533 yysemantic_stack_
= semantic_stack_type (0);
534 yylocation_stack_
= location_stack_type (0);
535 yysemantic_stack_
.push (yylval
);
536 yylocation_stack_
.push (yylloc
);
540 yystate_stack_
.push (yystate
);
541 YYCDEBUG
<< "Entering state " << yystate
<< std::endl
;
547 /* Try to take a decision without look-ahead. */
548 yyn
= yypact_
[yystate
];
549 if (yyn
== yypact_ninf_
)
552 /* Read a look-ahead token. */
553 if (yychar
== yyempty_
)
555 YYCDEBUG
<< "Reading a token: ";
556 yychar
= ]b4_c_function_call([yylex
], [int],
557 [[YYSTYPE
*], [&yylval
]][]dnl
558 b4_location_if([, [[location
*], [&yylloc
]]])dnl
559 m4_ifdef([b4_lex_param
], [, ]b4_lex_param
))[;
563 /* Convert token to internal form. */
564 if (yychar
<= yyeof_
)
566 yychar
= yytoken
= yyeof_
;
567 YYCDEBUG
<< "Now at end of input." << std::endl
;
571 yytoken
= yytranslate_ (yychar
);
572 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
575 /* If the proper action on seeing token YYTOKEN is to reduce or to
576 detect an error, take that action. */
578 if (yyn
< 0 || yylast_
< yyn
|| yycheck_
[yyn
] != yytoken
)
581 /* Reduce or error. */
585 if (yyn
== 0 || yyn
== yytable_ninf_
)
595 /* Shift the look-ahead token. */
596 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
598 /* Discard the token being shifted unless it is eof. */
599 if (yychar
!= yyeof_
)
602 yysemantic_stack_
.push (yylval
);
603 yylocation_stack_
.push (yylloc
);
605 /* Count tokens shifted since error; after three, turn off error
613 /*-----------------------------------------------------------.
614 | yydefault -- do the default action for the current state. |
615 `-----------------------------------------------------------*/
617 yyn
= yydefact_
[yystate
];
622 /*-----------------------------.
623 | yyreduce -- Do a reduction. |
624 `-----------------------------*/
627 /* If LEN_ is nonzero, implement the default value of the action:
628 `$$ = $1'. Otherwise, use the top of the stack.
630 Otherwise, the following line sets YYVAL to garbage.
631 This behavior is undocumented and Bison
632 users should not rely upon it. */
634 yyval
= yysemantic_stack_
[yylen
- 1];
636 yyval
= yysemantic_stack_
[0];
639 slice
<location_type
, location_stack_type
> slice (yylocation_stack_
, yylen
);
640 YYLLOC_DEFAULT (yyloc
, slice
, yylen
);
642 YY_REDUCE_PRINT (yyn
);
649 ]/* Line __line__ of lalr1.cc. */
650 b4_syncline([@oline@
], [@ofile@
])[
656 yysemantic_stack_
.push (yyval
);
657 yylocation_stack_
.push (yyloc
);
659 /* Shift the result of the reduction. */
661 yystate
= yypgoto_
[yyn
- yyntokens_
] + yystate_stack_
[0];
662 if (0 <= yystate
&& yystate
<= yylast_
663 && yycheck_
[yystate
] == yystate_stack_
[0])
664 yystate
= yytable_
[yystate
];
666 yystate
= yydefgoto_
[yyn
- yyntokens_
];
669 /*------------------------------------.
670 | yyerrlab -- here on detecting error |
671 `------------------------------------*/
673 /* If not already recovering from an error, report this error. */
677 error (yylloc
, yysyntax_error_ (yystate
]dnl
678 b4_error_verbose_if([, yytoken
])[));
681 yyerror_range
[0] = yylloc
;
682 if (yyerrstatus_
== 3)
684 /* If just tried and failed to reuse look-ahead token after an
685 error, discard it. */
687 if (yychar
<= yyeof_
)
689 /* Return failure if at end of input. */
690 if (yychar
== yyeof_
)
695 yydestruct_ ("Error: discarding", yytoken
, &yylval
, &yylloc
);
700 /* Else will try to reuse look-ahead token after shifting the error
705 /*---------------------------------------------------.
706 | yyerrorlab -- error raised explicitly by YYERROR. |
707 `---------------------------------------------------*/
710 /* Pacify compilers like GCC when the user code never invokes
711 YYERROR and the label yyerrorlab therefore never appears in user
716 yyerror_range
[0] = yylocation_stack_
[yylen
- 1];
718 yystate
= yystate_stack_
[0];
721 /*-------------------------------------------------------------.
722 | yyerrlab1 -- common code for both syntax error and YYERROR. |
723 `-------------------------------------------------------------*/
725 yyerrstatus_
= 3; /* Each real token shifted decrements this. */
729 yyn
= yypact_
[yystate
];
730 if (yyn
!= yypact_ninf_
)
733 if (0 <= yyn
&& yyn
<= yylast_
&& yycheck_
[yyn
] == yyterror_
)
741 /* Pop the current state because it cannot handle the error token. */
742 if (yystate_stack_
.height () == 1)
745 yyerror_range
[0] = yylocation_stack_
[0];
746 yydestruct_ ("Error: popping",
748 &yysemantic_stack_
[0], &yylocation_stack_
[0]);
750 yystate
= yystate_stack_
[0];
757 yyerror_range
[1] = yylloc
;
758 // Using YYLLOC is tempting, but would change the location of
759 // the look-ahead. YYLOC is available though.
760 YYLLOC_DEFAULT (yyloc
, yyerror_range
- 1, 2);
761 yysemantic_stack_
.push (yylval
);
762 yylocation_stack_
.push (yyloc
);
764 /* Shift the error token. */
765 YY_SYMBOL_PRINT ("Shifting", yystos_
[yyn
],
766 &yysemantic_stack_
[0], &yylocation_stack_
[0]);
782 if (yychar
!= yyeof_
&& yychar
!= yyempty_
)
783 yydestruct_ ("Cleanup: discarding lookahead", yytoken
, &yylval
, &yylloc
);
785 while (yystate_stack_
.height () != 1)
787 yydestruct_ ("Cleanup: popping",
788 yystos_
[yystate_stack_
[0]],
789 &yysemantic_stack_
[0],
790 &yylocation_stack_
[0]);
797 // Generate an error message.
799 yy::]b4_parser_class_name
[::yysyntax_error_ (int yystate
]dnl
800 b4_error_verbose_if([, int tok
])[)
804 int yyn
= yypact_
[yystate
];
805 if (yypact_ninf_
< yyn
&& yyn
< yylast_
)
807 /* Start YYX at -YYN if negative to avoid negative indexes in
809 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
811 /* Stay within bounds of both yycheck and yytname. */
812 int yychecklim
= yylast_
- yyn
;
813 int yyxend
= yychecklim
< yyntokens_
? yychecklim
: yyntokens_
;
815 for (int x
= yyxbegin
; x
< yyxend
; ++x
)
816 if (yycheck_
[x
+ yyn
] == x
&& x
!= yyterror_
)
819 // FIXME: This method of building the message is not compatible
820 // with internationalization. It should work like yacc.c does it.
821 // That is, first build a string that looks like this:
822 // "syntax error, unexpected %s or %s or %s"
823 // Then, invoke YY_ on this string.
824 // Finally, use the string as a format to output
825 // yytname_[tok], etc.
826 // Until this gets fixed, this message appears in English only.
827 res
= "syntax error, unexpected ";
828 res
+= yytnamerr_ (yytname_
[tok
]);
832 for (int x
= yyxbegin
; x
< yyxend
; ++x
)
833 if (yycheck_
[x
+ yyn
] == x
&& x
!= yyterror_
)
835 res
+= (!count
++) ? ", expecting " : " or ";
836 res
+= yytnamerr_ (yytname_
[x
]);
842 res
= YY_("syntax error");
847 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
849 const ]b4_int_type(b4_pact_ninf
, b4_pact_ninf
) yy::b4_parser_class_name::yypact_ninf_
= b4_pact_ninf
[;
850 const ]b4_int_type_for([b4_pact
])[
851 yy::]b4_parser_class_name
[::yypact_
[] =
856 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
857 doesn't specify something else to do. Zero means the default is an
859 const ]b4_int_type_for([b4_defact
])[
860 yy::]b4_parser_class_name
[::yydefact_
[] =
865 /* YYPGOTO[NTERM-NUM]. */
866 const ]b4_int_type_for([b4_pgoto
])[
867 yy::]b4_parser_class_name
[::yypgoto_
[] =
872 /* YYDEFGOTO[NTERM-NUM]. */
873 const ]b4_int_type_for([b4_defgoto
])[
874 yy::]b4_parser_class_name
[::yydefgoto_
[] =
879 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
880 positive, shift that token. If negative, reduce the rule which
881 number is the opposite. If zero, do what YYDEFACT says. */
882 const ]b4_int_type(b4_table_ninf
, b4_table_ninf
) yy::b4_parser_class_name::yytable_ninf_
= b4_table_ninf
[;
883 const ]b4_int_type_for([b4_table
])[
884 yy::]b4_parser_class_name
[::yytable_
[] =
890 const ]b4_int_type_for([b4_check
])[
891 yy::]b4_parser_class_name
[::yycheck_
[] =
896 /* STOS_[STATE-NUM] -- The (internal number of the) accessing
897 symbol of state STATE-NUM. */
898 const ]b4_int_type_for([b4_stos
])[
899 yy::]b4_parser_class_name
[::yystos_
[] =
905 /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
907 const ]b4_int_type_for([b4_toknum
])[
908 yy::]b4_parser_class_name
[::yytoken_number_
[] =
914 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
915 const ]b4_int_type_for([b4_r1
])[
916 yy::]b4_parser_class_name
[::yyr1_
[] =
921 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
922 const ]b4_int_type_for([b4_r2
])[
923 yy::]b4_parser_class_name
[::yyr2_
[] =
928 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
929 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
930 First, the terminals, then, starting at \a yyntokens_, nonterminals. */
932 const yy::]b4_parser_class_name
[::yytname_
[] =
939 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
940 const yy::]b4_parser_class_name
[::rhs_number_type
941 yy::]b4_parser_class_name
[::yyrhs_
[] =
946 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
948 const ]b4_int_type_for([b4_prhs
])[
949 yy::]b4_parser_class_name
[::yyprhs_
[] =
954 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
955 const ]b4_int_type_for([b4_rline
])[
956 yy::]b4_parser_class_name
[::yyrline_
[] =
961 // Print the state stack on the debug stream.
963 yy::]b4_parser_class_name
[::yystack_print_ ()
965 *yycdebug_
<< "Stack now";
966 for (state_stack_type::const_iterator i
= yystate_stack_
.begin ();
967 i
!= yystate_stack_
.end (); ++i
)
968 *yycdebug_
<< ' ' << *i
;
969 *yycdebug_
<< std::endl
;
972 // Report on the debug stream that the rule \a yyrule is going to be reduced.
974 yy::]b4_parser_class_name
[::yyreduce_print_ (int yyrule
)
976 unsigned int yylno
= yyrline_
[yyrule
];
977 /* Print the symbols being reduced, and their result. */
978 *yycdebug_
<< "Reducing stack by rule " << yyrule
- 1
979 << " (line " << yylno
<< "), ";
980 for (]b4_int_type_for([b4_prhs
])[ i
= yyprhs_
[yyrule
];
982 *yycdebug_
<< yytname_
[yyrhs_
[i
]] << ' ';
983 *yycdebug_
<< "-> " << yytname_
[yyr1_
[yyrule
]] << std::endl
;
987 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
988 yy::]b4_parser_class_name
[::token_number_type
989 yy::]b4_parser_class_name
[::yytranslate_ (int token
)
992 const token_number_type
997 if ((unsigned int) token
<= yyuser_token_number_max_
)
998 return translate_table
[token
];
1000 return yyundef_token_
;
1003 const int yy::]b4_parser_class_name
[::yyeof_
= 0;
1004 const int yy::]b4_parser_class_name
[::yylast_
= ]b4_last
[;
1005 const int yy::]b4_parser_class_name
[::yynnts_
= ]b4_nterms_number
[;
1006 const int yy::]b4_parser_class_name
[::yyempty_
= -2;
1007 const int yy::]b4_parser_class_name
[::yyfinal_
= ]b4_final_state_number
[;
1008 const int yy::]b4_parser_class_name
[::yyterror_
= 1;
1009 const int yy::]b4_parser_class_name
[::yyerrcode_
= 256;
1010 const int yy::]b4_parser_class_name
[::yyntokens_
= ]b4_tokens_number
[;
1012 const unsigned int yy::]b4_parser_class_name
[::yyuser_token_number_max_
= ]b4_user_token_number_max
[;
1013 const yy::]b4_parser_class_name
[::token_number_type
yy::]b4_parser_class_name
[::yyundef_token_
= ]b4_undef_token_number
[;
1017 @output b4_dir_prefix
[]stack
.hh
1018 b4_copyright([stack handling
for Bison C
++ parsers
], [2002, 2003, 2004, 2005])[
1020 #ifndef BISON_STACK_HH
1021 # define BISON_STACK_HH
1027 template <class T
, class S
= std::deque
<T
> >
1032 // Hide our reversed order.
1033 typedef typename
S::reverse_iterator iterator
;
1034 typedef typename
S::const_reverse_iterator const_iterator
;
1040 stack (unsigned int n
) : seq_ (n
)
1046 operator [] (unsigned int i
)
1053 operator [] (unsigned int i
) const
1062 seq_
.push_front (t
);
1067 pop (unsigned int n
= 1)
1077 return seq_
.size ();
1080 inline const_iterator
begin () const { return seq_
.rbegin (); }
1081 inline const_iterator
end () const { return seq_
.rend (); }
1088 /// Present a slice of the top of a stack.
1089 template <class T
, class S
= stack
<T
> >
1094 slice (const S
& stack
,
1095 unsigned int range
) : stack_ (stack
),
1102 operator [] (unsigned int i
) const
1104 return stack_
[range_
- i
];
1110 unsigned int range_
;
1114 #endif // not BISON_STACK_HH]