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
.
34 #ifndef PARSER_HEADER_H
35 # define PARSER_HEADER_H
47 /* First part of user declarations. */
50 ]/* Line __line__ of lalr1.cc. */
51 b4_syncline([@oline@
], [@ofile@
])[
53 ]dnl Include location
.hh here
: it might depend on headers included above
.
54 [#include "location.hh"
56 /* Enabling traces. */
58 # define YYDEBUG ]b4_debug[
61 /* Enabling verbose error messages. */
62 #ifdef YYERROR_VERBOSE
63 # undef YYERROR_VERBOSE
64 # define YYERROR_VERBOSE 1
66 # define YYERROR_VERBOSE ]b4_error_verbose[
69 /* Enabling the token table. */
71 # define YYTOKEN_TABLE ]b4_token_table[
74 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
75 If N is 0, then set CURRENT to the empty location which ends
76 the previous symbol: RHS[0] (always defined). */
78 #ifndef YYLLOC_DEFAULT
79 # define YYLLOC_DEFAULT(Current, Rhs, N) \
83 (Current).begin = (Rhs)[1].begin; \
84 (Current).end = (Rhs)[N].end; \
88 (Current).begin = (Current).end = (Rhs)[0].end; \
97 class ]b4_parser_class_name
[
100 /// Symbol semantic values.
101 #if ! defined (YYSTYPE)
102 ]m4_ifdef([b4_stype
],
103 [b4_syncline([b4_stype_line
], [b4_file_name
])
104 union semantic_type b4_stype
;
105 /* Line __line__ of lalr1.cc. */
106 b4_syncline([@oline@
], [@ofile@
])],
107 [ typedef int semantic_type
;])[
109 typedef YYSTYPE semantic_type
;
111 /// Symbol locations.
112 typedef ]b4_location_type
[ location_type
;
116 ]b4_token_enums(b4_tokens
)[
119 /// Build a parser object.
120 ]b4_parser_class_name
[ (]b4_parse_param_decl
[);
121 virtual ~]b4_parser_class_name
[ ();
124 /// \returns 0 iff parsing succeeded.
125 virtual int parse ();
127 /// The current debugging stream.
128 std::ostream
& debug_stream () const;
129 /// Set the current debugging stream.
130 void set_debug_stream (std::ostream
&);
132 /// Type for debugging levels.
133 typedef int debug_level_type
;
134 /// The current debugging level.
135 debug_level_type
debug_level () const;
136 /// Set the current debugging level.
137 void set_debug_level (debug_level_type l
);
140 /// Report a syntax error.
141 /// \param loc where the syntax error is found.
142 /// \param msg a description of the syntax error.
143 virtual void error (const location_type
& loc
, const std::string
& msg
);
145 /// Generate an error message.
146 /// \param state the state where the error occurred.
147 /// \param tok the look-ahead token.
148 virtual std::string
yysyntax_error_ (int yystate
]dnl
149 b4_error_verbose_if([, int tok
])[);
152 /// \brief Report a symbol on the debug stream.
153 /// \param yytype The token type.
154 /// \param yyvaluep Its semantic value.
155 /// \param yylocationp Its location.
156 virtual void yysymprint_ (int yytype
,
157 const semantic_type
* yyvaluep
,
158 const location_type
* yylocationp
);
159 #endif /* ! YYDEBUG */
163 typedef int state_type
;
164 /// State stack type.
165 typedef stack
<state_type
> state_stack_type
;
166 /// Semantic value stack type.
167 typedef stack
<semantic_type
> semantic_stack_type
;
168 /// location stack type.
169 typedef stack
<location_type
> location_stack_type
;
172 state_stack_type yystate_stack_
;
173 /// The semantic value stack.
174 semantic_stack_type yysemantic_stack_
;
175 /// The location stack.
176 location_stack_type yylocation_stack_
;
178 /// Internal symbol numbers.
179 typedef ]b4_int_type_for([b4_translate
])[ token_number_type
;
181 /// For a state, the index in \a yytable_ of its portion.
182 static const ]b4_int_type_for([b4_pact
])[ yypact_
[];
183 static const ]b4_int_type(b4_pact_ninf
, b4_pact_ninf
)[ yypact_ninf_
;
185 /// For a state, default rule to reduce.
186 /// Unless\a yytable_ specifies something else to do.
187 /// Zero means the default is an error.
188 static const ]b4_int_type_for([b4_defact
])[ yydefact_
[];
190 static const ]b4_int_type_for([b4_pgoto
])[ yypgoto_
[];
191 static const ]b4_int_type_for([b4_defgoto
])[ yydefgoto_
[];
193 /// What to do in a state.
194 /// \a yytable_[yypact_[s]]: what to do in state \a s.
195 /// - if positive, shift that token.
196 /// - if negative, reduce the rule which number is the opposite.
197 /// - if zero, do what YYDEFACT says.
198 static const ]b4_int_type_for([b4_table
])[ yytable_
[];
199 static const ]b4_int_type(b4_table_ninf
, b4_table_ninf
)[ yytable_ninf_
;
201 static const ]b4_int_type_for([b4_check
])[ yycheck_
[];
203 /// For a state, its accessing symbol.
204 static const ]b4_int_type_for([b4_stos
])[ yystos_
[];
206 /// For a rule, its LHS.
207 static const ]b4_int_type_for([b4_r1
])[ yyr1_
[];
208 /// For a rule, its RHS length.
209 static const ]b4_int_type_for([b4_r2
])[ yyr2_
[];
211 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
212 /// For a symbol, its name in clear.
213 static const char* const yytname_
[];
217 /// Convert the symbol name \a n to a form suitable for a diagnostic.
218 virtual std::string
yytnamerr_ (const char *n
);
222 /// A type to store symbol numbers and -1.
223 typedef ]b4_int_type_for([b4_rhs
])[ rhs_number_type
;
224 /// A `-1'-separated list of the rules' RHS.
225 static const rhs_number_type yyrhs_
[];
226 /// For each rule, the index of the first RHS symbol in \a yyrhs_.
227 static const ]b4_int_type_for([b4_prhs
])[ yyprhs_
[];
228 /// For each rule, its source line number.
229 static const ]b4_int_type_for([b4_rline
])[ yyrline_
[];
230 /// For each scanner token number, its symbol number.
231 static const ]b4_int_type_for([b4_toknum
])[ yytoken_number_
[];
232 /// Report on the debug stream that the rule \a r is going to be reduced.
233 virtual void yyreduce_print_ (int r
);
234 /// Print the state stack on the debug stream.
235 virtual void yystack_print_ ();
238 /// Convert a scanner token number to a symbol number.
239 inline token_number_type
yytranslate_ (int token
);
241 /// \brief Reclaim the memory associated to a symbol.
242 /// \param yymsg Why this token is reclaimed.
243 /// \param yytype The symbol type.
244 /// \param yyvaluep Its semantic value.
245 /// \param yylocationp Its location.
246 inline void yydestruct_ (const char* yymsg
,
248 semantic_type
* yyvaluep
,
249 location_type
* yylocationp
);
251 /// Pop \a n symbols the three stacks.
252 inline void yypop_ (unsigned int n
= 1);
255 static const int yyeof_
;
256 /* LAST_ -- Last index in TABLE_. */
257 static const int yylast_
;
258 static const int yynnts_
;
259 static const int yyempty_
;
260 static const int yyfinal_
;
261 static const int yyterror_
;
262 static const int yyerrcode_
;
263 static const int yyntokens_
;
264 static const unsigned int yyuser_token_number_max_
;
265 static const token_number_type yyundef_token_
;
269 std::ostream
* yycdebug_
;
271 ]b4_parse_param_vars
[
275 ]m4_ifset([b4_global_tokens_and_yystype
],
276 [b4_token_defines(b4_tokens
)
279 /* Redirection for backward compatibility. */
280 # define YYSTYPE yy::b4_parser_class_name::semantic_type
283 #endif /* ! defined PARSER_HEADER_H */]
285 @output @output_parser_name@
286 b4_copyright([C
++ Skeleton parser
for LALR(1) parsing with Bison
],
287 [2002, 2003, 2004, 2005])
288 m4_if(b4_prefix
[], [yy
], [],
290 // Take the name prefix into account.
291 #define yylex b4_prefix[]lex])
292 m4_if(b4_defines_flag
, 0, [],
294 #include @output_header_name@])[
296 /* User implementation prologue. */
299 ]/* Line __line__ of lalr1.cc. */
300 b4_syncline([@oline@
], [@ofile@
])[
305 # include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */
306 # define YY_(msgid) dgettext ("bison-runtime", msgid)
310 # define YY_(msgid) msgid
314 /* Suppress unused-variable warnings by "using" E. */
315 #define YYUSE(e) do {;} while (false && (e))
317 /* A pseudo ostream that takes yydebug_ into account. */
319 for (bool yydebugcond_ = yydebug_; yydebugcond_; yydebugcond_ = false) \
322 /* Enable debugging if requested. */
325 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
329 *yycdebug_ << (Title) << ' '; \
330 yysymprint_ ((Type), (Value), (Location)); \
331 *yycdebug_ << std::endl; \
335 # define YY_REDUCE_PRINT(Rule) \
338 yyreduce_print_ (Rule); \
341 # define YY_STACK_PRINT() \
349 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
350 # define YY_REDUCE_PRINT(Rule)
351 # define YY_STACK_PRINT()
353 #endif /* !YYDEBUG */
355 #define YYACCEPT goto yyacceptlab
356 #define YYABORT goto yyabortlab
357 #define YYERROR goto yyerrorlab
361 /* Return YYSTR after stripping away unnecessary quotes and
362 backslashes, so that it's suitable for yyerror. The heuristic is
363 that double-quoting is unnecessary unless the string contains an
364 apostrophe, a comma, or backslash (other than backslash-backslash).
365 YYSTR is taken from yytname. */
367 yy::]b4_parser_class_name
[::yytnamerr_ (const char *yystr
)
371 std::string yyr
= "";
372 char const *yyp
= yystr
;
379 goto do_not_strip_quotes
;
383 goto do_not_strip_quotes
;
392 do_not_strip_quotes
: ;
402 /// Build a parser object.
403 ]b4_parser_class_name::b4_parser_class_name
[ (]b4_parse_param_decl
[)
405 yycdebug_ (&std::cerr
)]b4_parse_param_cons
[
409 ]b4_parser_class_name::~b4_parser_class_name
[ ()
414 /*--------------------------------.
415 | Print this symbol on YYOUTPUT. |
416 `--------------------------------*/
419 ]b4_parser_class_name
[::yysymprint_ (int yytype
,
420 const semantic_type
* yyvaluep
, const location_type
* yylocationp
)
422 /* Backward compatibility, but should be removed eventually. */
423 std::ostream
& cdebug_
= *yycdebug_
;
429 *yycdebug_
<< (yytype
< yyntokens_
? "token" : "nterm")
430 << ' ' << yytname_
[yytype
] << " ("
431 << *yylocationp
<< ": ";
434 ]m4_map([b4_symbol_actions
], m4_defn([b4_symbol_printers
]))dnl
440 #endif /* ! YYDEBUG */
443 ]b4_parser_class_name
[::yydestruct_ (const char* yymsg
,
444 int yytype
, semantic_type
* yyvaluep
, location_type
* yylocationp
)
450 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
454 ]m4_map([b4_symbol_actions
], m4_defn([b4_symbol_destructors
]))[
461 ]b4_parser_class_name
[::yypop_ (unsigned int n
)
463 yystate_stack_
.pop (n
);
464 yysemantic_stack_
.pop (n
);
465 yylocation_stack_
.pop (n
);
469 ]b4_parser_class_name
[::debug_stream () const
475 ]b4_parser_class_name
[::set_debug_stream (std::ostream
& o
)
481 ]b4_parser_class_name
[::debug_level_type
482 ]b4_parser_class_name
[::debug_level () const
488 ]b4_parser_class_name
[::set_debug_level (debug_level_type l
)
495 ]b4_parser_class_name
[::parse ()
497 /// Look-ahead and look-ahead in internal form.
498 int yychar
= yyempty_
;
506 /* Error handling. */
508 int yyerrstatus_
= 0;
510 /// Semantic value of the look-ahead.
511 semantic_type yylval
;
512 /// Location of the look-ahead.
513 location_type yylloc
;
514 /// The locations where the error started and ended.
515 location yyerror_range
[2];
524 YYCDEBUG
<< "Starting parse" << std::endl
;
526 ]m4_ifdef([b4_initial_action
], [
527 m4_pushdef([b4_at_dollar
], [yylloc
])dnl
528 m4_pushdef([b4_dollar_dollar
], [yylval
])dnl
529 /* User initialization code. */
531 m4_popdef([b4_dollar_dollar
])dnl
532 m4_popdef([b4_at_dollar
])dnl
533 /* Line __line__ of yacc.c. */
534 b4_syncline([@oline@
], [@ofile@
])])dnl
536 [ /* Initialize the stacks. The initial state will be pushed in
537 yynewstate, since the latter expects the semantical and the
538 location values to have been already stored, initialize these
539 stacks with a primary value. */
540 yystate_stack_
= state_stack_type (0);
541 yysemantic_stack_
= semantic_stack_type (0);
542 yylocation_stack_
= location_stack_type (0);
543 yysemantic_stack_
.push (yylval
);
544 yylocation_stack_
.push (yylloc
);
548 yystate_stack_
.push (yystate
);
549 YYCDEBUG
<< "Entering state " << yystate
<< std::endl
;
555 /* Try to take a decision without look-ahead. */
556 yyn
= yypact_
[yystate
];
557 if (yyn
== yypact_ninf_
)
560 /* Read a look-ahead token. */
561 if (yychar
== yyempty_
)
563 YYCDEBUG
<< "Reading a token: ";
564 yychar
= ]b4_c_function_call([yylex
], [int],
565 [[YYSTYPE
*], [&yylval
]][]dnl
566 b4_location_if([, [[location
*], [&yylloc
]]])dnl
567 m4_ifdef([b4_lex_param
], [, ]b4_lex_param
))[;
571 /* Convert token to internal form. */
572 if (yychar
<= yyeof_
)
574 yychar
= yytoken
= yyeof_
;
575 YYCDEBUG
<< "Now at end of input." << std::endl
;
579 yytoken
= yytranslate_ (yychar
);
580 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
583 /* If the proper action on seeing token YYTOKEN is to reduce or to
584 detect an error, take that action. */
586 if (yyn
< 0 || yylast_
< yyn
|| yycheck_
[yyn
] != yytoken
)
589 /* Reduce or error. */
593 if (yyn
== 0 || yyn
== yytable_ninf_
)
603 /* Shift the look-ahead token. */
604 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
606 /* Discard the token being shifted unless it is eof. */
607 if (yychar
!= yyeof_
)
610 yysemantic_stack_
.push (yylval
);
611 yylocation_stack_
.push (yylloc
);
613 /* Count tokens shifted since error; after three, turn off error
621 /*-----------------------------------------------------------.
622 | yydefault -- do the default action for the current state. |
623 `-----------------------------------------------------------*/
625 yyn
= yydefact_
[yystate
];
630 /*-----------------------------.
631 | yyreduce -- Do a reduction. |
632 `-----------------------------*/
635 /* If LEN_ is nonzero, implement the default value of the action:
636 `$$ = $1'. Otherwise, use the top of the stack.
638 Otherwise, the following line sets YYVAL to garbage.
639 This behavior is undocumented and Bison
640 users should not rely upon it. */
642 yyval
= yysemantic_stack_
[yylen
- 1];
644 yyval
= yysemantic_stack_
[0];
647 slice
<location_type
, location_stack_type
> slice (yylocation_stack_
, yylen
);
648 YYLLOC_DEFAULT (yyloc
, slice
, yylen
);
650 YY_REDUCE_PRINT (yyn
);
657 ]/* Line __line__ of lalr1.cc. */
658 b4_syncline([@oline@
], [@ofile@
])[
664 yysemantic_stack_
.push (yyval
);
665 yylocation_stack_
.push (yyloc
);
667 /* Shift the result of the reduction. */
669 yystate
= yypgoto_
[yyn
- yyntokens_
] + yystate_stack_
[0];
670 if (0 <= yystate
&& yystate
<= yylast_
671 && yycheck_
[yystate
] == yystate_stack_
[0])
672 yystate
= yytable_
[yystate
];
674 yystate
= yydefgoto_
[yyn
- yyntokens_
];
677 /*------------------------------------.
678 | yyerrlab -- here on detecting error |
679 `------------------------------------*/
681 /* If not already recovering from an error, report this error. */
685 error (yylloc
, yysyntax_error_ (yystate
]dnl
686 b4_error_verbose_if([, yytoken
])[));
689 yyerror_range
[0] = yylloc
;
690 if (yyerrstatus_
== 3)
692 /* If just tried and failed to reuse look-ahead token after an
693 error, discard it. */
695 if (yychar
<= yyeof_
)
697 /* Return failure if at end of input. */
698 if (yychar
== yyeof_
)
703 yydestruct_ ("Error: discarding", yytoken
, &yylval
, &yylloc
);
708 /* Else will try to reuse look-ahead token after shifting the error
713 /*---------------------------------------------------.
714 | yyerrorlab -- error raised explicitly by YYERROR. |
715 `---------------------------------------------------*/
718 /* Pacify compilers like GCC when the user code never invokes
719 YYERROR and the label yyerrorlab therefore never appears in user
724 yyerror_range
[0] = yylocation_stack_
[yylen
- 1];
726 yystate
= yystate_stack_
[0];
729 /*-------------------------------------------------------------.
730 | yyerrlab1 -- common code for both syntax error and YYERROR. |
731 `-------------------------------------------------------------*/
733 yyerrstatus_
= 3; /* Each real token shifted decrements this. */
737 yyn
= yypact_
[yystate
];
738 if (yyn
!= yypact_ninf_
)
741 if (0 <= yyn
&& yyn
<= yylast_
&& yycheck_
[yyn
] == yyterror_
)
749 /* Pop the current state because it cannot handle the error token. */
750 if (yystate_stack_
.height () == 1)
753 yyerror_range
[0] = yylocation_stack_
[0];
754 yydestruct_ ("Error: popping",
756 &yysemantic_stack_
[0], &yylocation_stack_
[0]);
758 yystate
= yystate_stack_
[0];
765 yyerror_range
[1] = yylloc
;
766 // Using YYLLOC is tempting, but would change the location of
767 // the look-ahead. YYLOC is available though.
768 YYLLOC_DEFAULT (yyloc
, yyerror_range
- 1, 2);
769 yysemantic_stack_
.push (yylval
);
770 yylocation_stack_
.push (yyloc
);
772 /* Shift the error token. */
773 YY_SYMBOL_PRINT ("Shifting", yystos_
[yyn
],
774 &yysemantic_stack_
[0], &yylocation_stack_
[0]);
790 if (yychar
!= yyeof_
&& yychar
!= yyempty_
)
791 yydestruct_ ("Cleanup: discarding lookahead", yytoken
, &yylval
, &yylloc
);
793 while (yystate_stack_
.height () != 1)
795 yydestruct_ ("Cleanup: popping",
796 yystos_
[yystate_stack_
[0]],
797 &yysemantic_stack_
[0],
798 &yylocation_stack_
[0]);
805 // Generate an error message.
807 ]b4_parser_class_name
[::yysyntax_error_ (int yystate
]dnl
808 b4_error_verbose_if([, int tok
])[)
812 int yyn
= yypact_
[yystate
];
813 if (yypact_ninf_
< yyn
&& yyn
< yylast_
)
815 /* Start YYX at -YYN if negative to avoid negative indexes in
817 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
819 /* Stay within bounds of both yycheck and yytname. */
820 int yychecklim
= yylast_
- yyn
;
821 int yyxend
= yychecklim
< yyntokens_
? yychecklim
: yyntokens_
;
823 for (int x
= yyxbegin
; x
< yyxend
; ++x
)
824 if (yycheck_
[x
+ yyn
] == x
&& x
!= yyterror_
)
827 // FIXME: This method of building the message is not compatible
828 // with internationalization. It should work like yacc.c does it.
829 // That is, first build a string that looks like this:
830 // "syntax error, unexpected %s or %s or %s"
831 // Then, invoke YY_ on this string.
832 // Finally, use the string as a format to output
833 // yytname_[tok], etc.
834 // Until this gets fixed, this message appears in English only.
835 res
= "syntax error, unexpected ";
836 res
+= yytnamerr_ (yytname_
[tok
]);
840 for (int x
= yyxbegin
; x
< yyxend
; ++x
)
841 if (yycheck_
[x
+ yyn
] == x
&& x
!= yyterror_
)
843 res
+= (!count
++) ? ", expecting " : " or ";
844 res
+= yytnamerr_ (yytname_
[x
]);
850 res
= YY_("syntax error");
855 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
857 const ]b4_int_type(b4_pact_ninf
, b4_pact_ninf
) b4_parser_class_name::yypact_ninf_
= b4_pact_ninf
[;
858 const ]b4_int_type_for([b4_pact
])[
859 ]b4_parser_class_name
[::yypact_
[] =
864 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
865 doesn't specify something else to do. Zero means the default is an
867 const ]b4_int_type_for([b4_defact
])[
868 ]b4_parser_class_name
[::yydefact_
[] =
873 /* YYPGOTO[NTERM-NUM]. */
874 const ]b4_int_type_for([b4_pgoto
])[
875 ]b4_parser_class_name
[::yypgoto_
[] =
880 /* YYDEFGOTO[NTERM-NUM]. */
881 const ]b4_int_type_for([b4_defgoto
])[
882 ]b4_parser_class_name
[::yydefgoto_
[] =
887 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
888 positive, shift that token. If negative, reduce the rule which
889 number is the opposite. If zero, do what YYDEFACT says. */
890 const ]b4_int_type(b4_table_ninf
, b4_table_ninf
) b4_parser_class_name::yytable_ninf_
= b4_table_ninf
[;
891 const ]b4_int_type_for([b4_table
])[
892 ]b4_parser_class_name
[::yytable_
[] =
898 const ]b4_int_type_for([b4_check
])[
899 ]b4_parser_class_name
[::yycheck_
[] =
904 /* STOS_[STATE-NUM] -- The (internal number of the) accessing
905 symbol of state STATE-NUM. */
906 const ]b4_int_type_for([b4_stos
])[
907 ]b4_parser_class_name
[::yystos_
[] =
913 /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
915 const ]b4_int_type_for([b4_toknum
])[
916 ]b4_parser_class_name
[::yytoken_number_
[] =
922 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
923 const ]b4_int_type_for([b4_r1
])[
924 ]b4_parser_class_name
[::yyr1_
[] =
929 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
930 const ]b4_int_type_for([b4_r2
])[
931 ]b4_parser_class_name
[::yyr2_
[] =
936 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
937 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
938 First, the terminals, then, starting at \a yyntokens_, nonterminals. */
940 const ]b4_parser_class_name
[::yytname_
[] =
947 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
948 const ]b4_parser_class_name
[::rhs_number_type
949 ]b4_parser_class_name
[::yyrhs_
[] =
954 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
956 const ]b4_int_type_for([b4_prhs
])[
957 ]b4_parser_class_name
[::yyprhs_
[] =
962 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
963 const ]b4_int_type_for([b4_rline
])[
964 ]b4_parser_class_name
[::yyrline_
[] =
969 // Print the state stack on the debug stream.
971 ]b4_parser_class_name
[::yystack_print_ ()
973 *yycdebug_
<< "Stack now";
974 for (state_stack_type::const_iterator i
= yystate_stack_
.begin ();
975 i
!= yystate_stack_
.end (); ++i
)
976 *yycdebug_
<< ' ' << *i
;
977 *yycdebug_
<< std::endl
;
980 // Report on the debug stream that the rule \a yyrule is going to be reduced.
982 ]b4_parser_class_name
[::yyreduce_print_ (int yyrule
)
984 unsigned int yylno
= yyrline_
[yyrule
];
985 /* Print the symbols being reduced, and their result. */
986 *yycdebug_
<< "Reducing stack by rule " << yyrule
- 1
987 << " (line " << yylno
<< "), ";
988 for (]b4_int_type_for([b4_prhs
])[ i
= yyprhs_
[yyrule
];
990 *yycdebug_
<< yytname_
[yyrhs_
[i
]] << ' ';
991 *yycdebug_
<< "-> " << yytname_
[yyr1_
[yyrule
]] << std::endl
;
995 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
996 ]b4_parser_class_name
[::token_number_type
997 ]b4_parser_class_name
[::yytranslate_ (int token
)
1000 const token_number_type
1005 if ((unsigned int) token
<= yyuser_token_number_max_
)
1006 return translate_table
[token
];
1008 return yyundef_token_
;
1011 const int ]b4_parser_class_name
[::yyeof_
= 0;
1012 const int ]b4_parser_class_name
[::yylast_
= ]b4_last
[;
1013 const int ]b4_parser_class_name
[::yynnts_
= ]b4_nterms_number
[;
1014 const int ]b4_parser_class_name
[::yyempty_
= -2;
1015 const int ]b4_parser_class_name
[::yyfinal_
= ]b4_final_state_number
[;
1016 const int ]b4_parser_class_name
[::yyterror_
= 1;
1017 const int ]b4_parser_class_name
[::yyerrcode_
= 256;
1018 const int ]b4_parser_class_name
[::yyntokens_
= ]b4_tokens_number
[;
1020 const unsigned int ]b4_parser_class_name
[::yyuser_token_number_max_
= ]b4_user_token_number_max
[;
1021 const ]b4_parser_class_name
[::token_number_type
]b4_parser_class_name
[::yyundef_token_
= ]b4_undef_token_number
[;
1027 @output b4_dir_prefix
[]stack
.hh
1028 b4_copyright([stack handling
for Bison C
++ parsers
], [2002, 2003, 2004, 2005])[
1030 #ifndef BISON_STACK_HH
1031 # define BISON_STACK_HH
1037 template <class T
, class S
= std::deque
<T
> >
1042 // Hide our reversed order.
1043 typedef typename
S::reverse_iterator iterator
;
1044 typedef typename
S::const_reverse_iterator const_iterator
;
1050 stack (unsigned int n
) : seq_ (n
)
1056 operator [] (unsigned int i
)
1063 operator [] (unsigned int i
) const
1072 seq_
.push_front (t
);
1077 pop (unsigned int n
= 1)
1087 return seq_
.size ();
1090 inline const_iterator
begin () const { return seq_
.rbegin (); }
1091 inline const_iterator
end () const { return seq_
.rend (); }
1098 /// Present a slice of the top of a stack.
1099 template <class T
, class S
= stack
<T
> >
1104 slice (const S
& stack
,
1105 unsigned int range
) : stack_ (stack
),
1112 operator [] (unsigned int i
) const
1114 return stack_
[range_
- i
];
1120 unsigned int range_
;
1124 #endif // not BISON_STACK_HH]