c: rename YY_LOCATION_PRINT as YYLOCATION_PRINT and make it public

It is very helpful to be able to look at the locations in the debug
traces, let's provide the users with (i) a means to do that for their
location types, and (ii) a public macro to print locations when debug
traces are enabled.

* data/skeletons/c.m4 (b4_yy_location_print_define): Rename as...
(b4_yylocation_print_define): this.
Define YYLOCATION_PRINT instead of YY_LOCATION_PRINT.
Ensure backward compatibility for those who might have defined/used
YY_LOCATION_PRINT in spite the warnings.
Adjust dependencies.
* data/skeletons/glr2.cc: We don't use YYLOCATION_PRINT here.
This commit is contained in:
Akim Demaille
2021-02-03 08:21:35 +01:00
parent 96b881094b
commit c80b404dfa
4 changed files with 29 additions and 16 deletions

View File

@@ -781,7 +781,7 @@ yy_symbol_print (FILE *yyo,
YYFPRINTF (yyo, "%s %s (",
yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
]b4_locations_if([ YY_LOCATION_PRINT (yyo, *yylocationp);
]b4_locations_if([ YYLOCATION_PRINT (yyo, yylocationp);
YYFPRINTF (yyo, ": ");
])dnl
[ yy_symbol_value_print (yyo, yykind, yyvaluep]dnl
@@ -1038,17 +1038,24 @@ m4_define([b4_yylloc_default_define],
#endif
]])
# b4_yy_location_print_define
# ---------------------------
# Define YY_LOCATION_PRINT.
m4_define([b4_yy_location_print_define],
# b4_yylocation_print_define
# --------------------------
# Define YYLOCATION_PRINT.
m4_define([b4_yylocation_print_define],
[b4_locations_if([[
/* YY_LOCATION_PRINT -- Print the location on the stream.
/* YYLOCATION_PRINT -- Print the location on the stream.
This macro was not mandated originally: define only if we know
we won't break user code: when these are the locations we know. */
# ifndef YY_LOCATION_PRINT
# if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
# ifndef YYLOCATION_PRINT
# if defined YY_LOCATION_PRINT
/* Temporary convenience wrapper in case some people defined the
undocumented and private YY_LOCATION_PRINT macros. */
# define YYLOCATION_PRINT(File, Loc) YY_LOCATION_PRINT(File, *(Loc))
# elif defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
/* Print *YYLOCP on YYO. Private, do not rely on its existence. */
@@ -1078,13 +1085,21 @@ yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
return res;
}
# define YY_LOCATION_PRINT(File, Loc) \
yy_location_print_ (File, &(Loc))
# define YYLOCATION_PRINT yy_location_print_
/* Temporary convenience wrapper in case some people defined the
undocumented and private YY_LOCATION_PRINT macros. */
# define YY_LOCATION_PRINT(File, Loc) YYLOCATION_PRINT(File, &(Loc))
# else
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
# define YYLOCATION_PRINT(File, Loc) ((void) 0)
/* Temporary convenience wrapper in case some people defined the
undocumented and private YY_LOCATION_PRINT macros. */
# define YY_LOCATION_PRINT YYLOCATION_PRINT
# endif
# endif /* !defined YY_LOCATION_PRINT */]])
# endif /* !defined YYLOCATION_PRINT */]])
])
# b4_yyloc_default

View File

@@ -683,7 +683,7 @@ yylhsNonterm (yyRuleNum yyrule)
YY_IGNORE_USELESS_CAST_END \
} while (0)
]b4_yy_location_print_define[
]b4_yylocation_print_define[
]b4_yy_symbol_print_define[

View File

@@ -553,8 +553,6 @@ enum YYRESULTTAG { yyok, yyaccept, yyabort, yyerr };
#if ]b4_api_PREFIX[DEBUG
]b4_yy_location_print_define[
#define YYCDEBUG if (!yydebug) {} else std::cerr
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \

View File

@@ -768,7 +768,7 @@ do { \
YYFPRINTF Args; \
} while (0)
]b4_yy_location_print_define[
]b4_yylocation_print_define[
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
do { \