From 1efe31185ff6b0bc22ff527098971bedf1ace5f4 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 1 Feb 2021 06:45:15 +0100 Subject: [PATCH] yacc: remove support for YYPRINT Its removal was annonced several times in NEWS (for Bison 3.5, 3.6, 3.7). * data/skeletons/c.m4, data/skeletons/yacc.c: Remove support for YYPRINT. * NEWS: Fix the mess introduced by the merge. Document the removal of YYPRINT. * doc/bison.texi (The YYPRINT Macro): Remove. --- NEWS | 49 +++++++++++++++++++++++++++-------------------- TODO | 5 +---- data/skeletons/c.m4 | 7 ------- data/skeletons/yacc.c | 9 --------- doc/bison.texi | 53 +-------------------------------------------------- src/parse-gram.c | 25 +++--------------------- src/parse-gram.h | 2 +- 7 files changed, 34 insertions(+), 116 deletions(-) diff --git a/NEWS b/NEWS index 8434ac25..fe6dda6f 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ GNU Bison NEWS -* Noteworthy changes in release 3.7.5 (2021-01-24) [stable] +* Noteworthy changes in release ?.? (????-??-??) [?] ** Deprecated features @@ -9,26 +9,9 @@ GNU Bison NEWS with Yacc, but not in C++. Warnings are now issued if `#define YYSTYPE` is used in C++, and eventually support will be removed. -** Bug fixes - -*** Counterexample Generation - - In some cases counterexample generation could crash. This is fixed. - -*** Fix Table Generation - - In some very rare conditions, when there are many useless tokens, it was - possible to generate incorrect parsers. - -*** GLR parsers now support %merge together with api.value.type=union. - -*** C++ parsers use noexcept in more places. - -*** Generated parsers avoid some warnings about signedness issues. - -*** C-language parsers now avoid warnings from pedantic clang. - -*** C-language parsers now work around quirks of HP-UX 11.23 (2003). + Support for the YYPRINT macro is removed. It worked only with yacc.c and + only for tokens. It was obsoleted by %printer, introduced in Bison 1.50 + (November 2002). ** Changes @@ -98,6 +81,30 @@ GNU Bison NEWS memory exhaustion. +* Noteworthy changes in release 3.7.5 (2021-01-24) [stable] + +** Bug fixes + +*** Counterexample Generation + + In some cases counterexample generation could crash. This is fixed. + +*** Fix Table Generation + + In some very rare conditions, when there are many useless tokens, it was + possible to generate incorrect parsers. + +*** GLR parsers now support %merge together with api.value.type=union. + +*** C++ parsers use noexcept in more places. + +*** Generated parsers avoid some warnings about signedness issues. + +*** C-language parsers now avoid warnings from pedantic clang. + +*** C-language parsers now work around quirks of HP-UX 11.23 (2003). + + * Noteworthy changes in release 3.7.4 (2020-11-14) [stable] ** Bug fixes diff --git a/TODO b/TODO index cb6ed40d..9e8dc183 100644 --- a/TODO +++ b/TODO @@ -462,9 +462,6 @@ $ ./tests/testsuite -l | grep errors | sed q 38: input.at:1730 errors * Short term -** Get rid of YYPRINT and b4_toknum -Besides yytoknum is wrong when api.token.raw is defined. - ** Better design for diagnostics The current implementation of diagnostics is ad hoc, it grew organically. It works as a series of calls to several functions, with dependency of the @@ -808,7 +805,7 @@ Equip the parser with a means to create the (visual) parse tree. # LocalWords: SymbolKind YYEMPTY YYUNDEF YYTNAME NUM yyntokens yytname sed # LocalWords: nonterminals yykind yycode YYNAMES yynames init getName conv # LocalWords: TokenKind ival yychar yylval yylexer Tolmer hoc -# LocalWords: Sobisch YYPTRDIFF ptrdiff Autotest YYPRINT toknum yytoknum +# LocalWords: Sobisch YYPTRDIFF ptrdiff Autotest toknum yytoknum # LocalWords: sym Wother stderr FP fixits xgettext fdiagnostics Graphviz # LocalWords: graphviz VCG bitset xml bw maint yytoken YYABORT deps # LocalWords: YYACCEPT yytranslate nonnegative destructors yyerrlab repo diff --git a/data/skeletons/c.m4 b/data/skeletons/c.m4 index 0bc0d7a6..a8e1a9d4 100644 --- a/data/skeletons/c.m4 +++ b/data/skeletons/c.m4 @@ -761,13 +761,6 @@ yy_symbol_value_print (FILE *yyo, ]b4_parse_param_use([yyoutput], [yylocationp])dnl [ if (!yyvaluep) return;] -dnl glr.c does not feature yytoknum. -m4_if(b4_skeleton, ["yacc.c"], -[[# ifdef YYPRINT - if (yykind < YYNTOKENS) - YYPRINT (yyo, yytoknum[yykind], *yyvaluep); -# endif -]])dnl b4_percent_code_get([[pre-printer]])dnl YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN b4_symbol_actions([printer]) diff --git a/data/skeletons/yacc.c b/data/skeletons/yacc.c index 4c214840..ee05ae1b 100644 --- a/data/skeletons/yacc.c +++ b/data/skeletons/yacc.c @@ -703,15 +703,6 @@ yysymbol_name (yysymbol_kind_t yysymbol) }]])[ #endif -#ifdef YYPRINT -/* YYTOKNUM[NUM] -- (External) token number corresponding to the - (internal) symbol number NUM (which must be that of a token). */ -static const ]b4_int_type_for([b4_toknum])[ yytoknum[] = -{ - ]b4_toknum[ -}; -#endif - #define YYPACT_NINF (]b4_pact_ninf[) #define yypact_value_is_default(Yyn) \ diff --git a/doc/bison.texi b/doc/bison.texi index 3f7922ab..879d7bd8 100644 --- a/doc/bison.texi +++ b/doc/bison.texi @@ -472,7 +472,6 @@ Tracing Your Parser * Enabling Traces:: Activating run-time trace support * Mfcalc Traces:: Extending @code{mfcalc} to support traces -* The YYPRINT Macro:: Obsolete interface for semantic value reports Invoking Bison @@ -10892,7 +10891,6 @@ When a Bison grammar compiles properly but parses ``incorrectly'', the @menu * Enabling Traces:: Activating run-time trace support * Mfcalc Traces:: Extending @code{mfcalc} to support traces -* The YYPRINT Macro:: Obsolete interface for semantic value reports @end menu @node Enabling Traces @@ -11156,49 +11154,6 @@ Cleanup: popping nterm input () @end example -@node The YYPRINT Macro -@subsection The @code{YYPRINT} Macro -@findex YYPRINT - -The @code{%printer} directive was introduced in Bison 1.50 (November 2002). -Before then, @code{YYPRINT} provided a similar feature, but only for -terminal symbols and only with the @file{yacc.c} skeleton. - -@deffn {Macro} YYPRINT (@var{stream}, @var{token}, @var{value}); -@findex YYPRINT -Deprecated, will be removed eventually. - -If you define @code{YYPRINT}, it should take three arguments. The parser -will pass a standard I/O stream, the numeric code for the token kind, and -the token value (from @code{yylval}). - -For @file{yacc.c} only. Obsoleted by @code{%printer}. -@end deffn - -Here is an example of @code{YYPRINT} suitable for the multi-function -calculator (@pxref{Mfcalc Declarations}): - -@example -%@{ - static void print_token_value (FILE *file, int type, YYSTYPE value); - #define YYPRINT(File, Type, Value) \ - print_token_value (File, Type, Value) -%@} - -@dots{} %% @dots{} %% @dots{} - -static void -print_token_value (FILE *file, yytoken_kind_t kind, YYSTYPE value) -@{ - if (kind == VAR) - fprintf (file, "%s", value.tptr->name); - else if (kind == NUM) - fprintf (file, "%d", value.val); -@} -@end example - -@xref{Mfcalc Traces}, for the proper use of @code{%printer}. - @c ================================================= Invoking Bison @node Invocation @@ -16018,12 +15973,6 @@ The parser function produced by Bison; call this function to start parsing. @xref{Parser Function}. @end deffn -@deffn {Macro} YYPRINT -Macro used to output token semantic values. For @file{yacc.c} only. -Deprecated, use @code{%printer} instead (@pxref{Printer Decl}). -@xref{The YYPRINT Macro}. -@end deffn - @deffn {Function} yypstate_delete The function to delete a parser instance, produced by Bison in push mode; call this function to delete the memory associated with a parser. @@ -16465,7 +16414,7 @@ London, Department of Computer Science, TR-00-12 (December 2000). @c LocalWords: symrec val tptr FUN func struct sym enum IEC syntaxes Byacc @c LocalWords: fun putsym getsym arith funs atan ptr malloc sizeof Lex pcc @c LocalWords: strlen strcpy fctn strcmp isalpha symbuf realloc isalnum DOTDOT -@c LocalWords: ptypes itype YYPRINT trigraphs yytname expseq vindex dtype Unary +@c LocalWords: ptypes itype trigraphs yytname expseq vindex dtype Unary @c LocalWords: Rhs YYRHSLOC LE nonassoc op deffn typeless yynerrs nonterminal @c LocalWords: yychar yydebug msg YYNTOKENS YYNNTS YYNRULES YYNSTATES reentrant @c LocalWords: cparse clex deftypefun NE defmac YYACCEPT YYABORT param yypstate diff --git a/src/parse-gram.c b/src/parse-gram.c index b826a955..0ce97a10 100644 --- a/src/parse-gram.c +++ b/src/parse-gram.c @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 3.7.5.284-c9445. */ +/* A Bison parser, made by GNU Bison 3.7.5.297-b46a. */ /* Bison implementation for Yacc-like parsers in C @@ -49,7 +49,7 @@ #define YYBISON 30705 /* Bison version string. */ -#define YYBISON_VERSION "3.7.5.284-c9445" +#define YYBISON_VERSION "3.7.5.297-b46a" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -728,21 +728,6 @@ yysymbol_name (yysymbol_kind_t yysymbol) } #endif -#ifdef YYPRINT -/* YYTOKNUM[NUM] -- (External) token number corresponding to the - (internal) symbol number NUM (which must be that of a token). */ -static const yytype_int16 yytoknum[] = -{ - 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, - 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, - 315 -}; -#endif - #define YYPACT_NINF (-148) #define yypact_value_is_default(Yyn) \ @@ -1051,7 +1036,7 @@ yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp) res += YYFPRINTF (yyo, "-%d", end_col); } return res; - } +} # define YY_LOCATION_PRINT(File, Loc) \ yy_location_print_ (File, &(Loc)) @@ -1087,10 +1072,6 @@ yy_symbol_value_print (FILE *yyo, YY_USE (yylocationp); if (!yyvaluep) return; -# ifdef YYPRINT - if (yykind < YYNTOKENS) - YYPRINT (yyo, yytoknum[yykind], *yyvaluep); -# endif /* "%code pre-printer" blocks. */ tron (yyo); diff --git a/src/parse-gram.h b/src/parse-gram.h index 8136581d..10a63528 100644 --- a/src/parse-gram.h +++ b/src/parse-gram.h @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 3.7.5.284-c9445. */ +/* A Bison parser, made by GNU Bison 3.7.5.297-b46a. */ /* Bison interface for Yacc-like parsers in C -- 2.11.4.GIT