glr2.cc: move free-functions into glr_stack

* data/skeletons/glr2.cc (yypreference, yyLRgotoState): Move into...
(glr_stack): here.
This commit is contained in:
Akim Demaille
2021-01-15 07:32:18 +01:00
parent 42d5a16f8d
commit 19418cfc75

View File

@@ -699,9 +699,6 @@ yyisErrorAction (int yyaction)
return yyaction == 0; return yyaction == 0;
} }
static inline int
yygetLRActions (state_num yystate, yysymbol_kind_t yytoken, const short*& yyconflicts);
/** Accessing symbol of state YYSTATE. */ /** Accessing symbol of state YYSTATE. */
static inline yysymbol_kind_t static inline yysymbol_kind_t
yy_accessing_symbol (state_num yystate) yy_accessing_symbol (state_num yystate)
@@ -731,9 +728,12 @@ yylhsNonterm (rule_num yyrule)
return static_cast<yysymbol_kind_t>(yyr1[yyrule]); return static_cast<yysymbol_kind_t>(yyr1[yyrule]);
} }
/** Number of symbols composing the right hand side of rule #RULE. */
static inline int static inline int
yyrhsLength (rule_num yyrule); yyrhsLength (rule_num yyrule)
{
return yyr2[yyrule];
}
class glr_state class glr_state
{ {
@@ -1582,12 +1582,6 @@ void glr_state::destroy (char const* yymsg, ]b4_namespace_ref[::]b4_parser_class
} }
static int
yypreference (const semantic_option& y0, const semantic_option& y1);
static inline state_num
yyLRgotoState (state_num yystate, yysymbol_kind_t yysym);
#undef YYFILL #undef YYFILL
#define YYFILL(N) yyfill (yyvsp, yylow, (N), yynormal) #define YYFILL(N) yyfill (yyvsp, yylow, (N), yynormal)
@@ -3130,21 +3124,10 @@ private:
YY_SYMBOL_PRINT ("Next token is", this->yytoken, this->yylval, this->yylloc); YY_SYMBOL_PRINT ("Next token is", this->yytoken, this->yylval, this->yylloc);
} }
]b4_parse_param_vars[
};
/* Bison grammar-table manipulation. */ /* Bison grammar-table manipulation. */
/** Number of symbols composing the right hand side of rule #RULE. */ /** The action to take in YYSTATE on seeing YYTOKEN.
static inline int
yyrhsLength (rule_num yyrule)
{
return yyr2[yyrule];
}
/** The action to take in YYSTATE on seeing YYTOKEN.
* Result R means * Result R means
* R < 0: Reduce on rule -R. * R < 0: Reduce on rule -R.
* R = 0: Error. * R = 0: Error.
@@ -3152,9 +3135,9 @@ yyrhsLength (rule_num yyrule)
* Set *YYCONFLICTS to a pointer into yyconfl to a 0-terminated list * Set *YYCONFLICTS to a pointer into yyconfl to a 0-terminated list
* of conflicting reductions. * of conflicting reductions.
*/ */
static inline int static int
yygetLRActions (state_num yystate, yysymbol_kind_t yytoken, const short*& yyconflicts) yygetLRActions (state_num yystate, yysymbol_kind_t yytoken, const short*& yyconflicts)
{ {
int yyindex = yypact[yystate] + yytoken; int yyindex = yypact[yystate] + yytoken;
if (yytoken == ]b4_namespace_ref[::]b4_parser_class[::]b4_symbol(error, kind)[) if (yytoken == ]b4_namespace_ref[::]b4_parser_class[::]b4_symbol(error, kind)[)
{ {
@@ -3178,30 +3161,30 @@ yygetLRActions (state_num yystate, yysymbol_kind_t yytoken, const short*& yyconf
yyconflicts = yyconfl + yyconflp[yyindex]; yyconflicts = yyconfl + yyconflp[yyindex];
return 0; return 0;
} }
} }
/** Compute post-reduction state. /** Compute post-reduction state.
* \param yystate the current state * \param yystate the current state
* \param yysym the nonterminal to push on the stack * \param yysym the nonterminal to push on the stack
*/ */
static inline state_num static state_num
yyLRgotoState (state_num yystate, yysymbol_kind_t yysym) yyLRgotoState (state_num yystate, yysymbol_kind_t yysym)
{ {
const int yyr = yypgoto[yysym - YYNTOKENS] + yystate; const int yyr = yypgoto[yysym - YYNTOKENS] + yystate;
if (0 <= yyr && yyr <= YYLAST && yycheck[yyr] == yystate) if (0 <= yyr && yyr <= YYLAST && yycheck[yyr] == yystate)
return yytable[yyr]; return yytable[yyr];
else else
return yydefgoto[yysym - YYNTOKENS]; return yydefgoto[yysym - YYNTOKENS];
} }
/* GLRStacks */ /* GLRStacks */
/** Y0 and Y1 represent two possible actions to take in a given /** Y0 and Y1 represent two possible actions to take in a given
* parsing state; return 0 if no combination is possible, * parsing state; return 0 if no combination is possible,
* 1 if user-mergeable, 2 if Y0 is preferred, 3 if Y1 is preferred. */ * 1 if user-mergeable, 2 if Y0 is preferred, 3 if Y1 is preferred. */
static int static int
yypreference (const semantic_option& y0, const semantic_option& y1) yypreference (const semantic_option& y0, const semantic_option& y1)
{ {
rule_num r0 = y0.yyrule, r1 = y1.yyrule; rule_num r0 = y0.yyrule, r1 = y1.yyrule;
int p0 = yydprec[r0], p1 = yydprec[r1]; int p0 = yydprec[r0], p1 = yydprec[r1];
@@ -3219,7 +3202,12 @@ yypreference (const semantic_option& y0, const semantic_option& y1)
if (p1 < p0) if (p1 < p0)
return 2; return 2;
return 0; return 0;
} }
]b4_parse_param_vars[
};
/* DEBUGGING ONLY */ /* DEBUGGING ONLY */
#if ]b4_api_PREFIX[DEBUG #if ]b4_api_PREFIX[DEBUG
@@ -3430,4 +3418,3 @@ static void yypdumpstack (const glr_stack& yystack)
]b4_namespace_close[]dnl ]b4_namespace_close[]dnl
b4_epilogue[]dnl b4_epilogue[]dnl
b4_output_end b4_output_end