yacc.c: improve formatting of the generated code

* data/skeletons/yacc.c (yy_reduce_print): here.
This commit is contained in:
Akim Demaille
2020-05-02 10:03:29 +02:00
parent 6275137378
commit 76c3bccf40
3 changed files with 11 additions and 12 deletions

View File

@@ -132,6 +132,7 @@ m4_define([b4_rhs_value],
# b4_lhs_location()
# -----------------
# Expansion of @$.
# Overparenthetized to avoid obscure problems with "foo$$bar = foo$1bar".
m4_define([b4_lhs_location],
[(yyloc)])
@@ -140,6 +141,7 @@ m4_define([b4_lhs_location],
# ---------------------------------
# Expansion of @POS, where the current rule has RULE-LENGTH symbols
# on RHS.
# Overparenthetized to avoid obscure problems with "foo$$bar = foo$1bar".
m4_define([b4_rhs_location],
[(yylsp@{b4_subtract([$2], [$1])@})])
@@ -826,9 +828,8 @@ yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,]b4_locations_if([[ YYLTYPE *
YYFPRINTF (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr,
YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
&]b4_rhs_value(yynrhs, yyi + 1)[
]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
b4_user_args[);
&]b4_rhs_value(yynrhs, yyi + 1)[]b4_locations_if([,
&]b4_rhs_location(yynrhs, yyi + 1))[]b4_user_args[);
YYFPRINTF (stderr, "\n");
}
}

View File

@@ -1,4 +1,4 @@
/* A Bison parser, made by GNU Bison 3.5.90. */
/* A Bison parser, made by GNU Bison 3.5.91. */
/* Bison implementation for Yacc-like parsers in C
@@ -49,7 +49,7 @@
#define YYBISON 1
/* Bison version. */
#define YYBISON_VERSION "3.5.90"
#define YYBISON_VERSION "3.5.91"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -1304,8 +1304,8 @@ yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp,
YYFPRINTF (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr,
YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
&yyvsp[(yyi + 1) - (yynrhs)]
, &(yylsp[(yyi + 1) - (yynrhs)]) );
&yyvsp[(yyi + 1) - (yynrhs)],
&(yylsp[(yyi + 1) - (yynrhs)]));
YYFPRINTF (stderr, "\n");
}
}
@@ -2738,10 +2738,8 @@ yyerrlab1:
YY_IGNORE_MAYBE_UNINITIALIZED_END
yyerror_range[2] = yylloc;
/* Using YYLLOC is tempting, but would change the location of
the lookahead. YYLOC is available though. */
YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
*++yylsp = yyloc;
++yylsp;
YYLLOC_DEFAULT (*yylsp, yyerror_range, 2);
/* Shift the error token. */
YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);

View File

@@ -1,4 +1,4 @@
/* A Bison parser, made by GNU Bison 3.5.90. */
/* A Bison parser, made by GNU Bison 3.5.91. */
/* Bison interface for Yacc-like parsers in C