commit ae1e65a285d8e9ab6d1bb4515a9ad5661933b686
Author: Akim Demaille <[email protected]>
Date: Mon Oct 22 12:01:56 2018 +0200
yacc.c: clarify the computation of yystate
The yacc.c skeleton is old, and was using many tricks to save
registers. Today's register allocators can do this themselves. Let's
keep the code simpler to read and let compilers do their job.
* data/yacc.c: Avoid using yystate for different types of content.
An inline function would be better, but doing this portably will be
a problem.
diff --git a/data/yacc.c b/data/yacc.c
index e44735a9..2e1c275c 100644
--- a/data/yacc.c
+++ b/data/yacc.c
@@ -972,13 +972,11 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes,
{
int yystate;
{
- int yylhs = yyr1[yyrule] - YYNTOKENS;
- yystate = yypgoto[yylhs] + *yyesp;
- if (yystate < 0 || YYLAST < yystate
- || yycheck[yystate] != *yyesp)
- yystate = yydefgoto[yylhs];
- else
- yystate = yytable[yystate];
+ const int yylhs = yyr1[yyrule] - YYNTOKENS;
+ const int yyi = yypgoto[yylhs] + *yyesp;
+ yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyesp
+ ? yytable[yyi]
+ : yydefgoto[yylhs]);
}
if (yyesp == yyes_prev)
{
@@ -1683,14 +1681,13 @@ yyreduce:
/* Now 'shift' the result of the reduction. Determine what state
that goes to, based on the state we popped back to and the rule
number reduced by. */
-
- yyn = yyr1[yyn];
-
- yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
- if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
- yystate = yytable[yystate];
- else
- yystate = yydefgoto[yyn - YYNTOKENS];
+ {
+ const int yylhs = yyr1[yyn] - YYNTOKENS;
+ const int yyi = yypgoto[yylhs] + *yyssp;
+ yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
+ ? yytable[yyi]
+ : yydefgoto[yylhs]);
+ }
goto yynewstate;