3 # C++ skeleton for Bison
5 # Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 m4_include(b4_pkgdatadir
/[c
++.m4
])
23 # Backward compatibility.
24 m4_define([b4_location_constructors
])
25 m4_include(b4_pkgdatadir
/[location
.cc
])
27 # We do want M4 expansion after # for CPP macros.
30 m4_if(b4_defines_flag
, 0, [],
31 [@output @output_header_name@
32 b4_copyright([C
++ Skeleton parser
for LALR(1) parsing with Bison
],
33 [2002, 2003, 2004, 2005])
34 dnl FIXME
: This is wrong
, we want computed header guards
.
36 #ifndef PARSER_HEADER_H
37 # define PARSER_HEADER_H
49 /* First part of user declarations. */
52 ]/* Line __line__ of lalr1.cc. */
53 b4_syncline([@oline@
], [@ofile@
])[
55 ]dnl Include location
.hh here
: it might depend on headers included above
.
56 [#include "location.hh"
58 /* Enabling traces. */
60 # define YYDEBUG ]b4_debug[
63 /* Enabling verbose error messages. */
64 #ifdef YYERROR_VERBOSE
65 # undef YYERROR_VERBOSE
66 # define YYERROR_VERBOSE 1
68 # define YYERROR_VERBOSE ]b4_error_verbose[
71 /* Enabling the token table. */
73 # define YYTOKEN_TABLE ]b4_token_table[
76 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
77 If N is 0, then set CURRENT to the empty location which ends
78 the previous symbol: RHS[0] (always defined). */
80 #ifndef YYLLOC_DEFAULT
81 # define YYLLOC_DEFAULT(Current, Rhs, N) \
85 (Current).begin = (Rhs)[1].begin; \
86 (Current).end = (Rhs)[N].end; \
90 (Current).begin = (Current).end = (Rhs)[0].end; \
99 class ]b4_parser_class_name
[
102 /// Symbol semantic values.
103 #if ! defined (YYSTYPE)
104 ]m4_ifdef([b4_stype
],
105 [b4_syncline([b4_stype_line
], [b4_file_name
])
106 union semantic_type b4_stype
;
107 /* Line __line__ of lalr1.cc. */
108 b4_syncline([@oline@
], [@ofile@
])],
109 [ typedef int semantic_type
;])[
111 typedef YYSTYPE semantic_type
;
113 /// Symbol locations.
114 typedef ]b4_location_type
[ location_type
;
118 ]b4_token_enums(b4_tokens
)[
121 /// Build a parser object.
122 ]b4_parser_class_name
[ (]b4_parse_param_decl
[);
123 virtual ~]b4_parser_class_name
[ ();
126 /// \returns 0 iff parsing succeeded.
127 virtual int parse ();
129 /// The current debugging stream.
130 std::ostream
& debug_stream () const;
131 /// Set the current debugging stream.
132 void set_debug_stream (std::ostream
&);
134 /// Type for debugging levels.
135 typedef int debug_level_type
;
136 /// The current debugging level.
137 debug_level_type
debug_level () const;
138 /// Set the current debugging level.
139 void set_debug_level (debug_level_type l
);
142 /// Report a syntax error.
143 /// \param loc where the syntax error is found.
144 /// \param msg a description of the syntax error.
145 virtual void error (const location_type
& loc
, const std::string
& msg
);
147 /// Generate an error message.
148 /// \param state the state where the error occurred.
149 /// \param tok the look-ahead token.
150 virtual std::string
yysyntax_error_ (int yystate
]dnl
151 b4_error_verbose_if([, int tok
])[);
154 /// \brief Report a symbol on the debug stream.
155 /// \param yytype The token type.
156 /// \param yyvaluep Its semantic value.
157 /// \param yylocationp Its location.
158 virtual void yysymprint_ (int yytype
,
159 const semantic_type
* yyvaluep
,
160 const location_type
* yylocationp
);
161 #endif /* ! YYDEBUG */
165 typedef int state_type
;
166 /// State stack type.
167 typedef stack
<state_type
> state_stack_type
;
168 /// Semantic value stack type.
169 typedef stack
<semantic_type
> semantic_stack_type
;
170 /// location stack type.
171 typedef stack
<location_type
> location_stack_type
;
174 state_stack_type yystate_stack_
;
175 /// The semantic value stack.
176 semantic_stack_type yysemantic_stack_
;
177 /// The location stack.
178 location_stack_type yylocation_stack_
;
180 /// Internal symbol numbers.
181 typedef ]b4_int_type_for([b4_translate
])[ token_number_type
;
183 /// For a state, the index in \a yytable_ of its portion.
184 static const ]b4_int_type_for([b4_pact
])[ yypact_
[];
185 static const ]b4_int_type(b4_pact_ninf
, b4_pact_ninf
)[ yypact_ninf_
;
187 /// For a state, default rule to reduce.
188 /// Unless\a yytable_ specifies something else to do.
189 /// Zero means the default is an error.
190 static const ]b4_int_type_for([b4_defact
])[ yydefact_
[];
192 static const ]b4_int_type_for([b4_pgoto
])[ yypgoto_
[];
193 static const ]b4_int_type_for([b4_defgoto
])[ yydefgoto_
[];
195 /// What to do in a state.
196 /// \a yytable_[yypact_[s]]: what to do in state \a s.
197 /// - if positive, shift that token.
198 /// - if negative, reduce the rule which number is the opposite.
199 /// - if zero, do what YYDEFACT says.
200 static const ]b4_int_type_for([b4_table
])[ yytable_
[];
201 static const ]b4_int_type(b4_table_ninf
, b4_table_ninf
)[ yytable_ninf_
;
203 static const ]b4_int_type_for([b4_check
])[ yycheck_
[];
205 /// For a state, its accessing symbol.
206 static const ]b4_int_type_for([b4_stos
])[ yystos_
[];
208 /// For a rule, its LHS.
209 static const ]b4_int_type_for([b4_r1
])[ yyr1_
[];
210 /// For a rule, its RHS length.
211 static const ]b4_int_type_for([b4_r2
])[ yyr2_
[];
213 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
214 /// For a symbol, its name in clear.
215 static const char* const yytname_
[];
219 /// Convert the symbol name \a n to a form suitable for a diagnostic.
220 virtual std::string
yytnamerr_ (const char *n
);
224 /// A type to store symbol numbers and -1.
225 typedef ]b4_int_type_for([b4_rhs
])[ rhs_number_type
;
226 /// A `-1'-separated list of the rules' RHS.
227 static const rhs_number_type yyrhs_
[];
228 /// For each rule, the index of the first RHS symbol in \a yyrhs_.
229 static const ]b4_int_type_for([b4_prhs
])[ yyprhs_
[];
230 /// For each rule, its source line number.
231 static const ]b4_int_type_for([b4_rline
])[ yyrline_
[];
232 /// For each scanner token number, its symbol number.
233 static const ]b4_int_type_for([b4_toknum
])[ yytoken_number_
[];
234 /// Report on the debug stream that the rule \a r is going to be reduced.
235 virtual void yyreduce_print_ (int r
);
236 /// Print the state stack on the debug stream.
237 virtual void yystack_print_ ();
240 /// Convert a scanner token number to a symbol number.
241 inline token_number_type
yytranslate_ (int token
);
243 /// \brief Reclaim the memory associated to a symbol.
244 /// \param yymsg Why this token is reclaimed.
245 /// \param yytype The symbol type.
246 /// \param yyvaluep Its semantic value.
247 /// \param yylocationp Its location.
248 inline void yydestruct_ (const char* yymsg
,
250 semantic_type
* yyvaluep
,
251 location_type
* yylocationp
);
253 /// Pop \a n symbols the three stacks.
254 inline void yypop_ (unsigned int n
= 1);
257 static const int yyeof_
;
258 /* LAST_ -- Last index in TABLE_. */
259 static const int yylast_
;
260 static const int yynnts_
;
261 static const int yyempty_
;
262 static const int yyfinal_
;
263 static const int yyterror_
;
264 static const int yyerrcode_
;
265 static const int yyntokens_
;
266 static const unsigned int yyuser_token_number_max_
;
267 static const token_number_type yyundef_token_
;
271 std::ostream
* yycdebug_
;
273 ]b4_parse_param_vars
[
277 ]m4_ifset([b4_global_tokens_and_yystype
],
278 [b4_token_defines(b4_tokens
)
281 /* Redirection for backward compatibility. */
282 # define YYSTYPE yy::b4_parser_class_name::semantic_type
285 #endif /* ! defined PARSER_HEADER_H */]
287 @output @output_parser_name@
288 b4_copyright([C
++ Skeleton parser
for LALR(1) parsing with Bison
],
289 [2002, 2003, 2004, 2005])
290 m4_if(b4_prefix
[], [yy
], [],
292 // Take the name prefix into account.
293 #define yylex b4_prefix[]lex])
294 m4_if(b4_defines_flag
, 0, [],
296 #include @output_header_name@])[
298 /* User implementation prologue. */
301 ]/* Line __line__ of lalr1.cc. */
302 b4_syncline([@oline@
], [@ofile@
])[
307 # include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */
308 # define YY_(msgid) dgettext ("bison-runtime", msgid)
312 # define YY_(msgid) msgid
316 /* Suppress unused-variable warnings by "using" E. */
317 #define YYUSE(e) do {;} while (false && (e))
319 /* A pseudo ostream that takes yydebug_ into account. */
321 for (bool yydebugcond_ = yydebug_; yydebugcond_; yydebugcond_ = false) \
324 /* Enable debugging if requested. */
327 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
331 *yycdebug_ << (Title) << ' '; \
332 yysymprint_ ((Type), (Value), (Location)); \
333 *yycdebug_ << std::endl; \
337 # define YY_REDUCE_PRINT(Rule) \
340 yyreduce_print_ (Rule); \
343 # define YY_STACK_PRINT() \
351 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
352 # define YY_REDUCE_PRINT(Rule)
353 # define YY_STACK_PRINT()
355 #endif /* !YYDEBUG */
357 #define YYACCEPT goto yyacceptlab
358 #define YYABORT goto yyabortlab
359 #define YYERROR goto yyerrorlab
363 /* Return YYSTR after stripping away unnecessary quotes and
364 backslashes, so that it's suitable for yyerror. The heuristic is
365 that double-quoting is unnecessary unless the string contains an
366 apostrophe, a comma, or backslash (other than backslash-backslash).
367 YYSTR is taken from yytname. */
369 yy::]b4_parser_class_name
[::yytnamerr_ (const char *yystr
)
373 std::string yyr
= "";
374 char const *yyp
= yystr
;
381 goto do_not_strip_quotes
;
385 goto do_not_strip_quotes
;
394 do_not_strip_quotes
: ;
404 /// Build a parser object.
405 ]b4_parser_class_name::b4_parser_class_name
[ (]b4_parse_param_decl
[)
407 yycdebug_ (&std::cerr
)]b4_parse_param_cons
[
411 ]b4_parser_class_name::~b4_parser_class_name
[ ()
416 /*--------------------------------.
417 | Print this symbol on YYOUTPUT. |
418 `--------------------------------*/
421 ]b4_parser_class_name
[::yysymprint_ (int yytype
,
422 const semantic_type
* yyvaluep
, const location_type
* yylocationp
)
424 /* Backward compatibility, but should be removed eventually. */
425 std::ostream
& cdebug_
= *yycdebug_
;
431 *yycdebug_
<< (yytype
< yyntokens_
? "token" : "nterm")
432 << ' ' << yytname_
[yytype
] << " ("
433 << *yylocationp
<< ": ";
436 ]m4_map([b4_symbol_actions
], m4_defn([b4_symbol_printers
]))dnl
442 #endif /* ! YYDEBUG */
445 ]b4_parser_class_name
[::yydestruct_ (const char* yymsg
,
446 int yytype
, semantic_type
* yyvaluep
, location_type
* yylocationp
)
452 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
456 ]m4_map([b4_symbol_actions
], m4_defn([b4_symbol_destructors
]))[
463 ]b4_parser_class_name
[::yypop_ (unsigned int n
)
465 yystate_stack_
.pop (n
);
466 yysemantic_stack_
.pop (n
);
467 yylocation_stack_
.pop (n
);
471 ]b4_parser_class_name
[::debug_stream () const
477 ]b4_parser_class_name
[::set_debug_stream (std::ostream
& o
)
483 ]b4_parser_class_name
[::debug_level_type
484 ]b4_parser_class_name
[::debug_level () const
490 ]b4_parser_class_name
[::set_debug_level (debug_level_type l
)
497 ]b4_parser_class_name
[::parse ()
499 /// Look-ahead and look-ahead in internal form.
500 int yychar
= yyempty_
;
508 /* Error handling. */
510 int yyerrstatus_
= 0;
512 /// Semantic value of the look-ahead.
513 semantic_type yylval
;
514 /// Location of the look-ahead.
515 location_type yylloc
;
516 /// The locations where the error started and ended.
517 location yyerror_range
[2];
526 YYCDEBUG
<< "Starting parse" << std::endl
;
528 ]m4_ifdef([b4_initial_action
], [
529 m4_pushdef([b4_at_dollar
], [yylloc
])dnl
530 m4_pushdef([b4_dollar_dollar
], [yylval
])dnl
531 /* User initialization code. */
533 m4_popdef([b4_dollar_dollar
])dnl
534 m4_popdef([b4_at_dollar
])dnl
535 /* Line __line__ of yacc.c. */
536 b4_syncline([@oline@
], [@ofile@
])])dnl
538 [ /* Initialize the stacks. The initial state will be pushed in
539 yynewstate, since the latter expects the semantical and the
540 location values to have been already stored, initialize these
541 stacks with a primary value. */
542 yystate_stack_
= state_stack_type (0);
543 yysemantic_stack_
= semantic_stack_type (0);
544 yylocation_stack_
= location_stack_type (0);
545 yysemantic_stack_
.push (yylval
);
546 yylocation_stack_
.push (yylloc
);
550 yystate_stack_
.push (yystate
);
551 YYCDEBUG
<< "Entering state " << yystate
<< std::endl
;
557 /* Try to take a decision without look-ahead. */
558 yyn
= yypact_
[yystate
];
559 if (yyn
== yypact_ninf_
)
562 /* Read a look-ahead token. */
563 if (yychar
== yyempty_
)
565 YYCDEBUG
<< "Reading a token: ";
566 yychar
= ]b4_c_function_call([yylex
], [int],
567 [[YYSTYPE
*], [&yylval
]][]dnl
568 b4_location_if([, [[location
*], [&yylloc
]]])dnl
569 m4_ifdef([b4_lex_param
], [, ]b4_lex_param
))[;
573 /* Convert token to internal form. */
574 if (yychar
<= yyeof_
)
576 yychar
= yytoken
= yyeof_
;
577 YYCDEBUG
<< "Now at end of input." << std::endl
;
581 yytoken
= yytranslate_ (yychar
);
582 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
585 /* If the proper action on seeing token YYTOKEN is to reduce or to
586 detect an error, take that action. */
588 if (yyn
< 0 || yylast_
< yyn
|| yycheck_
[yyn
] != yytoken
)
591 /* Reduce or error. */
595 if (yyn
== 0 || yyn
== yytable_ninf_
)
605 /* Shift the look-ahead token. */
606 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
608 /* Discard the token being shifted unless it is eof. */
609 if (yychar
!= yyeof_
)
612 yysemantic_stack_
.push (yylval
);
613 yylocation_stack_
.push (yylloc
);
615 /* Count tokens shifted since error; after three, turn off error
623 /*-----------------------------------------------------------.
624 | yydefault -- do the default action for the current state. |
625 `-----------------------------------------------------------*/
627 yyn
= yydefact_
[yystate
];
632 /*-----------------------------.
633 | yyreduce -- Do a reduction. |
634 `-----------------------------*/
637 /* If LEN_ is nonzero, implement the default value of the action:
638 `$$ = $1'. Otherwise, use the top of the stack.
640 Otherwise, the following line sets YYVAL to garbage.
641 This behavior is undocumented and Bison
642 users should not rely upon it. */
644 yyval
= yysemantic_stack_
[yylen
- 1];
646 yyval
= yysemantic_stack_
[0];
649 slice
<location_type
, location_stack_type
> slice (yylocation_stack_
, yylen
);
650 YYLLOC_DEFAULT (yyloc
, slice
, yylen
);
652 YY_REDUCE_PRINT (yyn
);
659 ]/* Line __line__ of lalr1.cc. */
660 b4_syncline([@oline@
], [@ofile@
])[
666 yysemantic_stack_
.push (yyval
);
667 yylocation_stack_
.push (yyloc
);
669 /* Shift the result of the reduction. */
671 yystate
= yypgoto_
[yyn
- yyntokens_
] + yystate_stack_
[0];
672 if (0 <= yystate
&& yystate
<= yylast_
673 && yycheck_
[yystate
] == yystate_stack_
[0])
674 yystate
= yytable_
[yystate
];
676 yystate
= yydefgoto_
[yyn
- yyntokens_
];
679 /*------------------------------------.
680 | yyerrlab -- here on detecting error |
681 `------------------------------------*/
683 /* If not already recovering from an error, report this error. */
687 error (yylloc
, yysyntax_error_ (yystate
]dnl
688 b4_error_verbose_if([, yytoken
])[));
691 yyerror_range
[0] = yylloc
;
692 if (yyerrstatus_
== 3)
694 /* If just tried and failed to reuse look-ahead token after an
695 error, discard it. */
697 if (yychar
<= yyeof_
)
699 /* Return failure if at end of input. */
700 if (yychar
== yyeof_
)
705 yydestruct_ ("Error: discarding", yytoken
, &yylval
, &yylloc
);
710 /* Else will try to reuse look-ahead token after shifting the error
715 /*---------------------------------------------------.
716 | yyerrorlab -- error raised explicitly by YYERROR. |
717 `---------------------------------------------------*/
720 /* Pacify compilers like GCC when the user code never invokes
721 YYERROR and the label yyerrorlab therefore never appears in user
726 yyerror_range
[0] = yylocation_stack_
[yylen
- 1];
728 yystate
= yystate_stack_
[0];
731 /*-------------------------------------------------------------.
732 | yyerrlab1 -- common code for both syntax error and YYERROR. |
733 `-------------------------------------------------------------*/
735 yyerrstatus_
= 3; /* Each real token shifted decrements this. */
739 yyn
= yypact_
[yystate
];
740 if (yyn
!= yypact_ninf_
)
743 if (0 <= yyn
&& yyn
<= yylast_
&& yycheck_
[yyn
] == yyterror_
)
751 /* Pop the current state because it cannot handle the error token. */
752 if (yystate_stack_
.height () == 1)
755 yyerror_range
[0] = yylocation_stack_
[0];
756 yydestruct_ ("Error: popping",
758 &yysemantic_stack_
[0], &yylocation_stack_
[0]);
760 yystate
= yystate_stack_
[0];
767 yyerror_range
[1] = yylloc
;
768 // Using YYLLOC is tempting, but would change the location of
769 // the look-ahead. YYLOC is available though.
770 YYLLOC_DEFAULT (yyloc
, yyerror_range
- 1, 2);
771 yysemantic_stack_
.push (yylval
);
772 yylocation_stack_
.push (yyloc
);
774 /* Shift the error token. */
775 YY_SYMBOL_PRINT ("Shifting", yystos_
[yyn
],
776 &yysemantic_stack_
[0], &yylocation_stack_
[0]);
792 if (yychar
!= yyeof_
&& yychar
!= yyempty_
)
793 yydestruct_ ("Cleanup: discarding lookahead", yytoken
, &yylval
, &yylloc
);
795 while (yystate_stack_
.height () != 1)
797 yydestruct_ ("Cleanup: popping",
798 yystos_
[yystate_stack_
[0]],
799 &yysemantic_stack_
[0],
800 &yylocation_stack_
[0]);
807 // Generate an error message.
809 ]b4_parser_class_name
[::yysyntax_error_ (int yystate
]dnl
810 b4_error_verbose_if([, int tok
])[)
814 int yyn
= yypact_
[yystate
];
815 if (yypact_ninf_
< yyn
&& yyn
< yylast_
)
817 /* Start YYX at -YYN if negative to avoid negative indexes in
819 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
821 /* Stay within bounds of both yycheck and yytname. */
822 int yychecklim
= yylast_
- yyn
;
823 int yyxend
= yychecklim
< yyntokens_
? yychecklim
: yyntokens_
;
825 for (int x
= yyxbegin
; x
< yyxend
; ++x
)
826 if (yycheck_
[x
+ yyn
] == x
&& x
!= yyterror_
)
829 // FIXME: This method of building the message is not compatible
830 // with internationalization. It should work like yacc.c does it.
831 // That is, first build a string that looks like this:
832 // "syntax error, unexpected %s or %s or %s"
833 // Then, invoke YY_ on this string.
834 // Finally, use the string as a format to output
835 // yytname_[tok], etc.
836 // Until this gets fixed, this message appears in English only.
837 res
= "syntax error, unexpected ";
838 res
+= yytnamerr_ (yytname_
[tok
]);
842 for (int x
= yyxbegin
; x
< yyxend
; ++x
)
843 if (yycheck_
[x
+ yyn
] == x
&& x
!= yyterror_
)
845 res
+= (!count
++) ? ", expecting " : " or ";
846 res
+= yytnamerr_ (yytname_
[x
]);
852 res
= YY_("syntax error");
857 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
859 const ]b4_int_type(b4_pact_ninf
, b4_pact_ninf
) b4_parser_class_name::yypact_ninf_
= b4_pact_ninf
[;
860 const ]b4_int_type_for([b4_pact
])[
861 ]b4_parser_class_name
[::yypact_
[] =
866 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
867 doesn't specify something else to do. Zero means the default is an
869 const ]b4_int_type_for([b4_defact
])[
870 ]b4_parser_class_name
[::yydefact_
[] =
875 /* YYPGOTO[NTERM-NUM]. */
876 const ]b4_int_type_for([b4_pgoto
])[
877 ]b4_parser_class_name
[::yypgoto_
[] =
882 /* YYDEFGOTO[NTERM-NUM]. */
883 const ]b4_int_type_for([b4_defgoto
])[
884 ]b4_parser_class_name
[::yydefgoto_
[] =
889 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
890 positive, shift that token. If negative, reduce the rule which
891 number is the opposite. If zero, do what YYDEFACT says. */
892 const ]b4_int_type(b4_table_ninf
, b4_table_ninf
) b4_parser_class_name::yytable_ninf_
= b4_table_ninf
[;
893 const ]b4_int_type_for([b4_table
])[
894 ]b4_parser_class_name
[::yytable_
[] =
900 const ]b4_int_type_for([b4_check
])[
901 ]b4_parser_class_name
[::yycheck_
[] =
906 /* STOS_[STATE-NUM] -- The (internal number of the) accessing
907 symbol of state STATE-NUM. */
908 const ]b4_int_type_for([b4_stos
])[
909 ]b4_parser_class_name
[::yystos_
[] =
915 /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
917 const ]b4_int_type_for([b4_toknum
])[
918 ]b4_parser_class_name
[::yytoken_number_
[] =
924 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
925 const ]b4_int_type_for([b4_r1
])[
926 ]b4_parser_class_name
[::yyr1_
[] =
931 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
932 const ]b4_int_type_for([b4_r2
])[
933 ]b4_parser_class_name
[::yyr2_
[] =
938 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
939 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
940 First, the terminals, then, starting at \a yyntokens_, nonterminals. */
942 const ]b4_parser_class_name
[::yytname_
[] =
949 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
950 const ]b4_parser_class_name
[::rhs_number_type
951 ]b4_parser_class_name
[::yyrhs_
[] =
956 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
958 const ]b4_int_type_for([b4_prhs
])[
959 ]b4_parser_class_name
[::yyprhs_
[] =
964 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
965 const ]b4_int_type_for([b4_rline
])[
966 ]b4_parser_class_name
[::yyrline_
[] =
971 // Print the state stack on the debug stream.
973 ]b4_parser_class_name
[::yystack_print_ ()
975 *yycdebug_
<< "Stack now";
976 for (state_stack_type::const_iterator i
= yystate_stack_
.begin ();
977 i
!= yystate_stack_
.end (); ++i
)
978 *yycdebug_
<< ' ' << *i
;
979 *yycdebug_
<< std::endl
;
982 // Report on the debug stream that the rule \a yyrule is going to be reduced.
984 ]b4_parser_class_name
[::yyreduce_print_ (int yyrule
)
986 unsigned int yylno
= yyrline_
[yyrule
];
987 /* Print the symbols being reduced, and their result. */
988 *yycdebug_
<< "Reducing stack by rule " << yyrule
- 1
989 << " (line " << yylno
<< "), ";
990 for (]b4_int_type_for([b4_prhs
])[ i
= yyprhs_
[yyrule
];
992 *yycdebug_
<< yytname_
[yyrhs_
[i
]] << ' ';
993 *yycdebug_
<< "-> " << yytname_
[yyr1_
[yyrule
]] << std::endl
;
997 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
998 ]b4_parser_class_name
[::token_number_type
999 ]b4_parser_class_name
[::yytranslate_ (int token
)
1002 const token_number_type
1007 if ((unsigned int) token
<= yyuser_token_number_max_
)
1008 return translate_table
[token
];
1010 return yyundef_token_
;
1013 const int ]b4_parser_class_name
[::yyeof_
= 0;
1014 const int ]b4_parser_class_name
[::yylast_
= ]b4_last
[;
1015 const int ]b4_parser_class_name
[::yynnts_
= ]b4_nterms_number
[;
1016 const int ]b4_parser_class_name
[::yyempty_
= -2;
1017 const int ]b4_parser_class_name
[::yyfinal_
= ]b4_final_state_number
[;
1018 const int ]b4_parser_class_name
[::yyterror_
= 1;
1019 const int ]b4_parser_class_name
[::yyerrcode_
= 256;
1020 const int ]b4_parser_class_name
[::yyntokens_
= ]b4_tokens_number
[;
1022 const unsigned int ]b4_parser_class_name
[::yyuser_token_number_max_
= ]b4_user_token_number_max
[;
1023 const ]b4_parser_class_name
[::token_number_type
]b4_parser_class_name
[::yyundef_token_
= ]b4_undef_token_number
[;
1029 @output b4_dir_prefix
[]stack
.hh
1030 b4_copyright([stack handling
for Bison C
++ parsers
], [2002, 2003, 2004, 2005])[
1032 #ifndef BISON_STACK_HH
1033 # define BISON_STACK_HH
1039 template <class T
, class S
= std::deque
<T
> >
1044 // Hide our reversed order.
1045 typedef typename
S::reverse_iterator iterator
;
1046 typedef typename
S::const_reverse_iterator const_iterator
;
1052 stack (unsigned int n
) : seq_ (n
)
1058 operator [] (unsigned int i
)
1065 operator [] (unsigned int i
) const
1074 seq_
.push_front (t
);
1079 pop (unsigned int n
= 1)
1089 return seq_
.size ();
1092 inline const_iterator
begin () const { return seq_
.rbegin (); }
1093 inline const_iterator
end () const { return seq_
.rend (); }
1100 /// Present a slice of the top of a stack.
1101 template <class T
, class S
= stack
<T
> >
1106 slice (const S
& stack
,
1107 unsigned int range
) : stack_ (stack
),
1114 operator [] (unsigned int i
) const
1116 return stack_
[range_
- i
];
1122 unsigned int range_
;
1126 #endif // not BISON_STACK_HH]