Dan Willemsen | 2212d17 | 2018-01-09 12:48:54 -0800 | [diff] [blame] | 1 | # C++ skeleton for Bison |
| 2 | |
| 3 | # Copyright (C) 2002-2012 Free Software Foundation, Inc. |
| 4 | |
| 5 | # This program is free software: you can redistribute it and/or modify |
| 6 | # it under the terms of the GNU General Public License as published by |
| 7 | # the Free Software Foundation, either version 3 of the License, or |
| 8 | # (at your option) any later version. |
| 9 | # |
| 10 | # This program is distributed in the hope that it will be useful, |
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | # GNU General Public License for more details. |
| 14 | # |
| 15 | # You should have received a copy of the GNU General Public License |
| 16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | m4_include(b4_pkgdatadir/[c++.m4]) |
| 19 | |
| 20 | m4_define([b4_parser_class_name], |
| 21 | [b4_percent_define_get([[parser_class_name]])]) |
| 22 | |
| 23 | # The header is mandatory. |
| 24 | b4_defines_if([], |
| 25 | [b4_fatal([b4_skeleton[: using %%defines is mandatory]])]) |
| 26 | |
| 27 | b4_percent_define_ifdef([[api.location.type]], [], |
| 28 | [# Backward compatibility. |
| 29 | m4_define([b4_location_constructors]) |
| 30 | m4_include(b4_pkgdatadir/[location.cc])]) |
| 31 | m4_include(b4_pkgdatadir/[stack.hh]) |
| 32 | |
| 33 | b4_defines_if( |
| 34 | [b4_output_begin([b4_spec_defines_file]) |
| 35 | b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++], |
| 36 | [2002-2012]) |
| 37 | [ |
| 38 | /** |
| 39 | ** \file ]b4_spec_defines_file[ |
| 40 | ** Define the ]b4_namespace_ref[::parser class. |
| 41 | */ |
| 42 | |
| 43 | /* C++ LALR(1) parser skeleton written by Akim Demaille. */ |
| 44 | |
| 45 | ]b4_cpp_guard_open([b4_spec_defines_file])[ |
| 46 | |
| 47 | ]b4_percent_code_get([[requires]])[ |
| 48 | |
| 49 | #include <string> |
| 50 | #include <iostream> |
| 51 | #include "stack.hh" |
| 52 | ]b4_percent_define_ifdef([[api.location.type]], [], |
| 53 | [[#include "location.hh"]])[ |
| 54 | |
| 55 | ]b4_YYDEBUG_define[ |
| 56 | |
| 57 | ]b4_namespace_open[ |
| 58 | |
| 59 | /// A Bison parser. |
| 60 | class ]b4_parser_class_name[ |
| 61 | { |
| 62 | public: |
| 63 | /// Symbol semantic values. |
| 64 | #ifndef ]b4_api_PREFIX[STYPE |
| 65 | ]m4_ifdef([b4_stype], |
| 66 | [ union semantic_type |
| 67 | { |
| 68 | b4_user_stype |
| 69 | };], |
| 70 | [m4_if(b4_tag_seen_flag, 0, |
| 71 | [[ typedef int semantic_type;]], |
| 72 | [[ typedef ]b4_api_PREFIX[STYPE semantic_type;]])])[ |
| 73 | #else |
| 74 | typedef ]b4_api_PREFIX[STYPE semantic_type; |
| 75 | #endif |
| 76 | /// Symbol locations. |
| 77 | typedef ]b4_percent_define_get([[api.location.type]], |
| 78 | [[location]])[ location_type; |
| 79 | /// Tokens. |
| 80 | struct token |
| 81 | { |
| 82 | ]b4_token_enums(b4_tokens)[ |
| 83 | }; |
| 84 | /// Token type. |
| 85 | typedef token::yytokentype token_type; |
| 86 | |
| 87 | /// Build a parser object. |
| 88 | ]b4_parser_class_name[ (]b4_parse_param_decl[); |
| 89 | virtual ~]b4_parser_class_name[ (); |
| 90 | |
| 91 | /// Parse. |
| 92 | /// \returns 0 iff parsing succeeded. |
| 93 | virtual int parse (); |
| 94 | |
| 95 | #if ]b4_api_PREFIX[DEBUG |
| 96 | /// The current debugging stream. |
| 97 | std::ostream& debug_stream () const; |
| 98 | /// Set the current debugging stream. |
| 99 | void set_debug_stream (std::ostream &); |
| 100 | |
| 101 | /// Type for debugging levels. |
| 102 | typedef int debug_level_type; |
| 103 | /// The current debugging level. |
| 104 | debug_level_type debug_level () const; |
| 105 | /// Set the current debugging level. |
| 106 | void set_debug_level (debug_level_type l); |
| 107 | #endif |
| 108 | |
| 109 | private: |
| 110 | /// Report a syntax error. |
| 111 | /// \param loc where the syntax error is found. |
| 112 | /// \param msg a description of the syntax error. |
| 113 | virtual void error (const location_type& loc, const std::string& msg); |
| 114 | |
| 115 | /// Generate an error message. |
| 116 | /// \param state the state where the error occurred. |
| 117 | /// \param tok the lookahead token. |
| 118 | virtual std::string yysyntax_error_ (int yystate, int tok); |
| 119 | |
| 120 | #if ]b4_api_PREFIX[DEBUG |
| 121 | /// \brief Report a symbol value on the debug stream. |
| 122 | /// \param yytype The token type. |
| 123 | /// \param yyvaluep Its semantic value. |
| 124 | /// \param yylocationp Its location. |
| 125 | virtual void yy_symbol_value_print_ (int yytype, |
| 126 | const semantic_type* yyvaluep, |
| 127 | const location_type* yylocationp); |
| 128 | /// \brief Report a symbol on the debug stream. |
| 129 | /// \param yytype The token type. |
| 130 | /// \param yyvaluep Its semantic value. |
| 131 | /// \param yylocationp Its location. |
| 132 | virtual void yy_symbol_print_ (int yytype, |
| 133 | const semantic_type* yyvaluep, |
| 134 | const location_type* yylocationp); |
| 135 | #endif |
| 136 | |
| 137 | |
| 138 | /// State numbers. |
| 139 | typedef int state_type; |
| 140 | /// State stack type. |
| 141 | typedef stack<state_type> state_stack_type; |
| 142 | /// Semantic value stack type. |
| 143 | typedef stack<semantic_type> semantic_stack_type; |
| 144 | /// location stack type. |
| 145 | typedef stack<location_type> location_stack_type; |
| 146 | |
| 147 | /// The state stack. |
| 148 | state_stack_type yystate_stack_; |
| 149 | /// The semantic value stack. |
| 150 | semantic_stack_type yysemantic_stack_; |
| 151 | /// The location stack. |
| 152 | location_stack_type yylocation_stack_; |
| 153 | |
| 154 | /// Whether the given \c yypact_ value indicates a defaulted state. |
| 155 | /// \param yyvalue the value to check |
| 156 | static bool yy_pact_value_is_default_ (int yyvalue); |
| 157 | |
| 158 | /// Whether the given \c yytable_ value indicates a syntax error. |
| 159 | /// \param yyvalue the value to check |
| 160 | static bool yy_table_value_is_error_ (int yyvalue); |
| 161 | |
| 162 | /// Internal symbol numbers. |
| 163 | typedef ]b4_int_type_for([b4_translate])[ token_number_type; |
| 164 | /* Tables. */ |
| 165 | /// For a state, the index in \a yytable_ of its portion. |
| 166 | static const ]b4_int_type_for([b4_pact])[ yypact_[]; |
| 167 | static const ]b4_int_type(b4_pact_ninf, b4_pact_ninf)[ yypact_ninf_; |
| 168 | |
| 169 | /// For a state, default reduction number. |
| 170 | /// Unless\a yytable_ specifies something else to do. |
| 171 | /// Zero means the default is an error. |
| 172 | static const ]b4_int_type_for([b4_defact])[ yydefact_[]; |
| 173 | |
| 174 | static const ]b4_int_type_for([b4_pgoto])[ yypgoto_[]; |
| 175 | static const ]b4_int_type_for([b4_defgoto])[ yydefgoto_[]; |
| 176 | |
| 177 | /// What to do in a state. |
| 178 | /// \a yytable_[yypact_[s]]: what to do in state \a s. |
| 179 | /// - if positive, shift that token. |
| 180 | /// - if negative, reduce the rule which number is the opposite. |
| 181 | /// - if zero, do what YYDEFACT says. |
| 182 | static const ]b4_int_type_for([b4_table])[ yytable_[]; |
| 183 | static const ]b4_int_type(b4_table_ninf, b4_table_ninf)[ yytable_ninf_; |
| 184 | |
| 185 | static const ]b4_int_type_for([b4_check])[ yycheck_[]; |
| 186 | |
| 187 | /// For a state, its accessing symbol. |
| 188 | static const ]b4_int_type_for([b4_stos])[ yystos_[]; |
| 189 | |
| 190 | /// For a rule, its LHS. |
| 191 | static const ]b4_int_type_for([b4_r1])[ yyr1_[]; |
| 192 | /// For a rule, its RHS length. |
| 193 | static const ]b4_int_type_for([b4_r2])[ yyr2_[]; ]b4_error_verbose_if([ |
| 194 | |
| 195 | /// Convert the symbol name \a n to a form suitable for a diagnostic. |
| 196 | static std::string yytnamerr_ (const char *n);])[ |
| 197 | |
| 198 | ]b4_token_table_if([], [[#if ]b4_api_PREFIX[DEBUG]])[ |
| 199 | /// For a symbol, its name in clear. |
| 200 | static const char* const yytname_[]; |
| 201 | ]b4_token_table_if([[#if ]b4_api_PREFIX[DEBUG]])[ |
| 202 | /// A type to store symbol numbers and -1. |
| 203 | typedef ]b4_int_type_for([b4_rhs])[ rhs_number_type; |
| 204 | /// A `-1'-separated list of the rules' RHS. |
| 205 | static const rhs_number_type yyrhs_[]; |
| 206 | /// For each rule, the index of the first RHS symbol in \a yyrhs_. |
| 207 | static const ]b4_int_type_for([b4_prhs])[ yyprhs_[]; |
| 208 | /// For each rule, its source line number. |
| 209 | static const ]b4_int_type_for([b4_rline])[ yyrline_[]; |
| 210 | /// For each scanner token number, its symbol number. |
| 211 | static const ]b4_int_type_for([b4_toknum])[ yytoken_number_[]; |
| 212 | /// Report on the debug stream that the rule \a r is going to be reduced. |
| 213 | virtual void yy_reduce_print_ (int r); |
| 214 | /// Print the state stack on the debug stream. |
| 215 | virtual void yystack_print_ (); |
| 216 | |
| 217 | /* Debugging. */ |
| 218 | int yydebug_; |
| 219 | std::ostream* yycdebug_; |
| 220 | #endif |
| 221 | |
| 222 | /// Convert a scanner token number \a t to a symbol number. |
| 223 | token_number_type yytranslate_ (int t); |
| 224 | |
| 225 | /// \brief Reclaim the memory associated to a symbol. |
| 226 | /// \param yymsg Why this token is reclaimed. |
| 227 | /// If null, do not display the symbol, just free it. |
| 228 | /// \param yytype The symbol type. |
| 229 | /// \param yyvaluep Its semantic value. |
| 230 | /// \param yylocationp Its location. |
| 231 | inline void yydestruct_ (const char* yymsg, |
| 232 | int yytype, |
| 233 | semantic_type* yyvaluep, |
| 234 | location_type* yylocationp); |
| 235 | |
| 236 | /// Pop \a n symbols the three stacks. |
| 237 | inline void yypop_ (unsigned int n = 1); |
| 238 | |
| 239 | /* Constants. */ |
| 240 | static const int yyeof_; |
| 241 | /* LAST_ -- Last index in TABLE_. */ |
| 242 | static const int yylast_; |
| 243 | static const int yynnts_; |
| 244 | static const int yyempty_; |
| 245 | static const int yyfinal_; |
| 246 | static const int yyterror_; |
| 247 | static const int yyerrcode_; |
| 248 | static const int yyntokens_; |
| 249 | static const unsigned int yyuser_token_number_max_; |
| 250 | static const token_number_type yyundef_token_; |
| 251 | ]b4_parse_param_vars[ |
| 252 | }; |
| 253 | ]b4_namespace_close[ |
| 254 | |
| 255 | ]b4_percent_define_flag_if([[global_tokens_and_yystype]], |
| 256 | [b4_token_defines(b4_tokens) |
| 257 | |
| 258 | #ifndef ]b4_api_PREFIX[STYPE |
| 259 | /* Redirection for backward compatibility. */ |
| 260 | # define ]b4_api_PREFIX[STYPE b4_namespace_ref::b4_parser_class_name::semantic_type |
| 261 | #endif |
| 262 | ])[ |
| 263 | ]b4_percent_code_get([[provides]])[ |
| 264 | ]b4_cpp_guard_close([b4_spec_defines_file]) |
| 265 | b4_output_end() |
| 266 | ]) |
| 267 | |
| 268 | |
| 269 | b4_output_begin([b4_parser_file_name]) |
| 270 | b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++], |
| 271 | [2002-2012]) |
| 272 | b4_percent_code_get([[top]])[]dnl |
| 273 | m4_if(b4_prefix, [yy], [], |
| 274 | [ |
| 275 | // Take the name prefix into account. |
| 276 | #define yylex b4_prefix[]lex])[ |
| 277 | |
| 278 | /* First part of user declarations. */ |
| 279 | ]b4_user_pre_prologue[ |
| 280 | |
| 281 | ]b4_defines_if([[ |
| 282 | #include "@basename(]b4_spec_defines_file[@)"]])[ |
| 283 | |
| 284 | /* User implementation prologue. */ |
| 285 | ]b4_user_post_prologue[ |
| 286 | ]b4_percent_code_get[ |
| 287 | |
| 288 | ]b4_null_define[ |
| 289 | |
| 290 | #ifndef YY_ |
| 291 | # if defined YYENABLE_NLS && YYENABLE_NLS |
| 292 | # if ENABLE_NLS |
| 293 | # include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */ |
| 294 | # define YY_(msgid) dgettext ("bison-runtime", msgid) |
| 295 | # endif |
| 296 | # endif |
| 297 | # ifndef YY_ |
| 298 | # define YY_(msgid) msgid |
| 299 | # endif |
| 300 | #endif |
| 301 | |
| 302 | #define YYRHSLOC(Rhs, K) ((Rhs)[K]) |
| 303 | ]b4_yylloc_default_define[ |
| 304 | |
| 305 | /* Suppress unused-variable warnings by "using" E. */ |
| 306 | #define YYUSE(e) ((void) (e)) |
| 307 | |
| 308 | /* Enable debugging if requested. */ |
| 309 | #if ]b4_api_PREFIX[DEBUG |
| 310 | |
| 311 | /* A pseudo ostream that takes yydebug_ into account. */ |
| 312 | # define YYCDEBUG if (yydebug_) (*yycdebug_) |
| 313 | |
| 314 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ |
| 315 | do { \ |
| 316 | if (yydebug_) \ |
| 317 | { \ |
| 318 | *yycdebug_ << Title << ' '; \ |
| 319 | yy_symbol_print_ ((Type), (Value), (Location)); \ |
| 320 | *yycdebug_ << std::endl; \ |
| 321 | } \ |
| 322 | } while (false) |
| 323 | |
| 324 | # define YY_REDUCE_PRINT(Rule) \ |
| 325 | do { \ |
| 326 | if (yydebug_) \ |
| 327 | yy_reduce_print_ (Rule); \ |
| 328 | } while (false) |
| 329 | |
| 330 | # define YY_STACK_PRINT() \ |
| 331 | do { \ |
| 332 | if (yydebug_) \ |
| 333 | yystack_print_ (); \ |
| 334 | } while (false) |
| 335 | |
| 336 | #else /* !]b4_api_PREFIX[DEBUG */ |
| 337 | |
| 338 | # define YYCDEBUG if (false) std::cerr |
| 339 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) YYUSE(Type) |
| 340 | # define YY_REDUCE_PRINT(Rule) static_cast<void>(0) |
| 341 | # define YY_STACK_PRINT() static_cast<void>(0) |
| 342 | |
| 343 | #endif /* !]b4_api_PREFIX[DEBUG */ |
| 344 | |
| 345 | #define yyerrok (yyerrstatus_ = 0) |
| 346 | #define yyclearin (yychar = yyempty_) |
| 347 | |
| 348 | #define YYACCEPT goto yyacceptlab |
| 349 | #define YYABORT goto yyabortlab |
| 350 | #define YYERROR goto yyerrorlab |
| 351 | #define YYRECOVERING() (!!yyerrstatus_) |
| 352 | |
| 353 | ]b4_namespace_open[]b4_error_verbose_if([[ |
| 354 | |
| 355 | /* Return YYSTR after stripping away unnecessary quotes and |
| 356 | backslashes, so that it's suitable for yyerror. The heuristic is |
| 357 | that double-quoting is unnecessary unless the string contains an |
| 358 | apostrophe, a comma, or backslash (other than backslash-backslash). |
| 359 | YYSTR is taken from yytname. */ |
| 360 | std::string |
| 361 | ]b4_parser_class_name[::yytnamerr_ (const char *yystr) |
| 362 | { |
| 363 | if (*yystr == '"') |
| 364 | { |
| 365 | std::string yyr = ""; |
| 366 | char const *yyp = yystr; |
| 367 | |
| 368 | for (;;) |
| 369 | switch (*++yyp) |
| 370 | { |
| 371 | case '\'': |
| 372 | case ',': |
| 373 | goto do_not_strip_quotes; |
| 374 | |
| 375 | case '\\': |
| 376 | if (*++yyp != '\\') |
| 377 | goto do_not_strip_quotes; |
| 378 | /* Fall through. */ |
Dan Willemsen | 693c385 | 2018-11-27 11:05:01 -0800 | [diff] [blame] | 379 | [[fallthrough]]; |
Dan Willemsen | 2212d17 | 2018-01-09 12:48:54 -0800 | [diff] [blame] | 380 | default: |
| 381 | yyr += *yyp; |
| 382 | break; |
| 383 | |
| 384 | case '"': |
| 385 | return yyr; |
| 386 | } |
| 387 | do_not_strip_quotes: ; |
| 388 | } |
| 389 | |
| 390 | return yystr; |
| 391 | } |
| 392 | ]])[ |
| 393 | |
| 394 | /// Build a parser object. |
| 395 | ]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [ |
| 396 | :])[ |
| 397 | #if ]b4_api_PREFIX[DEBUG |
| 398 | ]m4_ifset([b4_parse_param], [ ], [ :])[yydebug_ (false), |
| 399 | yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[ |
| 400 | #endif]b4_parse_param_cons[ |
| 401 | { |
| 402 | } |
| 403 | |
| 404 | ]b4_parser_class_name::~b4_parser_class_name[ () |
| 405 | { |
| 406 | } |
| 407 | |
| 408 | #if ]b4_api_PREFIX[DEBUG |
| 409 | /*--------------------------------. |
| 410 | | Print this symbol on YYOUTPUT. | |
| 411 | `--------------------------------*/ |
| 412 | |
| 413 | inline void |
| 414 | ]b4_parser_class_name[::yy_symbol_value_print_ (int yytype, |
| 415 | const semantic_type* yyvaluep, const location_type* yylocationp) |
| 416 | { |
| 417 | YYUSE (yylocationp); |
| 418 | YYUSE (yyvaluep); |
| 419 | std::ostream& yyo = debug_stream (); |
| 420 | std::ostream& yyoutput = yyo; |
| 421 | YYUSE (yyoutput); |
| 422 | switch (yytype) |
| 423 | { |
| 424 | ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl |
| 425 | [ default: |
| 426 | break; |
| 427 | } |
| 428 | } |
| 429 | |
| 430 | |
| 431 | void |
| 432 | ]b4_parser_class_name[::yy_symbol_print_ (int yytype, |
| 433 | const semantic_type* yyvaluep, const location_type* yylocationp) |
| 434 | { |
| 435 | *yycdebug_ << (yytype < yyntokens_ ? "token" : "nterm") |
| 436 | << ' ' << yytname_[yytype] << " (" |
| 437 | << *yylocationp << ": "; |
| 438 | yy_symbol_value_print_ (yytype, yyvaluep, yylocationp); |
| 439 | *yycdebug_ << ')'; |
| 440 | } |
| 441 | #endif |
| 442 | |
| 443 | void |
| 444 | ]b4_parser_class_name[::yydestruct_ (const char* yymsg, |
| 445 | int yytype, semantic_type* yyvaluep, location_type* yylocationp) |
| 446 | { |
| 447 | YYUSE (yylocationp); |
| 448 | YYUSE (yymsg); |
| 449 | YYUSE (yyvaluep); |
| 450 | |
| 451 | if (yymsg) |
| 452 | YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); |
| 453 | |
| 454 | switch (yytype) |
| 455 | { |
| 456 | ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))[ |
| 457 | default: |
| 458 | break; |
| 459 | } |
| 460 | } |
| 461 | |
| 462 | void |
| 463 | ]b4_parser_class_name[::yypop_ (unsigned int n) |
| 464 | { |
| 465 | yystate_stack_.pop (n); |
| 466 | yysemantic_stack_.pop (n); |
| 467 | yylocation_stack_.pop (n); |
| 468 | } |
| 469 | |
| 470 | #if ]b4_api_PREFIX[DEBUG |
| 471 | std::ostream& |
| 472 | ]b4_parser_class_name[::debug_stream () const |
| 473 | { |
| 474 | return *yycdebug_; |
| 475 | } |
| 476 | |
| 477 | void |
| 478 | ]b4_parser_class_name[::set_debug_stream (std::ostream& o) |
| 479 | { |
| 480 | yycdebug_ = &o; |
| 481 | } |
| 482 | |
| 483 | |
| 484 | ]b4_parser_class_name[::debug_level_type |
| 485 | ]b4_parser_class_name[::debug_level () const |
| 486 | { |
| 487 | return yydebug_; |
| 488 | } |
| 489 | |
| 490 | void |
| 491 | ]b4_parser_class_name[::set_debug_level (debug_level_type l) |
| 492 | { |
| 493 | yydebug_ = l; |
| 494 | } |
| 495 | #endif |
| 496 | |
| 497 | inline bool |
| 498 | ]b4_parser_class_name[::yy_pact_value_is_default_ (int yyvalue) |
| 499 | { |
| 500 | return yyvalue == yypact_ninf_; |
| 501 | } |
| 502 | |
| 503 | inline bool |
| 504 | ]b4_parser_class_name[::yy_table_value_is_error_ (int yyvalue) |
| 505 | { |
| 506 | return yyvalue == yytable_ninf_; |
| 507 | } |
| 508 | |
| 509 | int |
| 510 | ]b4_parser_class_name[::parse () |
| 511 | { |
| 512 | /// Lookahead and lookahead in internal form. |
| 513 | int yychar = yyempty_; |
| 514 | int yytoken = 0; |
| 515 | |
| 516 | // State. |
| 517 | int yyn; |
| 518 | int yylen = 0; |
| 519 | int yystate = 0; |
| 520 | |
| 521 | // Error handling. |
| 522 | int yynerrs_ = 0; |
| 523 | int yyerrstatus_ = 0; |
| 524 | |
| 525 | /// Semantic value of the lookahead. |
| 526 | static semantic_type yyval_default; |
| 527 | semantic_type yylval = yyval_default; |
| 528 | /// Location of the lookahead. |
| 529 | location_type yylloc; |
| 530 | /// The locations where the error started and ended. |
| 531 | location_type yyerror_range[3]; |
| 532 | |
| 533 | /// $$. |
| 534 | semantic_type yyval; |
| 535 | /// @@$. |
| 536 | location_type yyloc; |
| 537 | |
| 538 | int yyresult; |
| 539 | |
| 540 | // FIXME: This shoud be completely indented. It is not yet to |
| 541 | // avoid gratuitous conflicts when merging into the master branch. |
| 542 | try |
| 543 | { |
| 544 | YYCDEBUG << "Starting parse" << std::endl; |
| 545 | |
| 546 | ]m4_ifdef([b4_initial_action], [ |
| 547 | b4_dollar_pushdef([yylval], [], [yylloc])dnl |
| 548 | /* User initialization code. */ |
| 549 | b4_user_initial_action |
| 550 | b4_dollar_popdef])[]dnl |
| 551 | |
| 552 | [ /* Initialize the stacks. The initial state will be pushed in |
| 553 | yynewstate, since the latter expects the semantical and the |
| 554 | location values to have been already stored, initialize these |
| 555 | stacks with a primary value. */ |
| 556 | yystate_stack_ = state_stack_type (0); |
| 557 | yysemantic_stack_ = semantic_stack_type (0); |
| 558 | yylocation_stack_ = location_stack_type (0); |
| 559 | yysemantic_stack_.push (yylval); |
| 560 | yylocation_stack_.push (yylloc); |
| 561 | |
| 562 | /* New state. */ |
| 563 | yynewstate: |
| 564 | yystate_stack_.push (yystate); |
| 565 | YYCDEBUG << "Entering state " << yystate << std::endl; |
| 566 | |
| 567 | /* Accept? */ |
| 568 | if (yystate == yyfinal_) |
| 569 | goto yyacceptlab; |
| 570 | |
| 571 | goto yybackup; |
| 572 | |
| 573 | /* Backup. */ |
| 574 | yybackup: |
| 575 | |
| 576 | /* Try to take a decision without lookahead. */ |
| 577 | yyn = yypact_[yystate]; |
| 578 | if (yy_pact_value_is_default_ (yyn)) |
| 579 | goto yydefault; |
| 580 | |
| 581 | /* Read a lookahead token. */ |
| 582 | if (yychar == yyempty_) |
| 583 | { |
| 584 | YYCDEBUG << "Reading a token: "; |
| 585 | yychar = ]b4_c_function_call([yylex], [int], |
| 586 | [b4_api_PREFIX[STYPE*], [&yylval]][]dnl |
| 587 | b4_locations_if([, [[location*], [&yylloc]]])dnl |
| 588 | m4_ifdef([b4_lex_param], [, ]b4_lex_param))[; |
| 589 | } |
| 590 | |
| 591 | /* Convert token to internal form. */ |
| 592 | if (yychar <= yyeof_) |
| 593 | { |
| 594 | yychar = yytoken = yyeof_; |
| 595 | YYCDEBUG << "Now at end of input." << std::endl; |
| 596 | } |
| 597 | else |
| 598 | { |
| 599 | yytoken = yytranslate_ (yychar); |
| 600 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); |
| 601 | } |
| 602 | |
| 603 | /* If the proper action on seeing token YYTOKEN is to reduce or to |
| 604 | detect an error, take that action. */ |
| 605 | yyn += yytoken; |
| 606 | if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken) |
| 607 | goto yydefault; |
| 608 | |
| 609 | /* Reduce or error. */ |
| 610 | yyn = yytable_[yyn]; |
| 611 | if (yyn <= 0) |
| 612 | { |
| 613 | if (yy_table_value_is_error_ (yyn)) |
| 614 | goto yyerrlab; |
| 615 | yyn = -yyn; |
| 616 | goto yyreduce; |
| 617 | } |
| 618 | |
| 619 | /* Shift the lookahead token. */ |
| 620 | YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); |
| 621 | |
| 622 | /* Discard the token being shifted. */ |
| 623 | yychar = yyempty_; |
| 624 | |
| 625 | yysemantic_stack_.push (yylval); |
| 626 | yylocation_stack_.push (yylloc); |
| 627 | |
| 628 | /* Count tokens shifted since error; after three, turn off error |
| 629 | status. */ |
| 630 | if (yyerrstatus_) |
| 631 | --yyerrstatus_; |
| 632 | |
| 633 | yystate = yyn; |
| 634 | goto yynewstate; |
| 635 | |
| 636 | /*-----------------------------------------------------------. |
| 637 | | yydefault -- do the default action for the current state. | |
| 638 | `-----------------------------------------------------------*/ |
| 639 | yydefault: |
| 640 | yyn = yydefact_[yystate]; |
| 641 | if (yyn == 0) |
| 642 | goto yyerrlab; |
| 643 | goto yyreduce; |
| 644 | |
| 645 | /*-----------------------------. |
| 646 | | yyreduce -- Do a reduction. | |
| 647 | `-----------------------------*/ |
| 648 | yyreduce: |
| 649 | yylen = yyr2_[yyn]; |
| 650 | /* If YYLEN is nonzero, implement the default value of the action: |
| 651 | `$$ = $1'. Otherwise, use the top of the stack. |
| 652 | |
| 653 | Otherwise, the following line sets YYVAL to garbage. |
| 654 | This behavior is undocumented and Bison |
| 655 | users should not rely upon it. */ |
| 656 | if (yylen) |
| 657 | yyval = yysemantic_stack_[yylen - 1]; |
| 658 | else |
| 659 | yyval = yysemantic_stack_[0]; |
| 660 | |
| 661 | // Compute the default @@$. |
| 662 | { |
| 663 | slice<location_type, location_stack_type> slice (yylocation_stack_, yylen); |
| 664 | YYLLOC_DEFAULT (yyloc, slice, yylen); |
| 665 | } |
| 666 | |
| 667 | // Perform the reduction. |
| 668 | YY_REDUCE_PRINT (yyn); |
| 669 | switch (yyn) |
| 670 | { |
| 671 | ]b4_user_actions[ |
| 672 | default: |
| 673 | break; |
| 674 | } |
| 675 | |
| 676 | /* User semantic actions sometimes alter yychar, and that requires |
| 677 | that yytoken be updated with the new translation. We take the |
| 678 | approach of translating immediately before every use of yytoken. |
| 679 | One alternative is translating here after every semantic action, |
| 680 | but that translation would be missed if the semantic action |
| 681 | invokes YYABORT, YYACCEPT, or YYERROR immediately after altering |
| 682 | yychar. In the case of YYABORT or YYACCEPT, an incorrect |
| 683 | destructor might then be invoked immediately. In the case of |
| 684 | YYERROR, subsequent parser actions might lead to an incorrect |
| 685 | destructor call or verbose syntax error message before the |
| 686 | lookahead is translated. */ |
| 687 | YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc); |
| 688 | |
| 689 | yypop_ (yylen); |
| 690 | yylen = 0; |
| 691 | YY_STACK_PRINT (); |
| 692 | |
| 693 | yysemantic_stack_.push (yyval); |
| 694 | yylocation_stack_.push (yyloc); |
| 695 | |
| 696 | /* Shift the result of the reduction. */ |
| 697 | yyn = yyr1_[yyn]; |
| 698 | yystate = yypgoto_[yyn - yyntokens_] + yystate_stack_[0]; |
| 699 | if (0 <= yystate && yystate <= yylast_ |
| 700 | && yycheck_[yystate] == yystate_stack_[0]) |
| 701 | yystate = yytable_[yystate]; |
| 702 | else |
| 703 | yystate = yydefgoto_[yyn - yyntokens_]; |
| 704 | goto yynewstate; |
| 705 | |
| 706 | /*------------------------------------. |
| 707 | | yyerrlab -- here on detecting error | |
| 708 | `------------------------------------*/ |
| 709 | yyerrlab: |
| 710 | /* Make sure we have latest lookahead translation. See comments at |
| 711 | user semantic actions for why this is necessary. */ |
| 712 | yytoken = yytranslate_ (yychar); |
| 713 | |
| 714 | /* If not already recovering from an error, report this error. */ |
| 715 | if (!yyerrstatus_) |
| 716 | { |
| 717 | ++yynerrs_; |
| 718 | if (yychar == yyempty_) |
| 719 | yytoken = yyempty_; |
| 720 | error (yylloc, yysyntax_error_ (yystate, yytoken)); |
| 721 | } |
| 722 | |
| 723 | yyerror_range[1] = yylloc; |
| 724 | if (yyerrstatus_ == 3) |
| 725 | { |
| 726 | /* If just tried and failed to reuse lookahead token after an |
| 727 | error, discard it. */ |
| 728 | if (yychar <= yyeof_) |
| 729 | { |
| 730 | /* Return failure if at end of input. */ |
| 731 | if (yychar == yyeof_) |
| 732 | YYABORT; |
| 733 | } |
| 734 | else |
| 735 | { |
| 736 | yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc); |
| 737 | yychar = yyempty_; |
| 738 | } |
| 739 | } |
| 740 | |
| 741 | /* Else will try to reuse lookahead token after shifting the error |
| 742 | token. */ |
| 743 | goto yyerrlab1; |
| 744 | |
| 745 | |
| 746 | /*---------------------------------------------------. |
| 747 | | yyerrorlab -- error raised explicitly by YYERROR. | |
| 748 | `---------------------------------------------------*/ |
| 749 | yyerrorlab: |
| 750 | |
| 751 | /* Pacify compilers like GCC when the user code never invokes |
| 752 | YYERROR and the label yyerrorlab therefore never appears in user |
| 753 | code. */ |
| 754 | if (false) |
| 755 | goto yyerrorlab; |
| 756 | |
| 757 | yyerror_range[1] = yylocation_stack_[yylen - 1]; |
| 758 | /* Do not reclaim the symbols of the rule which action triggered |
| 759 | this YYERROR. */ |
| 760 | yypop_ (yylen); |
| 761 | yylen = 0; |
| 762 | yystate = yystate_stack_[0]; |
| 763 | goto yyerrlab1; |
| 764 | |
| 765 | /*-------------------------------------------------------------. |
| 766 | | yyerrlab1 -- common code for both syntax error and YYERROR. | |
| 767 | `-------------------------------------------------------------*/ |
| 768 | yyerrlab1: |
| 769 | yyerrstatus_ = 3; /* Each real token shifted decrements this. */ |
| 770 | |
| 771 | for (;;) |
| 772 | { |
| 773 | yyn = yypact_[yystate]; |
| 774 | if (!yy_pact_value_is_default_ (yyn)) |
| 775 | { |
| 776 | yyn += yyterror_; |
| 777 | if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_) |
| 778 | { |
| 779 | yyn = yytable_[yyn]; |
| 780 | if (0 < yyn) |
| 781 | break; |
| 782 | } |
| 783 | } |
| 784 | |
| 785 | /* Pop the current state because it cannot handle the error token. */ |
| 786 | if (yystate_stack_.height () == 1) |
| 787 | YYABORT; |
| 788 | |
| 789 | yyerror_range[1] = yylocation_stack_[0]; |
| 790 | yydestruct_ ("Error: popping", |
| 791 | yystos_[yystate], |
| 792 | &yysemantic_stack_[0], &yylocation_stack_[0]); |
| 793 | yypop_ (); |
| 794 | yystate = yystate_stack_[0]; |
| 795 | YY_STACK_PRINT (); |
| 796 | } |
| 797 | |
| 798 | yyerror_range[2] = yylloc; |
| 799 | // Using YYLLOC is tempting, but would change the location of |
| 800 | // the lookahead. YYLOC is available though. |
| 801 | YYLLOC_DEFAULT (yyloc, yyerror_range, 2); |
| 802 | yysemantic_stack_.push (yylval); |
| 803 | yylocation_stack_.push (yyloc); |
| 804 | |
| 805 | /* Shift the error token. */ |
| 806 | YY_SYMBOL_PRINT ("Shifting", yystos_[yyn], |
| 807 | &yysemantic_stack_[0], &yylocation_stack_[0]); |
| 808 | |
| 809 | yystate = yyn; |
| 810 | goto yynewstate; |
| 811 | |
| 812 | /* Accept. */ |
| 813 | yyacceptlab: |
| 814 | yyresult = 0; |
| 815 | goto yyreturn; |
| 816 | |
| 817 | /* Abort. */ |
| 818 | yyabortlab: |
| 819 | yyresult = 1; |
| 820 | goto yyreturn; |
| 821 | |
| 822 | yyreturn: |
| 823 | if (yychar != yyempty_) |
| 824 | { |
| 825 | /* Make sure we have latest lookahead translation. See comments |
| 826 | at user semantic actions for why this is necessary. */ |
| 827 | yytoken = yytranslate_ (yychar); |
| 828 | yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, |
| 829 | &yylloc); |
| 830 | } |
| 831 | |
| 832 | /* Do not reclaim the symbols of the rule which action triggered |
| 833 | this YYABORT or YYACCEPT. */ |
| 834 | yypop_ (yylen); |
| 835 | while (1 < yystate_stack_.height ()) |
| 836 | { |
| 837 | yydestruct_ ("Cleanup: popping", |
| 838 | yystos_[yystate_stack_[0]], |
| 839 | &yysemantic_stack_[0], |
| 840 | &yylocation_stack_[0]); |
| 841 | yypop_ (); |
| 842 | } |
| 843 | |
| 844 | return yyresult; |
| 845 | } |
| 846 | catch (...) |
| 847 | { |
| 848 | YYCDEBUG << "Exception caught: cleaning lookahead and stack" |
| 849 | << std::endl; |
| 850 | // Do not try to display the values of the reclaimed symbols, |
| 851 | // as their printer might throw an exception. |
| 852 | if (yychar != yyempty_) |
| 853 | { |
| 854 | /* Make sure we have latest lookahead translation. See |
| 855 | comments at user semantic actions for why this is |
| 856 | necessary. */ |
| 857 | yytoken = yytranslate_ (yychar); |
| 858 | yydestruct_ (YY_NULL, yytoken, &yylval, &yylloc); |
| 859 | } |
| 860 | |
| 861 | while (1 < yystate_stack_.height ()) |
| 862 | { |
| 863 | yydestruct_ (YY_NULL, |
| 864 | yystos_[yystate_stack_[0]], |
| 865 | &yysemantic_stack_[0], |
| 866 | &yylocation_stack_[0]); |
| 867 | yypop_ (); |
| 868 | } |
| 869 | throw; |
| 870 | } |
| 871 | } |
| 872 | |
| 873 | // Generate an error message. |
| 874 | std::string |
| 875 | ]b4_parser_class_name[::yysyntax_error_ (]dnl |
| 876 | b4_error_verbose_if([int yystate, int yytoken], |
| 877 | [int, int])[) |
| 878 | {]b4_error_verbose_if([[ |
| 879 | std::string yyres; |
| 880 | // Number of reported tokens (one for the "unexpected", one per |
| 881 | // "expected"). |
| 882 | size_t yycount = 0; |
| 883 | // Its maximum. |
| 884 | enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; |
| 885 | // Arguments of yyformat. |
| 886 | char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; |
| 887 | |
| 888 | /* There are many possibilities here to consider: |
| 889 | - If this state is a consistent state with a default action, then |
| 890 | the only way this function was invoked is if the default action |
| 891 | is an error action. In that case, don't check for expected |
| 892 | tokens because there are none. |
| 893 | - The only way there can be no lookahead present (in yytoken) is |
| 894 | if this state is a consistent state with a default action. |
| 895 | Thus, detecting the absence of a lookahead is sufficient to |
| 896 | determine that there is no unexpected or expected token to |
| 897 | report. In that case, just report a simple "syntax error". |
| 898 | - Don't assume there isn't a lookahead just because this state is |
| 899 | a consistent state with a default action. There might have |
| 900 | been a previous inconsistent state, consistent state with a |
| 901 | non-default action, or user semantic action that manipulated |
| 902 | yychar. |
| 903 | - Of course, the expected token list depends on states to have |
| 904 | correct lookahead information, and it depends on the parser not |
| 905 | to perform extra reductions after fetching a lookahead from the |
| 906 | scanner and before detecting a syntax error. Thus, state |
| 907 | merging (from LALR or IELR) and default reductions corrupt the |
| 908 | expected token list. However, the list is correct for |
| 909 | canonical LR with one exception: it will still contain any |
| 910 | token that will not be accepted due to an error action in a |
| 911 | later state. |
| 912 | */ |
| 913 | if (yytoken != yyempty_) |
| 914 | { |
| 915 | yyarg[yycount++] = yytname_[yytoken]; |
| 916 | int yyn = yypact_[yystate]; |
| 917 | if (!yy_pact_value_is_default_ (yyn)) |
| 918 | { |
| 919 | /* Start YYX at -YYN if negative to avoid negative indexes in |
| 920 | YYCHECK. In other words, skip the first -YYN actions for |
| 921 | this state because they are default actions. */ |
| 922 | int yyxbegin = yyn < 0 ? -yyn : 0; |
| 923 | /* Stay within bounds of both yycheck and yytname. */ |
| 924 | int yychecklim = yylast_ - yyn + 1; |
| 925 | int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; |
| 926 | for (int yyx = yyxbegin; yyx < yyxend; ++yyx) |
| 927 | if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_ |
| 928 | && !yy_table_value_is_error_ (yytable_[yyx + yyn])) |
| 929 | { |
| 930 | if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) |
| 931 | { |
| 932 | yycount = 1; |
| 933 | break; |
| 934 | } |
| 935 | else |
| 936 | yyarg[yycount++] = yytname_[yyx]; |
| 937 | } |
| 938 | } |
| 939 | } |
| 940 | |
| 941 | char const* yyformat = YY_NULL; |
| 942 | switch (yycount) |
| 943 | { |
| 944 | #define YYCASE_(N, S) \ |
| 945 | case N: \ |
| 946 | yyformat = S; \ |
| 947 | break |
| 948 | YYCASE_(0, YY_("syntax error")); |
| 949 | YYCASE_(1, YY_("syntax error, unexpected %s")); |
| 950 | YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); |
| 951 | YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); |
| 952 | YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); |
| 953 | YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); |
| 954 | #undef YYCASE_ |
| 955 | } |
| 956 | |
| 957 | // Argument number. |
| 958 | size_t yyi = 0; |
| 959 | for (char const* yyp = yyformat; *yyp; ++yyp) |
| 960 | if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount) |
| 961 | { |
| 962 | yyres += yytnamerr_ (yyarg[yyi++]); |
| 963 | ++yyp; |
| 964 | } |
| 965 | else |
| 966 | yyres += *yyp; |
| 967 | return yyres;]], [[ |
| 968 | return YY_("syntax error");]])[ |
| 969 | } |
| 970 | |
| 971 | |
| 972 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing |
| 973 | STATE-NUM. */ |
| 974 | const ]b4_int_type(b4_pact_ninf, b4_pact_ninf) b4_parser_class_name::yypact_ninf_ = b4_pact_ninf[; |
| 975 | const ]b4_int_type_for([b4_pact])[ |
| 976 | ]b4_parser_class_name[::yypact_[] = |
| 977 | { |
| 978 | ]b4_pact[ |
| 979 | }; |
| 980 | |
| 981 | /* YYDEFACT[S] -- default reduction number in state S. Performed when |
| 982 | YYTABLE doesn't specify something else to do. Zero means the |
| 983 | default is an error. */ |
| 984 | const ]b4_int_type_for([b4_defact])[ |
| 985 | ]b4_parser_class_name[::yydefact_[] = |
| 986 | { |
| 987 | ]b4_defact[ |
| 988 | }; |
| 989 | |
| 990 | /* YYPGOTO[NTERM-NUM]. */ |
| 991 | const ]b4_int_type_for([b4_pgoto])[ |
| 992 | ]b4_parser_class_name[::yypgoto_[] = |
| 993 | { |
| 994 | ]b4_pgoto[ |
| 995 | }; |
| 996 | |
| 997 | /* YYDEFGOTO[NTERM-NUM]. */ |
| 998 | const ]b4_int_type_for([b4_defgoto])[ |
| 999 | ]b4_parser_class_name[::yydefgoto_[] = |
| 1000 | { |
| 1001 | ]b4_defgoto[ |
| 1002 | }; |
| 1003 | |
| 1004 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If |
| 1005 | positive, shift that token. If negative, reduce the rule which |
| 1006 | number is the opposite. If YYTABLE_NINF_, syntax error. */ |
| 1007 | const ]b4_int_type(b4_table_ninf, b4_table_ninf) b4_parser_class_name::yytable_ninf_ = b4_table_ninf[; |
| 1008 | const ]b4_int_type_for([b4_table])[ |
| 1009 | ]b4_parser_class_name[::yytable_[] = |
| 1010 | { |
| 1011 | ]b4_table[ |
| 1012 | }; |
| 1013 | |
| 1014 | /* YYCHECK. */ |
| 1015 | const ]b4_int_type_for([b4_check])[ |
| 1016 | ]b4_parser_class_name[::yycheck_[] = |
| 1017 | { |
| 1018 | ]b4_check[ |
| 1019 | }; |
| 1020 | |
| 1021 | /* STOS_[STATE-NUM] -- The (internal number of the) accessing |
| 1022 | symbol of state STATE-NUM. */ |
| 1023 | const ]b4_int_type_for([b4_stos])[ |
| 1024 | ]b4_parser_class_name[::yystos_[] = |
| 1025 | { |
| 1026 | ]b4_stos[ |
| 1027 | }; |
| 1028 | |
| 1029 | #if ]b4_api_PREFIX[DEBUG |
| 1030 | /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding |
| 1031 | to YYLEX-NUM. */ |
| 1032 | const ]b4_int_type_for([b4_toknum])[ |
| 1033 | ]b4_parser_class_name[::yytoken_number_[] = |
| 1034 | { |
| 1035 | ]b4_toknum[ |
| 1036 | }; |
| 1037 | #endif |
| 1038 | |
| 1039 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ |
| 1040 | const ]b4_int_type_for([b4_r1])[ |
| 1041 | ]b4_parser_class_name[::yyr1_[] = |
| 1042 | { |
| 1043 | ]b4_r1[ |
| 1044 | }; |
| 1045 | |
| 1046 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ |
| 1047 | const ]b4_int_type_for([b4_r2])[ |
| 1048 | ]b4_parser_class_name[::yyr2_[] = |
| 1049 | { |
| 1050 | ]b4_r2[ |
| 1051 | }; |
| 1052 | |
| 1053 | ]b4_token_table_if([], [[#if ]b4_api_PREFIX[DEBUG]])[ |
| 1054 | /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. |
| 1055 | First, the terminals, then, starting at \a yyntokens_, nonterminals. */ |
| 1056 | const char* |
| 1057 | const ]b4_parser_class_name[::yytname_[] = |
| 1058 | { |
| 1059 | ]b4_tname[ |
| 1060 | }; |
| 1061 | |
| 1062 | ]b4_token_table_if([[#if ]b4_api_PREFIX[DEBUG]])[ |
| 1063 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ |
| 1064 | const ]b4_parser_class_name[::rhs_number_type |
| 1065 | ]b4_parser_class_name[::yyrhs_[] = |
| 1066 | { |
| 1067 | ]b4_rhs[ |
| 1068 | }; |
| 1069 | |
| 1070 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in |
| 1071 | YYRHS. */ |
| 1072 | const ]b4_int_type_for([b4_prhs])[ |
| 1073 | ]b4_parser_class_name[::yyprhs_[] = |
| 1074 | { |
| 1075 | ]b4_prhs[ |
| 1076 | }; |
| 1077 | |
| 1078 | /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ |
| 1079 | const ]b4_int_type_for([b4_rline])[ |
| 1080 | ]b4_parser_class_name[::yyrline_[] = |
| 1081 | { |
| 1082 | ]b4_rline[ |
| 1083 | }; |
| 1084 | |
| 1085 | // Print the state stack on the debug stream. |
| 1086 | void |
| 1087 | ]b4_parser_class_name[::yystack_print_ () |
| 1088 | { |
| 1089 | *yycdebug_ << "Stack now"; |
| 1090 | for (state_stack_type::const_iterator i = yystate_stack_.begin (); |
| 1091 | i != yystate_stack_.end (); ++i) |
| 1092 | *yycdebug_ << ' ' << *i; |
| 1093 | *yycdebug_ << std::endl; |
| 1094 | } |
| 1095 | |
| 1096 | // Report on the debug stream that the rule \a yyrule is going to be reduced. |
| 1097 | void |
| 1098 | ]b4_parser_class_name[::yy_reduce_print_ (int yyrule) |
| 1099 | { |
| 1100 | unsigned int yylno = yyrline_[yyrule]; |
| 1101 | int yynrhs = yyr2_[yyrule]; |
| 1102 | /* Print the symbols being reduced, and their result. */ |
| 1103 | *yycdebug_ << "Reducing stack by rule " << yyrule - 1 |
| 1104 | << " (line " << yylno << "):" << std::endl; |
| 1105 | /* The symbols being reduced. */ |
| 1106 | for (int yyi = 0; yyi < yynrhs; yyi++) |
| 1107 | YY_SYMBOL_PRINT (" $" << yyi + 1 << " =", |
| 1108 | yyrhs_[yyprhs_[yyrule] + yyi], |
| 1109 | &]b4_rhs_value(yynrhs, yyi + 1)[, |
| 1110 | &]b4_rhs_location(yynrhs, yyi + 1)[); |
| 1111 | } |
| 1112 | #endif // ]b4_api_PREFIX[DEBUG |
| 1113 | |
| 1114 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ |
| 1115 | ]b4_parser_class_name[::token_number_type |
| 1116 | ]b4_parser_class_name[::yytranslate_ (int t) |
| 1117 | { |
| 1118 | static |
| 1119 | const token_number_type |
| 1120 | translate_table[] = |
| 1121 | { |
| 1122 | ]b4_translate[ |
| 1123 | }; |
| 1124 | if ((unsigned int) t <= yyuser_token_number_max_) |
| 1125 | return translate_table[t]; |
| 1126 | else |
| 1127 | return yyundef_token_; |
| 1128 | } |
| 1129 | |
| 1130 | const int ]b4_parser_class_name[::yyeof_ = 0; |
| 1131 | const int ]b4_parser_class_name[::yylast_ = ]b4_last[; |
| 1132 | const int ]b4_parser_class_name[::yynnts_ = ]b4_nterms_number[; |
| 1133 | const int ]b4_parser_class_name[::yyempty_ = -2; |
| 1134 | const int ]b4_parser_class_name[::yyfinal_ = ]b4_final_state_number[; |
| 1135 | const int ]b4_parser_class_name[::yyterror_ = 1; |
| 1136 | const int ]b4_parser_class_name[::yyerrcode_ = 256; |
| 1137 | const int ]b4_parser_class_name[::yyntokens_ = ]b4_tokens_number[; |
| 1138 | |
| 1139 | const unsigned int ]b4_parser_class_name[::yyuser_token_number_max_ = ]b4_user_token_number_max[; |
| 1140 | const ]b4_parser_class_name[::token_number_type ]b4_parser_class_name[::yyundef_token_ = ]b4_undef_token_number[; |
| 1141 | |
| 1142 | ]b4_namespace_close[ |
| 1143 | ]b4_epilogue[]dnl |
| 1144 | b4_output_end() |