yacc: comply with recent POSIX updates: declare yyerror and yylex
[bison.git] / NEWS
bloba908bdb016d176de50c4eec92e7d6cd104a96dcc
1 GNU Bison NEWS
3 * Noteworthy changes in release ?.? (????-??-??) [?]
5 ** Backward incompatible changes
7   In conformance with the recommendations of the Graphviz team
8   (https://marc.info/?l=graphviz-devel&m=129418103126092), `-g`/`--graph`
9   now generates a *.gv file by default, instead of *.dot.  A transition
10   started in Bison 3.4.
12   To comply with the latest POSIX standard, in Yacc compatibility mode
13   (options `-y`/`--yacc`) Bison now generates prototypes for yyerror and
14   yylex.  In some situations, this is breaking compatibility: if the user
15   has already declared these functions but with some differences (e.g., to
16   declare them as static, or to use specific attributes), the generated
17   parser will fail to compile.  To disable these prototypes, #define yyerror
18   (to `yyerror`), and likewise for yylex.
20 ** Deprecated features
22   Support for the YYPRINT macro is removed. It worked only with yacc.c and
23   only for tokens.  It was obsoleted by %printer, introduced in Bison 1.50
24   (November 2002).
26   It has always been recommended to prefer `%define api.value.type foo` to
27   `#define YYSTYPE foo`.  The latter is supported in C for compatibility
28   with Yacc, but not in C++.  Warnings are now issued if `#define YYSTYPE`
29   is used in C++, and eventually support will be removed.
31   In C++ code, prefer value_type to semantic_type to denote the semantic
32   value type, which is specified by the `api.value.type` %define variable.
34 ** New features
36 *** A skeleton for the D programming language
38   The "lalr1.d" skeleton is now officially part of Bison.
40   It was originally contributed by Oliver Mangold, based on Paolo Bonzini's
41   lalr1.java, and was improved by H. S. Teoh.  Adela Vais then took over
42   maintenance and invested a lot of efforts to complete, test and document
43   it.
45   It now supports all the bells and whistles of the other deterministic
46   parsers, which include: pull/push interfaces, verbose and custom error
47   messages, lookahead correction, token constructors, internationalization,
48   locations, printers, token and symbol prefixes, etc.
50   Two examples demonstrate the D parsers: a basic one (examples/d/simple),
51   and an advanced one (examples/d/calc).
53 *** Option -H, --header and directive %header
55   The option `-H`/`--header` supersedes the option `--defines`, and the
56   directive %header supersedes %defines.  Both `--defines` and `%defines`
57   are, of course, maintained for backward compatibility.
59 *** Option --html
61   Since version 2.4 Bison can be used to generate HTML reports.  However it
62   was a two-step process: first bison must be invoked with option `--xml`,
63   and then xsltproc must be run to the convert the XML reports into HTML.
65   The new option `--html` combines these steps.  The xsltproc program must
66   be available.
68 *** A C++ native GLR parser
70   A new version of the generated C++ GLR parser was added as "glr2.cc". It
71   is forked from the existing glr.c/cc parser, with the objective of making
72   it a more modern, truly C++ parser (instead of a C++ wrapper around a C
73   parser).  Down the line, the goal is to support `%define api.value.type
74   variant` and maybe share code with lalr1.cc.
76   The current parser should be identical in terms of interface, functionality
77   and performance to "glr.cc". To try it out, simply use
79   %skeleton "glr2.cc"
81   It will eventually replace "glr.cc".  However we need user feedback on
82   this skeleton.  _Please_ report your results and comments about it.
84 *** Counterexamples
86   Counterexamples now show the rule numbers, and always show ε for rules
87   with an empty right-hand side.  For instance
89     exp
90     ↳ 1: e1       e2     "a"
91          ↳ 3: ε • ↳ 1: ε
93   instead of
95     exp
96     ↳ e1  e2  "a"
97       ↳ • ↳ ε
99 *** Lookahead correction in Java
101   The Java skeleton (lalr1.java) now supports LAC, via the `parse.lac`
102   %define variable.
104 *** Abort parsing for memory exhaustion (C)
106   User actions may now use `YYNOMEM` (similar to `YYACCEPT` and `YYABORT`)
107   to abort the current parse with memory exhaustion.
109 *** Printing locations in debug traces (C)
111   The `YYLOCATION_PRINT(File, Loc)` macro prints a location.  It is defined
112   when (i) locations are enabled, (ii) the default type for locations is
113   used, (iii) debug traces are enabled, and (iv) `YYLOCATION_PRINT` is not
114   already defined.
116   Users may define `YYLOCATION_PRINT` to cover other cases.
118 *** GLR traces
120   There were no debug traces for deferred calls to user actions.  They are
121   logged now.
124 * Noteworthy changes in release 3.7.6 (2021-03-08) [stable]
126 ** Bug fixes
128 *** Reused Push Parsers
130   When a push-parser state structure is used for multiple parses, it was
131   possible for some state to leak from one run into the following one.
133 *** Fix Table Generation
135   In some very rare conditions, when there are many useless tokens, it was
136   possible to generate incorrect parsers.
139 * Noteworthy changes in release 3.7.5 (2021-01-24) [stable]
141 ** Bug fixes
143 *** Counterexample Generation
145   In some cases counterexample generation could crash.  This is fixed.
147 *** Fix Table Generation
149   In some very rare conditions, when there are many useless tokens, it was
150   possible to generate incorrect parsers.
152 *** GLR parsers now support %merge together with api.value.type=union.
154 *** C++ parsers use noexcept in more places.
156 *** Generated parsers avoid some warnings about signedness issues.
158 *** C-language parsers now avoid warnings from pedantic clang.
160 *** C-language parsers now work around quirks of HP-UX 11.23 (2003).
163 * Noteworthy changes in release 3.7.4 (2020-11-14) [stable]
165 ** Bug fixes
167 *** Bug fixes in yacc.c
169   In Yacc mode, all the tokens are defined twice: once as an enum, and then
170   as a macro.  YYEMPTY was missing its macro.
172 *** Bug fixes in lalr1.cc
174   The lalr1.cc skeleton used to emit internal assertions (using YY_ASSERT)
175   even when the `parse.assert` %define variable is not enabled.  It no
176   longer does.
178   The private internal macro YY_ASSERT now obeys the `api.prefix` %define
179   variable.
181   When there is a very large number of tokens, some assertions could be long
182   enough to hit arbitrary limits in Visual C++.  They have been rewritten to
183   work around this limitation.
185 ** Changes
187   The YYBISON macro in generated "regular C parsers" (from the "yacc.c"
188   skeleton) used to be defined to 1.  It is now defined to the version of
189   Bison as an integer (e.g., 30704 for version 3.7.4).
192 * Noteworthy changes in release 3.7.3 (2020-10-13) [stable]
194 ** Bug fixes
196   Fix concurrent build issues.
198   The bison executable is no longer linked uselessly against libreadline.
200   Fix incorrect use of yytname in glr.cc.
203 * Noteworthy changes in release 3.7.2 (2020-09-05) [stable]
205   This release of Bison fixes all known bugs reported for Bison in MITRE's
206   Common Vulnerabilities and Exposures (CVE) system.  These vulnerabilities
207   are only about bison-the-program itself, not the generated code.
209   Although these bugs are typically irrelevant to how Bison is used, they
210   are worth fixing if only to give users peace of mind.
212   There is no known vulnerability in the generated parsers.
214 ** Bug fixes
216   Fix concurrent build issues (introduced in Bison 3.5).
218   Push parsers always use YYMALLOC/YYFREE (no direct calls to malloc/free).
220   Fix portability issues of the test suite, and of bison itself.
222   Some unlikely crashes found by fuzzing have been fixed.  This is only
223   about bison itself, not the generated parsers.
226 * Noteworthy changes in release 3.7.1 (2020-08-02) [stable]
228 ** Bug fixes
230   Crash when a token alias contains a NUL byte.
232   Portability issues with libtextstyle.
234   Portability issues of Bison itself with MSVC.
236 ** Changes
238   Improvements and fixes in the documentation.
240   More precise location about symbol type redefinitions.
243 * Noteworthy changes in release 3.7 (2020-07-23) [stable]
245 ** Deprecated features
247   The YYPRINT macro, which works only with yacc.c and only for tokens, was
248   obsoleted long ago by %printer, introduced in Bison 1.50 (November 2002).
249   It is deprecated and its support will be removed eventually.
251   In conformance with the recommendations of the Graphviz team, in the next
252   version Bison the option `--graph` will generate a *.gv file by default,
253   instead of *.dot.  A transition started in Bison 3.4.
255 ** New features
257 *** Counterexample Generation
259   Contributed by Vincent Imbimbo.
261   When given `-Wcounterexamples`/`-Wcex`, bison will now output
262   counterexamples for conflicts.
264 **** Unifying Counterexamples
266   Unifying counterexamples are strings which can be parsed in two ways due
267   to the conflict.  For example on a grammar that contains the usual
268   "dangling else" ambiguity:
270     $ bison else.y
271     else.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
272     else.y: note: rerun with option '-Wcounterexamples' to generate conflict counterexamples
274     $ bison else.y -Wcex
275     else.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
276     else.y: warning: shift/reduce conflict on token "else" [-Wcounterexamples]
277       Example: "if" exp "then" "if" exp "then" exp • "else" exp
278       Shift derivation
279         exp
280         ↳ "if" exp "then" exp
281                           ↳ "if" exp "then" exp • "else" exp
282       Example: "if" exp "then" "if" exp "then" exp • "else" exp
283       Reduce derivation
284         exp
285         ↳ "if" exp "then" exp                     "else" exp
286                           ↳ "if" exp "then" exp •
288   When text styling is enabled, colors are used in the examples and the
289   derivations to highlight the structure of both analyses.  In this case,
291     "if" exp "then" [ "if" exp "then" exp • ] "else" exp
293   vs.
295     "if" exp "then" [ "if" exp "then" exp • "else" exp ]
298   The counterexamples are "focused", in two different ways.  First, they do
299   not clutter the output with all the derivations from the start symbol,
300   rather they start on the "conflicted nonterminal". They go straight to the
301   point.  Second, they don't "expand" nonterminal symbols uselessly.
303 **** Nonunifying Counterexamples
305   In the case of the dangling else, Bison found an example that can be
306   parsed in two ways (therefore proving that the grammar is ambiguous).
307   When it cannot find such an example, it instead generates two examples
308   that are the same up until the dot:
310     $ bison foo.y
311     foo.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
312     foo.y: note: rerun with option '-Wcounterexamples' to generate conflict counterexamples
313     foo.y:4.4-7: warning: rule useless in parser due to conflicts [-Wother]
314         4 | a: expr
315           |    ^~~~
317     $ bison -Wcex foo.y
318     foo.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
319     foo.y: warning: shift/reduce conflict on token ID [-Wcounterexamples]
320       First example: expr • ID ',' ID $end
321       Shift derivation
322         $accept
323         ↳ s                      $end
324           ↳ a                 ID
325             ↳ expr
326               ↳ expr • ID ','
327       Second example: expr • ID $end
328       Reduce derivation
329         $accept
330         ↳ s             $end
331           ↳ a        ID
332             ↳ expr •
333     foo.y:4.4-7: warning: rule useless in parser due to conflicts [-Wother]
334         4 | a: expr
335           |    ^~~~
337   In these cases, the parser usually doesn't have enough lookahead to
338   differentiate the two given examples.
340 **** Reports
342   Counterexamples are also included in the report when given
343   `--report=counterexamples`/`-rcex` (or `--report=all`), with more
344   technical details:
346     State 7
348       1 exp: "if" exp "then" exp •  [$end, "then", "else"]
349       2    | "if" exp "then" exp • "else" exp
351       "else"  shift, and go to state 8
353       "else"    [reduce using rule 1 (exp)]
354       $default  reduce using rule 1 (exp)
356       shift/reduce conflict on token "else":
357           1 exp: "if" exp "then" exp •
358           2 exp: "if" exp "then" exp • "else" exp
359         Example: "if" exp "then" "if" exp "then" exp • "else" exp
360         Shift derivation
361           exp
362           ↳ "if" exp "then" exp
363                             ↳ "if" exp "then" exp • "else" exp
364         Example: "if" exp "then" "if" exp "then" exp • "else" exp
365         Reduce derivation
366           exp
367           ↳ "if" exp "then" exp                     "else" exp
368                             ↳ "if" exp "then" exp •
370 *** File prefix mapping
372   Contributed by Joshua Watt.
374   Bison learned a new argument, `--file-prefix-map OLD=NEW`.  Any file path
375   in the output (specifically `#line` directives and `#ifdef` header guards)
376   that begins with the prefix OLD will have it replaced with the prefix NEW,
377   similar to the `-ffile-prefix-map` in GCC.  This option can be used to
378   make bison output reproducible.
380 ** Changes
382 *** Diagnostics
384   When text styling is enabled and the terminal supports it, the warnings
385   now include hyperlinks to the documentation.
387 *** Relocatable installation
389   When installed to be relocatable (via `configure --enable-relocatable`),
390   bison will now also look for a relocated m4.
392 *** C++ file names
394   The `filename_type` %define variable was renamed `api.filename.type`.
395   Instead of
397     %define filename_type "symbol"
399   write
401     %define api.filename.type {symbol}
403   (Or let `bison --update` do it for you).
405   It now defaults to `const std::string` instead of `std::string`.
407 *** Deprecated %define variable names
409   The following variables have been renamed for consistency.  Backward
410   compatibility is ensured, but upgrading is recommended.
412     filename_type       -> api.filename.type
413     package             -> api.package
415 *** Push parsers no longer clear their state when parsing is finished
417   Previously push-parsers cleared their state when parsing was finished (on
418   success and on failure).  This made it impossible to check if there were
419   parse errors, since `yynerrs` was also reset.  This can be especially
420   troublesome when used in autocompletion, since a parser with error
421   recovery would suggest (irrelevant) expected tokens even if there were
422   failures.
424   Now the parser state can be examined when parsing is finished.  The parser
425   state is reset when starting a new parse.
427 ** Documentation
429 *** Examples
431   The bistromathic demonstrates %param and how to quote sources in the error
432   messages:
434     > 123 456
435     1.5-7: syntax error: expected end of file or + or - or * or / or ^ before number
436         1 | 123 456
437           |     ^~~
439 ** Bug fixes
441 *** Include the generated header (yacc.c)
443   Historically, when --defines was used, bison generated a header and pasted
444   an exact copy of it into the generated parser implementation file.  Since
445   Bison 3.4 it is possible to specify that the header should be `#include`d,
446   and how.  For instance
448     %define api.header.include {"parse.h"}
450   or
452     %define api.header.include {<parser/parse.h>}
454   Now api.header.include defaults to `"header-basename"`, as was intended in
455   Bison 3.4, where `header-basename` is the basename of the generated
456   header.  This is disabled when the generated header is `y.tab.h`, to
457   comply with Automake's ylwrap.
459 *** String aliases are faithfully propagated
461   Bison used to interpret user strings (i.e., decoding backslash escapes)
462   when reading them, and to escape them (i.e., issue non-printable
463   characters as backslash escapes, taking the locale into account) when
464   outputting them.  As a consequence non-ASCII strings (say in UTF-8) ended
465   up "ciphered" as sequences of backslash escapes.  This happened not only
466   in the generated sources (where the compiler will reinterpret them), but
467   also in all the generated reports (text, xml, html, dot, etc.).  Reports
468   were therefore not readable when string aliases were not pure ASCII.
469   Worse yet: the output depended on the user's locale.
471   Now Bison faithfully treats the string aliases exactly the way the user
472   spelled them.  This fixes all the aforementioned problems.  However, now,
473   string aliases semantically equivalent but syntactically different (e.g.,
474   "A", "\x41", "\101") are considered to be different.
476 *** Crash when generating IELR
478   An old, well hidden, bug in the generation of IELR parsers was fixed.
481 * Noteworthy changes in release 3.6.4 (2020-06-15) [stable]
483 ** Bug fixes
485   In glr.cc some internal macros leaked in the user's code, and could damage
486   access to the token kinds.
489 * Noteworthy changes in release 3.6.3 (2020-06-03) [stable]
491 ** Bug fixes
493   Incorrect comments in the generated parsers.
495   Warnings in push parsers (yacc.c).
497   Incorrect display of gotos in LAC traces (lalr1.cc).
500 * Noteworthy changes in release 3.6.2 (2020-05-17) [stable]
502 ** Bug fixes
504   Some tests were fixed.
506   When token aliases contain comment delimiters:
508     %token FOO "/* foo */"
510   bison used to emit "nested" comments, which is invalid C.
513 * Noteworthy changes in release 3.6.1 (2020-05-10) [stable]
515 ** Bug fixes
517   Restored ANSI-C compliance in yacc.c.
519   GNU readline portability issues.
521   In C++, yy::parser::symbol_name is now a public member, as was intended.
523 ** New features
525   In C++, yy::parser::symbol_type now has a public name() member function.
528 * Noteworthy changes in release 3.6 (2020-05-08) [stable]
530 ** Backward incompatible changes
532   TL;DR: replace "#define YYERROR_VERBOSE 1" by "%define parse.error verbose".
534   The YYERROR_VERBOSE macro is no longer supported; the parsers that still
535   depend on it will now produce Yacc-like error messages (just "syntax
536   error").  It was superseded by the "%error-verbose" directive in Bison
537   1.875 (2003-01-01).  Bison 2.6 (2012-07-19) clearly announced that support
538   for YYERROR_VERBOSE would be removed.  Note that since Bison 3.0
539   (2013-07-25), "%error-verbose" is deprecated in favor of "%define
540   parse.error verbose".
542 ** Deprecated features
544   The YYPRINT macro, which works only with yacc.c and only for tokens, was
545   obsoleted long ago by %printer, introduced in Bison 1.50 (November 2002).
546   It is deprecated and its support will be removed eventually.
548 ** New features
550 *** Improved syntax error messages
552   Two new values for the %define parse.error variable offer more control to
553   the user.  Available in all the skeletons (C, C++, Java).
555 **** %define parse.error detailed
557   The behavior of "%define parse.error detailed" is closely resembling that
558   of "%define parse.error verbose" with a few exceptions.  First, it is safe
559   to use non-ASCII characters in token aliases (with 'verbose', the result
560   depends on the locale with which bison was run).  Second, a yysymbol_name
561   function is exposed to the user, instead of the yytnamerr function and the
562   yytname table.  Third, token internationalization is supported (see
563   below).
565 **** %define parse.error custom
567   With this directive, the user forges and emits the syntax error message
568   herself by defining the yyreport_syntax_error function.  A new type,
569   yypcontext_t, captures the circumstances of the error, and provides the
570   user with functions to get details, such as yypcontext_expected_tokens to
571   get the list of expected token kinds.
573   A possible implementation of yyreport_syntax_error is:
575     int
576     yyreport_syntax_error (const yypcontext_t *ctx)
577     {
578       int res = 0;
579       YY_LOCATION_PRINT (stderr, *yypcontext_location (ctx));
580       fprintf (stderr, ": syntax error");
581       // Report the tokens expected at this point.
582       {
583         enum { TOKENMAX = 10 };
584         yysymbol_kind_t expected[TOKENMAX];
585         int n = yypcontext_expected_tokens (ctx, expected, TOKENMAX);
586         if (n < 0)
587           // Forward errors to yyparse.
588           res = n;
589         else
590           for (int i = 0; i < n; ++i)
591             fprintf (stderr, "%s %s",
592                      i == 0 ? ": expected" : " or", yysymbol_name (expected[i]));
593       }
594       // Report the unexpected token.
595       {
596         yysymbol_kind_t lookahead = yypcontext_token (ctx);
597         if (lookahead != YYSYMBOL_YYEMPTY)
598           fprintf (stderr, " before %s", yysymbol_name (lookahead));
599       }
600       fprintf (stderr, "\n");
601       return res;
602     }
604 **** Token aliases internationalization
606   When the %define variable parse.error is set to `custom` or `detailed`,
607   one may specify which token aliases are to be translated using _().  For
608   instance
610     %token
611         PLUS   "+"
612         MINUS  "-"
613       <double>
614         NUM _("number")
615       <symrec*>
616         FUN _("function")
617         VAR _("variable")
619   In that case the user must define _() and N_(), and yysymbol_name returns
620   the translated symbol (i.e., it returns '_("variable")' rather that
621   '"variable"').  In Java, the user must provide an i18n() function.
623 *** List of expected tokens (yacc.c)
625   Push parsers may invoke yypstate_expected_tokens at any point during
626   parsing (including even before submitting the first token) to get the list
627   of possible tokens.  This feature can be used to propose autocompletion
628   (see below the "bistromathic" example).
630   It makes little sense to use this feature without enabling LAC (lookahead
631   correction).
633 *** Returning the error token
635   When the scanner returns an invalid token or the undefined token
636   (YYUNDEF), the parser generates an error message and enters error
637   recovery.  Because of that error message, most scanners that find lexical
638   errors generate an error message, and then ignore the invalid input
639   without entering the error-recovery.
641   The scanners may now return YYerror, the error token, to enter the
642   error-recovery mode without triggering an additional error message.  See
643   the bistromathic for an example.
645 *** Deep overhaul of the symbol and token kinds
647   To avoid the confusion with types in programming languages, we now refer
648   to token and symbol "kinds" instead of token and symbol "types".  The
649   documentation and error messages have been revised.
651   All the skeletons have been updated to use dedicated enum types rather
652   than integral types.  Special symbols are now regular citizens, instead of
653   being declared in ad hoc ways.
655 **** Token kinds
657   The "token kind" is what is returned by the scanner, e.g., PLUS, NUMBER,
658   LPAREN, etc.  While backward compatibility is of course ensured, users are
659   nonetheless invited to replace their uses of "enum yytokentype" by
660   "yytoken_kind_t".
662   This type now also includes tokens that were previously hidden: YYEOF (end
663   of input), YYUNDEF (undefined token), and YYerror (error token).  They
664   now have string aliases, internationalized when internationalization is
665   enabled.  Therefore, by default, error messages now refer to "end of file"
666   (internationalized) rather than the cryptic "$end", or to "invalid token"
667   rather than "$undefined".
669   Therefore in most cases it is now useless to define the end-of-line token
670   as follows:
672     %token T_EOF 0 "end of file"
674   Rather simply use "YYEOF" in your scanner.
676 **** Symbol kinds
678   The "symbol kinds" is what the parser actually uses.  (Unless the
679   api.token.raw %define variable is used, the symbol kind of a terminal
680   differs from the corresponding token kind.)
682   They are now exposed as a enum, "yysymbol_kind_t".
684   This allows users to tailor the error messages the way they want, or to
685   process some symbols in a specific way in autocompletion (see the
686   bistromathic example below).
688 *** Modernize display of explanatory statements in diagnostics
690   Since Bison 2.7, output was indented four spaces for explanatory
691   statements.  For example:
693     input.y:2.7-13: error: %type redeclaration for exp
694     input.y:1.7-11:     previous declaration
696   Since the introduction of caret-diagnostics, it became less clear.  This
697   indentation has been removed and submessages are displayed similarly as in
698   GCC:
700     input.y:2.7-13: error: %type redeclaration for exp
701         2 | %type <float> exp
702           |       ^~~~~~~
703     input.y:1.7-11: note: previous declaration
704         1 | %type <int> exp
705           |       ^~~~~
707   Contributed by Victor Morales Cayuela.
709 *** C++
711   The token and symbol kinds are yy::parser::token_kind_type and
712   yy::parser::symbol_kind_type.
714   The symbol_type::kind() member function allows to get the kind of a
715   symbol.  This can be used to write unit tests for scanners, e.g.,
717     yy::parser::symbol_type t = make_NUMBER ("123");
718     assert (t.kind () == yy::parser::symbol_kind::S_NUMBER);
719     assert (t.value.as<int> () == 123);
721 ** Documentation
723 *** User Manual
725   In order to avoid ambiguities with "type" as in "typing", we now refer to
726   the "token kind" (e.g., `PLUS`, `NUMBER`, etc.) rather than the "token
727   type".  We now also refer to the "symbol type" (e.g., `PLUS`, `expr`,
728   etc.).
730 *** Examples
732   There are now examples/java: a very simple calculator, and a more complete
733   one (push-parser, location tracking, and debug traces).
735   The lexcalc example (a simple example in C based on Flex and Bison) now
736   also demonstrates location tracking.
739   A new C example, bistromathic, is a fully featured interactive calculator
740   using many Bison features: pure interface, push parser, autocompletion
741   based on the current parser state (using yypstate_expected_tokens),
742   location tracking, internationalized custom error messages, lookahead
743   correction, rich debug traces, etc.
745   It shows how to depend on the symbol kinds to tailor autocompletion.  For
746   instance it recognizes the symbol kind "VARIABLE" to propose
747   autocompletion on the existing variables, rather than of the word
748   "variable".
751 * Noteworthy changes in release 3.5.4 (2020-04-05) [stable]
753 ** WARNING: Future backward-incompatibilities!
755   TL;DR: replace "#define YYERROR_VERBOSE 1" by "%define parse.error verbose".
757   Bison 3.6 will no longer support the YYERROR_VERBOSE macro; the parsers
758   that still depend on it will produce Yacc-like error messages (just
759   "syntax error").  It was superseded by the "%error-verbose" directive in
760   Bison 1.875 (2003-01-01).  Bison 2.6 (2012-07-19) clearly announced that
761   support for YYERROR_VERBOSE would be removed.  Note that since Bison 3.0
762   (2013-07-25), "%error-verbose" is deprecated in favor of "%define
763   parse.error verbose".
765 ** Bug fixes
767   Fix portability issues of the package itself on old compilers.
769   Fix api.token.raw support in Java.
772 * Noteworthy changes in release 3.5.3 (2020-03-08) [stable]
774 ** Bug fixes
776   Error messages could quote lines containing zero-width characters (such as
777   \005) with incorrect styling.  Fixes for similar issues with unexpectedly
778   short lines (e.g., the file was changed between parsing and diagnosing).
780   Some unlikely crashes found by fuzzing have been fixed.  This is only
781   about bison itself, not the generated parsers.
784 * Noteworthy changes in release 3.5.2 (2020-02-13) [stable]
786 ** Bug fixes
788   Portability issues and minor cosmetic issues.
790   The lalr1.cc skeleton properly rejects unsupported values for parse.lac
791   (as yacc.c does).
794 * Noteworthy changes in release 3.5.1 (2020-01-19) [stable]
796 ** Bug fixes
798   Portability fixes.
800   Fix compiler warnings.
803 * Noteworthy changes in release 3.5 (2019-12-11) [stable]
805 ** Backward incompatible changes
807   Lone carriage-return characters (aka \r or ^M) in the grammar files are no
808   longer treated as end-of-lines.  This changes the diagnostics, and in
809   particular their locations.
811   In C++, line numbers and columns are now represented as 'int' not
812   'unsigned', so that integer overflow on positions is easily checkable via
813   'gcc -fsanitize=undefined' and the like.  This affects the API for
814   positions.  The default position and location classes now expose
815   'counter_type' (int), used to define line and column numbers.
817 ** Deprecated features
819   The YYPRINT macro, which works only with yacc.c and only for tokens, was
820   obsoleted long ago by %printer, introduced in Bison 1.50 (November 2002).
821   It is deprecated and its support will be removed eventually.
823 ** New features
825 *** Lookahead correction in C++
827   Contributed by Adrian Vogelsgesang.
829   The C++ deterministic skeleton (lalr1.cc) now supports LAC, via the
830   %define variable parse.lac.
832 *** Variable api.token.raw: Optimized token numbers (all skeletons)
834   In the generated parsers, tokens have two numbers: the "external" token
835   number as returned by yylex (which starts at 257), and the "internal"
836   symbol number (which starts at 3).  Each time yylex is called, a table
837   lookup maps the external token number to the internal symbol number.
839   When the %define variable api.token.raw is set, tokens are assigned their
840   internal number, which saves one table lookup per token, and also saves
841   the generation of the mapping table.
843   The gain is typically moderate, but in extreme cases (very simple user
844   actions), a 10% improvement can be observed.
846 *** Generated parsers use better types for states
848   Stacks now use the best integral type for state numbers, instead of always
849   using 15 bits.  As a result "small" parsers now have a smaller memory
850   footprint (they use 8 bits), and there is support for large automata (16
851   bits), and extra large (using int, i.e., typically 31 bits).
853 *** Generated parsers prefer signed integer types
855   Bison skeletons now prefer signed to unsigned integer types when either
856   will do, as the signed types are less error-prone and allow for better
857   checking with 'gcc -fsanitize=undefined'.  Also, the types chosen are now
858   portable to unusual machines where char, short and int are all the same
859   width.  On non-GNU platforms this may entail including <limits.h> and (if
860   available) <stdint.h> to define integer types and constants.
862 *** A skeleton for the D programming language
864   For the last few releases, Bison has shipped a stealth experimental
865   skeleton: lalr1.d.  It was first contributed by Oliver Mangold, based on
866   Paolo Bonzini's lalr1.java, and was cleaned and improved thanks to
867   H. S. Teoh.
869   However, because nobody has committed to improving, testing, and
870   documenting this skeleton, it is not clear that it will be supported in
871   the future.
873   The lalr1.d skeleton *is functional*, and works well, as demonstrated in
874   examples/d/calc.d.  Please try it, enjoy it, and... commit to support it.
876 *** Debug traces in Java
878   The Java backend no longer emits code and data for parser tracing if the
879   %define variable parse.trace is not defined.
881 ** Diagnostics
883 *** New diagnostic: -Wdangling-alias
885   String literals, which allow for better error messages, are (too)
886   liberally accepted by Bison, which might result in silent errors.  For
887   instance
889     %type <exVal> cond "condition"
891   does not define "condition" as a string alias to 'cond' (nonterminal
892   symbols do not have string aliases).  It is rather equivalent to
894     %nterm <exVal> cond
895     %token <exVal> "condition"
897   i.e., it gives the type 'exVal' to the "condition" token, which was
898   clearly not the intention.
900   Also, because string aliases need not be defined, typos such as "baz"
901   instead of "bar" will be not reported.
903   The option `-Wdangling-alias` catches these situations.  On
905     %token BAR "bar"
906     %type <ival> foo "foo"
907     %%
908     foo: "baz" {}
910   bison -Wdangling-alias reports
912     warning: string literal not attached to a symbol
913           | %type <ival> foo "foo"
914           |                  ^~~~~
915     warning: string literal not attached to a symbol
916           | foo: "baz" {}
917           |      ^~~~~
919    The `-Wall` option does not (yet?) include `-Wdangling-alias`.
921 *** Better POSIX Yacc compatibility diagnostics
923   POSIX Yacc restricts %type to nonterminals.  This is now diagnosed by
924   -Wyacc.
926     %token TOKEN1
927     %type  <ival> TOKEN1 TOKEN2 't'
928     %token TOKEN2
929     %%
930     expr:
932   gives with -Wyacc
934     input.y:2.15-20: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
935         2 | %type  <ival> TOKEN1 TOKEN2 't'
936           |               ^~~~~~
937     input.y:2.29-31: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
938         2 | %type  <ival> TOKEN1 TOKEN2 't'
939           |                             ^~~
940     input.y:2.22-27: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
941         2 | %type  <ival> TOKEN1 TOKEN2 't'
942           |                      ^~~~~~
944 *** Diagnostics with insertion
946   The diagnostics now display the suggestion below the underlined source.
947   Replacement for undeclared symbols are now also suggested.
949     $ cat /tmp/foo.y
950     %%
951     list: lis '.' |
953     $ bison -Wall foo.y
954     foo.y:2.7-9: error: symbol 'lis' is used, but is not defined as a token and has no rules; did you mean 'list'?
955         2 | list: lis '.' |
956           |       ^~~
957           |       list
958     foo.y:2.16: warning: empty rule without %empty [-Wempty-rule]
959         2 | list: lis '.' |
960           |                ^
961           |                %empty
962     foo.y: warning: fix-its can be applied.  Rerun with option '--update'. [-Wother]
964 *** Diagnostics about long lines
966   Quoted sources may now be truncated to fit the screen.  For instance, on a
967   30-column wide terminal:
969     $ cat foo.y
970     %token FOO                       FOO                         FOO
971     %%
972     exp: FOO
973     $ bison foo.y
974     foo.y:1.34-36: warning: symbol FOO redeclared [-Wother]
975         1 | …         FOO                  …
976           |           ^~~
977     foo.y:1.8-10:      previous declaration
978         1 | %token FOO                     …
979           |        ^~~
980     foo.y:1.62-64: warning: symbol FOO redeclared [-Wother]
981         1 | …         FOO
982           |           ^~~
983     foo.y:1.8-10:      previous declaration
984         1 | %token FOO                     …
985           |        ^~~
987 ** Changes
989 *** Debugging glr.c and glr.cc
991   The glr.c skeleton always had asserts to check its own behavior (not the
992   user's).  These assertions are now under the control of the parse.assert
993   %define variable (disabled by default).
995 *** Clean up
997   Several new compiler warnings in the generated output have been avoided.
998   Some unused features are no longer emitted.  Cleaner generated code in
999   general.
1001 ** Bug Fixes
1003   Portability issues in the test suite.
1005   In theory, parsers using %nonassoc could crash when reporting verbose
1006   error messages. This unlikely bug has been fixed.
1008   In Java, %define api.prefix was ignored.  It now behaves as expected.
1011 * Noteworthy changes in release 3.4.2 (2019-09-12) [stable]
1013 ** Bug fixes
1015   In some cases, when warnings are disabled, bison could emit tons of white
1016   spaces as diagnostics.
1018   When running out of memory, bison could crash (found by fuzzing).
1020   When defining twice the EOF token, bison would crash.
1022   New warnings from recent compilers have been addressed in the generated
1023   parsers (yacc.c, glr.c, glr.cc).
1025   When lone carriage-return characters appeared in the input file,
1026   diagnostics could hang forever.
1029 * Noteworthy changes in release 3.4.1 (2019-05-22) [stable]
1031 ** Bug fixes
1033   Portability fixes.
1036 * Noteworthy changes in release 3.4 (2019-05-19) [stable]
1038 ** Deprecated features
1040   The %pure-parser directive is deprecated in favor of '%define api.pure'
1041   since Bison 2.3b (2008-05-27), but no warning was issued; there is one
1042   now.  Note that since Bison 2.7 you are strongly encouraged to use
1043   '%define api.pure full' instead of '%define api.pure'.
1045 ** New features
1047 *** Colored diagnostics
1049   As an experimental feature, diagnostics are now colored, controlled by the
1050   new options --color and --style.
1052   To use them, install the libtextstyle library before configuring Bison.
1053   It is available from
1055     https://alpha.gnu.org/gnu/gettext/
1057   for instance
1059     https://alpha.gnu.org/gnu/gettext/libtextstyle-0.8.tar.gz
1061   The option --color supports the following arguments:
1062     - always, yes: Enable colors.
1063     - never, no: Disable colors.
1064     - auto, tty (default): Enable colors if the output device is a tty.
1066   To customize the styles, create a CSS file similar to
1068     /* bison-bw.css */
1069     .warning   { }
1070     .error     { font-weight: 800; text-decoration: underline; }
1071     .note      { }
1073   then invoke bison with --style=bison-bw.css, or set the BISON_STYLE
1074   environment variable to "bison-bw.css".
1076 *** Disabling output
1078   When given -fsyntax-only, the diagnostics are reported, but no output is
1079   generated.
1081   The name of this option is somewhat misleading as bison does more than
1082   just checking the syntax: every stage is run (including checking for
1083   conflicts for instance), except the generation of the output files.
1085 *** Include the generated header (yacc.c)
1087   Before, when --defines is used, bison generated a header, and pasted an
1088   exact copy of it into the generated parser implementation file.  If the
1089   header name is not "y.tab.h", it is now #included instead of being
1090   duplicated.
1092   To use an '#include' even if the header name is "y.tab.h" (which is what
1093   happens with --yacc, or when using the Autotools' ylwrap), define
1094   api.header.include to the exact argument to pass to #include.  For
1095   instance:
1097     %define api.header.include {"parse.h"}
1099   or
1101     %define api.header.include {<parser/parse.h>}
1103 *** api.location.type is now supported in C (yacc.c, glr.c)
1105   The %define variable api.location.type defines the name of the type to use
1106   for locations.  When defined, Bison no longer defines YYLTYPE.
1108   This can be used in programs with several parsers to factor their
1109   definition of locations: let one of them generate them, and the others
1110   just use them.
1112 ** Changes
1114 *** Graphviz output
1116   In conformance with the recommendations of the Graphviz team, if %require
1117   "3.4" (or better) is specified, the option --graph generates a *.gv file
1118   by default, instead of *.dot.
1120 *** Diagnostics overhaul
1122   Column numbers were wrong with multibyte characters, which would also
1123   result in skewed diagnostics with carets.  Beside, because we were
1124   indenting the quoted source with a single space, lines with tab characters
1125   were incorrectly underlined.
1127   To address these issues, and to be clearer, Bison now issues diagnostics
1128   as GCC9 does.  For instance it used to display (there's a tab before the
1129   opening brace):
1131     foo.y:3.37-38: error: $2 of ‘expr’ has no declared type
1132      expr: expr '+' "number"        { $$ = $1 + $2; }
1133                                          ^~
1134   It now reports
1136     foo.y:3.37-38: error: $2 of ‘expr’ has no declared type
1137         3 | expr: expr '+' "number" { $$ = $1 + $2; }
1138           |                                     ^~
1140   Other constructs now also have better locations, resulting in more precise
1141   diagnostics.
1143 *** Fix-it hints for %empty
1145   Running Bison with -Wempty-rules and --update will remove incorrect %empty
1146   annotations, and add the missing ones.
1148 *** Generated reports
1150   The format of the reports (parse.output) was improved for readability.
1152 *** Better support for --no-line.
1154   When --no-line is used, the generated files are now cleaner: no lines are
1155   generated instead of empty lines.  Together with using api.header.include,
1156   that should help people saving the generated files into version control
1157   systems get smaller diffs.
1159 ** Documentation
1161   A new example in C shows an simple infix calculator with a hand-written
1162   scanner (examples/c/calc).
1164   A new example in C shows a reentrant parser (capable of recursive calls)
1165   built with Flex and Bison (examples/c/reccalc).
1167   There is a new section about the history of Yaccs and Bison.
1169 ** Bug fixes
1171   A few obscure bugs were fixed, including the second oldest (known) bug in
1172   Bison: it was there when Bison was entered in the RCS version control
1173   system, in December 1987.  See the NEWS of Bison 3.3 for the previous
1174   oldest bug.
1177 * Noteworthy changes in release 3.3.2 (2019-02-03) [stable]
1179 ** Bug fixes
1181   Bison 3.3 failed to generate parsers for grammars with unused nonterminal
1182   symbols.
1185 * Noteworthy changes in release 3.3.1 (2019-01-27) [stable]
1187 ** Changes
1189   The option -y/--yacc used to imply -Werror=yacc, which turns uses of Bison
1190   extensions into errors.  It now makes them simple warnings (-Wyacc).
1193 * Noteworthy changes in release 3.3 (2019-01-26) [stable]
1195   A new mailing list was created, Bison Announce.  It is low traffic, and is
1196   only about announcing new releases and important messages (e.g., polls
1197   about major decisions to make).
1199   https://lists.gnu.org/mailman/listinfo/bison-announce
1201 ** Backward incompatible changes
1203   Support for DJGPP, which has been unmaintained and untested for years, is
1204   removed.
1206 ** Deprecated features
1208   A new feature, --update (see below) helps adjusting existing grammars to
1209   deprecations.
1211 *** Deprecated directives
1213   The %error-verbose directive is deprecated in favor of '%define
1214   parse.error verbose' since Bison 3.0, but no warning was issued.
1216   The '%name-prefix "xx"' directive is deprecated in favor of '%define
1217   api.prefix {xx}' since Bison 3.0, but no warning was issued.  These
1218   directives are slightly different, you might need to adjust your code.
1219   %name-prefix renames only symbols with external linkage, while api.prefix
1220   also renames types and macros, including YYDEBUG, YYTOKENTYPE,
1221   yytokentype, YYSTYPE, YYLTYPE, etc.
1223   Users of Flex that move from '%name-prefix "xx"' to '%define api.prefix
1224   {xx}' will typically have to update YY_DECL from
1226     #define YY_DECL int xxlex (YYSTYPE *yylval, YYLTYPE *yylloc)
1228   to
1230     #define YY_DECL int xxlex (XXSTYPE *yylval, XXLTYPE *yylloc)
1232 *** Deprecated %define variable names
1234   The following variables, mostly related to parsers in Java, have been
1235   renamed for consistency.  Backward compatibility is ensured, but upgrading
1236   is recommended.
1238     abstract           -> api.parser.abstract
1239     annotations        -> api.parser.annotations
1240     extends            -> api.parser.extends
1241     final              -> api.parser.final
1242     implements         -> api.parser.implements
1243     parser_class_name  -> api.parser.class
1244     public             -> api.parser.public
1245     strictfp           -> api.parser.strictfp
1247 ** New features
1249 *** Generation of fix-its for IDEs/Editors
1251   When given the new option -ffixit (aka -fdiagnostics-parseable-fixits),
1252   bison now generates machine readable editing instructions to fix some
1253   issues.  Currently, this is mostly limited to updating deprecated
1254   directives and removing duplicates.  For instance:
1256     $ cat foo.y
1257     %error-verbose
1258     %define parser_class_name "Parser"
1259     %define api.parser.class "Parser"
1260     %%
1261     exp:;
1263   See the "fix-it:" lines below:
1265     $ bison -ffixit foo.y
1266     foo.y:1.1-14: warning: deprecated directive, use '%define parse.error verbose' [-Wdeprecated]
1267      %error-verbose
1268      ^~~~~~~~~~~~~~
1269     fix-it:"foo.y":{1:1-1:15}:"%define parse.error verbose"
1270     foo.y:2.1-34: warning: deprecated directive, use '%define api.parser.class {Parser}' [-Wdeprecated]
1271      %define parser_class_name "Parser"
1272      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1273     fix-it:"foo.y":{2:1-2:35}:"%define api.parser.class {Parser}"
1274     foo.y:3.1-33: error: %define variable 'api.parser.class' redefined
1275      %define api.parser.class "Parser"
1276      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1277     foo.y:2.1-34:     previous definition
1278      %define parser_class_name "Parser"
1279      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1280     fix-it:"foo.y":{3:1-3:34}:""
1281     foo.y: warning: fix-its can be applied.  Rerun with option '--update'. [-Wother]
1283   This uses the same output format as GCC and Clang.
1285 *** Updating grammar files
1287   Fixes can be applied on the fly.  The previous example ends with the
1288   suggestion to re-run bison with the option -u/--update, which results in a
1289   cleaner grammar file.
1291     $ bison --update foo.y
1292     [...]
1293     bison: file 'foo.y' was updated (backup: 'foo.y~')
1295     $ cat foo.y
1296     %define parse.error verbose
1297     %define api.parser.class {Parser}
1298     %%
1299     exp:;
1301 *** Bison is now relocatable
1303   If you pass '--enable-relocatable' to 'configure', Bison is relocatable.
1305   A relocatable program can be moved or copied to a different location on
1306   the file system.  It can also be used through mount points for network
1307   sharing.  It is possible to make symbolic links to the installed and moved
1308   programs, and invoke them through the symbolic link.
1310 *** %expect and %expect-rr modifiers on individual rules
1312   One can now document (and check) which rules participate in shift/reduce
1313   and reduce/reduce conflicts.  This is particularly important GLR parsers,
1314   where conflicts are a normal occurrence.  For example,
1316       %glr-parser
1317       %expect 1
1318       %%
1320       ...
1322       argument_list:
1323         arguments %expect 1
1324       | arguments ','
1325       | %empty
1326       ;
1328       arguments:
1329         expression
1330       | argument_list ',' expression
1331       ;
1333       ...
1335   Looking at the output from -v, one can see that the shift/reduce conflict
1336   here is due to the fact that the parser does not know whether to reduce
1337   arguments to argument_list until it sees the token _after_ the following
1338   ','.  By marking the rule with %expect 1 (because there is a conflict in
1339   one state), we document the source of the 1 overall shift/reduce conflict.
1341   In GLR parsers, we can use %expect-rr in a rule for reduce/reduce
1342   conflicts.  In this case, we mark each of the conflicting rules.  For
1343   example,
1345       %glr-parser
1346       %expect-rr 1
1348       %%
1350       stmt:
1351         target_list '=' expr ';'
1352       | expr_list ';'
1353       ;
1355       target_list:
1356         target
1357       | target ',' target_list
1358       ;
1360       target:
1361         ID %expect-rr 1
1362       ;
1364       expr_list:
1365         expr
1366       | expr ',' expr_list
1367       ;
1369       expr:
1370         ID %expect-rr 1
1371       | ...
1372       ;
1374   In a statement such as
1376       x, y = 3, 4;
1378   the parser must reduce x to a target or an expr, but does not know which
1379   until it sees the '='.  So we notate the two possible reductions to
1380   indicate that each conflicts in one rule.
1382   This feature needs user feedback, and might evolve in the future.
1384 *** C++: Actual token constructors
1386   When variants and token constructors are enabled, in addition to the
1387   type-safe named token constructors (make_ID, make_INT, etc.), we now
1388   generate genuine constructors for symbol_type.
1390   For instance with these declarations
1392     %token           ':'
1393        <std::string> ID
1394        <int>         INT;
1396   you may use these constructors:
1398     symbol_type (int token, const std::string&);
1399     symbol_type (int token, const int&);
1400     symbol_type (int token);
1402   Correct matching between token types and value types is checked via
1403   'assert'; for instance, 'symbol_type (ID, 42)' would abort.  Named
1404   constructors are preferable, as they offer better type safety (for
1405   instance 'make_ID (42)' would not even compile), but symbol_type
1406   constructors may help when token types are discovered at run-time, e.g.,
1408      [a-z]+   {
1409                 if (auto i = lookup_keyword (yytext))
1410                   return yy::parser::symbol_type (i);
1411                 else
1412                   return yy::parser::make_ID (yytext);
1413               }
1415 *** C++: Variadic emplace
1417   If your application requires C++11 and you don't use symbol constructors,
1418   you may now use a variadic emplace for semantic values:
1420     %define api.value.type variant
1421     %token <std::pair<int, int>> PAIR
1423   in your scanner:
1425     int yylex (parser::semantic_type *lvalp)
1426     {
1427       lvalp->emplace <std::pair<int, int>> (1, 2);
1428       return parser::token::PAIR;
1429     }
1431 *** C++: Syntax error exceptions in GLR
1433   The glr.cc skeleton now supports syntax_error exceptions thrown from user
1434   actions, or from the scanner.
1436 *** More POSIX Yacc compatibility warnings
1438   More Bison specific directives are now reported with -y or -Wyacc.  This
1439   change was ready since the release of Bison 3.0 in September 2015.  It was
1440   delayed because Autoconf used to define YACC as `bison -y`, which resulted
1441   in numerous warnings for Bison users that use the GNU Build System.
1443   If you still experience that problem, either redefine YACC as `bison -o
1444   y.tab.c`, or pass -Wno-yacc to Bison.
1446 *** The tables yyrhs and yyphrs are back
1448   Because no Bison skeleton uses them, these tables were removed (no longer
1449   passed to the skeletons, not even computed) in 2008.  However, some users
1450   have expressed interest in being able to use them in their own skeletons.
1452 ** Bug fixes
1454 *** Incorrect number of reduce/reduce conflicts
1456   On a grammar such as
1458      exp: "num" | "num" | "num"
1460   bison used to report a single RR conflict, instead of two.  This is now
1461   fixed.  This was the oldest (known) bug in Bison: it was there when Bison
1462   was entered in the RCS version control system, in December 1987.
1464   Some grammar files might have to adjust their %expect-rr.
1466 *** Parser directives that were not careful enough
1468   Passing invalid arguments to %nterm, for instance character literals, used
1469   to result in unclear error messages.
1471 ** Documentation
1473   The examples/ directory (installed in .../share/doc/bison/examples) has
1474   been restructured per language for clarity.  The examples come with a
1475   README and a Makefile.  Not only can they be used to toy with Bison, they
1476   can also be starting points for your own grammars.
1478   There is now a Java example, and a simple example in C based on Flex and
1479   Bison (examples/c/lexcalc/).
1481 ** Changes
1483 *** Parsers in C++
1485   They now use noexcept and constexpr.  Please, report missing annotations.
1487 *** Symbol Declarations
1489   The syntax of the variation directives to declare symbols was overhauled
1490   for more consistency, and also better POSIX Yacc compliance (which, for
1491   instance, allows "%type" without actually providing a type).  The %nterm
1492   directive, supported by Bison since its inception, is now documented and
1493   officially supported.
1495   The syntax is now as follows:
1497     %token TAG? ( ID NUMBER? STRING? )+ ( TAG ( ID NUMBER? STRING? )+ )*
1498     %left  TAG? ( ID NUMBER? )+ ( TAG ( ID NUMBER? )+ )*
1499     %type  TAG? ( ID | CHAR | STRING )+ ( TAG ( ID | CHAR | STRING )+ )*
1500     %nterm TAG? ID+ ( TAG ID+ )*
1502   where TAG denotes a type tag such as ‘<ival>’, ID denotes an identifier
1503   such as ‘NUM’, NUMBER a decimal or hexadecimal integer such as ‘300’ or
1504   ‘0x12d’, CHAR a character literal such as ‘'+'’, and STRING a string
1505   literal such as ‘"number"’.  The post-fix quantifiers are ‘?’ (zero or
1506   one), ‘*’ (zero or more) and ‘+’ (one or more).
1509 * Noteworthy changes in release 3.2.4 (2018-12-24) [stable]
1511 ** Bug fixes
1513   Fix the move constructor of symbol_type.
1515   Always provide a copy constructor for symbol_type, even in modern C++.
1518 * Noteworthy changes in release 3.2.3 (2018-12-18) [stable]
1520 ** Bug fixes
1522   Properly support token constructors in C++ with types that include commas
1523   (e.g., std::pair<int, int>).  A regression introduced in Bison 3.2.
1526 * Noteworthy changes in release 3.2.2 (2018-11-21) [stable]
1528 ** Bug fixes
1530   C++ portability issues.
1533 * Noteworthy changes in release 3.2.1 (2018-11-09) [stable]
1535 ** Bug fixes
1537   Several portability issues have been fixed in the build system, in the
1538   test suite, and in the generated parsers in C++.
1541 * Noteworthy changes in release 3.2 (2018-10-29) [stable]
1543 ** Backward incompatible changes
1545   Support for DJGPP, which has been unmaintained and untested for years, is
1546   obsolete.  Unless there is activity to revive it, it will be removed.
1548 ** Changes
1550   %printers should use yyo rather than yyoutput to denote the output stream.
1552   Variant-based symbols in C++ should use emplace() rather than build().
1554   In C++ parsers, parser::operator() is now a synonym for the parser::parse.
1556 ** Documentation
1558   A new section, "A Simple C++ Example", is a tutorial for parsers in C++.
1560   A comment in the generated code now emphasizes that users should not
1561   depend upon non-documented implementation details, such as macros starting
1562   with YY_.
1564 ** New features
1566 *** C++: Support for move semantics (lalr1.cc)
1568   The lalr1.cc skeleton now fully supports C++ move semantics, while
1569   maintaining compatibility with C++98.  You may now store move-only types
1570   when using Bison's variants.  For instance:
1572     %code {
1573       #include <memory>
1574       #include <vector>
1575     }
1577     %skeleton "lalr1.cc"
1578     %define api.value.type variant
1580     %%
1582     %token <int> INT "int";
1583     %type <std::unique_ptr<int>> int;
1584     %type <std::vector<std::unique_ptr<int>>> list;
1586     list:
1587       %empty    {}
1588     | list int  { $$ = std::move($1); $$.emplace_back(std::move($2)); }
1590     int: "int"  { $$ = std::make_unique<int>($1); }
1592 *** C++: Implicit move of right-hand side values (lalr1.cc)
1594   In modern C++ (C++11 and later), you should always use 'std::move' with
1595   the values of the right-hand side symbols ($1, $2, etc.), as they will be
1596   popped from the stack anyway.  Using 'std::move' is mandatory for
1597   move-only types such as unique_ptr, and it provides a significant speedup
1598   for large types such as std::string, or std::vector, etc.
1600   If '%define api.value.automove' is set, every occurrence '$n' is replaced
1601   by 'std::move ($n)'.  The second rule in the previous grammar can be
1602   simplified to:
1604     list: list int  { $$ = $1; $$.emplace_back($2); }
1606   With automove enabled, the semantic values are no longer lvalues, so do
1607   not use the swap idiom:
1609     list: list int  { std::swap($$, $1); $$.emplace_back($2); }
1611   This idiom is anyway obsolete: it is preferable to move than to swap.
1613   A warning is issued when automove is enabled, and a value is used several
1614   times.
1616     input.yy:16.31-32: warning: multiple occurrences of $2 with api.value.automove enabled [-Wother]
1617     exp: "twice" exp   { $$ = $2 + $2; }
1618                                    ^^
1620   Enabling api.value.automove does not require support for modern C++.  The
1621   generated code is valid C++98/03, but will use copies instead of moves.
1623   The new examples/c++/variant-11.yy shows these features in action.
1625 *** C++: The implicit default semantic action is always run
1627   When variants are enabled, the default action was not run, so
1629     exp: "number"
1631   was equivalent to
1633     exp: "number"  {}
1635   It now behaves like in all the other cases, as
1637     exp: "number"  { $$ = $1; }
1639   possibly using std::move if automove is enabled.
1641   We do not expect backward compatibility issues.  However, beware of
1642   forward compatibility issues: if you rely on default actions with
1643   variants, be sure to '%require "3.2"' to avoid older versions of Bison to
1644   generate incorrect parsers.
1646 *** C++: Renaming location.hh
1648   When both %defines and %locations are enabled, Bison generates a
1649   location.hh file.  If you don't use locations outside of the parser, you
1650   may avoid its creation with:
1652     %define api.location.file none
1654   However this file is useful if, for instance, your parser builds an AST
1655   decorated with locations: you may use Bison's location independently of
1656   Bison's parser.  You can now give it another name, for instance:
1658     %define api.location.file "my-location.hh"
1660   This name can have directory components, and even be absolute.  The name
1661   under which the location file is included is controlled by
1662   api.location.include.
1664   This way it is possible to have several parsers share the same location
1665   file.
1667   For instance, in src/foo/parser.hh, generate the include/ast/loc.hh file:
1669     %locations
1670     %define api.namespace {foo}
1671     %define api.location.file "include/ast/loc.hh"
1672     %define api.location.include {<ast/loc.hh>}
1674   and use it in src/bar/parser.hh:
1676     %locations
1677     %define api.namespace {bar}
1678     %code requires {#include <ast/loc.hh>}
1679     %define api.location.type {bar::location}
1681   Absolute file names are supported, so in your Makefile, passing the flag
1682   -Dapi.location.file='"$(top_srcdir)/include/ast/location.hh"' to bison is
1683   safe.
1685 *** C++: stack.hh and position.hh are deprecated
1687   When asked to generate a header file (%defines), the lalr1.cc skeleton
1688   generates a stack.hh file.  This file had no interest for users; it is now
1689   made useless: its content is included in the parser definition.  It is
1690   still generated for backward compatibility.
1692   When in addition to %defines, location support is requested (%locations),
1693   the file position.hh is also generated.  It is now also useless: its
1694   content is now included in location.hh.
1696   These files are no longer generated when your grammar file requires at
1697   least Bison 3.2 (%require "3.2").
1699 ** Bug fixes
1701   Portability issues on MinGW and VS2015.
1703   Portability issues in the test suite.
1705   Portability/warning issues with Flex.
1708 * Noteworthy changes in release 3.1 (2018-08-27) [stable]
1710 ** Backward incompatible changes
1712   Compiling Bison now requires a C99 compiler---as announced during the
1713   release of Bison 3.0, five years ago.  Generated parsers do not require a
1714   C99 compiler.
1716   Support for DJGPP, which has been unmaintained and untested for years, is
1717   obsolete. Unless there is activity to revive it, the next release of Bison
1718   will have it removed.
1720 ** New features
1722 *** Typed midrule actions
1724   Because their type is unknown to Bison, the values of midrule actions are
1725   not treated like the others: they don't have %printer and %destructor
1726   support.  It also prevents C++ (Bison) variants to handle them properly.
1728   Typed midrule actions address these issues.  Instead of:
1730     exp: { $<ival>$ = 1; } { $<ival>$ = 2; }   { $$ = $<ival>1 + $<ival>2; }
1732   write:
1734     exp: <ival>{ $$ = 1; } <ival>{ $$ = 2; }   { $$ = $1 + $2; }
1736 *** Reports include the type of the symbols
1738   The sections about terminal and nonterminal symbols of the '*.output' file
1739   now specify their declared type.  For instance, for:
1741     %token <ival> NUM
1743   the report now shows '<ival>':
1745     Terminals, with rules where they appear
1747     NUM <ival> (258) 5
1749 *** Diagnostics about useless rules
1751   In the following grammar, the 'exp' nonterminal is trivially useless.  So,
1752   of course, its rules are useless too.
1754     %%
1755     input: '0' | exp
1756     exp: exp '+' exp | exp '-' exp | '(' exp ')'
1758   Previously all the useless rules were reported, including those whose
1759   left-hand side is the 'exp' nonterminal:
1761     warning: 1 nonterminal useless in grammar [-Wother]
1762     warning: 4 rules useless in grammar [-Wother]
1763     2.14-16: warning: nonterminal useless in grammar: exp [-Wother]
1764      input: '0' | exp
1765                   ^^^
1766     2.14-16: warning: rule useless in grammar [-Wother]
1767      input: '0' | exp
1768                   ^^^
1769     3.6-16: warning: rule useless in grammar [-Wother]
1770      exp: exp '+' exp | exp '-' exp | '(' exp ')'
1771           ^^^^^^^^^^^
1772     3.20-30: warning: rule useless in grammar [-Wother]
1773      exp: exp '+' exp | exp '-' exp | '(' exp ')'
1774                         ^^^^^^^^^^^
1775     3.34-44: warning: rule useless in grammar [-Wother]
1776      exp: exp '+' exp | exp '-' exp | '(' exp ')'
1777                                       ^^^^^^^^^^^
1779   Now, rules whose left-hand side symbol is useless are no longer reported
1780   as useless.  The locations of the errors have also been adjusted to point
1781   to the first use of the nonterminal as a left-hand side of a rule:
1783     warning: 1 nonterminal useless in grammar [-Wother]
1784     warning: 4 rules useless in grammar [-Wother]
1785     3.1-3: warning: nonterminal useless in grammar: exp [-Wother]
1786      exp: exp '+' exp | exp '-' exp | '(' exp ')'
1787      ^^^
1788     2.14-16: warning: rule useless in grammar [-Wother]
1789      input: '0' | exp
1790                   ^^^
1792 *** C++: Generated parsers can be compiled with -fno-exceptions (lalr1.cc)
1794   When compiled with exceptions disabled, the generated parsers no longer
1795   uses try/catch clauses.
1797   Currently only GCC and Clang are supported.
1799 ** Documentation
1801 *** A demonstration of variants
1803   A new example was added (installed in .../share/doc/bison/examples),
1804   'variant.yy', which shows how to use (Bison) variants in C++.
1806   The other examples were made nicer to read.
1808 *** Some features are no longer 'experimental'
1810   The following features, mature enough, are no longer flagged as
1811   experimental in the documentation: push parsers, default %printer and
1812   %destructor (typed: <*> and untyped: <>), %define api.value.type union and
1813   variant, Java parsers, XML output, LR family (lr, ielr, lalr), and
1814   semantic predicates (%?).
1816 ** Bug fixes
1818 *** GLR: Predicates support broken by #line directives
1820   Predicates (%?) in GLR such as
1822     widget:
1823       %? {new_syntax} 'w' id new_args
1824     | %?{!new_syntax} 'w' id old_args
1826   were issued with #lines in the middle of C code.
1828 *** Printer and destructor with broken #line directives
1830   The #line directives were not properly escaped when emitting the code for
1831   %printer/%destructor, which resulted in compiler errors if there are
1832   backslashes or double-quotes in the grammar file name.
1834 *** Portability on ICC
1836   The Intel compiler claims compatibility with GCC, yet rejects its _Pragma.
1837   Generated parsers now work around this.
1839 *** Various
1841   There were several small fixes in the test suite and in the build system,
1842   many warnings in bison and in the generated parsers were eliminated.  The
1843   documentation also received its share of minor improvements.
1845   Useless code was removed from C++ parsers, and some of the generated
1846   constructors are more 'natural'.
1849 * Noteworthy changes in release 3.0.5 (2018-05-27) [stable]
1851 ** Bug fixes
1853 *** C++: Fix support of 'syntax_error'
1855   One incorrect 'inline' resulted in linking errors about the constructor of
1856   the syntax_error exception.
1858 *** C++: Fix warnings
1860   GCC 7.3 (with -O1 or -O2 but not -O0 or -O3) issued null-dereference
1861   warnings about yyformat being possibly null.  It also warned about the
1862   deprecated implicit definition of copy constructors when there's a
1863   user-defined (copy) assignment operator.
1865 *** Location of errors
1867   In C++ parsers, out-of-bounds errors can happen when a rule with an empty
1868   ride-hand side raises a syntax error.  The behavior of the default parser
1869   (yacc.c) in such a condition was undefined.
1871   Now all the parsers match the behavior of glr.c: @$ is used as the
1872   location of the error.  This handles gracefully rules with and without
1873   rhs.
1875 *** Portability fixes in the test suite
1877   On some platforms, some Java and/or C++ tests were failing.
1880 * Noteworthy changes in release 3.0.4 (2015-01-23) [stable]
1882 ** Bug fixes
1884 *** C++ with Variants (lalr1.cc)
1886   Fix a compiler warning when no %destructor use $$.
1888 *** Test suites
1890   Several portability issues in tests were fixed.
1893 * Noteworthy changes in release 3.0.3 (2015-01-15) [stable]
1895 ** Bug fixes
1897 *** C++ with Variants (lalr1.cc)
1899   Problems with %destructor and '%define parse.assert' have been fixed.
1901 *** Named %union support (yacc.c, glr.c)
1903   Bison 3.0 introduced a regression on named %union such as
1905     %union foo { int ival; };
1907   The possibility to use a name was introduced "for Yacc compatibility".
1908   It is however not required by POSIX Yacc, and its usefulness is not clear.
1910 *** %define api.value.type union with %defines (yacc.c, glr.c)
1912   The C parsers were broken when %defines was used together with "%define
1913   api.value.type union".
1915 *** Redeclarations are reported in proper order
1917   On
1919     %token FOO "foo"
1920     %printer {} "foo"
1921     %printer {} FOO
1923   bison used to report:
1925     foo.yy:2.10-11: error: %printer redeclaration for FOO
1926      %printer {} "foo"
1927               ^^
1928     foo.yy:3.10-11:     previous declaration
1929      %printer {} FOO
1930               ^^
1932   Now, the "previous" declaration is always the first one.
1935 ** Documentation
1937   Bison now installs various files in its docdir (which defaults to
1938   '/usr/local/share/doc/bison'), including the three fully blown examples
1939   extracted from the documentation:
1941    - rpcalc
1942      Reverse Polish Calculator, a simple introductory example.
1943    - mfcalc
1944      Multi-function Calc, a calculator with memory and functions and located
1945      error messages.
1946    - calc++
1947      a calculator in C++ using variant support and token constructors.
1950 * Noteworthy changes in release 3.0.2 (2013-12-05) [stable]
1952 ** Bug fixes
1954 *** Generated source files when errors are reported
1956   When warnings are issued and -Werror is set, bison would still generate
1957   the source files (*.c, *.h...).  As a consequence, some runs of "make"
1958   could fail the first time, but not the second (as the files were generated
1959   anyway).
1961   This is fixed: bison no longer generates this source files, but, of
1962   course, still produces the various reports (*.output, *.xml, etc.).
1964 *** %empty is used in reports
1966   Empty right-hand sides are denoted by '%empty' in all the reports (text,
1967   dot, XML and formats derived from it).
1969 *** YYERROR and variants
1971   When C++ variant support is enabled, an error triggered via YYERROR, but
1972   not caught via error recovery, resulted in a double deletion.
1975 * Noteworthy changes in release 3.0.1 (2013-11-12) [stable]
1977 ** Bug fixes
1979 *** Errors in caret diagnostics
1981   On some platforms, some errors could result in endless diagnostics.
1983 *** Fixes of the -Werror option
1985   Options such as "-Werror -Wno-error=foo" were still turning "foo"
1986   diagnostics into errors instead of warnings.  This is fixed.
1988   Actually, for consistency with GCC, "-Wno-error=foo -Werror" now also
1989   leaves "foo" diagnostics as warnings.  Similarly, with "-Werror=foo
1990   -Wno-error", "foo" diagnostics are now errors.
1992 *** GLR Predicates
1994   As demonstrated in the documentation, one can now leave spaces between
1995   "%?" and its "{".
1997 *** Installation
1999   The yacc.1 man page is no longer installed if --disable-yacc was
2000   specified.
2002 *** Fixes in the test suite
2004   Bugs and portability issues.
2007 * Noteworthy changes in release 3.0 (2013-07-25) [stable]
2009 ** WARNING: Future backward-incompatibilities!
2011   Like other GNU packages, Bison will start using some of the C99 features
2012   for its own code, especially the definition of variables after statements.
2013   The generated C parsers still aim at C90.
2015 ** Backward incompatible changes
2017 *** Obsolete features
2019   Support for YYFAIL is removed (deprecated in Bison 2.4.2): use YYERROR.
2021   Support for yystype and yyltype is removed (deprecated in Bison 1.875):
2022   use YYSTYPE and YYLTYPE.
2024   Support for YYLEX_PARAM and YYPARSE_PARAM is removed (deprecated in Bison
2025   1.875): use %lex-param, %parse-param, or %param.
2027   Missing semicolons at the end of actions are no longer added (as announced
2028   in the release 2.5).
2030 *** Use of YACC='bison -y'
2032   TL;DR: With Autoconf <= 2.69, pass -Wno-yacc to (AM_)YFLAGS if you use
2033   Bison extensions.
2035   Traditional Yacc generates 'y.tab.c' whatever the name of the input file.
2036   Therefore Makefiles written for Yacc expect 'y.tab.c' (and possibly
2037   'y.tab.h' and 'y.output') to be generated from 'foo.y'.
2039   To this end, for ages, AC_PROG_YACC, Autoconf's macro to look for an
2040   implementation of Yacc, was using Bison as 'bison -y'.  While it does
2041   ensure compatible output file names, it also enables warnings for
2042   incompatibilities with POSIX Yacc.  In other words, 'bison -y' triggers
2043   warnings for Bison extensions.
2045   Autoconf 2.70+ fixes this incompatibility by using YACC='bison -o y.tab.c'
2046   (which also generates 'y.tab.h' and 'y.output' when needed).
2047   Alternatively, disable Yacc warnings by passing '-Wno-yacc' to your Yacc
2048   flags (YFLAGS, or AM_YFLAGS with Automake).
2050 ** Bug fixes
2052 *** The epilogue is no longer affected by internal #defines (glr.c)
2054   The glr.c skeleton uses defines such as #define yylval (yystackp->yyval) in
2055   generated code.  These weren't properly undefined before the inclusion of
2056   the user epilogue, so functions such as the following were butchered by the
2057   preprocessor expansion:
2059     int yylex (YYSTYPE *yylval);
2061   This is fixed: yylval, yynerrs, yychar, and yylloc are now valid
2062   identifiers for user-provided variables.
2064 *** stdio.h is no longer needed when locations are enabled (yacc.c)
2066   Changes in Bison 2.7 introduced a dependency on FILE and fprintf when
2067   locations are enabled.  This is fixed.
2069 *** Warnings about useless %pure-parser/%define api.pure are restored
2071 ** Diagnostics reported by Bison
2073   Most of these features were contributed by Théophile Ranquet and Victor
2074   Santet.
2076 *** Carets
2078   Version 2.7 introduced caret errors, for a prettier output.  These are now
2079   activated by default.  The old format can still be used by invoking Bison
2080   with -fno-caret (or -fnone).
2082   Some error messages that reproduced excerpts of the grammar are now using
2083   the caret information only.  For instance on:
2085     %%
2086     exp: 'a' | 'a';
2088   Bison 2.7 reports:
2090     in.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
2091     in.y:2.12-14: warning: rule useless in parser due to conflicts: exp: 'a' [-Wother]
2093   Now bison reports:
2095     in.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
2096     in.y:2.12-14: warning: rule useless in parser due to conflicts [-Wother]
2097      exp: 'a' | 'a';
2098                 ^^^
2100   and "bison -fno-caret" reports:
2102     in.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
2103     in.y:2.12-14: warning: rule useless in parser due to conflicts [-Wother]
2105 *** Enhancements of the -Werror option
2107   The -Werror=CATEGORY option is now recognized, and will treat specified
2108   warnings as errors. The warnings need not have been explicitly activated
2109   using the -W option, this is similar to what GCC 4.7 does.
2111   For example, given the following command line, Bison will treat both
2112   warnings related to POSIX Yacc incompatibilities and S/R conflicts as
2113   errors (and only those):
2115     $ bison -Werror=yacc,error=conflicts-sr input.y
2117   If no categories are specified, -Werror will make all active warnings into
2118   errors. For example, the following line does the same the previous example:
2120     $ bison -Werror -Wnone -Wyacc -Wconflicts-sr input.y
2122   (By default -Wconflicts-sr,conflicts-rr,deprecated,other is enabled.)
2124   Note that the categories in this -Werror option may not be prefixed with
2125   "no-". However, -Wno-error[=CATEGORY] is valid.
2127   Note that -y enables -Werror=yacc. Therefore it is now possible to require
2128   Yacc-like behavior (e.g., always generate y.tab.c), but to report
2129   incompatibilities as warnings: "-y -Wno-error=yacc".
2131 *** The display of warnings is now richer
2133   The option that controls a given warning is now displayed:
2135     foo.y:4.6: warning: type clash on default action: <foo> != <bar> [-Wother]
2137   In the case of warnings treated as errors, the prefix is changed from
2138   "warning: " to "error: ", and the suffix is displayed, in a manner similar
2139   to GCC, as [-Werror=CATEGORY].
2141   For instance, where the previous version of Bison would report (and exit
2142   with failure):
2144     bison: warnings being treated as errors
2145     input.y:1.1: warning: stray ',' treated as white space
2147   it now reports:
2149     input.y:1.1: error: stray ',' treated as white space [-Werror=other]
2151 *** Deprecated constructs
2153   The new 'deprecated' warning category flags obsolete constructs whose
2154   support will be discontinued.  It is enabled by default.  These warnings
2155   used to be reported as 'other' warnings.
2157 *** Useless semantic types
2159   Bison now warns about useless (uninhabited) semantic types.  Since
2160   semantic types are not declared to Bison (they are defined in the opaque
2161   %union structure), it is %printer/%destructor directives about useless
2162   types that trigger the warning:
2164     %token <type1> term
2165     %type  <type2> nterm
2166     %printer    {} <type1> <type3>
2167     %destructor {} <type2> <type4>
2168     %%
2169     nterm: term { $$ = $1; };
2171     3.28-34: warning: type <type3> is used, but is not associated to any symbol
2172     4.28-34: warning: type <type4> is used, but is not associated to any symbol
2174 *** Undefined but unused symbols
2176   Bison used to raise an error for undefined symbols that are not used in
2177   the grammar.  This is now only a warning.
2179     %printer    {} symbol1
2180     %destructor {} symbol2
2181     %type <type>   symbol3
2182     %%
2183     exp: "a";
2185 *** Useless destructors or printers
2187   Bison now warns about useless destructors or printers.  In the following
2188   example, the printer for <type1>, and the destructor for <type2> are
2189   useless: all symbols of <type1> (token1) already have a printer, and all
2190   symbols of type <type2> (token2) already have a destructor.
2192     %token <type1> token1
2193            <type2> token2
2194            <type3> token3
2195            <type4> token4
2196     %printer    {} token1 <type1> <type3>
2197     %destructor {} token2 <type2> <type4>
2199 *** Conflicts
2201   The warnings and error messages about shift/reduce and reduce/reduce
2202   conflicts have been normalized.  For instance on the following foo.y file:
2204     %glr-parser
2205     %%
2206     exp: exp '+' exp | '0' | '0';
2208   compare the previous version of bison:
2210     $ bison foo.y
2211     foo.y: conflicts: 1 shift/reduce, 2 reduce/reduce
2212     $ bison -Werror foo.y
2213     bison: warnings being treated as errors
2214     foo.y: conflicts: 1 shift/reduce, 2 reduce/reduce
2216   with the new behavior:
2218     $ bison foo.y
2219     foo.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
2220     foo.y: warning: 2 reduce/reduce conflicts [-Wconflicts-rr]
2221     $ bison -Werror foo.y
2222     foo.y: error: 1 shift/reduce conflict [-Werror=conflicts-sr]
2223     foo.y: error: 2 reduce/reduce conflicts [-Werror=conflicts-rr]
2225   When %expect or %expect-rr is used, such as with bar.y:
2227     %expect 0
2228     %glr-parser
2229     %%
2230     exp: exp '+' exp | '0' | '0';
2232   Former behavior:
2234     $ bison bar.y
2235     bar.y: conflicts: 1 shift/reduce, 2 reduce/reduce
2236     bar.y: expected 0 shift/reduce conflicts
2237     bar.y: expected 0 reduce/reduce conflicts
2239   New one:
2241     $ bison bar.y
2242     bar.y: error: shift/reduce conflicts: 1 found, 0 expected
2243     bar.y: error: reduce/reduce conflicts: 2 found, 0 expected
2245 ** Incompatibilities with POSIX Yacc
2247   The 'yacc' category is no longer part of '-Wall', enable it explicitly
2248   with '-Wyacc'.
2250 ** Additional yylex/yyparse arguments
2252   The new directive %param declares additional arguments to both yylex and
2253   yyparse.  The %lex-param, %parse-param, and %param directives support one
2254   or more arguments.  Instead of
2256     %lex-param   {arg1_type *arg1}
2257     %lex-param   {arg2_type *arg2}
2258     %parse-param {arg1_type *arg1}
2259     %parse-param {arg2_type *arg2}
2261   one may now declare
2263     %param {arg1_type *arg1} {arg2_type *arg2}
2265 ** Types of values for %define variables
2267   Bison used to make no difference between '%define foo bar' and '%define
2268   foo "bar"'.  The former is now called a 'keyword value', and the latter a
2269   'string value'.  A third kind was added: 'code values', such as '%define
2270   foo {bar}'.
2272   Keyword variables are used for fixed value sets, e.g.,
2274     %define lr.type lalr
2276   Code variables are used for value in the target language, e.g.,
2278     %define api.value.type {struct semantic_type}
2280   String variables are used remaining cases, e.g. file names.
2282 ** Variable api.token.prefix
2284   The variable api.token.prefix changes the way tokens are identified in
2285   the generated files.  This is especially useful to avoid collisions
2286   with identifiers in the target language.  For instance
2288     %token FILE for ERROR
2289     %define api.token.prefix {TOK_}
2290     %%
2291     start: FILE for ERROR;
2293   will generate the definition of the symbols TOK_FILE, TOK_for, and
2294   TOK_ERROR in the generated sources.  In particular, the scanner must
2295   use these prefixed token names, although the grammar itself still
2296   uses the short names (as in the sample rule given above).
2298 ** Variable api.value.type
2300   This new %define variable supersedes the #define macro YYSTYPE.  The use
2301   of YYSTYPE is discouraged.  In particular, #defining YYSTYPE *and* either
2302   using %union or %defining api.value.type results in undefined behavior.
2304   Either define api.value.type, or use "%union":
2306     %union
2307     {
2308       int ival;
2309       char *sval;
2310     }
2311     %token <ival> INT "integer"
2312     %token <sval> STRING "string"
2313     %printer { fprintf (yyo, "%d", $$); } <ival>
2314     %destructor { free ($$); } <sval>
2316     /* In yylex().  */
2317     yylval.ival = 42; return INT;
2318     yylval.sval = "42"; return STRING;
2320   The %define variable api.value.type supports both keyword and code values.
2322   The keyword value 'union' means that the user provides genuine types, not
2323   union member names such as "ival" and "sval" above (WARNING: will fail if
2324   -y/--yacc/%yacc is enabled).
2326     %define api.value.type union
2327     %token <int> INT "integer"
2328     %token <char *> STRING "string"
2329     %printer { fprintf (yyo, "%d", $$); } <int>
2330     %destructor { free ($$); } <char *>
2332     /* In yylex().  */
2333     yylval.INT = 42; return INT;
2334     yylval.STRING = "42"; return STRING;
2336   The keyword value variant is somewhat equivalent, but for C++ special
2337   provision is made to allow classes to be used (more about this below).
2339     %define api.value.type variant
2340     %token <int> INT "integer"
2341     %token <std::string> STRING "string"
2343   Code values (in braces) denote user defined types.  This is where YYSTYPE
2344   used to be used.
2346     %code requires
2347     {
2348       struct my_value
2349       {
2350         enum
2351         {
2352           is_int, is_string
2353         } kind;
2354         union
2355         {
2356           int ival;
2357           char *sval;
2358         } u;
2359       };
2360     }
2361     %define api.value.type {struct my_value}
2362     %token <u.ival> INT "integer"
2363     %token <u.sval> STRING "string"
2364     %printer { fprintf (yyo, "%d", $$); } <u.ival>
2365     %destructor { free ($$); } <u.sval>
2367     /* In yylex().  */
2368     yylval.u.ival = 42; return INT;
2369     yylval.u.sval = "42"; return STRING;
2371 ** Variable parse.error
2373   This variable controls the verbosity of error messages.  The use of the
2374   %error-verbose directive is deprecated in favor of "%define parse.error
2375   verbose".
2377 ** Deprecated %define variable names
2379   The following variables have been renamed for consistency.  Backward
2380   compatibility is ensured, but upgrading is recommended.
2382     lr.default-reductions      -> lr.default-reduction
2383     lr.keep-unreachable-states -> lr.keep-unreachable-state
2384     namespace                  -> api.namespace
2385     stype                      -> api.value.type
2387 ** Semantic predicates
2389   Contributed by Paul Hilfinger.
2391   The new, experimental, semantic-predicate feature allows actions of the
2392   form "%?{ BOOLEAN-EXPRESSION }", which cause syntax errors (as for
2393   YYERROR) if the expression evaluates to 0, and are evaluated immediately
2394   in GLR parsers, rather than being deferred.  The result is that they allow
2395   the programmer to prune possible parses based on the values of run-time
2396   expressions.
2398 ** The directive %expect-rr is now an error in non GLR mode
2400   It used to be an error only if used in non GLR mode, _and_ if there are
2401   reduce/reduce conflicts.
2403 ** Tokens are numbered in their order of appearance
2405   Contributed by Valentin Tolmer.
2407   With '%token A B', A had a number less than the one of B.  However,
2408   precedence declarations used to generate a reversed order.  This is now
2409   fixed, and introducing tokens with any of %token, %left, %right,
2410   %precedence, or %nonassoc yields the same result.
2412   When mixing declarations of tokens with a literal character (e.g., 'a') or
2413   with an identifier (e.g., B) in a precedence declaration, Bison numbered
2414   the literal characters first.  For example
2416     %right A B 'c' 'd'
2418   would lead to the tokens declared in this order: 'c' 'd' A B.  Again, the
2419   input order is now preserved.
2421   These changes were made so that one can remove useless precedence and
2422   associativity declarations (i.e., map %nonassoc, %left or %right to
2423   %precedence, or to %token) and get exactly the same output.
2425 ** Useless precedence and associativity
2427   Contributed by Valentin Tolmer.
2429   When developing and maintaining a grammar, useless associativity and
2430   precedence directives are common.  They can be a nuisance: new ambiguities
2431   arising are sometimes masked because their conflicts are resolved due to
2432   the extra precedence or associativity information.  Furthermore, it can
2433   hinder the comprehension of a new grammar: one will wonder about the role
2434   of a precedence, where in fact it is useless.  The following changes aim
2435   at detecting and reporting these extra directives.
2437 *** Precedence warning category
2439   A new category of warning, -Wprecedence, was introduced. It flags the
2440   useless precedence and associativity directives.
2442 *** Useless associativity
2444   Bison now warns about symbols with a declared associativity that is never
2445   used to resolve conflicts.  In that case, using %precedence is sufficient;
2446   the parsing tables will remain unchanged.  Solving these warnings may raise
2447   useless precedence warnings, as the symbols no longer have associativity.
2448   For example:
2450     %left '+'
2451     %left '*'
2452     %%
2453     exp:
2454       "number"
2455     | exp '+' "number"
2456     | exp '*' exp
2457     ;
2459   will produce a
2461     warning: useless associativity for '+', use %precedence [-Wprecedence]
2462      %left '+'
2463            ^^^
2465 *** Useless precedence
2467   Bison now warns about symbols with a declared precedence and no declared
2468   associativity (i.e., declared with %precedence), and whose precedence is
2469   never used.  In that case, the symbol can be safely declared with %token
2470   instead, without modifying the parsing tables.  For example:
2472     %precedence '='
2473     %%
2474     exp: "var" '=' "number";
2476   will produce a
2478     warning: useless precedence for '=' [-Wprecedence]
2479      %precedence '='
2480                  ^^^
2482 *** Useless precedence and associativity
2484   In case of both useless precedence and associativity, the issue is flagged
2485   as follows:
2487     %nonassoc '='
2488     %%
2489     exp: "var" '=' "number";
2491   The warning is:
2493     warning: useless precedence and associativity for '=' [-Wprecedence]
2494      %nonassoc '='
2495                ^^^
2497 ** Empty rules
2499   With help from Joel E. Denny and Gabriel Rassoul.
2501   Empty rules (i.e., with an empty right-hand side) can now be explicitly
2502   marked by the new %empty directive.  Using %empty on a non-empty rule is
2503   an error.  The new -Wempty-rule warning reports empty rules without
2504   %empty.  On the following grammar:
2506     %%
2507     s: a b c;
2508     a: ;
2509     b: %empty;
2510     c: 'a' %empty;
2512   bison reports:
2514     3.4-5: warning: empty rule without %empty [-Wempty-rule]
2515      a: {}
2516         ^^
2517     5.8-13: error: %empty on non-empty rule
2518      c: 'a' %empty {};
2519             ^^^^^^
2521 ** Java skeleton improvements
2523   The constants for token names were moved to the Lexer interface.  Also, it
2524   is possible to add code to the parser's constructors using "%code init"
2525   and "%define init_throws".
2526   Contributed by Paolo Bonzini.
2528   The Java skeleton now supports push parsing.
2529   Contributed by Dennis Heimbigner.
2531 ** C++ skeletons improvements
2533 *** The parser header is no longer mandatory (lalr1.cc, glr.cc)
2535   Using %defines is now optional.  Without it, the needed support classes
2536   are defined in the generated parser, instead of additional files (such as
2537   location.hh, position.hh and stack.hh).
2539 *** Locations are no longer mandatory (lalr1.cc, glr.cc)
2541   Both lalr1.cc and glr.cc no longer require %location.
2543 *** syntax_error exception (lalr1.cc)
2545   The C++ parser features a syntax_error exception, which can be
2546   thrown from the scanner or from user rules to raise syntax errors.
2547   This facilitates reporting errors caught in sub-functions (e.g.,
2548   rejecting too large integral literals from a conversion function
2549   used by the scanner, or rejecting invalid combinations from a
2550   factory invoked by the user actions).
2552 *** %define api.value.type variant
2554   This is based on a submission from Michiel De Wilde.  With help
2555   from Théophile Ranquet.
2557   In this mode, complex C++ objects can be used as semantic values.  For
2558   instance:
2560     %token <::std::string> TEXT;
2561     %token <int> NUMBER;
2562     %token SEMICOLON ";"
2563     %type <::std::string> item;
2564     %type <::std::list<std::string>> list;
2565     %%
2566     result:
2567       list  { std::cout << $1 << std::endl; }
2568     ;
2570     list:
2571       %empty        { /* Generates an empty string list. */ }
2572     | list item ";" { std::swap ($$, $1); $$.push_back ($2); }
2573     ;
2575     item:
2576       TEXT    { std::swap ($$, $1); }
2577     | NUMBER  { $$ = string_cast ($1); }
2578     ;
2580 *** %define api.token.constructor
2582   When variants are enabled, Bison can generate functions to build the
2583   tokens.  This guarantees that the token type (e.g., NUMBER) is consistent
2584   with the semantic value (e.g., int):
2586     parser::symbol_type yylex ()
2587     {
2588       parser::location_type loc = ...;
2589       ...
2590       return parser::make_TEXT ("Hello, world!", loc);
2591       ...
2592       return parser::make_NUMBER (42, loc);
2593       ...
2594       return parser::make_SEMICOLON (loc);
2595       ...
2596     }
2598 *** C++ locations
2600   There are operator- and operator-= for 'location'.  Negative line/column
2601   increments can no longer underflow the resulting value.
2604 * Noteworthy changes in release 2.7.1 (2013-04-15) [stable]
2606 ** Bug fixes
2608 *** Fix compiler attribute portability (yacc.c)
2610   With locations enabled, __attribute__ was used unprotected.
2612 *** Fix some compiler warnings (lalr1.cc)
2615 * Noteworthy changes in release 2.7 (2012-12-12) [stable]
2617 ** Bug fixes
2619   Warnings about uninitialized yylloc in yyparse have been fixed.
2621   Restored C90 compliance (yet no report was ever made).
2623 ** Diagnostics are improved
2625   Contributed by Théophile Ranquet.
2627 *** Changes in the format of error messages
2629   This used to be the format of many error reports:
2631     input.y:2.7-12: %type redeclaration for exp
2632     input.y:1.7-12: previous declaration
2634   It is now:
2636     input.y:2.7-12: error: %type redeclaration for exp
2637     input.y:1.7-12:     previous declaration
2639 *** New format for error reports: carets
2641   Caret errors have been added to Bison:
2643     input.y:2.7-12: error: %type redeclaration for exp
2644      %type <sval> exp
2645            ^^^^^^
2646     input.y:1.7-12:     previous declaration
2647      %type <ival> exp
2648            ^^^^^^
2650   or
2652     input.y:3.20-23: error: ambiguous reference: '$exp'
2653      exp: exp '+' exp { $exp = $1 + $3; };
2654                         ^^^^
2655     input.y:3.1-3:       refers to: $exp at $$
2656      exp: exp '+' exp { $exp = $1 + $3; };
2657      ^^^
2658     input.y:3.6-8:       refers to: $exp at $1
2659      exp: exp '+' exp { $exp = $1 + $3; };
2660           ^^^
2661     input.y:3.14-16:     refers to: $exp at $3
2662      exp: exp '+' exp { $exp = $1 + $3; };
2663                   ^^^
2665   The default behavior for now is still not to display these unless
2666   explicitly asked with -fcaret (or -fall). However, in a later release, it
2667   will be made the default behavior (but may still be deactivated with
2668   -fno-caret).
2670 ** New value for %define variable: api.pure full
2672   The %define variable api.pure requests a pure (reentrant) parser. However,
2673   for historical reasons, using it in a location-tracking Yacc parser
2674   resulted in a yyerror function that did not take a location as a
2675   parameter. With this new value, the user may request a better pure parser,
2676   where yyerror does take a location as a parameter (in location-tracking
2677   parsers).
2679   The use of "%define api.pure true" is deprecated in favor of this new
2680   "%define api.pure full".
2682 ** New %define variable: api.location.type (glr.cc, lalr1.cc, lalr1.java)
2684   The %define variable api.location.type defines the name of the type to use
2685   for locations.  When defined, Bison no longer generates the position.hh
2686   and location.hh files, nor does the parser will include them: the user is
2687   then responsible to define her type.
2689   This can be used in programs with several parsers to factor their location
2690   and position files: let one of them generate them, and the others just use
2691   them.
2693   This feature was actually introduced, but not documented, in Bison 2.5,
2694   under the name "location_type" (which is maintained for backward
2695   compatibility).
2697   For consistency, lalr1.java's %define variables location_type and
2698   position_type are deprecated in favor of api.location.type and
2699   api.position.type.
2701 ** Exception safety (lalr1.cc)
2703   The parse function now catches exceptions, uses the %destructors to
2704   release memory (the lookahead symbol and the symbols pushed on the stack)
2705   before re-throwing the exception.
2707   This feature is somewhat experimental.  User feedback would be
2708   appreciated.
2710 ** Graph improvements in DOT and XSLT
2712   Contributed by Théophile Ranquet.
2714   The graphical presentation of the states is more readable: their shape is
2715   now rectangular, the state number is clearly displayed, and the items are
2716   numbered and left-justified.
2718   The reductions are now explicitly represented as transitions to other
2719   diamond shaped nodes.
2721   These changes are present in both --graph output and xml2dot.xsl XSLT
2722   processing, with minor (documented) differences.
2724 ** %language is no longer an experimental feature.
2726   The introduction of this feature, in 2.4, was four years ago. The
2727   --language option and the %language directive are no longer experimental.
2729 ** Documentation
2731   The sections about shift/reduce and reduce/reduce conflicts resolution
2732   have been fixed and extended.
2734   Although introduced more than four years ago, XML and Graphviz reports
2735   were not properly documented.
2737   The translation of midrule actions is now described.
2740 * Noteworthy changes in release 2.6.5 (2012-11-07) [stable]
2742   We consider compiler warnings about Bison generated parsers to be bugs.
2743   Rather than working around them in your own project, please consider
2744   reporting them to us.
2746 ** Bug fixes
2748   Warnings about uninitialized yylval and/or yylloc for push parsers with a
2749   pure interface have been fixed for GCC 4.0 up to 4.8, and Clang 2.9 to
2750   3.2.
2752   Other issues in the test suite have been addressed.
2754   Null characters are correctly displayed in error messages.
2756   When possible, yylloc is correctly initialized before calling yylex.  It
2757   is no longer necessary to initialize it in the %initial-action.
2760 * Noteworthy changes in release 2.6.4 (2012-10-23) [stable]
2762   Bison 2.6.3's --version was incorrect.  This release fixes this issue.
2765 * Noteworthy changes in release 2.6.3 (2012-10-22) [stable]
2767 ** Bug fixes
2769   Bugs and portability issues in the test suite have been fixed.
2771   Some errors in translations have been addressed, and --help now directs
2772   users to the appropriate place to report them.
2774   Stray Info files shipped by accident are removed.
2776   Incorrect definitions of YY_, issued by yacc.c when no parser header is
2777   generated, are removed.
2779   All the generated headers are self-contained.
2781 ** Header guards (yacc.c, glr.c, glr.cc)
2783   In order to avoid collisions, the header guards are now
2784   YY_<PREFIX>_<FILE>_INCLUDED, instead of merely <PREFIX>_<FILE>.
2785   For instance the header generated from
2787     %define api.prefix "calc"
2788     %defines "lib/parse.h"
2790   will use YY_CALC_LIB_PARSE_H_INCLUDED as guard.
2792 ** Fix compiler warnings in the generated parser (yacc.c, glr.c)
2794   The compilation of pure parsers (%define api.pure) can trigger GCC
2795   warnings such as:
2797     input.c: In function 'yyparse':
2798     input.c:1503:12: warning: 'yylval' may be used uninitialized in this
2799                               function [-Wmaybe-uninitialized]
2800        *++yyvsp = yylval;
2801                 ^
2803   This is now fixed; pragmas to avoid these warnings are no longer needed.
2805   Warnings from clang ("equality comparison with extraneous parentheses" and
2806   "function declared 'noreturn' should not return") have also been
2807   addressed.
2810 * Noteworthy changes in release 2.6.2 (2012-08-03) [stable]
2812 ** Bug fixes
2814   Buffer overruns, complaints from Flex, and portability issues in the test
2815   suite have been fixed.
2817 ** Spaces in %lex- and %parse-param (lalr1.cc, glr.cc)
2819   Trailing end-of-lines in %parse-param or %lex-param would result in
2820   invalid C++.  This is fixed.
2822 ** Spurious spaces and end-of-lines
2824   The generated files no longer end (nor start) with empty lines.
2827 * Noteworthy changes in release 2.6.1 (2012-07-30) [stable]
2829  Bison no longer executes user-specified M4 code when processing a grammar.
2831 ** Future Changes
2833   In addition to the removal of the features announced in Bison 2.6, the
2834   next major release will remove the "Temporary hack for adding a semicolon
2835   to the user action", as announced in the release 2.5.  Instead of:
2837     exp: exp "+" exp { $$ = $1 + $3 };
2839   write:
2841     exp: exp "+" exp { $$ = $1 + $3; };
2843 ** Bug fixes
2845 *** Type names are now properly escaped.
2847 *** glr.cc: set_debug_level and debug_level work as expected.
2849 *** Stray @ or $ in actions
2851   While Bison used to warn about stray $ or @ in action rules, it did not
2852   for other actions such as printers, destructors, or initial actions.  It
2853   now does.
2855 ** Type names in actions
2857   For consistency with rule actions, it is now possible to qualify $$ by a
2858   type-name in destructors, printers, and initial actions.  For instance:
2860     %printer { fprintf (yyo, "(%d, %f)", $<ival>$, $<fval>$); } <*> <>;
2862   will display two values for each typed and untyped symbol (provided
2863   that YYSTYPE has both "ival" and "fval" fields).
2866 * Noteworthy changes in release 2.6 (2012-07-19) [stable]
2868 ** Future changes
2870   The next major release of Bison will drop support for the following
2871   deprecated features.  Please report disagreements to bug-bison@gnu.org.
2873 *** K&R C parsers
2875   Support for generating parsers in K&R C will be removed.  Parsers
2876   generated for C support ISO C90, and are tested with ISO C99 and ISO C11
2877   compilers.
2879 *** Features deprecated since Bison 1.875
2881   The definitions of yystype and yyltype will be removed; use YYSTYPE and
2882   YYLTYPE.
2884   YYPARSE_PARAM and YYLEX_PARAM, deprecated in favor of %parse-param and
2885   %lex-param, will no longer be supported.
2887   Support for the preprocessor symbol YYERROR_VERBOSE will be removed, use
2888   %error-verbose.
2890 *** The generated header will be included (yacc.c)
2892   Instead of duplicating the content of the generated header (definition of
2893   YYSTYPE, yyparse declaration etc.), the generated parser will include it,
2894   as is already the case for GLR or C++ parsers.  This change is deferred
2895   because existing versions of ylwrap (e.g., Automake 1.12.1) do not support
2896   it.
2898 ** Generated Parser Headers
2900 *** Guards (yacc.c, glr.c, glr.cc)
2902   The generated headers are now guarded, as is already the case for C++
2903   parsers (lalr1.cc).  For instance, with --defines=foo.h:
2905     #ifndef YY_FOO_H
2906     # define YY_FOO_H
2907     ...
2908     #endif /* !YY_FOO_H  */
2910 *** New declarations (yacc.c, glr.c)
2912   The generated header now declares yydebug and yyparse.  Both honor
2913   --name-prefix=bar_, and yield
2915     int bar_parse (void);
2917   rather than
2919     #define yyparse bar_parse
2920     int yyparse (void);
2922   in order to facilitate the inclusion of several parser headers inside a
2923   single compilation unit.
2925 *** Exported symbols in C++
2927   The symbols YYTOKEN_TABLE and YYERROR_VERBOSE, which were defined in the
2928   header, are removed, as they prevent the possibility of including several
2929   generated headers from a single compilation unit.
2931 *** YYLSP_NEEDED
2933   For the same reasons, the undocumented and unused macro YYLSP_NEEDED is no
2934   longer defined.
2936 ** New %define variable: api.prefix
2938   Now that the generated headers are more complete and properly protected
2939   against multiple inclusions, constant names, such as YYSTYPE are a
2940   problem.  While yyparse and others are properly renamed by %name-prefix,
2941   YYSTYPE, YYDEBUG and others have never been affected by it.  Because it
2942   would introduce backward compatibility issues in projects not expecting
2943   YYSTYPE to be renamed, instead of changing the behavior of %name-prefix,
2944   it is deprecated in favor of a new %define variable: api.prefix.
2946   The following examples compares both:
2948     %name-prefix "bar_"               | %define api.prefix "bar_"
2949     %token <ival> FOO                   %token <ival> FOO
2950     %union { int ival; }                %union { int ival; }
2951     %%                                  %%
2952     exp: 'a';                           exp: 'a';
2954   bison generates:
2956     #ifndef BAR_FOO_H                   #ifndef BAR_FOO_H
2957     # define BAR_FOO_H                  # define BAR_FOO_H
2959     /* Enabling traces.  */             /* Enabling traces.  */
2960     # ifndef YYDEBUG                  | # ifndef BAR_DEBUG
2961                                       > #  if defined YYDEBUG
2962                                       > #   if YYDEBUG
2963                                       > #    define BAR_DEBUG 1
2964                                       > #   else
2965                                       > #    define BAR_DEBUG 0
2966                                       > #   endif
2967                                       > #  else
2968     #  define YYDEBUG 0               | #   define BAR_DEBUG 0
2969                                       > #  endif
2970     # endif                           | # endif
2972     # if YYDEBUG                      | # if BAR_DEBUG
2973     extern int bar_debug;               extern int bar_debug;
2974     # endif                             # endif
2976     /* Tokens.  */                      /* Tokens.  */
2977     # ifndef YYTOKENTYPE              | # ifndef BAR_TOKENTYPE
2978     #  define YYTOKENTYPE             | #  define BAR_TOKENTYPE
2979        enum yytokentype {             |    enum bar_tokentype {
2980          FOO = 258                           FOO = 258
2981        };                                  };
2982     # endif                             # endif
2984     #if ! defined YYSTYPE \           | #if ! defined BAR_STYPE \
2985      && ! defined YYSTYPE_IS_DECLARED |  && ! defined BAR_STYPE_IS_DECLARED
2986     typedef union YYSTYPE             | typedef union BAR_STYPE
2987     {                                   {
2988      int ival;                           int ival;
2989     } YYSTYPE;                        | } BAR_STYPE;
2990     # define YYSTYPE_IS_DECLARED 1    | # define BAR_STYPE_IS_DECLARED 1
2991     #endif                              #endif
2993     extern YYSTYPE bar_lval;          | extern BAR_STYPE bar_lval;
2995     int bar_parse (void);               int bar_parse (void);
2997     #endif /* !BAR_FOO_H  */            #endif /* !BAR_FOO_H  */
3000 * Noteworthy changes in release 2.5.1 (2012-06-05) [stable]
3002 ** Future changes:
3004   The next major release will drop support for generating parsers in K&R C.
3006 ** yacc.c: YYBACKUP works as expected.
3008 ** glr.c improvements:
3010 *** Location support is eliminated when not requested:
3012   GLR parsers used to include location-related code even when locations were
3013   not requested, and therefore not even usable.
3015 *** __attribute__ is preserved:
3017   __attribute__ is no longer disabled when __STRICT_ANSI__ is defined (i.e.,
3018   when -std is passed to GCC).
3020 ** lalr1.java: several fixes:
3022   The Java parser no longer throws ArrayIndexOutOfBoundsException if the
3023   first token leads to a syntax error.  Some minor clean ups.
3025 ** Changes for C++:
3027 *** C++11 compatibility:
3029   C and C++ parsers use "nullptr" instead of "0" when __cplusplus is 201103L
3030   or higher.
3032 *** Header guards
3034   The header files such as "parser.hh", "location.hh", etc. used a constant
3035   name for preprocessor guards, for instance:
3037     #ifndef BISON_LOCATION_HH
3038     # define BISON_LOCATION_HH
3039     ...
3040     #endif // !BISON_LOCATION_HH
3042   The inclusion guard is now computed from "PREFIX/FILE-NAME", where lower
3043   case characters are converted to upper case, and series of
3044   non-alphanumerical characters are converted to an underscore.
3046   With "bison -o lang++/parser.cc", "location.hh" would now include:
3048     #ifndef YY_LANG_LOCATION_HH
3049     # define YY_LANG_LOCATION_HH
3050     ...
3051     #endif // !YY_LANG_LOCATION_HH
3053 *** C++ locations:
3055   The position and location constructors (and their initialize methods)
3056   accept new arguments for line and column.  Several issues in the
3057   documentation were fixed.
3059 ** liby is no longer asking for "rpl_fprintf" on some platforms.
3061 ** Changes in the manual:
3063 *** %printer is documented
3065   The "%printer" directive, supported since at least Bison 1.50, is finally
3066   documented.  The "mfcalc" example is extended to demonstrate it.
3068   For consistency with the C skeletons, the C++ parsers now also support
3069   "yyoutput" (as an alias to "debug_stream ()").
3071 *** Several improvements have been made:
3073   The layout for grammar excerpts was changed to a more compact scheme.
3074   Named references are motivated.  The description of the automaton
3075   description file (*.output) is updated to the current format.  Incorrect
3076   index entries were fixed.  Some other errors were fixed.
3078 ** Building bison:
3080 *** Conflicting prototypes with recent/modified Flex.
3082   Fixed build problems with the current, unreleased, version of Flex, and
3083   some modified versions of 2.5.35, which have modified function prototypes.
3085 *** Warnings during the build procedure have been eliminated.
3087 *** Several portability problems in the test suite have been fixed:
3089   This includes warnings with some compilers, unexpected behavior of tools
3090   such as diff, warning messages from the test suite itself, etc.
3092 *** The install-pdf target works properly:
3094   Running "make install-pdf" (or -dvi, -html, -info, and -ps) no longer
3095   halts in the middle of its course.
3098 * Noteworthy changes in release 2.5 (2011-05-14)
3100 ** Grammar symbol names can now contain non-initial dashes:
3102   Consistently with directives (such as %error-verbose) and with
3103   %define variables (e.g. push-pull), grammar symbol names may contain
3104   dashes in any position except the beginning.  This is a GNU
3105   extension over POSIX Yacc.  Thus, use of this extension is reported
3106   by -Wyacc and rejected in Yacc mode (--yacc).
3108 ** Named references:
3110   Historically, Yacc and Bison have supported positional references
3111   ($n, $$) to allow access to symbol values from inside of semantic
3112   actions code.
3114   Starting from this version, Bison can also accept named references.
3115   When no ambiguity is possible, original symbol names may be used
3116   as named references:
3118     if_stmt : "if" cond_expr "then" then_stmt ';'
3119     { $if_stmt = mk_if_stmt($cond_expr, $then_stmt); }
3121   In the more common case, explicit names may be declared:
3123     stmt[res] : "if" expr[cond] "then" stmt[then] "else" stmt[else] ';'
3124     { $res = mk_if_stmt($cond, $then, $else); }
3126   Location information is also accessible using @name syntax.  When
3127   accessing symbol names containing dots or dashes, explicit bracketing
3128   ($[sym.1]) must be used.
3130   These features are experimental in this version.  More user feedback
3131   will help to stabilize them.
3132   Contributed by Alex Rozenman.
3134 ** IELR(1) and canonical LR(1):
3136   IELR(1) is a minimal LR(1) parser table generation algorithm.  That
3137   is, given any context-free grammar, IELR(1) generates parser tables
3138   with the full language-recognition power of canonical LR(1) but with
3139   nearly the same number of parser states as LALR(1).  This reduction
3140   in parser states is often an order of magnitude.  More importantly,
3141   because canonical LR(1)'s extra parser states may contain duplicate
3142   conflicts in the case of non-LR(1) grammars, the number of conflicts
3143   for IELR(1) is often an order of magnitude less as well.  This can
3144   significantly reduce the complexity of developing of a grammar.
3146   Bison can now generate IELR(1) and canonical LR(1) parser tables in
3147   place of its traditional LALR(1) parser tables, which remain the
3148   default.  You can specify the type of parser tables in the grammar
3149   file with these directives:
3151     %define lr.type lalr
3152     %define lr.type ielr
3153     %define lr.type canonical-lr
3155   The default-reduction optimization in the parser tables can also be
3156   adjusted using "%define lr.default-reductions".  For details on both
3157   of these features, see the new section "Tuning LR" in the Bison
3158   manual.
3160   These features are experimental.  More user feedback will help to
3161   stabilize them.
3163 ** LAC (Lookahead Correction) for syntax error handling
3165   Contributed by Joel E. Denny.
3167   Canonical LR, IELR, and LALR can suffer from a couple of problems
3168   upon encountering a syntax error.  First, the parser might perform
3169   additional parser stack reductions before discovering the syntax
3170   error.  Such reductions can perform user semantic actions that are
3171   unexpected because they are based on an invalid token, and they
3172   cause error recovery to begin in a different syntactic context than
3173   the one in which the invalid token was encountered.  Second, when
3174   verbose error messages are enabled (with %error-verbose or the
3175   obsolete "#define YYERROR_VERBOSE"), the expected token list in the
3176   syntax error message can both contain invalid tokens and omit valid
3177   tokens.
3179   The culprits for the above problems are %nonassoc, default
3180   reductions in inconsistent states, and parser state merging.  Thus,
3181   IELR and LALR suffer the most.  Canonical LR can suffer only if
3182   %nonassoc is used or if default reductions are enabled for
3183   inconsistent states.
3185   LAC is a new mechanism within the parsing algorithm that solves
3186   these problems for canonical LR, IELR, and LALR without sacrificing
3187   %nonassoc, default reductions, or state merging.  When LAC is in
3188   use, canonical LR and IELR behave almost exactly the same for both
3189   syntactically acceptable and syntactically unacceptable input.
3190   While LALR still does not support the full language-recognition
3191   power of canonical LR and IELR, LAC at least enables LALR's syntax
3192   error handling to correctly reflect LALR's language-recognition
3193   power.
3195   Currently, LAC is only supported for deterministic parsers in C.
3196   You can enable LAC with the following directive:
3198     %define parse.lac full
3200   See the new section "LAC" in the Bison manual for additional
3201   details including a few caveats.
3203   LAC is an experimental feature.  More user feedback will help to
3204   stabilize it.
3206 ** %define improvements:
3208 *** Can now be invoked via the command line:
3210   Each of these command-line options
3212     -D NAME[=VALUE]
3213     --define=NAME[=VALUE]
3215     -F NAME[=VALUE]
3216     --force-define=NAME[=VALUE]
3218   is equivalent to this grammar file declaration
3220     %define NAME ["VALUE"]
3222   except that the manner in which Bison processes multiple definitions
3223   for the same NAME differs.  Most importantly, -F and --force-define
3224   quietly override %define, but -D and --define do not.  For further
3225   details, see the section "Bison Options" in the Bison manual.
3227 *** Variables renamed:
3229   The following %define variables
3231     api.push_pull
3232     lr.keep_unreachable_states
3234   have been renamed to
3236     api.push-pull
3237     lr.keep-unreachable-states
3239   The old names are now deprecated but will be maintained indefinitely
3240   for backward compatibility.
3242 *** Values no longer need to be quoted in the grammar file:
3244   If a %define value is an identifier, it no longer needs to be placed
3245   within quotations marks.  For example,
3247     %define api.push-pull "push"
3249   can be rewritten as
3251     %define api.push-pull push
3253 *** Unrecognized variables are now errors not warnings.
3255 *** Multiple invocations for any variable is now an error not a warning.
3257 ** Unrecognized %code qualifiers are now errors not warnings.
3259 ** Character literals not of length one:
3261   Previously, Bison quietly converted all character literals to length
3262   one.  For example, without warning, Bison interpreted the operators in
3263   the following grammar to be the same token:
3265     exp: exp '++'
3266        | exp '+' exp
3267        ;
3269   Bison now warns when a character literal is not of length one.  In
3270   some future release, Bison will start reporting an error instead.
3272 ** Destructor calls fixed for lookaheads altered in semantic actions:
3274   Previously for deterministic parsers in C, if a user semantic action
3275   altered yychar, the parser in some cases used the old yychar value to
3276   determine which destructor to call for the lookahead upon a syntax
3277   error or upon parser return.  This bug has been fixed.
3279 ** C++ parsers use YYRHSLOC:
3281   Similarly to the C parsers, the C++ parsers now define the YYRHSLOC
3282   macro and use it in the default YYLLOC_DEFAULT.  You are encouraged
3283   to use it.  If, for instance, your location structure has "first"
3284   and "last" members, instead of
3286     # define YYLLOC_DEFAULT(Current, Rhs, N)                             \
3287       do                                                                 \
3288         if (N)                                                           \
3289           {                                                              \
3290             (Current).first = (Rhs)[1].location.first;                   \
3291             (Current).last  = (Rhs)[N].location.last;                    \
3292           }                                                              \
3293         else                                                             \
3294           {                                                              \
3295             (Current).first = (Current).last = (Rhs)[0].location.last;   \
3296           }                                                              \
3297       while (false)
3299   use:
3301     # define YYLLOC_DEFAULT(Current, Rhs, N)                             \
3302       do                                                                 \
3303         if (N)                                                           \
3304           {                                                              \
3305             (Current).first = YYRHSLOC (Rhs, 1).first;                   \
3306             (Current).last  = YYRHSLOC (Rhs, N).last;                    \
3307           }                                                              \
3308         else                                                             \
3309           {                                                              \
3310             (Current).first = (Current).last = YYRHSLOC (Rhs, 0).last;   \
3311           }                                                              \
3312       while (false)
3314 ** YYLLOC_DEFAULT in C++:
3316   The default implementation of YYLLOC_DEFAULT used to be issued in
3317   the header file.  It is now output in the implementation file, after
3318   the user %code sections so that its #ifndef guard does not try to
3319   override the user's YYLLOC_DEFAULT if provided.
3321 ** YYFAIL now produces warnings and Java parsers no longer implement it:
3323   YYFAIL has existed for many years as an undocumented feature of
3324   deterministic parsers in C generated by Bison.  More recently, it was
3325   a documented feature of Bison's experimental Java parsers.  As
3326   promised in Bison 2.4.2's NEWS entry, any appearance of YYFAIL in a
3327   semantic action now produces a deprecation warning, and Java parsers
3328   no longer implement YYFAIL at all.  For further details, including a
3329   discussion of how to suppress C preprocessor warnings about YYFAIL
3330   being unused, see the Bison 2.4.2 NEWS entry.
3332 ** Temporary hack for adding a semicolon to the user action:
3334   Previously, Bison appended a semicolon to every user action for
3335   reductions when the output language defaulted to C (specifically, when
3336   neither %yacc, %language, %skeleton, or equivalent command-line
3337   options were specified).  This allowed actions such as
3339     exp: exp "+" exp { $$ = $1 + $3 };
3341   instead of
3343     exp: exp "+" exp { $$ = $1 + $3; };
3345   As a first step in removing this misfeature, Bison now issues a
3346   warning when it appends a semicolon.  Moreover, in cases where Bison
3347   cannot easily determine whether a semicolon is needed (for example, an
3348   action ending with a cpp directive or a braced compound initializer),
3349   it no longer appends one.  Thus, the C compiler might now complain
3350   about a missing semicolon where it did not before.  Future releases of
3351   Bison will cease to append semicolons entirely.
3353 ** Verbose syntax error message fixes:
3355   When %error-verbose or the obsolete "#define YYERROR_VERBOSE" is
3356   specified, syntax error messages produced by the generated parser
3357   include the unexpected token as well as a list of expected tokens.
3358   The effect of %nonassoc on these verbose messages has been corrected
3359   in two ways, but a more complete fix requires LAC, described above:
3361 *** When %nonassoc is used, there can exist parser states that accept no
3362     tokens, and so the parser does not always require a lookahead token
3363     in order to detect a syntax error.  Because no unexpected token or
3364     expected tokens can then be reported, the verbose syntax error
3365     message described above is suppressed, and the parser instead
3366     reports the simpler message, "syntax error".  Previously, this
3367     suppression was sometimes erroneously triggered by %nonassoc when a
3368     lookahead was actually required.  Now verbose messages are
3369     suppressed only when all previous lookaheads have already been
3370     shifted or discarded.
3372 *** Previously, the list of expected tokens erroneously included tokens
3373     that would actually induce a syntax error because conflicts for them
3374     were resolved with %nonassoc in the current parser state.  Such
3375     tokens are now properly omitted from the list.
3377 *** Expected token lists are still often wrong due to state merging
3378     (from LALR or IELR) and default reductions, which can both add
3379     invalid tokens and subtract valid tokens.  Canonical LR almost
3380     completely fixes this problem by eliminating state merging and
3381     default reductions.  However, there is one minor problem left even
3382     when using canonical LR and even after the fixes above.  That is,
3383     if the resolution of a conflict with %nonassoc appears in a later
3384     parser state than the one at which some syntax error is
3385     discovered, the conflicted token is still erroneously included in
3386     the expected token list.  Bison's new LAC implementation,
3387     described above, eliminates this problem and the need for
3388     canonical LR.  However, LAC is still experimental and is disabled
3389     by default.
3391 ** Java skeleton fixes:
3393 *** A location handling bug has been fixed.
3395 *** The top element of each of the value stack and location stack is now
3396     cleared when popped so that it can be garbage collected.
3398 *** Parser traces now print the top element of the stack.
3400 ** -W/--warnings fixes:
3402 *** Bison now properly recognizes the "no-" versions of categories:
3404   For example, given the following command line, Bison now enables all
3405   warnings except warnings for incompatibilities with POSIX Yacc:
3407     bison -Wall,no-yacc gram.y
3409 *** Bison now treats S/R and R/R conflicts like other warnings:
3411   Previously, conflict reports were independent of Bison's normal
3412   warning system.  Now, Bison recognizes the warning categories
3413   "conflicts-sr" and "conflicts-rr".  This change has important
3414   consequences for the -W and --warnings command-line options.  For
3415   example:
3417     bison -Wno-conflicts-sr gram.y  # S/R conflicts not reported
3418     bison -Wno-conflicts-rr gram.y  # R/R conflicts not reported
3419     bison -Wnone            gram.y  # no conflicts are reported
3420     bison -Werror           gram.y  # any conflict is an error
3422   However, as before, if the %expect or %expect-rr directive is
3423   specified, an unexpected number of conflicts is an error, and an
3424   expected number of conflicts is not reported, so -W and --warning
3425   then have no effect on the conflict report.
3427 *** The "none" category no longer disables a preceding "error":
3429   For example, for the following command line, Bison now reports
3430   errors instead of warnings for incompatibilities with POSIX Yacc:
3432     bison -Werror,none,yacc gram.y
3434 *** The "none" category now disables all Bison warnings:
3436   Previously, the "none" category disabled only Bison warnings for
3437   which there existed a specific -W/--warning category.  However,
3438   given the following command line, Bison is now guaranteed to
3439   suppress all warnings:
3441     bison -Wnone gram.y
3443 ** Precedence directives can now assign token number 0:
3445   Since Bison 2.3b, which restored the ability of precedence
3446   directives to assign token numbers, doing so for token number 0 has
3447   produced an assertion failure.  For example:
3449     %left END 0
3451   This bug has been fixed.
3454 * Noteworthy changes in release 2.4.3 (2010-08-05)
3456 ** Bison now obeys -Werror and --warnings=error for warnings about
3457    grammar rules that are useless in the parser due to conflicts.
3459 ** Problems with spawning M4 on at least FreeBSD 8 and FreeBSD 9 have
3460    been fixed.
3462 ** Failures in the test suite for GCC 4.5 have been fixed.
3464 ** Failures in the test suite for some versions of Sun Studio C++ have
3465    been fixed.
3467 ** Contrary to Bison 2.4.2's NEWS entry, it has been decided that
3468    warnings about undefined %prec identifiers will not be converted to
3469    errors in Bison 2.5.  They will remain warnings, which should be
3470    sufficient for POSIX while avoiding backward compatibility issues.
3472 ** Minor documentation fixes.
3475 * Noteworthy changes in release 2.4.2 (2010-03-20)
3477 ** Some portability problems that resulted in failures and livelocks
3478    in the test suite on some versions of at least Solaris, AIX, HP-UX,
3479    RHEL4, and Tru64 have been addressed.  As a result, fatal Bison
3480    errors should no longer cause M4 to report a broken pipe on the
3481    affected platforms.
3483 ** "%prec IDENTIFIER" requires IDENTIFIER to be defined separately.
3485   POSIX specifies that an error be reported for any identifier that does
3486   not appear on the LHS of a grammar rule and that is not defined by
3487   %token, %left, %right, or %nonassoc.  Bison 2.3b and later lost this
3488   error report for the case when an identifier appears only after a
3489   %prec directive.  It is now restored.  However, for backward
3490   compatibility with recent Bison releases, it is only a warning for
3491   now.  In Bison 2.5 and later, it will return to being an error.
3492   [Between the 2.4.2 and 2.4.3 releases, it was decided that this
3493   warning will not be converted to an error in Bison 2.5.]
3495 ** Detection of GNU M4 1.4.6 or newer during configure is improved.
3497 ** Warnings from gcc's -Wundef option about undefined YYENABLE_NLS,
3498    YYLTYPE_IS_TRIVIAL, and __STRICT_ANSI__ in C/C++ parsers are now
3499    avoided.
3501 ** %code is now a permanent feature.
3503   A traditional Yacc prologue directive is written in the form:
3505     %{CODE%}
3507   To provide a more flexible alternative, Bison 2.3b introduced the
3508   %code directive with the following forms for C/C++:
3510     %code          {CODE}
3511     %code requires {CODE}
3512     %code provides {CODE}
3513     %code top      {CODE}
3515   These forms are now considered permanent features of Bison.  See the
3516   %code entries in the section "Bison Declaration Summary" in the Bison
3517   manual for a summary of their functionality.  See the section
3518   "Prologue Alternatives" for a detailed discussion including the
3519   advantages of %code over the traditional Yacc prologue directive.
3521   Bison's Java feature as a whole including its current usage of %code
3522   is still considered experimental.
3524 ** YYFAIL is deprecated and will eventually be removed.
3526   YYFAIL has existed for many years as an undocumented feature of
3527   deterministic parsers in C generated by Bison.  Previously, it was
3528   documented for Bison's experimental Java parsers.  YYFAIL is no longer
3529   documented for Java parsers and is formally deprecated in both cases.
3530   Users are strongly encouraged to migrate to YYERROR, which is
3531   specified by POSIX.
3533   Like YYERROR, you can invoke YYFAIL from a semantic action in order to
3534   induce a syntax error.  The most obvious difference from YYERROR is
3535   that YYFAIL will automatically invoke yyerror to report the syntax
3536   error so that you don't have to.  However, there are several other
3537   subtle differences between YYERROR and YYFAIL, and YYFAIL suffers from
3538   inherent flaws when %error-verbose or "#define YYERROR_VERBOSE" is
3539   used.  For a more detailed discussion, see:
3541     https://lists.gnu.org/r/bison-patches/2009-12/msg00024.html
3543   The upcoming Bison 2.5 will remove YYFAIL from Java parsers, but
3544   deterministic parsers in C will continue to implement it.  However,
3545   because YYFAIL is already flawed, it seems futile to try to make new
3546   Bison features compatible with it.  Thus, during parser generation,
3547   Bison 2.5 will produce a warning whenever it discovers YYFAIL in a
3548   rule action.  In a later release, YYFAIL will be disabled for
3549   %error-verbose and "#define YYERROR_VERBOSE".  Eventually, YYFAIL will
3550   be removed altogether.
3552   There exists at least one case where Bison 2.5's YYFAIL warning will
3553   be a false positive.  Some projects add phony uses of YYFAIL and other
3554   Bison-defined macros for the sole purpose of suppressing C
3555   preprocessor warnings (from GCC cpp's -Wunused-macros, for example).
3556   To avoid Bison's future warning, such YYFAIL uses can be moved to the
3557   epilogue (that is, after the second "%%") in the Bison input file.  In
3558   this release (2.4.2), Bison already generates its own code to suppress
3559   C preprocessor warnings for YYFAIL, so projects can remove their own
3560   phony uses of YYFAIL if compatibility with Bison releases prior to
3561   2.4.2 is not necessary.
3563 ** Internationalization.
3565   Fix a regression introduced in Bison 2.4: Under some circumstances,
3566   message translations were not installed although supported by the
3567   host system.
3570 * Noteworthy changes in release 2.4.1 (2008-12-11)
3572 ** In the GLR defines file, unexpanded M4 macros in the yylval and yylloc
3573    declarations have been fixed.
3575 ** Temporary hack for adding a semicolon to the user action.
3577   Bison used to prepend a trailing semicolon at the end of the user
3578   action for reductions.  This allowed actions such as
3580     exp: exp "+" exp { $$ = $1 + $3 };
3582   instead of
3584     exp: exp "+" exp { $$ = $1 + $3; };
3586   Some grammars still depend on this "feature".  Bison 2.4.1 restores
3587   the previous behavior in the case of C output (specifically, when
3588   neither %language or %skeleton or equivalent command-line options
3589   are used) to leave more time for grammars depending on the old
3590   behavior to be adjusted.  Future releases of Bison will disable this
3591   feature.
3593 ** A few minor improvements to the Bison manual.
3596 * Noteworthy changes in release 2.4 (2008-11-02)
3598 ** %language is an experimental feature.
3600   We first introduced this feature in test release 2.3b as a cleaner
3601   alternative to %skeleton.  Since then, we have discussed the possibility of
3602   modifying its effect on Bison's output file names.  Thus, in this release,
3603   we consider %language to be an experimental feature that will likely evolve
3604   in future releases.
3606 ** Forward compatibility with GNU M4 has been improved.
3608 ** Several bugs in the C++ skeleton and the experimental Java skeleton have been
3609   fixed.
3612 * Noteworthy changes in release 2.3b (2008-05-27)
3614 ** The quotes around NAME that used to be required in the following directive
3615   are now deprecated:
3617     %define NAME "VALUE"
3619 ** The directive "%pure-parser" is now deprecated in favor of:
3621     %define api.pure
3623   which has the same effect except that Bison is more careful to warn about
3624   unreasonable usage in the latter case.
3626 ** Push Parsing
3628   Bison can now generate an LALR(1) parser in C with a push interface.  That
3629   is, instead of invoking "yyparse", which pulls tokens from "yylex", you can
3630   push one token at a time to the parser using "yypush_parse", which will
3631   return to the caller after processing each token.  By default, the push
3632   interface is disabled.  Either of the following directives will enable it:
3634     %define api.push_pull "push" // Just push; does not require yylex.
3635     %define api.push_pull "both" // Push and pull; requires yylex.
3637   See the new section "A Push Parser" in the Bison manual for details.
3639   The current push parsing interface is experimental and may evolve.  More user
3640   feedback will help to stabilize it.
3642 ** The -g and --graph options now output graphs in Graphviz DOT format,
3643   not VCG format.  Like --graph, -g now also takes an optional FILE argument
3644   and thus cannot be bundled with other short options.
3646 ** Java
3648   Bison can now generate an LALR(1) parser in Java.  The skeleton is
3649   "data/lalr1.java".  Consider using the new %language directive instead of
3650   %skeleton to select it.
3652   See the new section "Java Parsers" in the Bison manual for details.
3654   The current Java interface is experimental and may evolve.  More user
3655   feedback will help to stabilize it.
3656   Contributed by Paolo Bonzini.
3658 ** %language
3660   This new directive specifies the programming language of the generated
3661   parser, which can be C (the default), C++, or Java.  Besides the skeleton
3662   that Bison uses, the directive affects the names of the generated files if
3663   the grammar file's name ends in ".y".
3665 ** XML Automaton Report
3667   Bison can now generate an XML report of the LALR(1) automaton using the new
3668   "--xml" option.  The current XML schema is experimental and may evolve.  More
3669   user feedback will help to stabilize it.
3670   Contributed by Wojciech Polak.
3672 ** The grammar file may now specify the name of the parser header file using
3673   %defines.  For example:
3675     %defines "parser.h"
3677 ** When reporting useless rules, useless nonterminals, and unused terminals,
3678   Bison now employs the terms "useless in grammar" instead of "useless",
3679   "useless in parser" instead of "never reduced", and "unused in grammar"
3680   instead of "unused".
3682 ** Unreachable State Removal
3684   Previously, Bison sometimes generated parser tables containing unreachable
3685   states.  A state can become unreachable during conflict resolution if Bison
3686   disables a shift action leading to it from a predecessor state.  Bison now:
3688     1. Removes unreachable states.
3690     2. Does not report any conflicts that appeared in unreachable states.
3691        WARNING: As a result, you may need to update %expect and %expect-rr
3692        directives in existing grammar files.
3694     3. For any rule used only in such states, Bison now reports the rule as
3695        "useless in parser due to conflicts".
3697   This feature can be disabled with the following directive:
3699     %define lr.keep_unreachable_states
3701   See the %define entry in the "Bison Declaration Summary" in the Bison manual
3702   for further discussion.
3704 ** Lookahead Set Correction in the ".output" Report
3706   When instructed to generate a ".output" file including lookahead sets
3707   (using "--report=lookahead", for example), Bison now prints each reduction's
3708   lookahead set only next to the associated state's one item that (1) is
3709   associated with the same rule as the reduction and (2) has its dot at the end
3710   of its RHS.  Previously, Bison also erroneously printed the lookahead set
3711   next to all of the state's other items associated with the same rule.  This
3712   bug affected only the ".output" file and not the generated parser source
3713   code.
3715 ** --report-file=FILE is a new option to override the default ".output" file
3716   name.
3718 ** The "=" that used to be required in the following directives is now
3719   deprecated:
3721     %file-prefix "parser"
3722     %name-prefix "c_"
3723     %output "parser.c"
3725 ** An Alternative to "%{...%}" -- "%code QUALIFIER {CODE}"
3727   Bison 2.3a provided a new set of directives as a more flexible alternative to
3728   the traditional Yacc prologue blocks.  Those have now been consolidated into
3729   a single %code directive with an optional qualifier field, which identifies
3730   the purpose of the code and thus the location(s) where Bison should generate
3731   it:
3733     1. "%code          {CODE}" replaces "%after-header  {CODE}"
3734     2. "%code requires {CODE}" replaces "%start-header  {CODE}"
3735     3. "%code provides {CODE}" replaces "%end-header    {CODE}"
3736     4. "%code top      {CODE}" replaces "%before-header {CODE}"
3738   See the %code entries in section "Bison Declaration Summary" in the Bison
3739   manual for a summary of the new functionality.  See the new section "Prologue
3740   Alternatives" for a detailed discussion including the advantages of %code
3741   over the traditional Yacc prologues.
3743   The prologue alternatives are experimental.  More user feedback will help to
3744   determine whether they should become permanent features.
3746 ** Revised warning: unset or unused midrule values
3748   Since Bison 2.2, Bison has warned about midrule values that are set but not
3749   used within any of the actions of the parent rule.  For example, Bison warns
3750   about unused $2 in:
3752     exp: '1' { $$ = 1; } '+' exp { $$ = $1 + $4; };
3754   Now, Bison also warns about midrule values that are used but not set.  For
3755   example, Bison warns about unset $$ in the midrule action in:
3757     exp: '1' { $1 = 1; } '+' exp { $$ = $2 + $4; };
3759   However, Bison now disables both of these warnings by default since they
3760   sometimes prove to be false alarms in existing grammars employing the Yacc
3761   constructs $0 or $-N (where N is some positive integer).
3763   To enable these warnings, specify the option "--warnings=midrule-values" or
3764   "-W", which is a synonym for "--warnings=all".
3766 ** Default %destructor or %printer with "<*>" or "<>"
3768   Bison now recognizes two separate kinds of default %destructor's and
3769   %printer's:
3771     1. Place "<*>" in a %destructor/%printer symbol list to define a default
3772        %destructor/%printer for all grammar symbols for which you have formally
3773        declared semantic type tags.
3775     2. Place "<>" in a %destructor/%printer symbol list to define a default
3776        %destructor/%printer for all grammar symbols without declared semantic
3777        type tags.
3779   Bison no longer supports the "%symbol-default" notation from Bison 2.3a.
3780   "<*>" and "<>" combined achieve the same effect with one exception: Bison no
3781   longer applies any %destructor to a midrule value if that midrule value is
3782   not actually ever referenced using either $$ or $n in a semantic action.
3784   The default %destructor's and %printer's are experimental.  More user
3785   feedback will help to determine whether they should become permanent
3786   features.
3788   See the section "Freeing Discarded Symbols" in the Bison manual for further
3789   details.
3791 ** %left, %right, and %nonassoc can now declare token numbers.  This is required
3792   by POSIX.  However, see the end of section "Operator Precedence" in the Bison
3793   manual for a caveat concerning the treatment of literal strings.
3795 ** The nonfunctional --no-parser, -n, and %no-parser options have been
3796   completely removed from Bison.
3799 * Noteworthy changes in release 2.3a (2006-09-13)
3801 ** Instead of %union, you can define and use your own union type
3802   YYSTYPE if your grammar contains at least one <type> tag.
3803   Your YYSTYPE need not be a macro; it can be a typedef.
3804   This change is for compatibility with other Yacc implementations,
3805   and is required by POSIX.
3807 ** Locations columns and lines start at 1.
3808   In accordance with the GNU Coding Standards and Emacs.
3810 ** You may now declare per-type and default %destructor's and %printer's:
3812   For example:
3814     %union { char *string; }
3815     %token <string> STRING1
3816     %token <string> STRING2
3817     %type  <string> string1
3818     %type  <string> string2
3819     %union { char character; }
3820     %token <character> CHR
3821     %type  <character> chr
3822     %destructor { free ($$); } %symbol-default
3823     %destructor { free ($$); printf ("%d", @$.first_line); } STRING1 string1
3824     %destructor { } <character>
3826   guarantees that, when the parser discards any user-defined symbol that has a
3827   semantic type tag other than "<character>", it passes its semantic value to
3828   "free".  However, when the parser discards a "STRING1" or a "string1", it
3829   also prints its line number to "stdout".  It performs only the second
3830   "%destructor" in this case, so it invokes "free" only once.
3832   [Although we failed to mention this here in the 2.3a release, the default
3833   %destructor's and %printer's were experimental, and they were rewritten in
3834   future versions.]
3836 ** Except for LALR(1) parsers in C with POSIX Yacc emulation enabled (with "-y",
3837   "--yacc", or "%yacc"), Bison no longer generates #define statements for
3838   associating token numbers with token names.  Removing the #define statements
3839   helps to sanitize the global namespace during preprocessing, but POSIX Yacc
3840   requires them.  Bison still generates an enum for token names in all cases.
3842 ** Handling of traditional Yacc prologue blocks is now more consistent but
3843   potentially incompatible with previous releases of Bison.
3845   As before, you declare prologue blocks in your grammar file with the
3846   "%{ ... %}" syntax.  To generate the pre-prologue, Bison concatenates all
3847   prologue blocks that you've declared before the first %union.  To generate
3848   the post-prologue, Bison concatenates all prologue blocks that you've
3849   declared after the first %union.
3851   Previous releases of Bison inserted the pre-prologue into both the header
3852   file and the code file in all cases except for LALR(1) parsers in C.  In the
3853   latter case, Bison inserted it only into the code file.  For parsers in C++,
3854   the point of insertion was before any token definitions (which associate
3855   token numbers with names).  For parsers in C, the point of insertion was
3856   after the token definitions.
3858   Now, Bison never inserts the pre-prologue into the header file.  In the code
3859   file, it always inserts it before the token definitions.
3861 ** Bison now provides a more flexible alternative to the traditional Yacc
3862   prologue blocks: %before-header, %start-header, %end-header, and
3863   %after-header.
3865   For example, the following declaration order in the grammar file reflects the
3866   order in which Bison will output these code blocks.  However, you are free to
3867   declare these code blocks in your grammar file in whatever order is most
3868   convenient for you:
3870     %before-header {
3871       /* Bison treats this block like a pre-prologue block: it inserts it into
3872        * the code file before the contents of the header file.  It does *not*
3873        * insert it into the header file.  This is a good place to put
3874        * #include's that you want at the top of your code file.  A common
3875        * example is '#include "system.h"'.  */
3876     }
3877     %start-header {
3878       /* Bison inserts this block into both the header file and the code file.
3879        * In both files, the point of insertion is before any Bison-generated
3880        * token, semantic type, location type, and class definitions.  This is a
3881        * good place to define %union dependencies, for example.  */
3882     }
3883     %union {
3884       /* Unlike the traditional Yacc prologue blocks, the output order for the
3885        * new %*-header blocks is not affected by their declaration position
3886        * relative to any %union in the grammar file.  */
3887     }
3888     %end-header {
3889       /* Bison inserts this block into both the header file and the code file.
3890        * In both files, the point of insertion is after the Bison-generated
3891        * definitions.  This is a good place to declare or define public
3892        * functions or data structures that depend on the Bison-generated
3893        * definitions.  */
3894     }
3895     %after-header {
3896       /* Bison treats this block like a post-prologue block: it inserts it into
3897        * the code file after the contents of the header file.  It does *not*
3898        * insert it into the header file.  This is a good place to declare or
3899        * define internal functions or data structures that depend on the
3900        * Bison-generated definitions.  */
3901     }
3903   If you have multiple occurrences of any one of the above declarations, Bison
3904   will concatenate the contents in declaration order.
3906   [Although we failed to mention this here in the 2.3a release, the prologue
3907   alternatives were experimental, and they were rewritten in future versions.]
3909 ** The option "--report=look-ahead" has been changed to "--report=lookahead".
3910   The old spelling still works, but is not documented and may be removed
3911   in a future release.
3914 * Noteworthy changes in release 2.3 (2006-06-05)
3916 ** GLR grammars should now use "YYRECOVERING ()" instead of "YYRECOVERING",
3917   for compatibility with LALR(1) grammars.
3919 ** It is now documented that any definition of YYSTYPE or YYLTYPE should
3920   be to a type name that does not contain parentheses or brackets.
3923 * Noteworthy changes in release 2.2 (2006-05-19)
3925 ** The distribution terms for all Bison-generated parsers now permit
3926   using the parsers in nonfree programs.  Previously, this permission
3927   was granted only for Bison-generated LALR(1) parsers in C.
3929 ** %name-prefix changes the namespace name in C++ outputs.
3931 ** The C++ parsers export their token_type.
3933 ** Bison now allows multiple %union declarations, and concatenates
3934   their contents together.
3936 ** New warning: unused values
3937   Right-hand side symbols whose values are not used are reported,
3938   if the symbols have destructors.  For instance:
3940      exp: exp "?" exp ":" exp { $1 ? $1 : $3; }
3941         | exp "+" exp
3942         ;
3944   will trigger a warning about $$ and $5 in the first rule, and $3 in
3945   the second ($1 is copied to $$ by the default rule).  This example
3946   most likely contains three errors, and could be rewritten as:
3948      exp: exp "?" exp ":" exp
3949             { $$ = $1 ? $3 : $5; free ($1 ? $5 : $3); free ($1); }
3950         | exp "+" exp
3951             { $$ = $1 ? $1 : $3; if ($1) free ($3); }
3952         ;
3954   However, if the original actions were really intended, memory leaks
3955   and all, the warnings can be suppressed by letting Bison believe the
3956   values are used, e.g.:
3958      exp: exp "?" exp ":" exp { $1 ? $1 : $3; (void) ($$, $5); }
3959         | exp "+" exp         { $$ = $1; (void) $3; }
3960         ;
3962   If there are midrule actions, the warning is issued if no action
3963   uses it.  The following triggers no warning: $1 and $3 are used.
3965      exp: exp { push ($1); } '+' exp { push ($3); sum (); };
3967   The warning is intended to help catching lost values and memory leaks.
3968   If a value is ignored, its associated memory typically is not reclaimed.
3970 ** %destructor vs. YYABORT, YYACCEPT, and YYERROR.
3971   Destructors are now called when user code invokes YYABORT, YYACCEPT,
3972   and YYERROR, for all objects on the stack, other than objects
3973   corresponding to the right-hand side of the current rule.
3975 ** %expect, %expect-rr
3976   Incorrect numbers of expected conflicts are now actual errors,
3977   instead of warnings.
3979 ** GLR, YACC parsers.
3980   The %parse-params are available in the destructors (and the
3981   experimental printers) as per the documentation.
3983 ** Bison now warns if it finds a stray "$" or "@" in an action.
3985 ** %require "VERSION"
3986   This specifies that the grammar file depends on features implemented
3987   in Bison version VERSION or higher.
3989 ** lalr1.cc: The token and value types are now class members.
3990   The tokens were defined as free form enums and cpp macros.  YYSTYPE
3991   was defined as a free form union.  They are now class members:
3992   tokens are enumerations of the "yy::parser::token" struct, and the
3993   semantic values have the "yy::parser::semantic_type" type.
3995   If you do not want or can update to this scheme, the directive
3996   '%define "global_tokens_and_yystype" "1"' triggers the global
3997   definition of tokens and YYSTYPE.  This change is suitable both
3998   for previous releases of Bison, and this one.
4000   If you wish to update, then make sure older version of Bison will
4001   fail using '%require "2.2"'.
4003 ** DJGPP support added.
4006 * Noteworthy changes in release 2.1 (2005-09-16)
4008 ** The C++ lalr1.cc skeleton supports %lex-param.
4010 ** Bison-generated parsers now support the translation of diagnostics like
4011   "syntax error" into languages other than English.  The default
4012   language is still English.  For details, please see the new
4013   Internationalization section of the Bison manual.  Software
4014   distributors should also see the new PACKAGING file.  Thanks to
4015   Bruno Haible for this new feature.
4017 ** Wording in the Bison-generated parsers has been changed slightly to
4018   simplify translation.  In particular, the message "memory exhausted"
4019   has replaced "parser stack overflow", as the old message was not
4020   always accurate for modern Bison-generated parsers.
4022 ** Destructors are now called when the parser aborts, for all symbols left
4023   behind on the stack.  Also, the start symbol is now destroyed after a
4024   successful parse.  In both cases, the behavior was formerly inconsistent.
4026 ** When generating verbose diagnostics, Bison-generated parsers no longer
4027   quote the literal strings associated with tokens.  For example, for
4028   a syntax error associated with '%token NUM "number"' they might
4029   print 'syntax error, unexpected number' instead of 'syntax error,
4030   unexpected "number"'.
4033 * Noteworthy changes in release 2.0 (2004-12-25)
4035 ** Possibly-incompatible changes
4037   - Bison-generated parsers no longer default to using the alloca function
4038     (when available) to extend the parser stack, due to widespread
4039     problems in unchecked stack-overflow detection.  You can "#define
4040     YYSTACK_USE_ALLOCA 1" to require the use of alloca, but please read
4041     the manual to determine safe values for YYMAXDEPTH in that case.
4043   - Error token location.
4044     During error recovery, the location of the syntax error is updated
4045     to cover the whole sequence covered by the error token: it includes
4046     the shifted symbols thrown away during the first part of the error
4047     recovery, and the lookahead rejected during the second part.
4049   - Semicolon changes:
4050     . Stray semicolons are no longer allowed at the start of a grammar.
4051     . Semicolons are now required after in-grammar declarations.
4053   - Unescaped newlines are no longer allowed in character constants or
4054     string literals.  They were never portable, and GCC 3.4.0 has
4055     dropped support for them.  Better diagnostics are now generated if
4056     forget a closing quote.
4058   - NUL bytes are no longer allowed in Bison string literals, unfortunately.
4060 ** New features
4062   - GLR grammars now support locations.
4064   - New directive: %initial-action.
4065     This directive allows the user to run arbitrary code (including
4066     initializing @$) from yyparse before parsing starts.
4068   - A new directive "%expect-rr N" specifies the expected number of
4069     reduce/reduce conflicts in GLR parsers.
4071   - %token numbers can now be hexadecimal integers, e.g., "%token FOO 0x12d".
4072     This is a GNU extension.
4074   - The option "--report=lookahead" was changed to "--report=look-ahead".
4075     [However, this was changed back after 2.3.]
4077   - Experimental %destructor support has been added to lalr1.cc.
4079   - New configure option --disable-yacc, to disable installation of the
4080     yacc command and -ly library introduced in 1.875 for POSIX conformance.
4082 ** Bug fixes
4084   - For now, %expect-count violations are now just warnings, not errors.
4085     This is for compatibility with Bison 1.75 and earlier (when there are
4086     reduce/reduce conflicts) and with Bison 1.30 and earlier (when there
4087     are too many or too few shift/reduce conflicts).  However, in future
4088     versions of Bison we plan to improve the %expect machinery so that
4089     these violations will become errors again.
4091   - Within Bison itself, numbers (e.g., goto numbers) are no longer
4092     arbitrarily limited to 16-bit counts.
4094   - Semicolons are now allowed before "|" in grammar rules, as POSIX requires.
4097 * Noteworthy changes in release 1.875 (2003-01-01)
4099 ** The documentation license has been upgraded to version 1.2
4100   of the GNU Free Documentation License.
4102 ** syntax error processing
4104   - In Yacc-style parsers YYLLOC_DEFAULT is now used to compute error
4105     locations too.  This fixes bugs in error-location computation.
4107   - %destructor
4108     It is now possible to reclaim the memory associated to symbols
4109     discarded during error recovery.  This feature is still experimental.
4111   - %error-verbose
4112     This new directive is preferred over YYERROR_VERBOSE.
4114   - #defining yyerror to steal internal variables is discouraged.
4115     It is not guaranteed to work forever.
4117 ** POSIX conformance
4119   - Semicolons are once again optional at the end of grammar rules.
4120     This reverts to the behavior of Bison 1.33 and earlier, and improves
4121     compatibility with Yacc.
4123   - "parse error" -> "syntax error"
4124     Bison now uniformly uses the term "syntax error"; formerly, the code
4125     and manual sometimes used the term "parse error" instead.  POSIX
4126     requires "syntax error" in diagnostics, and it was thought better to
4127     be consistent.
4129   - The documentation now emphasizes that yylex and yyerror must be
4130     declared before use.  C99 requires this.
4132   - Bison now parses C99 lexical constructs like UCNs and
4133     backslash-newline within C escape sequences, as POSIX 1003.1-2001 requires.
4135   - File names are properly escaped in C output.  E.g., foo\bar.y is
4136     output as "foo\\bar.y".
4138   - Yacc command and library now available
4139     The Bison distribution now installs a "yacc" command, as POSIX requires.
4140     Also, Bison now installs a small library liby.a containing
4141     implementations of Yacc-compatible yyerror and main functions.
4142     This library is normally not useful, but POSIX requires it.
4144   - Type clashes now generate warnings, not errors.
4146   - If the user does not define YYSTYPE as a macro, Bison now declares it
4147     using typedef instead of defining it as a macro.
4148     For consistency, YYLTYPE is also declared instead of defined.
4150 ** Other compatibility issues
4152   - %union directives can now have a tag before the "{", e.g., the
4153     directive "%union foo {...}" now generates the C code
4154     "typedef union foo { ... } YYSTYPE;"; this is for Yacc compatibility.
4155     The default union tag is "YYSTYPE", for compatibility with Solaris 9 Yacc.
4156     For consistency, YYLTYPE's struct tag is now "YYLTYPE" not "yyltype".
4157     This is for compatibility with both Yacc and Bison 1.35.
4159   - ";" is output before the terminating "}" of an action, for
4160     compatibility with Bison 1.35.
4162   - Bison now uses a Yacc-style format for conflict reports, e.g.,
4163     "conflicts: 2 shift/reduce, 1 reduce/reduce".
4165   - "yystype" and "yyltype" are now obsolescent macros instead of being
4166     typedefs or tags; they are no longer documented and are planned to be
4167     withdrawn in a future release.
4169 ** GLR parser notes
4171   - GLR and inline
4172     Users of Bison have to decide how they handle the portability of the
4173     C keyword "inline".
4175   - "parsing stack overflow..." -> "parser stack overflow"
4176     GLR parsers now report "parser stack overflow" as per the Bison manual.
4178 ** %parse-param and %lex-param
4179   The macros YYPARSE_PARAM and YYLEX_PARAM provide a means to pass
4180   additional context to yyparse and yylex.  They suffer from several
4181   shortcomings:
4183   - a single argument only can be added,
4184   - their types are weak (void *),
4185   - this context is not passed to ancillary functions such as yyerror,
4186   - only yacc.c parsers support them.
4188   The new %parse-param/%lex-param directives provide a more precise control.
4189   For instance:
4191     %parse-param {int *nastiness}
4192     %lex-param   {int *nastiness}
4193     %parse-param {int *randomness}
4195   results in the following signatures:
4197     int yylex   (int *nastiness);
4198     int yyparse (int *nastiness, int *randomness);
4200   or, if both %pure-parser and %locations are used:
4202     int yylex   (YYSTYPE *lvalp, YYLTYPE *llocp, int *nastiness);
4203     int yyparse (int *nastiness, int *randomness);
4205 ** Bison now warns if it detects conflicting outputs to the same file,
4206   e.g., it generates a warning for "bison -d -o foo.h foo.y" since
4207   that command outputs both code and header to foo.h.
4209 ** #line in output files
4210   - --no-line works properly.
4212 ** Bison can no longer be built by a K&R C compiler; it requires C89 or
4213   later to be built.  This change originally took place a few versions
4214   ago, but nobody noticed until we recently asked someone to try
4215   building Bison with a K&R C compiler.
4218 * Noteworthy changes in release 1.75 (2002-10-14)
4220 ** Bison should now work on 64-bit hosts.
4222 ** Indonesian translation thanks to Tedi Heriyanto.
4224 ** GLR parsers
4225   Fix spurious parse errors.
4227 ** Pure parsers
4228   Some people redefine yyerror to steal yyparse' private variables.
4229   Reenable this trick until an official feature replaces it.
4231 ** Type Clashes
4232   In agreement with POSIX and with other Yaccs, leaving a default
4233   action is valid when $$ is untyped, and $1 typed:
4235         untyped: ... typed;
4237   but the converse remains an error:
4239         typed: ... untyped;
4241 ** Values of midrule actions
4242   The following code:
4244         foo: { ... } { $$ = $1; } ...
4246   was incorrectly rejected: $1 is defined in the second midrule
4247   action, and is equal to the $$ of the first midrule action.
4250 * Noteworthy changes in release 1.50 (2002-10-04)
4252 ** GLR parsing
4253   The declaration
4254      %glr-parser
4255   causes Bison to produce a Generalized LR (GLR) parser, capable of handling
4256   almost any context-free grammar, ambiguous or not.  The new declarations
4257   %dprec and %merge on grammar rules allow parse-time resolution of
4258   ambiguities.  Contributed by Paul Hilfinger.
4260   Unfortunately Bison 1.50 does not work properly on 64-bit hosts
4261   like the Alpha, so please stick to 32-bit hosts for now.
4263 ** Output Directory
4264   When not in Yacc compatibility mode, when the output file was not
4265   specified, running "bison foo/bar.y" created "foo/bar.c".  It
4266   now creates "bar.c".
4268 ** Undefined token
4269   The undefined token was systematically mapped to 2 which prevented
4270   the use of 2 by the user.  This is no longer the case.
4272 ** Unknown token numbers
4273   If yylex returned an out of range value, yyparse could die.  This is
4274   no longer the case.
4276 ** Error token
4277   According to POSIX, the error token must be 256.
4278   Bison extends this requirement by making it a preference: *if* the
4279   user specified that one of her tokens is numbered 256, then error
4280   will be mapped onto another number.
4282 ** Verbose error messages
4283   They no longer report "..., expecting error or..." for states where
4284   error recovery is possible.
4286 ** End token
4287   Defaults to "$end" instead of "$".
4289 ** Error recovery now conforms to documentation and to POSIX
4290   When a Bison-generated parser encounters a syntax error, it now pops
4291   the stack until it finds a state that allows shifting the error
4292   token.  Formerly, it popped the stack until it found a state that
4293   allowed some non-error action other than a default reduction on the
4294   error token.  The new behavior has long been the documented behavior,
4295   and has long been required by POSIX.  For more details, please see
4296   Paul Eggert, "Reductions during Bison error handling" (2002-05-20)
4297   <https://lists.gnu.org/r/bug-bison/2002-05/msg00038.html>.
4299 ** Traces
4300   Popped tokens and nonterminals are now reported.
4302 ** Larger grammars
4303   Larger grammars are now supported (larger token numbers, larger grammar
4304   size (= sum of the LHS and RHS lengths), larger LALR tables).
4305   Formerly, many of these numbers ran afoul of 16-bit limits;
4306   now these limits are 32 bits on most hosts.
4308 ** Explicit initial rule
4309   Bison used to play hacks with the initial rule, which the user does
4310   not write.  It is now explicit, and visible in the reports and
4311   graphs as rule 0.
4313 ** Useless rules
4314   Before, Bison reported the useless rules, but, although not used,
4315   included them in the parsers.  They are now actually removed.
4317 ** Useless rules, useless nonterminals
4318   They are now reported, as a warning, with their locations.
4320 ** Rules never reduced
4321   Rules that can never be reduced because of conflicts are now
4322   reported.
4324 ** Incorrect "Token not used"
4325   On a grammar such as
4327     %token useless useful
4328     %%
4329     exp: '0' %prec useful;
4331   where a token was used to set the precedence of the last rule,
4332   bison reported both "useful" and "useless" as useless tokens.
4334 ** Revert the C++ namespace changes introduced in 1.31
4335   as they caused too many portability hassles.
4337 ** Default locations
4338   By an accident of design, the default computation of @$ was
4339   performed after another default computation was performed: @$ = @1.
4340   The latter is now removed: YYLLOC_DEFAULT is fully responsible of
4341   the computation of @$.
4343 ** Token end-of-file
4344   The token end of file may be specified by the user, in which case,
4345   the user symbol is used in the reports, the graphs, and the verbose
4346   error messages instead of "$end", which remains being the default.
4347   For instance
4348     %token MYEOF 0
4349   or
4350     %token MYEOF 0 "end of file"
4352 ** Semantic parser
4353   This old option, which has been broken for ages, is removed.
4355 ** New translations
4356   Brazilian Portuguese, thanks to Alexandre Folle de Menezes.
4357   Croatian, thanks to Denis Lackovic.
4359 ** Incorrect token definitions
4360   When given
4361     %token 'a' "A"
4362   bison used to output
4363     #define 'a' 65
4365 ** Token definitions as enums
4366   Tokens are output both as the traditional #define's, and, provided
4367   the compiler supports ANSI C or is a C++ compiler, as enums.
4368   This lets debuggers display names instead of integers.
4370 ** Reports
4371   In addition to --verbose, bison supports --report=THINGS, which
4372   produces additional information:
4373   - itemset
4374     complete the core item sets with their closure
4375   - lookahead [changed to "look-ahead" in 1.875e through 2.3, but changed back]
4376     explicitly associate lookahead tokens to items
4377   - solved
4378     describe shift/reduce conflicts solving.
4379     Bison used to systematically output this information on top of
4380     the report.  Solved conflicts are now attached to their states.
4382 ** Type clashes
4383   Previous versions don't complain when there is a type clash on
4384   the default action if the rule has a midrule action, such as in:
4386     %type <foo> bar
4387     %%
4388     bar: '0' {} '0';
4390   This is fixed.
4392 ** GNU M4 is now required when using Bison.
4395 * Noteworthy changes in release 1.35 (2002-03-25)
4397 ** C Skeleton
4398   Some projects use Bison's C parser with C++ compilers, and define
4399   YYSTYPE as a class.  The recent adjustment of C parsers for data
4400   alignment and 64 bit architectures made this impossible.
4402   Because for the time being no real solution for C++ parser
4403   generation exists, kludges were implemented in the parser to
4404   maintain this use.  In the future, when Bison has C++ parsers, this
4405   kludge will be disabled.
4407   This kludge also addresses some C++ problems when the stack was
4408   extended.
4411 * Noteworthy changes in release 1.34 (2002-03-12)
4413 ** File name clashes are detected
4414   $ bison foo.y -d -o foo.x
4415   fatal error: header and parser would both be named "foo.x"
4417 ** A missing ";" at the end of a rule triggers a warning
4418   In accordance with POSIX, and in agreement with other
4419   Yacc implementations, Bison will mandate this semicolon in the near
4420   future.  This eases the implementation of a Bison parser of Bison
4421   grammars by making this grammar LALR(1) instead of LR(2).  To
4422   facilitate the transition, this release introduces a warning.
4424 ** Revert the C++ namespace changes introduced in 1.31, as they caused too
4425   many portability hassles.
4427 ** DJGPP support added.
4429 ** Fix test suite portability problems.
4432 * Noteworthy changes in release 1.33 (2002-02-07)
4434 ** Fix C++ issues
4435   Groff could not be compiled for the definition of size_t was lacking
4436   under some conditions.
4438 ** Catch invalid @n
4439   As is done with $n.
4442 * Noteworthy changes in release 1.32 (2002-01-23)
4444 ** Fix Yacc output file names
4446 ** Portability fixes
4448 ** Italian, Dutch translations
4451 * Noteworthy changes in release 1.31 (2002-01-14)
4453 ** Many Bug Fixes
4455 ** GNU Gettext and %expect
4456   GNU Gettext asserts 10 s/r conflicts, but there are 7.  Now that
4457   Bison dies on incorrect %expectations, we fear there will be
4458   too many bug reports for Gettext, so _for the time being_, %expect
4459   does not trigger an error when the input file is named "plural.y".
4461 ** Use of alloca in parsers
4462   If YYSTACK_USE_ALLOCA is defined to 0, then the parsers will use
4463   malloc exclusively.  Since 1.29, but was not NEWS'ed.
4465   alloca is used only when compiled with GCC, to avoid portability
4466   problems as on AIX.
4468 ** yyparse now returns 2 if memory is exhausted; formerly it dumped core.
4470 ** When the generated parser lacks debugging code, YYDEBUG is now 0
4471   (as POSIX requires) instead of being undefined.
4473 ** User Actions
4474   Bison has always permitted actions such as { $$ = $1 }: it adds the
4475   ending semicolon.  Now if in Yacc compatibility mode, the semicolon
4476   is no longer output: one has to write { $$ = $1; }.
4478 ** Better C++ compliance
4479   The output parsers try to respect C++ namespaces.
4480   [This turned out to be a failed experiment, and it was reverted later.]
4482 ** Reduced Grammars
4483   Fixed bugs when reporting useless nonterminals.
4485 ** 64 bit hosts
4486   The parsers work properly on 64 bit hosts.
4488 ** Error messages
4489   Some calls to strerror resulted in scrambled or missing error messages.
4491 ** %expect
4492   When the number of shift/reduce conflicts is correct, don't issue
4493   any warning.
4495 ** The verbose report includes the rule line numbers.
4497 ** Rule line numbers are fixed in traces.
4499 ** Swedish translation
4501 ** Parse errors
4502   Verbose parse error messages from the parsers are better looking.
4503   Before: parse error: unexpected `'/'', expecting `"number"' or `'-'' or `'(''
4504      Now: parse error: unexpected '/', expecting "number" or '-' or '('
4506 ** Fixed parser memory leaks.
4507   When the generated parser was using malloc to extend its stacks, the
4508   previous allocations were not freed.
4510 ** Fixed verbose output file.
4511   Some newlines were missing.
4512   Some conflicts in state descriptions were missing.
4514 ** Fixed conflict report.
4515   Option -v was needed to get the result.
4517 ** %expect
4518   Was not used.
4519   Mismatches are errors, not warnings.
4521 ** Fixed incorrect processing of some invalid input.
4523 ** Fixed CPP guards: 9foo.h uses BISON_9FOO_H instead of 9FOO_H.
4525 ** Fixed some typos in the documentation.
4527 ** %token MY_EOF 0 is supported.
4528   Before, MY_EOF was silently renumbered as 257.
4530 ** doc/refcard.tex is updated.
4532 ** %output, %file-prefix, %name-prefix.
4533   New.
4535 ** --output
4536   New, aliasing "--output-file".
4539 * Noteworthy changes in release 1.30 (2001-10-26)
4541 ** "--defines" and "--graph" have now an optional argument which is the
4542   output file name. "-d" and "-g" do not change; they do not take any
4543   argument.
4545 ** "%source_extension" and "%header_extension" are removed, failed
4546   experiment.
4548 ** Portability fixes.
4551 * Noteworthy changes in release 1.29 (2001-09-07)
4553 ** The output file does not define const, as this caused problems when used
4554   with common autoconfiguration schemes.  If you still use ancient compilers
4555   that lack const, compile with the equivalent of the C compiler option
4556   "-Dconst=".  Autoconf's AC_C_CONST macro provides one way to do this.
4558 ** Added "-g" and "--graph".
4560 ** The Bison manual is now distributed under the terms of the GNU FDL.
4562 ** The input and the output files has automatically a similar extension.
4564 ** Russian translation added.
4566 ** NLS support updated; should hopefully be less troublesome.
4568 ** Added the old Bison reference card.
4570 ** Added "--locations" and "%locations".
4572 ** Added "-S" and "--skeleton".
4574 ** "%raw", "-r", "--raw" is disabled.
4576 ** Special characters are escaped when output.  This solves the problems
4577   of the #line lines with path names including backslashes.
4579 ** New directives.
4580   "%yacc", "%fixed_output_files", "%defines", "%no_parser", "%verbose",
4581   "%debug", "%source_extension" and "%header_extension".
4583 ** @$
4584   Automatic location tracking.
4587 * Noteworthy changes in release 1.28 (1999-07-06)
4589 ** Should compile better now with K&R compilers.
4591 ** Added NLS.
4593 ** Fixed a problem with escaping the double quote character.
4595 ** There is now a FAQ.
4598 * Noteworthy changes in release 1.27
4600 ** The make rule which prevented bison.simple from being created on
4601   some systems has been fixed.
4604 * Noteworthy changes in release 1.26
4606 ** Bison now uses Automake.
4608 ** New mailing lists: <bug-bison@gnu.org> and <help-bison@gnu.org>.
4610 ** Token numbers now start at 257 as previously documented, not 258.
4612 ** Bison honors the TMPDIR environment variable.
4614 ** A couple of buffer overruns have been fixed.
4616 ** Problems when closing files should now be reported.
4618 ** Generated parsers should now work even on operating systems which do
4619   not provide alloca().
4622 * Noteworthy changes in release 1.25 (1995-10-16)
4624 ** Errors in the input grammar are not fatal; Bison keeps reading
4625 the grammar file, and reports all the errors found in it.
4627 ** Tokens can now be specified as multiple-character strings: for
4628 example, you could use "<=" for a token which looks like <=, instead
4629 of choosing a name like LESSEQ.
4631 ** The %token_table declaration says to write a table of tokens (names
4632 and numbers) into the parser file.  The yylex function can use this
4633 table to recognize multiple-character string tokens, or for other
4634 purposes.
4636 ** The %no_lines declaration says not to generate any #line preprocessor
4637 directives in the parser file.
4639 ** The %raw declaration says to use internal Bison token numbers, not
4640 Yacc-compatible token numbers, when token names are defined as macros.
4642 ** The --no-parser option produces the parser tables without including
4643 the parser engine; a project can now use its own parser engine.
4644 The actions go into a separate file called NAME.act, in the form of
4645 a switch statement body.
4648 * Noteworthy changes in release 1.23
4650 The user can define YYPARSE_PARAM as the name of an argument to be
4651 passed into yyparse.  The argument should have type void *.  It should
4652 actually point to an object.  Grammar actions can access the variable
4653 by casting it to the proper pointer type.
4655 Line numbers in output file corrected.
4658 * Noteworthy changes in release 1.22
4660 --help option added.
4663 * Noteworthy changes in release 1.20
4665 Output file does not redefine const for C++.
4667 -----
4669 LocalWords:  yacc YYBACKUP glr GCC lalr ArrayIndexOutOfBoundsException nullptr
4670 LocalWords:  cplusplus liby rpl fprintf mfcalc Wyacc stmt cond expr mk sym lr
4671 LocalWords:  IELR ielr Lookahead YYERROR nonassoc LALR's api lookaheads yychar
4672 LocalWords:  destructor lookahead YYRHSLOC YYLLOC Rhs ifndef YYFAIL cpp sr rr
4673 LocalWords:  preprocessor initializer Wno Wnone Werror FreeBSD prec livelocks
4674 LocalWords:  Solaris AIX UX RHEL Tru LHS gcc's Wundef YYENABLE NLS YYLTYPE VCG
4675 LocalWords:  yyerror cpp's Wunused yylval yylloc prepend yyparse yylex yypush
4676 LocalWords:  Graphviz xml nonterminals midrule destructor's YYSTYPE typedef ly
4677 LocalWords:  CHR chr printf stdout namespace preprocessing enum pre include's
4678 LocalWords:  YYRECOVERING nonfree destructors YYABORT YYACCEPT params enums de
4679 LocalWords:  struct yystype DJGPP lex param Haible NUM alloca YYSTACK NUL goto
4680 LocalWords:  YYMAXDEPTH Unescaped UCNs YYLTYPE's yyltype typedefs inline Yaccs
4681 LocalWords:  Heriyanto Reenable dprec Hilfinger Eggert MYEOF Folle Menezes EOF
4682 LocalWords:  Lackovic define's itemset Groff Gettext malloc NEWS'ed YYDEBUG YY
4683 LocalWords:  namespaces strerror const autoconfiguration Dconst Autoconf's FDL
4684 LocalWords:  Automake TMPDIR LESSEQ ylwrap endif yydebug YYTOKEN YYLSP ival hh
4685 LocalWords:  extern YYTOKENTYPE TOKENTYPE yytokentype tokentype STYPE lval pdf
4686 LocalWords:  lang yyoutput dvi html ps POSIX lvalp llocp Wother nterm arg init
4687 LocalWords:  TOK calc yyo fval Wconflicts parsers yystackp yyval yynerrs
4688 LocalWords:  Théophile Ranquet Santet fno fnone stype associativity Tolmer
4689 LocalWords:  Wprecedence Rassoul Wempty Paolo Bonzini parser's Michiel loc
4690 LocalWords:  redeclaration sval fcaret reentrant XSLT xsl Wmaybe yyvsp Tedi
4691 LocalWords:  pragmas noreturn untyped Rozenman unexpanded Wojciech Polak
4692 LocalWords:  Alexandre MERCHANTABILITY yytype emplace ptr automove lvalues
4693 LocalWords:  nonterminal yy args Pragma dereference yyformat rhs docdir bw
4694 LocalWords:  Redeclarations rpcalc Autoconf YFLAGS Makefiles PROG DECL num
4695 LocalWords:  Heimbigner AST src ast Makefile srcdir MinGW xxlex XXSTYPE CVE
4696 LocalWords:  XXLTYPE strictfp IDEs ffixit fdiagnostics parseable fixits
4697 LocalWords:  Wdeprecated yytext Variadic variadic yyrhs yyphrs RCS README
4698 LocalWords:  noexcept constexpr ispell american deprecations backend Teoh
4699 LocalWords:  YYPRINT Mangold Bonzini's Wdangling exVal baz checkable gcc
4700 LocalWords:  fsanitize Vogelsgesang lis redeclared stdint automata yytname
4701 LocalWords:  yysymbol yytnamerr yyreport ctx ARGMAX yysyntax stderr LPAREN
4702 LocalWords:  symrec yypcontext TOKENMAX yyexpected YYEMPTY yypstate YYEOF
4703 LocalWords:  autocompletion bistromathic submessages Cayuela lexcalc hoc
4704 LocalWords:  yytoken YYUNDEF YYerror basename Automake's UTF ifdef ffile
4705 LocalWords:  gotos readline Imbimbo Wcounterexamples Wcex Nonunifying rcex
4706 LocalWords:  Vais xsltproc YYNOMEM YYLOCATION signedness YYBISON MITRE's
4707 LocalWords:  libreadline YYMALLOC YYFREE MSVC redefinitions
4709 Local Variables:
4710 ispell-dictionary: "american"
4711 mode: outline
4712 fill-column: 76
4713 End:
4715 Copyright (C) 1995-2015, 2018-2021 Free Software Foundation, Inc.
4717 This file is part of Bison, the GNU Parser Generator.
4719 Permission is granted to copy, distribute and/or modify this document
4720 under the terms of the GNU Free Documentation License, Version 1.3 or
4721 any later version published by the Free Software Foundation; with no
4722 Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
4723 Texts.  A copy of the license is included in the "GNU Free
4724 Documentation License" file as part of this distribution.