mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-19 01:03:04 +00:00
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:
@@ -781,7 +781,7 @@ yy_symbol_print (FILE *yyo,
|
|||||||
YYFPRINTF (yyo, "%s %s (",
|
YYFPRINTF (yyo, "%s %s (",
|
||||||
yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
|
yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
|
||||||
|
|
||||||
]b4_locations_if([ YY_LOCATION_PRINT (yyo, *yylocationp);
|
]b4_locations_if([ YYLOCATION_PRINT (yyo, yylocationp);
|
||||||
YYFPRINTF (yyo, ": ");
|
YYFPRINTF (yyo, ": ");
|
||||||
])dnl
|
])dnl
|
||||||
[ yy_symbol_value_print (yyo, yykind, yyvaluep]dnl
|
[ yy_symbol_value_print (yyo, yykind, yyvaluep]dnl
|
||||||
@@ -1038,17 +1038,24 @@ m4_define([b4_yylloc_default_define],
|
|||||||
#endif
|
#endif
|
||||||
]])
|
]])
|
||||||
|
|
||||||
# b4_yy_location_print_define
|
# b4_yylocation_print_define
|
||||||
# ---------------------------
|
# --------------------------
|
||||||
# Define YY_LOCATION_PRINT.
|
# Define YYLOCATION_PRINT.
|
||||||
m4_define([b4_yy_location_print_define],
|
m4_define([b4_yylocation_print_define],
|
||||||
[b4_locations_if([[
|
[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
|
This macro was not mandated originally: define only if we know
|
||||||
we won't break user code: when these are the locations we know. */
|
we won't break user code: when these are the locations we know. */
|
||||||
|
|
||||||
# ifndef YY_LOCATION_PRINT
|
# ifndef YYLOCATION_PRINT
|
||||||
# if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
|
|
||||||
|
# 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. */
|
/* 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;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
# define YY_LOCATION_PRINT(File, Loc) \
|
# define YYLOCATION_PRINT yy_location_print_
|
||||||
yy_location_print_ (File, &(Loc))
|
|
||||||
|
/* 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
|
# 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
|
||||||
# endif /* !defined YY_LOCATION_PRINT */]])
|
# endif /* !defined YYLOCATION_PRINT */]])
|
||||||
])
|
])
|
||||||
|
|
||||||
# b4_yyloc_default
|
# b4_yyloc_default
|
||||||
|
|||||||
@@ -683,7 +683,7 @@ yylhsNonterm (yyRuleNum yyrule)
|
|||||||
YY_IGNORE_USELESS_CAST_END \
|
YY_IGNORE_USELESS_CAST_END \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
]b4_yy_location_print_define[
|
]b4_yylocation_print_define[
|
||||||
|
|
||||||
]b4_yy_symbol_print_define[
|
]b4_yy_symbol_print_define[
|
||||||
|
|
||||||
|
|||||||
@@ -553,8 +553,6 @@ enum YYRESULTTAG { yyok, yyaccept, yyabort, yyerr };
|
|||||||
|
|
||||||
#if ]b4_api_PREFIX[DEBUG
|
#if ]b4_api_PREFIX[DEBUG
|
||||||
|
|
||||||
]b4_yy_location_print_define[
|
|
||||||
|
|
||||||
#define YYCDEBUG if (!yydebug) {} else std::cerr
|
#define YYCDEBUG if (!yydebug) {} else std::cerr
|
||||||
|
|
||||||
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
|
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
|
||||||
|
|||||||
@@ -768,7 +768,7 @@ do { \
|
|||||||
YYFPRINTF Args; \
|
YYFPRINTF Args; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
]b4_yy_location_print_define[
|
]b4_yylocation_print_define[
|
||||||
|
|
||||||
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
|
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
|
||||||
do { \
|
do { \
|
||||||
|
|||||||
Reference in New Issue
Block a user