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 /* C++ LALR(1) parser skeleton written by Akim Demaille. */
38 #ifndef PARSER_HEADER_H
39 # define PARSER_HEADER_H
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; \
101 class ]b4_parser_class_name
[
104 /// Symbol semantic values.
105 #if ! defined (YYSTYPE)
106 ]m4_ifdef([b4_stype
],
107 [b4_syncline([b4_stype_line
], [b4_file_name
])
108 union semantic_type b4_stype
;
109 /* Line __line__ of lalr1.cc. */
110 b4_syncline([@oline@
], [@ofile@
])],
111 [ typedef int semantic_type
;])[
113 typedef YYSTYPE semantic_type
;
115 /// Symbol locations.
116 typedef ]b4_location_type
[ location_type
;
120 ]b4_token_enums(b4_tokens
)[
123 /// Build a parser object.
124 ]b4_parser_class_name
[ (]b4_parse_param_decl
[);
125 virtual ~]b4_parser_class_name
[ ();
128 /// \returns 0 iff parsing succeeded.
129 virtual int parse ();
131 /// The current debugging stream.
132 std::ostream
& debug_stream () const;
133 /// Set the current debugging stream.
134 void set_debug_stream (std::ostream
&);
136 /// Type for debugging levels.
137 typedef int debug_level_type
;
138 /// The current debugging level.
139 debug_level_type
debug_level () const;
140 /// Set the current debugging level.
141 void set_debug_level (debug_level_type l
);
144 /// Report a syntax error.
145 /// \param loc where the syntax error is found.
146 /// \param msg a description of the syntax error.
147 virtual void error (const location_type
& loc
, const std::string
& msg
);
149 /// Generate an error message.
150 /// \param state the state where the error occurred.
151 /// \param tok the look-ahead token.
152 virtual std::string
yysyntax_error_ (int yystate
]dnl
153 b4_error_verbose_if([, int tok
])[);
156 /// \brief Report a symbol value on the debug stream.
157 /// \param yytype The token type.
158 /// \param yyvaluep Its semantic value.
159 /// \param yylocationp Its location.
160 virtual void yy_symbol_value_print_ (int yytype
,
161 const semantic_type
* yyvaluep
,
162 const location_type
* yylocationp
);
163 /// \brief Report a symbol on the debug stream.
164 /// \param yytype The token type.
165 /// \param yyvaluep Its semantic value.
166 /// \param yylocationp Its location.
167 virtual void yy_symbol_print_ (int yytype
,
168 const semantic_type
* yyvaluep
,
169 const location_type
* yylocationp
);
170 #endif /* ! YYDEBUG */
174 typedef int state_type
;
175 /// State stack type.
176 typedef stack
<state_type
> state_stack_type
;
177 /// Semantic value stack type.
178 typedef stack
<semantic_type
> semantic_stack_type
;
179 /// location stack type.
180 typedef stack
<location_type
> location_stack_type
;
183 state_stack_type yystate_stack_
;
184 /// The semantic value stack.
185 semantic_stack_type yysemantic_stack_
;
186 /// The location stack.
187 location_stack_type yylocation_stack_
;
189 /// Internal symbol numbers.
190 typedef ]b4_int_type_for([b4_translate
])[ token_number_type
;
192 /// For a state, the index in \a yytable_ of its portion.
193 static const ]b4_int_type_for([b4_pact
])[ yypact_
[];
194 static const ]b4_int_type(b4_pact_ninf
, b4_pact_ninf
)[ yypact_ninf_
;
196 /// For a state, default rule to reduce.
197 /// Unless\a yytable_ specifies something else to do.
198 /// Zero means the default is an error.
199 static const ]b4_int_type_for([b4_defact
])[ yydefact_
[];
201 static const ]b4_int_type_for([b4_pgoto
])[ yypgoto_
[];
202 static const ]b4_int_type_for([b4_defgoto
])[ yydefgoto_
[];
204 /// What to do in a state.
205 /// \a yytable_[yypact_[s]]: what to do in state \a s.
206 /// - if positive, shift that token.
207 /// - if negative, reduce the rule which number is the opposite.
208 /// - if zero, do what YYDEFACT says.
209 static const ]b4_int_type_for([b4_table
])[ yytable_
[];
210 static const ]b4_int_type(b4_table_ninf
, b4_table_ninf
)[ yytable_ninf_
;
212 static const ]b4_int_type_for([b4_check
])[ yycheck_
[];
214 /// For a state, its accessing symbol.
215 static const ]b4_int_type_for([b4_stos
])[ yystos_
[];
217 /// For a rule, its LHS.
218 static const ]b4_int_type_for([b4_r1
])[ yyr1_
[];
219 /// For a rule, its RHS length.
220 static const ]b4_int_type_for([b4_r2
])[ yyr2_
[];
222 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
223 /// For a symbol, its name in clear.
224 static const char* const yytname_
[];
228 /// Convert the symbol name \a n to a form suitable for a diagnostic.
229 virtual std::string
yytnamerr_ (const char *n
);
233 /// A type to store symbol numbers and -1.
234 typedef ]b4_int_type_for([b4_rhs
])[ rhs_number_type
;
235 /// A `-1'-separated list of the rules' RHS.
236 static const rhs_number_type yyrhs_
[];
237 /// For each rule, the index of the first RHS symbol in \a yyrhs_.
238 static const ]b4_int_type_for([b4_prhs
])[ yyprhs_
[];
239 /// For each rule, its source line number.
240 static const ]b4_int_type_for([b4_rline
])[ yyrline_
[];
241 /// For each scanner token number, its symbol number.
242 static const ]b4_int_type_for([b4_toknum
])[ yytoken_number_
[];
243 /// Report on the debug stream that the rule \a r is going to be reduced.
244 virtual void yy_reduce_print_ (int r
);
245 /// Print the state stack on the debug stream.
246 virtual void yystack_print_ ();
249 /// Convert a scanner token number to a symbol number.
250 inline token_number_type
yytranslate_ (int token
);
252 /// \brief Reclaim the memory associated to a symbol.
253 /// \param yymsg Why this token is reclaimed.
254 /// \param yytype The symbol type.
255 /// \param yyvaluep Its semantic value.
256 /// \param yylocationp Its location.
257 inline void yydestruct_ (const char* yymsg
,
259 semantic_type
* yyvaluep
,
260 location_type
* yylocationp
);
262 /// Pop \a n symbols the three stacks.
263 inline void yypop_ (unsigned int n
= 1);
266 static const int yyeof_
;
267 /* LAST_ -- Last index in TABLE_. */
268 static const int yylast_
;
269 static const int yynnts_
;
270 static const int yyempty_
;
271 static const int yyfinal_
;
272 static const int yyterror_
;
273 static const int yyerrcode_
;
274 static const int yyntokens_
;
275 static const unsigned int yyuser_token_number_max_
;
276 static const token_number_type yyundef_token_
;
280 std::ostream
* yycdebug_
;
282 ]b4_parse_param_vars
[
286 ]m4_ifset([b4_global_tokens_and_yystype
],
287 [b4_token_defines(b4_tokens
)
290 /* Redirection for backward compatibility. */
291 # define YYSTYPE yy::b4_parser_class_name::semantic_type
294 #endif /* ! defined PARSER_HEADER_H */]
296 @output @output_parser_name@
297 b4_copyright([C
++ Skeleton parser
for LALR(1) parsing with Bison
],
298 [2002, 2003, 2004, 2005])
299 m4_if(b4_prefix
[], [yy
], [],
301 // Take the name prefix into account.
302 #define yylex b4_prefix[]lex])
303 m4_if(b4_defines_flag
, 0, [],
305 #include @output_header_name@])[
307 /* User implementation prologue. */
310 ]/* Line __line__ of lalr1.cc. */
311 b4_syncline([@oline@
], [@ofile@
])[
316 # include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */
317 # define YY_(msgid) dgettext ("bison-runtime", msgid)
321 # define YY_(msgid) msgid
325 /* Suppress unused-variable warnings by "using" E. */
326 #define YYUSE(e) ((void) (e))
328 /* A pseudo ostream that takes yydebug_ into account. */
330 for (bool yydebugcond_ = yydebug_; yydebugcond_; yydebugcond_ = false) \
333 /* Enable debugging if requested. */
336 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
340 *yycdebug_ << Title << ' '; \
341 yy_symbol_print_ ((Type), (Value), (Location)); \
342 *yycdebug_ << std::endl; \
346 # define YY_REDUCE_PRINT(Rule) \
349 yy_reduce_print_ (Rule); \
352 # define YY_STACK_PRINT() \
360 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
361 # define YY_REDUCE_PRINT(Rule)
362 # define YY_STACK_PRINT()
364 #endif /* !YYDEBUG */
366 #define YYACCEPT goto yyacceptlab
367 #define YYABORT goto yyabortlab
368 #define YYERROR goto yyerrorlab
372 /* Return YYSTR after stripping away unnecessary quotes and
373 backslashes, so that it's suitable for yyerror. The heuristic is
374 that double-quoting is unnecessary unless the string contains an
375 apostrophe, a comma, or backslash (other than backslash-backslash).
376 YYSTR is taken from yytname. */
378 yy::]b4_parser_class_name
[::yytnamerr_ (const char *yystr
)
382 std::string yyr
= "";
383 char const *yyp
= yystr
;
390 goto do_not_strip_quotes
;
394 goto do_not_strip_quotes
;
403 do_not_strip_quotes
: ;
413 /// Build a parser object.
414 ]b4_parser_class_name::b4_parser_class_name
[ (]b4_parse_param_decl
[)
416 yycdebug_ (&std::cerr
)]b4_parse_param_cons
[
420 ]b4_parser_class_name::~b4_parser_class_name
[ ()
425 /*--------------------------------.
426 | Print this symbol on YYOUTPUT. |
427 `--------------------------------*/
430 ]b4_parser_class_name
[::yy_symbol_value_print_ (int yytype
,
431 const semantic_type
* yyvaluep
, const location_type
* yylocationp
)
437 ]m4_map([b4_symbol_actions
], m4_defn([b4_symbol_printers
]))dnl
445 ]b4_parser_class_name
[::yy_symbol_print_ (int yytype
,
446 const semantic_type
* yyvaluep
, const location_type
* yylocationp
)
448 *yycdebug_
<< (yytype
< yyntokens_
? "token" : "nterm")
449 << ' ' << yytname_
[yytype
] << " ("
450 << *yylocationp
<< ": ";
451 yy_symbol_value_print_ (yytype
, yyvaluep
, yylocationp
);
454 #endif /* ! YYDEBUG */
457 ]b4_parser_class_name
[::yydestruct_ (const char* yymsg
,
458 int yytype
, semantic_type
* yyvaluep
, location_type
* yylocationp
)
464 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
468 ]m4_map([b4_symbol_actions
], m4_defn([b4_symbol_destructors
]))[
475 ]b4_parser_class_name
[::yypop_ (unsigned int n
)
477 yystate_stack_
.pop (n
);
478 yysemantic_stack_
.pop (n
);
479 yylocation_stack_
.pop (n
);
483 ]b4_parser_class_name
[::debug_stream () const
489 ]b4_parser_class_name
[::set_debug_stream (std::ostream
& o
)
495 ]b4_parser_class_name
[::debug_level_type
496 ]b4_parser_class_name
[::debug_level () const
502 ]b4_parser_class_name
[::set_debug_level (debug_level_type l
)
509 ]b4_parser_class_name
[::parse ()
511 /// Look-ahead and look-ahead in internal form.
512 int yychar
= yyempty_
;
520 /* Error handling. */
522 int yyerrstatus_
= 0;
524 /// Semantic value of the look-ahead.
525 semantic_type yylval
;
526 /// Location of the look-ahead.
527 location_type yylloc
;
528 /// The locations where the error started and ended.
529 location yyerror_range
[2];
538 YYCDEBUG
<< "Starting parse" << std::endl
;
540 ]m4_ifdef([b4_initial_action
], [
541 m4_pushdef([b4_at_dollar
], [yylloc
])dnl
542 m4_pushdef([b4_dollar_dollar
], [yylval
])dnl
543 /* User initialization code. */
545 m4_popdef([b4_dollar_dollar
])dnl
546 m4_popdef([b4_at_dollar
])dnl
547 /* Line __line__ of yacc.c. */
548 b4_syncline([@oline@
], [@ofile@
])])dnl
550 [ /* Initialize the stacks. The initial state will be pushed in
551 yynewstate, since the latter expects the semantical and the
552 location values to have been already stored, initialize these
553 stacks with a primary value. */
554 yystate_stack_
= state_stack_type (0);
555 yysemantic_stack_
= semantic_stack_type (0);
556 yylocation_stack_
= location_stack_type (0);
557 yysemantic_stack_
.push (yylval
);
558 yylocation_stack_
.push (yylloc
);
562 yystate_stack_
.push (yystate
);
563 YYCDEBUG
<< "Entering state " << yystate
<< std::endl
;
569 /* Try to take a decision without look-ahead. */
570 yyn
= yypact_
[yystate
];
571 if (yyn
== yypact_ninf_
)
574 /* Read a look-ahead token. */
575 if (yychar
== yyempty_
)
577 YYCDEBUG
<< "Reading a token: ";
578 yychar
= ]b4_c_function_call([yylex
], [int],
579 [[YYSTYPE
*], [&yylval
]][]dnl
580 b4_location_if([, [[location
*], [&yylloc
]]])dnl
581 m4_ifdef([b4_lex_param
], [, ]b4_lex_param
))[;
585 /* Convert token to internal form. */
586 if (yychar
<= yyeof_
)
588 yychar
= yytoken
= yyeof_
;
589 YYCDEBUG
<< "Now at end of input." << std::endl
;
593 yytoken
= yytranslate_ (yychar
);
594 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
597 /* If the proper action on seeing token YYTOKEN is to reduce or to
598 detect an error, take that action. */
600 if (yyn
< 0 || yylast_
< yyn
|| yycheck_
[yyn
] != yytoken
)
603 /* Reduce or error. */
607 if (yyn
== 0 || yyn
== yytable_ninf_
)
617 /* Shift the look-ahead token. */
618 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
620 /* Discard the token being shifted unless it is eof. */
621 if (yychar
!= yyeof_
)
624 yysemantic_stack_
.push (yylval
);
625 yylocation_stack_
.push (yylloc
);
627 /* Count tokens shifted since error; after three, turn off error
635 /*-----------------------------------------------------------.
636 | yydefault -- do the default action for the current state. |
637 `-----------------------------------------------------------*/
639 yyn
= yydefact_
[yystate
];
644 /*-----------------------------.
645 | yyreduce -- Do a reduction. |
646 `-----------------------------*/
649 /* If YYLEN is nonzero, implement the default value of the action:
650 `$$ = $1'. Otherwise, use the top of the stack.
652 Otherwise, the following line sets YYVAL to garbage.
653 This behavior is undocumented and Bison
654 users should not rely upon it. */
656 yyval
= yysemantic_stack_
[yylen
- 1];
658 yyval
= yysemantic_stack_
[0];
661 slice
<location_type
, location_stack_type
> slice (yylocation_stack_
, yylen
);
662 YYLLOC_DEFAULT (yyloc
, slice
, yylen
);
664 YY_REDUCE_PRINT (yyn
);
668 /* Line __line__ of lalr1.cc. */
669 b4_syncline([@oline@
], [@ofile@
])[
672 YY_SYMBOL_PRINT ("-> $$ =", yyr1_
[yyn
], &yyval
, &yyloc
);
678 yysemantic_stack_
.push (yyval
);
679 yylocation_stack_
.push (yyloc
);
681 /* Shift the result of the reduction. */
683 yystate
= yypgoto_
[yyn
- yyntokens_
] + yystate_stack_
[0];
684 if (0 <= yystate
&& yystate
<= yylast_
685 && yycheck_
[yystate
] == yystate_stack_
[0])
686 yystate
= yytable_
[yystate
];
688 yystate
= yydefgoto_
[yyn
- yyntokens_
];
691 /*------------------------------------.
692 | yyerrlab -- here on detecting error |
693 `------------------------------------*/
695 /* If not already recovering from an error, report this error. */
699 error (yylloc
, yysyntax_error_ (yystate
]dnl
700 b4_error_verbose_if([, yytoken
])[));
703 yyerror_range
[0] = yylloc
;
704 if (yyerrstatus_
== 3)
706 /* If just tried and failed to reuse look-ahead token after an
707 error, discard it. */
709 if (yychar
<= yyeof_
)
711 /* Return failure if at end of input. */
712 if (yychar
== yyeof_
)
717 yydestruct_ ("Error: discarding", yytoken
, &yylval
, &yylloc
);
722 /* Else will try to reuse look-ahead token after shifting the error
727 /*---------------------------------------------------.
728 | yyerrorlab -- error raised explicitly by YYERROR. |
729 `---------------------------------------------------*/
732 /* Pacify compilers like GCC when the user code never invokes
733 YYERROR and the label yyerrorlab therefore never appears in user
738 yyerror_range
[0] = yylocation_stack_
[yylen
- 1];
739 /* Do not reclaim the symbols of the rule which action triggered
743 yystate
= yystate_stack_
[0];
746 /*-------------------------------------------------------------.
747 | yyerrlab1 -- common code for both syntax error and YYERROR. |
748 `-------------------------------------------------------------*/
750 yyerrstatus_
= 3; /* Each real token shifted decrements this. */
754 yyn
= yypact_
[yystate
];
755 if (yyn
!= yypact_ninf_
)
758 if (0 <= yyn
&& yyn
<= yylast_
&& yycheck_
[yyn
] == yyterror_
)
766 /* Pop the current state because it cannot handle the error token. */
767 if (yystate_stack_
.height () == 1)
770 yyerror_range
[0] = yylocation_stack_
[0];
771 yydestruct_ ("Error: popping",
773 &yysemantic_stack_
[0], &yylocation_stack_
[0]);
775 yystate
= yystate_stack_
[0];
782 yyerror_range
[1] = yylloc
;
783 // Using YYLLOC is tempting, but would change the location of
784 // the look-ahead. YYLOC is available though.
785 YYLLOC_DEFAULT (yyloc
, yyerror_range
- 1, 2);
786 yysemantic_stack_
.push (yylval
);
787 yylocation_stack_
.push (yyloc
);
789 /* Shift the error token. */
790 YY_SYMBOL_PRINT ("Shifting", yystos_
[yyn
],
791 &yysemantic_stack_
[0], &yylocation_stack_
[0]);
807 if (yychar
!= yyeof_
&& yychar
!= yyempty_
)
808 yydestruct_ ("Cleanup: discarding lookahead", yytoken
, &yylval
, &yylloc
);
810 /* Do not reclaim the symbols of the rule which action triggered
811 this YYABORT or YYACCEPT. */
813 while (yystate_stack_
.height () != 1)
815 yydestruct_ ("Cleanup: popping",
816 yystos_
[yystate_stack_
[0]],
817 &yysemantic_stack_
[0],
818 &yylocation_stack_
[0]);
825 // Generate an error message.
827 ]b4_parser_class_name
[::yysyntax_error_ (int yystate
]dnl
828 b4_error_verbose_if([, int tok
])[)
832 int yyn
= yypact_
[yystate
];
833 if (yypact_ninf_
< yyn
&& yyn
< yylast_
)
835 /* Start YYX at -YYN if negative to avoid negative indexes in
837 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
839 /* Stay within bounds of both yycheck and yytname. */
840 int yychecklim
= yylast_
- yyn
;
841 int yyxend
= yychecklim
< yyntokens_
? yychecklim
: yyntokens_
;
843 for (int x
= yyxbegin
; x
< yyxend
; ++x
)
844 if (yycheck_
[x
+ yyn
] == x
&& x
!= yyterror_
)
847 // FIXME: This method of building the message is not compatible
848 // with internationalization. It should work like yacc.c does it.
849 // That is, first build a string that looks like this:
850 // "syntax error, unexpected %s or %s or %s"
851 // Then, invoke YY_ on this string.
852 // Finally, use the string as a format to output
853 // yytname_[tok], etc.
854 // Until this gets fixed, this message appears in English only.
855 res
= "syntax error, unexpected ";
856 res
+= yytnamerr_ (yytname_
[tok
]);
860 for (int x
= yyxbegin
; x
< yyxend
; ++x
)
861 if (yycheck_
[x
+ yyn
] == x
&& x
!= yyterror_
)
863 res
+= (!count
++) ? ", expecting " : " or ";
864 res
+= yytnamerr_ (yytname_
[x
]);
870 res
= YY_("syntax error");
875 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
877 const ]b4_int_type(b4_pact_ninf
, b4_pact_ninf
) b4_parser_class_name::yypact_ninf_
= b4_pact_ninf
[;
878 const ]b4_int_type_for([b4_pact
])[
879 ]b4_parser_class_name
[::yypact_
[] =
884 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
885 doesn't specify something else to do. Zero means the default is an
887 const ]b4_int_type_for([b4_defact
])[
888 ]b4_parser_class_name
[::yydefact_
[] =
893 /* YYPGOTO[NTERM-NUM]. */
894 const ]b4_int_type_for([b4_pgoto
])[
895 ]b4_parser_class_name
[::yypgoto_
[] =
900 /* YYDEFGOTO[NTERM-NUM]. */
901 const ]b4_int_type_for([b4_defgoto
])[
902 ]b4_parser_class_name
[::yydefgoto_
[] =
907 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
908 positive, shift that token. If negative, reduce the rule which
909 number is the opposite. If zero, do what YYDEFACT says. */
910 const ]b4_int_type(b4_table_ninf
, b4_table_ninf
) b4_parser_class_name::yytable_ninf_
= b4_table_ninf
[;
911 const ]b4_int_type_for([b4_table
])[
912 ]b4_parser_class_name
[::yytable_
[] =
918 const ]b4_int_type_for([b4_check
])[
919 ]b4_parser_class_name
[::yycheck_
[] =
924 /* STOS_[STATE-NUM] -- The (internal number of the) accessing
925 symbol of state STATE-NUM. */
926 const ]b4_int_type_for([b4_stos
])[
927 ]b4_parser_class_name
[::yystos_
[] =
933 /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
935 const ]b4_int_type_for([b4_toknum
])[
936 ]b4_parser_class_name
[::yytoken_number_
[] =
942 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
943 const ]b4_int_type_for([b4_r1
])[
944 ]b4_parser_class_name
[::yyr1_
[] =
949 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
950 const ]b4_int_type_for([b4_r2
])[
951 ]b4_parser_class_name
[::yyr2_
[] =
956 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
957 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
958 First, the terminals, then, starting at \a yyntokens_, nonterminals. */
960 const ]b4_parser_class_name
[::yytname_
[] =
967 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
968 const ]b4_parser_class_name
[::rhs_number_type
969 ]b4_parser_class_name
[::yyrhs_
[] =
974 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
976 const ]b4_int_type_for([b4_prhs
])[
977 ]b4_parser_class_name
[::yyprhs_
[] =
982 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
983 const ]b4_int_type_for([b4_rline
])[
984 ]b4_parser_class_name
[::yyrline_
[] =
989 // Print the state stack on the debug stream.
991 ]b4_parser_class_name
[::yystack_print_ ()
993 *yycdebug_
<< "Stack now";
994 for (state_stack_type::const_iterator i
= yystate_stack_
.begin ();
995 i
!= yystate_stack_
.end (); ++i
)
996 *yycdebug_
<< ' ' << *i
;
997 *yycdebug_
<< std::endl
;
1000 // Report on the debug stream that the rule \a yyrule is going to be reduced.
1002 ]b4_parser_class_name
[::yy_reduce_print_ (int yyrule
)
1004 unsigned int yylno
= yyrline_
[yyrule
];
1005 int yynrhs
= yyr2_
[yyrule
];
1006 /* Print the symbols being reduced, and their result. */
1007 *yycdebug_
<< "Reducing stack by rule " << yyrule
- 1
1008 << " (line " << yylno
<< "), ";
1009 /* The symbols being reduced. */
1010 for (int yyi
= 0; yyi
< yynrhs
; yyi
++)
1011 YY_SYMBOL_PRINT (" $" << yyi
+ 1 << " =",
1012 yyrhs_
[yyprhs_
[yyrule
] + yyi
],
1013 &]b4_rhs_value(yynrhs
, yyi
+ 1)[,
1014 &]b4_rhs_location(yynrhs
, yyi
+ 1)[);
1018 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1019 ]b4_parser_class_name
[::token_number_type
1020 ]b4_parser_class_name
[::yytranslate_ (int token
)
1023 const token_number_type
1028 if ((unsigned int) token
<= yyuser_token_number_max_
)
1029 return translate_table
[token
];
1031 return yyundef_token_
;
1034 const int ]b4_parser_class_name
[::yyeof_
= 0;
1035 const int ]b4_parser_class_name
[::yylast_
= ]b4_last
[;
1036 const int ]b4_parser_class_name
[::yynnts_
= ]b4_nterms_number
[;
1037 const int ]b4_parser_class_name
[::yyempty_
= -2;
1038 const int ]b4_parser_class_name
[::yyfinal_
= ]b4_final_state_number
[;
1039 const int ]b4_parser_class_name
[::yyterror_
= 1;
1040 const int ]b4_parser_class_name
[::yyerrcode_
= 256;
1041 const int ]b4_parser_class_name
[::yyntokens_
= ]b4_tokens_number
[;
1043 const unsigned int ]b4_parser_class_name
[::yyuser_token_number_max_
= ]b4_user_token_number_max
[;
1044 const ]b4_parser_class_name
[::token_number_type
]b4_parser_class_name
[::yyundef_token_
= ]b4_undef_token_number
[;
1050 @output b4_dir_prefix
[]stack
.hh
1051 b4_copyright([stack handling
for Bison C
++ parsers
], [2002, 2003, 2004, 2005])[
1053 #ifndef BISON_STACK_HH
1054 # define BISON_STACK_HH
1060 template <class T
, class S
= std::deque
<T
> >
1065 // Hide our reversed order.
1066 typedef typename
S::reverse_iterator iterator
;
1067 typedef typename
S::const_reverse_iterator const_iterator
;
1073 stack (unsigned int n
) : seq_ (n
)
1079 operator [] (unsigned int i
)
1086 operator [] (unsigned int i
) const
1095 seq_
.push_front (t
);
1100 pop (unsigned int n
= 1)
1110 return seq_
.size ();
1113 inline const_iterator
begin () const { return seq_
.rbegin (); }
1114 inline const_iterator
end () const { return seq_
.rend (); }
1121 /// Present a slice of the top of a stack.
1122 template <class T
, class S
= stack
<T
> >
1127 slice (const S
& stack
,
1128 unsigned int range
) : stack_ (stack
),
1135 operator [] (unsigned int i
) const
1137 return stack_
[range_
- i
];
1143 unsigned int range_
;
1147 #endif // not BISON_STACK_HH]