+
+ int
+ ]b4_parser_class_name[::parse ()
+ {
+ /// Whether yyla contains a lookahead.
+ bool yyempty = true;
+
+ /* State. */
+ int yyn;
+ int yylen = 0;
+ int yystate = 0;
+
+ /* Error handling. */
+ int yynerrs_ = 0;
+ int yyerrstatus_ = 0;
+
+ /// The lookahead symbol.
+ symbol_type yyla;
+
+ /// The locations where the error started and ended.
+ stack_symbol_type yyerror_range[2];
+
+ /// $$ and @@$.
+ stack_symbol_type yylhs;
+
+ /// The return value of parse().
+ int yyresult;
+
+ YYCDEBUG << "Starting parse" << std::endl;
+
+]m4_ifdef([b4_initial_action], [
+m4_pushdef([b4_at_dollar], [yyla.location])dnl
+m4_pushdef([b4_dollar_dollar], [yyla.value])dnl
+ /* User initialization code. */
+ b4_user_initial_action
+m4_popdef([b4_dollar_dollar])dnl
+m4_popdef([b4_at_dollar])])dnl
+
+ [ /* Initialize the stack. The initial state will be set in
+ yynewstate, since the latter expects the semantical and the
+ location values to have been already stored, initialize these
+ stacks with a primary value. */
+ yystack_ = stack_type (0);
+ yypush_ (0, 0, yyla);
+
+ // A new state was pushed on the stack.
+ // Invariant: yystate == yystack_[0].state, i.e.,
+ // yystate was just pushed onto the state stack.
+ yynewstate:
+ YYCDEBUG << "Entering state " << yystate << std::endl;
+
+ /* Accept? */
+ if (yystate == yyfinal_)
+ goto yyacceptlab;
+
+ goto yybackup;
+
+ /* Backup. */
+ yybackup:
+
+ /* Try to take a decision without lookahead. */
+ yyn = yypact_[yystate];
+ if (yyn == yypact_ninf_)
+ goto yydefault;
+
+ /* Read a lookahead token. */
+ if (yyempty)
+ {
+ YYCDEBUG << "Reading a token: ";
+]b4_lex_symbol_if(
+[ yyla = yylex();],
+[ yyla.type = yytranslate_ (b4_c_function_call([yylex], [int],
+ [[YYSTYPE*], [&yyla.value]][]dnl
+b4_locations_if([, [[location*], [&yyla.location]]])dnl
+m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
+ yyempty = false;
+ }
+ YY_SYMBOL_PRINT ("Next token is", yyla);
+
+ /* If the proper action on seeing token YYLA.TYPE is to reduce or
+ to detect an error, take that action. */
+ yyn += yyla.type;
+ if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.type)
+ goto yydefault;
+
+ /* Reduce or error. */
+ yyn = yytable_[yyn];
+ if (yyn <= 0)
+ {
+ if (yyn == 0 || yyn == yytable_ninf_)
+ goto yyerrlab;
+ yyn = -yyn;
+ goto yyreduce;
+ }
+
+ /* Discard the token being shifted. */
+ yyempty = true;
+
+ /* Count tokens shifted since error; after three, turn off error
+ status. */
+ if (yyerrstatus_)
+ --yyerrstatus_;
+
+ /* Shift the lookahead token. */
+ yystate = yyn;
+ yypush_ ("Shifting", yystate, yyla);
+ goto yynewstate;
+
+ /*-----------------------------------------------------------.
+ | yydefault -- do the default action for the current state. |
+ `-----------------------------------------------------------*/
+ yydefault:
+ yyn = yydefact_[yystate];
+ if (yyn == 0)
+ goto yyerrlab;
+ goto yyreduce;
+
+ /*-----------------------------.
+ | yyreduce -- Do a reduction. |
+ `-----------------------------*/
+ yyreduce:
+ yylen = yyr2_[yyn];]b4_variant_if([
+ /* Variants are always initialized to an empty instance of the
+ correct type. The default $$=$1 rule is NOT applied when using
+ variants */
+ ]b4_symbol_variant([[yyr1_@{yyn@}]], [yylhs.value], [build])[],[
+ /* If YYLEN is nonzero, implement the default value of the action:
+ `$$ = $1'. Otherwise, use the top of the stack.
+
+ Otherwise, the following line sets YYLHS.VALUE to garbage.
+ This behavior is undocumented and Bison
+ users should not rely upon it. */
+ if (yylen)
+ yylhs.value = yystack_@{yylen - 1@}.value;
+ else
+ yylhs.value = yystack_@{0@}.value;])[
+
+ // Compute the default @@$.
+ {
+ slice<stack_symbol_type, stack_type> slice (yystack_, yylen);
+ YYLLOC_DEFAULT (yylhs.location, slice, yylen);
+ }
+
+ // Perform the reduction.
+ YY_REDUCE_PRINT (yyn);
+ switch (yyn)
+ {
+]b4_user_actions[
+ default:
+ break;
+ }
+ // Compute post-reduction state.
+ yyn = yyr1_[yyn];
+ yystate = yypgoto_[yyn - yyntokens_] + yystack_[yylen].state;
+ if (0 <= yystate && yystate <= yylast_
+ && yycheck_[yystate] == yystack_[yylen].state)
+ yystate = yytable_[yystate];
+ else
+ yystate = yydefgoto_[yyn - yyntokens_];
+ yylhs.state = yystate;
+ YY_SYMBOL_PRINT ("-> $$ =", yylhs);
+]b4_variant_if([[
+ // Destroy the lhs symbols.
+ for (int i = 0; i < yylen; ++i)
+ // Destroy a variant which value may have be swapped with
+ // yylhs.value. The value of yylhs.value (hence maybe one of
+ // these lhs symbols) depends on what does the default
+ // contruction for this type. In the case of pointers for
+ // instance, nothing is done, so the value is junk. Therefore
+ // do not try to report the content in the debug trace, it's
+ // junk. Hence yymsg = 0. Besides, that keeps exactly the same
+ // traces as with the other Bison skeletons.
+ yy_destroy_ (0, yystack_[i]);]])[
+
+ yypop_ (yylen);
+ yylen = 0;
+ YY_STACK_PRINT ();
+
+ /* Shift the result of the reduction. */
+ yypush_ (0, yylhs);
+ goto yynewstate;
+
+ /*------------------------------------.
+ | yyerrlab -- here on detecting error |
+ `------------------------------------*/
+ yyerrlab:
+ /* If not already recovering from an error, report this error. */
+ if (!yyerrstatus_)
+ {
+ ++yynerrs_;
+ error (yyla.location, yysyntax_error_ (yystate, yyla.type));
+ }
+
+ yyerror_range[0].location = yyla.location;
+ if (yyerrstatus_ == 3)
+ {
+ /* If just tried and failed to reuse lookahead token after an
+ error, discard it. */
+
+ /* Return failure if at end of input. */
+ if (yyla.type == yyeof_)
+ YYABORT;
+ else
+ {
+ yy_destroy_ ("Error: discarding", yyla);
+ yyempty = true;
+ }
+ }
+
+ /* Else will try to reuse lookahead token after shifting the error
+ token. */
+ goto yyerrlab1;
+
+
+ /*---------------------------------------------------.
+ | yyerrorlab -- error raised explicitly by YYERROR. |
+ `---------------------------------------------------*/
+ yyerrorlab:
+
+ /* Pacify compilers like GCC when the user code never invokes
+ YYERROR and the label yyerrorlab therefore never appears in user
+ code. */
+ if (false)
+ goto yyerrorlab;
+
+ yyerror_range[0].location = yystack_[yylen - 1].location;
+ /* Do not reclaim the symbols of the rule which action triggered
+ this YYERROR. */
+ yypop_ (yylen);
+ yylen = 0;
+ yystate = yystack_[0].state;
+ goto yyerrlab1;
+
+ /*-------------------------------------------------------------.
+ | yyerrlab1 -- common code for both syntax error and YYERROR. |
+ `-------------------------------------------------------------*/
+ yyerrlab1:
+ yyerrstatus_ = 3; /* Each real token shifted decrements this. */
+ {
+ stack_symbol_type error_token;
+ for (;;)
+ {
+ yyn = yypact_[yystate];
+ if (yyn != yypact_ninf_)
+ {
+ yyn += yyterror_;
+ if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
+ {
+ yyn = yytable_[yyn];
+ if (0 < yyn)
+ break;
+ }
+ }
+
+ // Pop the current state because it cannot handle the error token.
+ if (yystack_.size () == 1)
+ YYABORT;
+
+ yyerror_range[0].location = yystack_[0].location;
+ yy_destroy_ ("Error: popping", yystack_[0]);
+ yypop_ ();
+ yystate = yystack_[0].state;
+ YY_STACK_PRINT ();
+ }
+
+ yyerror_range[1].location = yyla.location;
+ YYLLOC_DEFAULT (error_token.location, (yyerror_range - 1), 2);
+
+ /* Shift the error token. */
+ error_token.state = yystate = yyn;
+ yypush_ ("Shifting", error_token);