3 * Noteworthy changes in release ?.? (????-??-??) [?]
10 * Noteworthy changes in release 3.6.92 (2020-07-19) [beta]
12 Changes in the display of counterexamples.
18 The bistromathic demonstrates %param and how to quote sources in the error
22 1.5-7: syntax error: expected end of file or + or - or * or / or ^ before number
26 * Noteworthy changes in release 3.6.91 (2020-07-09) [beta]
33 * Noteworthy changes in release 3.6.90 (2020-07-04) [beta]
35 ** Deprecated features
37 The YYPRINT macro, which works only with yacc.c and only for tokens, was
38 obsoleted long ago by %printer, introduced in Bison 1.50 (November 2002).
39 It is deprecated and its support will be removed eventually.
41 In conformance with the recommendations of the Graphviz team, in the next
42 version Bison the option `--graph` will generate a *.gv file by default,
43 instead of *.dot. A transition started in Bison 3.4.
47 *** Counterexample Generation
49 Contributed by Vincent Imbimbo.
51 When given `--report=counterexamples` or `-Wcounterexamples`, bison will
52 now output counterexamples for conflicts in the grammar. These are
53 strings in the grammar which can be parsed in two ways due to the
54 conflict. For example:
56 Shift/reduce conflict on token "/":
57 Example exp "+" exp • "/" exp
62 Example exp "+" exp • "/" exp
68 When Bison is installed with text styling enabled, the example is actually
69 shown twice, with colors highlighting the ambiguity.
71 This is a shift/reduce conflict caused by none of the operators having
72 precedence, so the example can be parsed in the two ways shown. When
73 bison cannot find an example that can be derived in two ways, it instead
74 generates two examples that are the same up until the dot:
76 First example expr • ID ',' ID $end
83 Second example expr • ID $end
90 In these cases, the parser usually doesn't have enough lookahead to
91 differentiate the two given examples.
93 The counterexamples are "focused" in two different ways. First, they do
94 not clutter the output with all the derivations from the start symbol,
95 rather they start on the "conflicted nonterminal". They go straight to the
96 point. Second, they don't "expand" nonterminal symbols uselessly.
98 *** File prefix mapping
100 Contributed by Joshua Watt.
102 Bison learned a new argument, `--file-prefix-map OLD=NEW`. Any file path
103 in the output (specifically `#line` directives and `#ifdef` header guards)
104 that begins with the prefix OLD will have it replaced with the prefix NEW,
105 similar to the `-ffile-prefix-map` in GCC. This option can be used to
106 make bison output reproducible.
110 *** Relocatable installation
112 When installed to be relocatable (via `configure --enable-relocatable`),
113 bison will now also look for a relocated m4.
117 The `filename_type` %define variable was renamed `api.filename.type`.
120 %define filename_type "symbol"
124 %define api.filename.type {symbol}
126 (Or let `bison --update` do it for you).
128 It now defaults to `const std::string` instead of `std::string`.
130 *** Deprecated %define variable names
132 The following variables have been renamed for consistency. Backward
133 compatibility is ensured, but upgrading is recommended.
135 filename_type -> api.filename.type
136 package -> api.package
138 *** Push parsers no longer clear their state when parsing is finished
140 Previously push-parsers cleared their state when parsing was finished (on
141 success and on failure). This made it impossible to check if there were
142 parse errors, since `yynerrs` was also reset. This can be especially
143 troublesome when used in autocompletion, since a parser with error
144 recovery would suggest (irrelevant) expected tokens even if there were
147 Now the parser state can be examined when parsing is finished. The parser
148 state is reset when starting a new parse.
152 *** Include the generated header (yacc.c)
154 Historically, when --defines was used, bison generated a header and pasted
155 an exact copy of it into the generated parser implementation file. Since
156 Bison 3.4 it is possible to specify that the header should be `#include`d,
157 and how. For instance
159 %define api.header.include {"parse.h"}
163 %define api.header.include {<parser/parse.h>}
165 Now api.header.include defaults to `"header-basename"`, as was intended in
166 Bison 3.4, where `header-basename` is the basename of the generated
167 header. This is disabled when the generated header is `y.tab.h`, to
168 comply with Automake's ylwrap.
170 *** String aliases are faithfully propagated
172 Bison used to interpret user strings (i.e., decoding backslash escapes)
173 when reading them, and to escape them (i.e., issue non-printable
174 characters as backslash escapes, taking the locale into account) when
175 outputting them. As a consequence non-ASCII strings (say in UTF-8) ended
176 up "ciphered" as sequences of backslash escapes. This happened not only
177 in the generated sources (where the compiler will reinterpret them), but
178 also in all the generated reports (text, xml, html, dot, etc.). Reports
179 were therefore not readable when string aliases were not pure ASCII.
180 Worse yet: the output depended on the user's locale.
182 Now Bison faithfully treats the string aliases exactly the way the user
183 spelled them. This fixes all the aforementioned problems. However, now,
184 string aliases semantically equivalent but syntactically different (e.g.,
185 "A", "\x41", "\101") are considered to be different.
187 *** Crash when generating IELR
189 An old, well hidden, bug in the generation of IELR parsers was fixed.
192 * Noteworthy changes in release 3.6.4 (2020-06-15) [stable]
196 In glr.cc some internal macros leaked in the user's code, and could damage
197 access to the token kinds.
200 * Noteworthy changes in release 3.6.3 (2020-06-03) [stable]
204 Incorrect comments in the generated parsers.
206 Warnings in push parsers (yacc.c).
208 Incorrect display of gotos in LAC traces (lalr1.cc).
211 * Noteworthy changes in release 3.6.2 (2020-05-17) [stable]
215 Some tests were fixed.
217 When token aliases contain comment delimiters:
219 %token FOO "/* foo */"
221 bison used to emit "nested" comments, which is invalid C.
224 * Noteworthy changes in release 3.6.1 (2020-05-10) [stable]
228 Restored ANSI-C compliance in yacc.c.
230 GNU readline portability issues.
232 In C++, yy::parser::symbol_name is now a public member, as was intended.
236 In C++, yy::parser::symbol_type now has a public name() member function.
239 * Noteworthy changes in release 3.6 (2020-05-08) [stable]
241 ** Backward incompatible changes
243 TL;DR: replace "#define YYERROR_VERBOSE 1" by "%define parse.error verbose".
245 The YYERROR_VERBOSE macro is no longer supported; the parsers that still
246 depend on it will now produce Yacc-like error messages (just "syntax
247 error"). It was superseded by the "%error-verbose" directive in Bison
248 1.875 (2003-01-01). Bison 2.6 (2012-07-19) clearly announced that support
249 for YYERROR_VERBOSE would be removed. Note that since Bison 3.0
250 (2013-07-25), "%error-verbose" is deprecated in favor of "%define
251 parse.error verbose".
253 ** Deprecated features
255 The YYPRINT macro, which works only with yacc.c and only for tokens, was
256 obsoleted long ago by %printer, introduced in Bison 1.50 (November 2002).
257 It is deprecated and its support will be removed eventually.
261 *** Improved syntax error messages
263 Two new values for the %define parse.error variable offer more control to
264 the user. Available in all the skeletons (C, C++, Java).
266 **** %define parse.error detailed
268 The behavior of "%define parse.error detailed" is closely resembling that
269 of "%define parse.error verbose" with a few exceptions. First, it is safe
270 to use non-ASCII characters in token aliases (with 'verbose', the result
271 depends on the locale with which bison was run). Second, a yysymbol_name
272 function is exposed to the user, instead of the yytnamerr function and the
273 yytname table. Third, token internationalization is supported (see
276 **** %define parse.error custom
278 With this directive, the user forges and emits the syntax error message
279 herself by defining the yyreport_syntax_error function. A new type,
280 yypcontext_t, captures the circumstances of the error, and provides the
281 user with functions to get details, such as yypcontext_expected_tokens to
282 get the list of expected token kinds.
284 A possible implementation of yyreport_syntax_error is:
287 yyreport_syntax_error (const yypcontext_t *ctx)
290 YY_LOCATION_PRINT (stderr, *yypcontext_location (ctx));
291 fprintf (stderr, ": syntax error");
292 // Report the tokens expected at this point.
294 enum { TOKENMAX = 10 };
295 yysymbol_kind_t expected[TOKENMAX];
296 int n = yypcontext_expected_tokens (ctx, expected, TOKENMAX);
298 // Forward errors to yyparse.
301 for (int i = 0; i < n; ++i)
302 fprintf (stderr, "%s %s",
303 i == 0 ? ": expected" : " or", yysymbol_name (expected[i]));
305 // Report the unexpected token.
307 yysymbol_kind_t lookahead = yypcontext_token (ctx);
308 if (lookahead != YYSYMBOL_YYEMPTY)
309 fprintf (stderr, " before %s", yysymbol_name (lookahead));
311 fprintf (stderr, "\n");
315 **** Token aliases internationalization
317 When the %define variable parse.error is set to `custom` or `detailed`,
318 one may specify which token aliases are to be translated using _(). For
330 In that case the user must define _() and N_(), and yysymbol_name returns
331 the translated symbol (i.e., it returns '_("variable")' rather that
332 '"variable"'). In Java, the user must provide an i18n() function.
334 *** List of expected tokens (yacc.c)
336 Push parsers may invoke yypstate_expected_tokens at any point during
337 parsing (including even before submitting the first token) to get the list
338 of possible tokens. This feature can be used to propose autocompletion
339 (see below the "bistromathic" example).
341 It makes little sense to use this feature without enabling LAC (lookahead
344 *** Returning the error token
346 When the scanner returns an invalid token or the undefined token
347 (YYUNDEF), the parser generates an error message and enters error
348 recovery. Because of that error message, most scanners that find lexical
349 errors generate an error message, and then ignore the invalid input
350 without entering the error-recovery.
352 The scanners may now return YYerror, the error token, to enter the
353 error-recovery mode without triggering an additional error message. See
354 the bistromathic for an example.
356 *** Deep overhaul of the symbol and token kinds
358 To avoid the confusion with types in programming languages, we now refer
359 to token and symbol "kinds" instead of token and symbol "types". The
360 documentation and error messages have been revised.
362 All the skeletons have been updated to use dedicated enum types rather
363 than integral types. Special symbols are now regular citizens, instead of
364 being declared in ad hoc ways.
368 The "token kind" is what is returned by the scanner, e.g., PLUS, NUMBER,
369 LPAREN, etc. While backward compatibility is of course ensured, users are
370 nonetheless invited to replace their uses of "enum yytokentype" by
373 This type now also includes tokens that were previously hidden: YYEOF (end
374 of input), YYUNDEF (undefined token), and YYerror (error token). They
375 now have string aliases, internationalized when internationalization is
376 enabled. Therefore, by default, error messages now refer to "end of file"
377 (internationalized) rather than the cryptic "$end", or to "invalid token"
378 rather than "$undefined".
380 Therefore in most cases it is now useless to define the end-of-line token
383 %token T_EOF 0 "end of file"
385 Rather simply use "YYEOF" in your scanner.
389 The "symbol kinds" is what the parser actually uses. (Unless the
390 api.token.raw %define variable is used, the symbol kind of a terminal
391 differs from the corresponding token kind.)
393 They are now exposed as a enum, "yysymbol_kind_t".
395 This allows users to tailor the error messages the way they want, or to
396 process some symbols in a specific way in autocompletion (see the
397 bistromathic example below).
399 *** Modernize display of explanatory statements in diagnostics
401 Since Bison 2.7, output was indented four spaces for explanatory
402 statements. For example:
404 input.y:2.7-13: error: %type redeclaration for exp
405 input.y:1.7-11: previous declaration
407 Since the introduction of caret-diagnostics, it became less clear. This
408 indentation has been removed and submessages are displayed similarly as in
411 input.y:2.7-13: error: %type redeclaration for exp
412 2 | %type <float> exp
414 input.y:1.7-11: note: previous declaration
418 Contributed by Victor Morales Cayuela.
422 The token and symbol kinds are yy::parser::token_kind_type and
423 yy::parser::symbol_kind_type.
425 The symbol_type::kind() member function allows to get the kind of a
426 symbol. This can be used to write unit tests for scanners, e.g.,
428 yy::parser::symbol_type t = make_NUMBER ("123");
429 assert (t.kind () == yy::parser::symbol_kind::S_NUMBER);
430 assert (t.value.as<int> () == 123);
436 In order to avoid ambiguities with "type" as in "typing", we now refer to
437 the "token kind" (e.g., `PLUS`, `NUMBER`, etc.) rather than the "token
438 type". We now also refer to the "symbol type" (e.g., `PLUS`, `expr`,
443 There are now examples/java: a very simple calculator, and a more complete
444 one (push-parser, location tracking, and debug traces).
446 The lexcalc example (a simple example in C based on Flex and Bison) now
447 also demonstrates location tracking.
450 A new C example, bistromathic, is a fully featured interactive calculator
451 using many Bison features: pure interface, push parser, autocompletion
452 based on the current parser state (using yypstate_expected_tokens),
453 location tracking, internationalized custom error messages, lookahead
454 correction, rich debug traces, etc.
456 It shows how to depend on the symbol kinds to tailor autocompletion. For
457 instance it recognizes the symbol kind "VARIABLE" to propose
458 autocompletion on the existing variables, rather than of the word
462 * Noteworthy changes in release 3.5.4 (2020-04-05) [stable]
464 ** WARNING: Future backward-incompatibilities!
466 TL;DR: replace "#define YYERROR_VERBOSE 1" by "%define parse.error verbose".
468 Bison 3.6 will no longer support the YYERROR_VERBOSE macro; the parsers
469 that still depend on it will produce Yacc-like error messages (just
470 "syntax error"). It was superseded by the "%error-verbose" directive in
471 Bison 1.875 (2003-01-01). Bison 2.6 (2012-07-19) clearly announced that
472 support for YYERROR_VERBOSE would be removed. Note that since Bison 3.0
473 (2013-07-25), "%error-verbose" is deprecated in favor of "%define
474 parse.error verbose".
478 Fix portability issues of the package itself on old compilers.
480 Fix api.token.raw support in Java.
483 * Noteworthy changes in release 3.5.3 (2020-03-08) [stable]
487 Error messages could quote lines containing zero-width characters (such as
488 \005) with incorrect styling. Fixes for similar issues with unexpectedly
489 short lines (e.g., the file was changed between parsing and diagnosing).
491 Several unlikely crashes found by fuzzing have been fixed.
494 * Noteworthy changes in release 3.5.2 (2020-02-13) [stable]
498 Portability issues and minor cosmetic issues.
500 The lalr1.cc skeleton properly rejects unsupported values for parse.lac
504 * Noteworthy changes in release 3.5.1 (2020-01-19) [stable]
510 Fix compiler warnings.
513 * Noteworthy changes in release 3.5 (2019-12-11) [stable]
515 ** Backward incompatible changes
517 Lone carriage-return characters (aka \r or ^M) in the grammar files are no
518 longer treated as end-of-lines. This changes the diagnostics, and in
519 particular their locations.
521 In C++, line numbers and columns are now represented as 'int' not
522 'unsigned', so that integer overflow on positions is easily checkable via
523 'gcc -fsanitize=undefined' and the like. This affects the API for
524 positions. The default position and location classes now expose
525 'counter_type' (int), used to define line and column numbers.
527 ** Deprecated features
529 The YYPRINT macro, which works only with yacc.c and only for tokens, was
530 obsoleted long ago by %printer, introduced in Bison 1.50 (November 2002).
531 It is deprecated and its support will be removed eventually.
535 *** Lookahead correction in C++
537 Contributed by Adrian Vogelsgesang.
539 The C++ deterministic skeleton (lalr1.cc) now supports LAC, via the
540 %define variable parse.lac.
542 *** Variable api.token.raw: Optimized token numbers (all skeletons)
544 In the generated parsers, tokens have two numbers: the "external" token
545 number as returned by yylex (which starts at 257), and the "internal"
546 symbol number (which starts at 3). Each time yylex is called, a table
547 lookup maps the external token number to the internal symbol number.
549 When the %define variable api.token.raw is set, tokens are assigned their
550 internal number, which saves one table lookup per token, and also saves
551 the generation of the mapping table.
553 The gain is typically moderate, but in extreme cases (very simple user
554 actions), a 10% improvement can be observed.
556 *** Generated parsers use better types for states
558 Stacks now use the best integral type for state numbers, instead of always
559 using 15 bits. As a result "small" parsers now have a smaller memory
560 footprint (they use 8 bits), and there is support for large automata (16
561 bits), and extra large (using int, i.e., typically 31 bits).
563 *** Generated parsers prefer signed integer types
565 Bison skeletons now prefer signed to unsigned integer types when either
566 will do, as the signed types are less error-prone and allow for better
567 checking with 'gcc -fsanitize=undefined'. Also, the types chosen are now
568 portable to unusual machines where char, short and int are all the same
569 width. On non-GNU platforms this may entail including <limits.h> and (if
570 available) <stdint.h> to define integer types and constants.
572 *** A skeleton for the D programming language
574 For the last few releases, Bison has shipped a stealth experimental
575 skeleton: lalr1.d. It was first contributed by Oliver Mangold, based on
576 Paolo Bonzini's lalr1.java, and was cleaned and improved thanks to
579 However, because nobody has committed to improving, testing, and
580 documenting this skeleton, it is not clear that it will be supported in
583 The lalr1.d skeleton *is functional*, and works well, as demonstrated in
584 examples/d/calc.d. Please try it, enjoy it, and... commit to support it.
586 *** Debug traces in Java
588 The Java backend no longer emits code and data for parser tracing if the
589 %define variable parse.trace is not defined.
593 *** New diagnostic: -Wdangling-alias
595 String literals, which allow for better error messages, are (too)
596 liberally accepted by Bison, which might result in silent errors. For
599 %type <exVal> cond "condition"
601 does not define "condition" as a string alias to 'cond' (nonterminal
602 symbols do not have string aliases). It is rather equivalent to
605 %token <exVal> "condition"
607 i.e., it gives the type 'exVal' to the "condition" token, which was
608 clearly not the intention.
610 Also, because string aliases need not be defined, typos such as "baz"
611 instead of "bar" will be not reported.
613 The option -Wdangling-alias catches these situations. On
616 %type <ival> foo "foo"
620 bison -Wdangling-alias reports
622 warning: string literal not attached to a symbol
623 | %type <ival> foo "foo"
625 warning: string literal not attached to a symbol
629 The -Wall option does not (yet?) include -Wdangling-alias.
631 *** Better POSIX Yacc compatibility diagnostics
633 POSIX Yacc restricts %type to nonterminals. This is now diagnosed by
637 %type <ival> TOKEN1 TOKEN2 't'
644 input.y:2.15-20: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
645 2 | %type <ival> TOKEN1 TOKEN2 't'
647 input.y:2.29-31: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
648 2 | %type <ival> TOKEN1 TOKEN2 't'
650 input.y:2.22-27: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
651 2 | %type <ival> TOKEN1 TOKEN2 't'
654 *** Diagnostics with insertion
656 The diagnostics now display the suggestion below the underlined source.
657 Replacement for undeclared symbols are now also suggested.
664 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'?
668 foo.y:2.16: warning: empty rule without %empty [-Wempty-rule]
672 foo.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother]
674 *** Diagnostics about long lines
676 Quoted sources may now be truncated to fit the screen. For instance, on a
677 30-column wide terminal:
684 foo.y:1.34-36: warning: symbol FOO redeclared [-Wother]
687 foo.y:1.8-10: previous declaration
690 foo.y:1.62-64: warning: symbol FOO redeclared [-Wother]
693 foo.y:1.8-10: previous declaration
699 *** Debugging glr.c and glr.cc
701 The glr.c skeleton always had asserts to check its own behavior (not the
702 user's). These assertions are now under the control of the parse.assert
703 %define variable (disabled by default).
707 Several new compiler warnings in the generated output have been avoided.
708 Some unused features are no longer emitted. Cleaner generated code in
713 Portability issues in the test suite.
715 In theory, parsers using %nonassoc could crash when reporting verbose
716 error messages. This unlikely bug has been fixed.
718 In Java, %define api.prefix was ignored. It now behaves as expected.
721 * Noteworthy changes in release 3.4.2 (2019-09-12) [stable]
725 In some cases, when warnings are disabled, bison could emit tons of white
726 spaces as diagnostics.
728 When running out of memory, bison could crash (found by fuzzing).
730 When defining twice the EOF token, bison would crash.
732 New warnings from recent compilers have been addressed in the generated
733 parsers (yacc.c, glr.c, glr.cc).
735 When lone carriage-return characters appeared in the input file,
736 diagnostics could hang forever.
739 * Noteworthy changes in release 3.4.1 (2019-05-22) [stable]
746 * Noteworthy changes in release 3.4 (2019-05-19) [stable]
748 ** Deprecated features
750 The %pure-parser directive is deprecated in favor of '%define api.pure'
751 since Bison 2.3b (2008-05-27), but no warning was issued; there is one
752 now. Note that since Bison 2.7 you are strongly encouraged to use
753 '%define api.pure full' instead of '%define api.pure'.
757 *** Colored diagnostics
759 As an experimental feature, diagnostics are now colored, controlled by the
760 new options --color and --style.
762 To use them, install the libtextstyle library before configuring Bison.
765 https://alpha.gnu.org/gnu/gettext/
769 https://alpha.gnu.org/gnu/gettext/libtextstyle-0.8.tar.gz
771 The option --color supports the following arguments:
772 - always, yes: Enable colors.
773 - never, no: Disable colors.
774 - auto, tty (default): Enable colors if the output device is a tty.
776 To customize the styles, create a CSS file similar to
780 .error { font-weight: 800; text-decoration: underline; }
783 then invoke bison with --style=bison-bw.css, or set the BISON_STYLE
784 environment variable to "bison-bw.css".
788 When given -fsyntax-only, the diagnostics are reported, but no output is
791 The name of this option is somewhat misleading as bison does more than
792 just checking the syntax: every stage is run (including checking for
793 conflicts for instance), except the generation of the output files.
795 *** Include the generated header (yacc.c)
797 Before, when --defines is used, bison generated a header, and pasted an
798 exact copy of it into the generated parser implementation file. If the
799 header name is not "y.tab.h", it is now #included instead of being
802 To use an '#include' even if the header name is "y.tab.h" (which is what
803 happens with --yacc, or when using the Autotools' ylwrap), define
804 api.header.include to the exact argument to pass to #include. For
807 %define api.header.include {"parse.h"}
811 %define api.header.include {<parser/parse.h>}
813 *** api.location.type is now supported in C (yacc.c, glr.c)
815 The %define variable api.location.type defines the name of the type to use
816 for locations. When defined, Bison no longer defines YYLTYPE.
818 This can be used in programs with several parsers to factor their
819 definition of locations: let one of them generate them, and the others
826 In conformance with the recommendations of the Graphviz team, if %require
827 "3.4" (or better) is specified, the option --graph generates a *.gv file
828 by default, instead of *.dot.
830 *** Diagnostics overhaul
832 Column numbers were wrong with multibyte characters, which would also
833 result in skewed diagnostics with carets. Beside, because we were
834 indenting the quoted source with a single space, lines with tab characters
835 were incorrectly underlined.
837 To address these issues, and to be clearer, Bison now issues diagnostics
838 as GCC9 does. For instance it used to display (there's a tab before the
841 foo.y:3.37-38: error: $2 of ‘expr’ has no declared type
842 expr: expr '+' "number" { $$ = $1 + $2; }
846 foo.y:3.37-38: error: $2 of ‘expr’ has no declared type
847 3 | expr: expr '+' "number" { $$ = $1 + $2; }
850 Other constructs now also have better locations, resulting in more precise
853 *** Fix-it hints for %empty
855 Running Bison with -Wempty-rules and --update will remove incorrect %empty
856 annotations, and add the missing ones.
858 *** Generated reports
860 The format of the reports (parse.output) was improved for readability.
862 *** Better support for --no-line.
864 When --no-line is used, the generated files are now cleaner: no lines are
865 generated instead of empty lines. Together with using api.header.include,
866 that should help people saving the generated files into version control
867 systems get smaller diffs.
871 A new example in C shows an simple infix calculator with a hand-written
872 scanner (examples/c/calc).
874 A new example in C shows a reentrant parser (capable of recursive calls)
875 built with Flex and Bison (examples/c/reccalc).
877 There is a new section about the history of Yaccs and Bison.
881 A few obscure bugs were fixed, including the second oldest (known) bug in
882 Bison: it was there when Bison was entered in the RCS version control
883 system, in December 1987. See the NEWS of Bison 3.3 for the previous
887 * Noteworthy changes in release 3.3.2 (2019-02-03) [stable]
891 Bison 3.3 failed to generate parsers for grammars with unused nonterminal
895 * Noteworthy changes in release 3.3.1 (2019-01-27) [stable]
899 The option -y/--yacc used to imply -Werror=yacc, which turns uses of Bison
900 extensions into errors. It now makes them simple warnings (-Wyacc).
903 * Noteworthy changes in release 3.3 (2019-01-26) [stable]
905 A new mailing list was created, Bison Announce. It is low traffic, and is
906 only about announcing new releases and important messages (e.g., polls
907 about major decisions to make).
909 https://lists.gnu.org/mailman/listinfo/bison-announce
911 ** Backward incompatible changes
913 Support for DJGPP, which has been unmaintained and untested for years, is
916 ** Deprecated features
918 A new feature, --update (see below) helps adjusting existing grammars to
921 *** Deprecated directives
923 The %error-verbose directive is deprecated in favor of '%define
924 parse.error verbose' since Bison 3.0, but no warning was issued.
926 The '%name-prefix "xx"' directive is deprecated in favor of '%define
927 api.prefix {xx}' since Bison 3.0, but no warning was issued. These
928 directives are slightly different, you might need to adjust your code.
929 %name-prefix renames only symbols with external linkage, while api.prefix
930 also renames types and macros, including YYDEBUG, YYTOKENTYPE,
931 yytokentype, YYSTYPE, YYLTYPE, etc.
933 Users of Flex that move from '%name-prefix "xx"' to '%define api.prefix
934 {xx}' will typically have to update YY_DECL from
936 #define YY_DECL int xxlex (YYSTYPE *yylval, YYLTYPE *yylloc)
940 #define YY_DECL int xxlex (XXSTYPE *yylval, XXLTYPE *yylloc)
942 *** Deprecated %define variable names
944 The following variables, mostly related to parsers in Java, have been
945 renamed for consistency. Backward compatibility is ensured, but upgrading
948 abstract -> api.parser.abstract
949 annotations -> api.parser.annotations
950 extends -> api.parser.extends
951 final -> api.parser.final
952 implements -> api.parser.implements
953 parser_class_name -> api.parser.class
954 public -> api.parser.public
955 strictfp -> api.parser.strictfp
959 *** Generation of fix-its for IDEs/Editors
961 When given the new option -ffixit (aka -fdiagnostics-parseable-fixits),
962 bison now generates machine readable editing instructions to fix some
963 issues. Currently, this is mostly limited to updating deprecated
964 directives and removing duplicates. For instance:
968 %define parser_class_name "Parser"
969 %define api.parser.class "Parser"
973 See the "fix-it:" lines below:
975 $ bison -ffixit foo.y
976 foo.y:1.1-14: warning: deprecated directive, use '%define parse.error verbose' [-Wdeprecated]
979 fix-it:"foo.y":{1:1-1:15}:"%define parse.error verbose"
980 foo.y:2.1-34: warning: deprecated directive, use '%define api.parser.class {Parser}' [-Wdeprecated]
981 %define parser_class_name "Parser"
982 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
983 fix-it:"foo.y":{2:1-2:35}:"%define api.parser.class {Parser}"
984 foo.y:3.1-33: error: %define variable 'api.parser.class' redefined
985 %define api.parser.class "Parser"
986 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
987 foo.y:2.1-34: previous definition
988 %define parser_class_name "Parser"
989 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
990 fix-it:"foo.y":{3:1-3:34}:""
991 foo.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother]
993 This uses the same output format as GCC and Clang.
995 *** Updating grammar files
997 Fixes can be applied on the fly. The previous example ends with the
998 suggestion to re-run bison with the option -u/--update, which results in a
999 cleaner grammar file.
1001 $ bison --update foo.y
1003 bison: file 'foo.y' was updated (backup: 'foo.y~')
1006 %define parse.error verbose
1007 %define api.parser.class {Parser}
1011 *** Bison is now relocatable
1013 If you pass '--enable-relocatable' to 'configure', Bison is relocatable.
1015 A relocatable program can be moved or copied to a different location on
1016 the file system. It can also be used through mount points for network
1017 sharing. It is possible to make symbolic links to the installed and moved
1018 programs, and invoke them through the symbolic link.
1020 *** %expect and %expect-rr modifiers on individual rules
1022 One can now document (and check) which rules participate in shift/reduce
1023 and reduce/reduce conflicts. This is particularly important GLR parsers,
1024 where conflicts are a normal occurrence. For example,
1040 | argument_list ',' expression
1045 Looking at the output from -v, one can see that the shift/reduce conflict
1046 here is due to the fact that the parser does not know whether to reduce
1047 arguments to argument_list until it sees the token _after_ the following
1048 ','. By marking the rule with %expect 1 (because there is a conflict in
1049 one state), we document the source of the 1 overall shift/reduce conflict.
1051 In GLR parsers, we can use %expect-rr in a rule for reduce/reduce
1052 conflicts. In this case, we mark each of the conflicting rules. For
1061 target_list '=' expr ';'
1067 | target ',' target_list
1076 | expr ',' expr_list
1084 In a statement such as
1088 the parser must reduce x to a target or an expr, but does not know which
1089 until it sees the '='. So we notate the two possible reductions to
1090 indicate that each conflicts in one rule.
1092 This feature needs user feedback, and might evolve in the future.
1094 *** C++: Actual token constructors
1096 When variants and token constructors are enabled, in addition to the
1097 type-safe named token constructors (make_ID, make_INT, etc.), we now
1098 generate genuine constructors for symbol_type.
1100 For instance with these declarations
1106 you may use these constructors:
1108 symbol_type (int token, const std::string&);
1109 symbol_type (int token, const int&);
1110 symbol_type (int token);
1112 Correct matching between token types and value types is checked via
1113 'assert'; for instance, 'symbol_type (ID, 42)' would abort. Named
1114 constructors are preferable, as they offer better type safety (for
1115 instance 'make_ID (42)' would not even compile), but symbol_type
1116 constructors may help when token types are discovered at run-time, e.g.,
1119 if (auto i = lookup_keyword (yytext))
1120 return yy::parser::symbol_type (i);
1122 return yy::parser::make_ID (yytext);
1125 *** C++: Variadic emplace
1127 If your application requires C++11 and you don't use symbol constructors,
1128 you may now use a variadic emplace for semantic values:
1130 %define api.value.type variant
1131 %token <std::pair<int, int>> PAIR
1135 int yylex (parser::semantic_type *lvalp)
1137 lvalp->emplace <std::pair<int, int>> (1, 2);
1138 return parser::token::PAIR;
1141 *** C++: Syntax error exceptions in GLR
1143 The glr.cc skeleton now supports syntax_error exceptions thrown from user
1144 actions, or from the scanner.
1146 *** More POSIX Yacc compatibility warnings
1148 More Bison specific directives are now reported with -y or -Wyacc. This
1149 change was ready since the release of Bison 3.0 in September 2015. It was
1150 delayed because Autoconf used to define YACC as `bison -y`, which resulted
1151 in numerous warnings for Bison users that use the GNU Build System.
1153 If you still experience that problem, either redefine YACC as `bison -o
1154 y.tab.c`, or pass -Wno-yacc to Bison.
1156 *** The tables yyrhs and yyphrs are back
1158 Because no Bison skeleton uses them, these tables were removed (no longer
1159 passed to the skeletons, not even computed) in 2008. However, some users
1160 have expressed interest in being able to use them in their own skeletons.
1164 *** Incorrect number of reduce/reduce conflicts
1166 On a grammar such as
1168 exp: "num" | "num" | "num"
1170 bison used to report a single RR conflict, instead of two. This is now
1171 fixed. This was the oldest (known) bug in Bison: it was there when Bison
1172 was entered in the RCS version control system, in December 1987.
1174 Some grammar files might have to adjust their %expect-rr.
1176 *** Parser directives that were not careful enough
1178 Passing invalid arguments to %nterm, for instance character literals, used
1179 to result in unclear error messages.
1183 The examples/ directory (installed in .../share/doc/bison/examples) has
1184 been restructured per language for clarity. The examples come with a
1185 README and a Makefile. Not only can they be used to toy with Bison, they
1186 can also be starting points for your own grammars.
1188 There is now a Java example, and a simple example in C based on Flex and
1189 Bison (examples/c/lexcalc/).
1195 They now use noexcept and constexpr. Please, report missing annotations.
1197 *** Symbol Declarations
1199 The syntax of the variation directives to declare symbols was overhauled
1200 for more consistency, and also better POSIX Yacc compliance (which, for
1201 instance, allows "%type" without actually providing a type). The %nterm
1202 directive, supported by Bison since its inception, is now documented and
1203 officially supported.
1205 The syntax is now as follows:
1207 %token TAG? ( ID NUMBER? STRING? )+ ( TAG ( ID NUMBER? STRING? )+ )*
1208 %left TAG? ( ID NUMBER? )+ ( TAG ( ID NUMBER? )+ )*
1209 %type TAG? ( ID | CHAR | STRING )+ ( TAG ( ID | CHAR | STRING )+ )*
1210 %nterm TAG? ID+ ( TAG ID+ )*
1212 where TAG denotes a type tag such as ‘<ival>’, ID denotes an identifier
1213 such as ‘NUM’, NUMBER a decimal or hexadecimal integer such as ‘300’ or
1214 ‘0x12d’, CHAR a character literal such as ‘'+'’, and STRING a string
1215 literal such as ‘"number"’. The post-fix quantifiers are ‘?’ (zero or
1216 one), ‘*’ (zero or more) and ‘+’ (one or more).
1219 * Noteworthy changes in release 3.2.4 (2018-12-24) [stable]
1223 Fix the move constructor of symbol_type.
1225 Always provide a copy constructor for symbol_type, even in modern C++.
1228 * Noteworthy changes in release 3.2.3 (2018-12-18) [stable]
1232 Properly support token constructors in C++ with types that include commas
1233 (e.g., std::pair<int, int>). A regression introduced in Bison 3.2.
1236 * Noteworthy changes in release 3.2.2 (2018-11-21) [stable]
1240 C++ portability issues.
1243 * Noteworthy changes in release 3.2.1 (2018-11-09) [stable]
1247 Several portability issues have been fixed in the build system, in the
1248 test suite, and in the generated parsers in C++.
1251 * Noteworthy changes in release 3.2 (2018-10-29) [stable]
1253 ** Backward incompatible changes
1255 Support for DJGPP, which has been unmaintained and untested for years, is
1256 obsolete. Unless there is activity to revive it, it will be removed.
1260 %printers should use yyo rather than yyoutput to denote the output stream.
1262 Variant-based symbols in C++ should use emplace() rather than build().
1264 In C++ parsers, parser::operator() is now a synonym for the parser::parse.
1268 A new section, "A Simple C++ Example", is a tutorial for parsers in C++.
1270 A comment in the generated code now emphasizes that users should not
1271 depend upon non-documented implementation details, such as macros starting
1276 *** C++: Support for move semantics (lalr1.cc)
1278 The lalr1.cc skeleton now fully supports C++ move semantics, while
1279 maintaining compatibility with C++98. You may now store move-only types
1280 when using Bison's variants. For instance:
1287 %skeleton "lalr1.cc"
1288 %define api.value.type variant
1292 %token <int> INT "int";
1293 %type <std::unique_ptr<int>> int;
1294 %type <std::vector<std::unique_ptr<int>>> list;
1298 | list int { $$ = std::move($1); $$.emplace_back(std::move($2)); }
1300 int: "int" { $$ = std::make_unique<int>($1); }
1302 *** C++: Implicit move of right-hand side values (lalr1.cc)
1304 In modern C++ (C++11 and later), you should always use 'std::move' with
1305 the values of the right-hand side symbols ($1, $2, etc.), as they will be
1306 popped from the stack anyway. Using 'std::move' is mandatory for
1307 move-only types such as unique_ptr, and it provides a significant speedup
1308 for large types such as std::string, or std::vector, etc.
1310 If '%define api.value.automove' is set, every occurrence '$n' is replaced
1311 by 'std::move ($n)'. The second rule in the previous grammar can be
1314 list: list int { $$ = $1; $$.emplace_back($2); }
1316 With automove enabled, the semantic values are no longer lvalues, so do
1317 not use the swap idiom:
1319 list: list int { std::swap($$, $1); $$.emplace_back($2); }
1321 This idiom is anyway obsolete: it is preferable to move than to swap.
1323 A warning is issued when automove is enabled, and a value is used several
1326 input.yy:16.31-32: warning: multiple occurrences of $2 with api.value.automove enabled [-Wother]
1327 exp: "twice" exp { $$ = $2 + $2; }
1330 Enabling api.value.automove does not require support for modern C++. The
1331 generated code is valid C++98/03, but will use copies instead of moves.
1333 The new examples/c++/variant-11.yy shows these features in action.
1335 *** C++: The implicit default semantic action is always run
1337 When variants are enabled, the default action was not run, so
1345 It now behaves like in all the other cases, as
1347 exp: "number" { $$ = $1; }
1349 possibly using std::move if automove is enabled.
1351 We do not expect backward compatibility issues. However, beware of
1352 forward compatibility issues: if you rely on default actions with
1353 variants, be sure to '%require "3.2"' to avoid older versions of Bison to
1354 generate incorrect parsers.
1356 *** C++: Renaming location.hh
1358 When both %defines and %locations are enabled, Bison generates a
1359 location.hh file. If you don't use locations outside of the parser, you
1360 may avoid its creation with:
1362 %define api.location.file none
1364 However this file is useful if, for instance, your parser builds an AST
1365 decorated with locations: you may use Bison's location independently of
1366 Bison's parser. You can now give it another name, for instance:
1368 %define api.location.file "my-location.hh"
1370 This name can have directory components, and even be absolute. The name
1371 under which the location file is included is controlled by
1372 api.location.include.
1374 This way it is possible to have several parsers share the same location
1377 For instance, in src/foo/parser.hh, generate the include/ast/loc.hh file:
1380 %define api.namespace {foo}
1381 %define api.location.file "include/ast/loc.hh"
1382 %define api.location.include {<ast/loc.hh>}
1384 and use it in src/bar/parser.hh:
1387 %define api.namespace {bar}
1388 %code requires {#include <ast/loc.hh>}
1389 %define api.location.type {bar::location}
1391 Absolute file names are supported, so in your Makefile, passing the flag
1392 -Dapi.location.file='"$(top_srcdir)/include/ast/location.hh"' to bison is
1395 *** C++: stack.hh and position.hh are deprecated
1397 When asked to generate a header file (%defines), the lalr1.cc skeleton
1398 generates a stack.hh file. This file had no interest for users; it is now
1399 made useless: its content is included in the parser definition. It is
1400 still generated for backward compatibility.
1402 When in addition to %defines, location support is requested (%locations),
1403 the file position.hh is also generated. It is now also useless: its
1404 content is now included in location.hh.
1406 These files are no longer generated when your grammar file requires at
1407 least Bison 3.2 (%require "3.2").
1411 Portability issues on MinGW and VS2015.
1413 Portability issues in the test suite.
1415 Portability/warning issues with Flex.
1418 * Noteworthy changes in release 3.1 (2018-08-27) [stable]
1420 ** Backward incompatible changes
1422 Compiling Bison now requires a C99 compiler---as announced during the
1423 release of Bison 3.0, five years ago. Generated parsers do not require a
1426 Support for DJGPP, which has been unmaintained and untested for years, is
1427 obsolete. Unless there is activity to revive it, the next release of Bison
1428 will have it removed.
1432 *** Typed midrule actions
1434 Because their type is unknown to Bison, the values of midrule actions are
1435 not treated like the others: they don't have %printer and %destructor
1436 support. It also prevents C++ (Bison) variants to handle them properly.
1438 Typed midrule actions address these issues. Instead of:
1440 exp: { $<ival>$ = 1; } { $<ival>$ = 2; } { $$ = $<ival>1 + $<ival>2; }
1444 exp: <ival>{ $$ = 1; } <ival>{ $$ = 2; } { $$ = $1 + $2; }
1446 *** Reports include the type of the symbols
1448 The sections about terminal and nonterminal symbols of the '*.output' file
1449 now specify their declared type. For instance, for:
1453 the report now shows '<ival>':
1455 Terminals, with rules where they appear
1459 *** Diagnostics about useless rules
1461 In the following grammar, the 'exp' nonterminal is trivially useless. So,
1462 of course, its rules are useless too.
1466 exp: exp '+' exp | exp '-' exp | '(' exp ')'
1468 Previously all the useless rules were reported, including those whose
1469 left-hand side is the 'exp' nonterminal:
1471 warning: 1 nonterminal useless in grammar [-Wother]
1472 warning: 4 rules useless in grammar [-Wother]
1473 2.14-16: warning: nonterminal useless in grammar: exp [-Wother]
1476 2.14-16: warning: rule useless in grammar [-Wother]
1479 3.6-16: warning: rule useless in grammar [-Wother]
1480 exp: exp '+' exp | exp '-' exp | '(' exp ')'
1482 3.20-30: warning: rule useless in grammar [-Wother]
1483 exp: exp '+' exp | exp '-' exp | '(' exp ')'
1485 3.34-44: warning: rule useless in grammar [-Wother]
1486 exp: exp '+' exp | exp '-' exp | '(' exp ')'
1489 Now, rules whose left-hand side symbol is useless are no longer reported
1490 as useless. The locations of the errors have also been adjusted to point
1491 to the first use of the nonterminal as a left-hand side of a rule:
1493 warning: 1 nonterminal useless in grammar [-Wother]
1494 warning: 4 rules useless in grammar [-Wother]
1495 3.1-3: warning: nonterminal useless in grammar: exp [-Wother]
1496 exp: exp '+' exp | exp '-' exp | '(' exp ')'
1498 2.14-16: warning: rule useless in grammar [-Wother]
1502 *** C++: Generated parsers can be compiled with -fno-exceptions (lalr1.cc)
1504 When compiled with exceptions disabled, the generated parsers no longer
1505 uses try/catch clauses.
1507 Currently only GCC and Clang are supported.
1511 *** A demonstration of variants
1513 A new example was added (installed in .../share/doc/bison/examples),
1514 'variant.yy', which shows how to use (Bison) variants in C++.
1516 The other examples were made nicer to read.
1518 *** Some features are no longer 'experimental'
1520 The following features, mature enough, are no longer flagged as
1521 experimental in the documentation: push parsers, default %printer and
1522 %destructor (typed: <*> and untyped: <>), %define api.value.type union and
1523 variant, Java parsers, XML output, LR family (lr, ielr, lalr), and
1524 semantic predicates (%?).
1528 *** GLR: Predicates support broken by #line directives
1530 Predicates (%?) in GLR such as
1533 %? {new_syntax} 'w' id new_args
1534 | %?{!new_syntax} 'w' id old_args
1536 were issued with #lines in the middle of C code.
1538 *** Printer and destructor with broken #line directives
1540 The #line directives were not properly escaped when emitting the code for
1541 %printer/%destructor, which resulted in compiler errors if there are
1542 backslashes or double-quotes in the grammar file name.
1544 *** Portability on ICC
1546 The Intel compiler claims compatibility with GCC, yet rejects its _Pragma.
1547 Generated parsers now work around this.
1551 There were several small fixes in the test suite and in the build system,
1552 many warnings in bison and in the generated parsers were eliminated. The
1553 documentation also received its share of minor improvements.
1555 Useless code was removed from C++ parsers, and some of the generated
1556 constructors are more 'natural'.
1559 * Noteworthy changes in release 3.0.5 (2018-05-27) [stable]
1563 *** C++: Fix support of 'syntax_error'
1565 One incorrect 'inline' resulted in linking errors about the constructor of
1566 the syntax_error exception.
1568 *** C++: Fix warnings
1570 GCC 7.3 (with -O1 or -O2 but not -O0 or -O3) issued null-dereference
1571 warnings about yyformat being possibly null. It also warned about the
1572 deprecated implicit definition of copy constructors when there's a
1573 user-defined (copy) assignment operator.
1575 *** Location of errors
1577 In C++ parsers, out-of-bounds errors can happen when a rule with an empty
1578 ride-hand side raises a syntax error. The behavior of the default parser
1579 (yacc.c) in such a condition was undefined.
1581 Now all the parsers match the behavior of glr.c: @$ is used as the
1582 location of the error. This handles gracefully rules with and without
1585 *** Portability fixes in the test suite
1587 On some platforms, some Java and/or C++ tests were failing.
1590 * Noteworthy changes in release 3.0.4 (2015-01-23) [stable]
1594 *** C++ with Variants (lalr1.cc)
1596 Fix a compiler warning when no %destructor use $$.
1600 Several portability issues in tests were fixed.
1603 * Noteworthy changes in release 3.0.3 (2015-01-15) [stable]
1607 *** C++ with Variants (lalr1.cc)
1609 Problems with %destructor and '%define parse.assert' have been fixed.
1611 *** Named %union support (yacc.c, glr.c)
1613 Bison 3.0 introduced a regression on named %union such as
1615 %union foo { int ival; };
1617 The possibility to use a name was introduced "for Yacc compatibility".
1618 It is however not required by POSIX Yacc, and its usefulness is not clear.
1620 *** %define api.value.type union with %defines (yacc.c, glr.c)
1622 The C parsers were broken when %defines was used together with "%define
1623 api.value.type union".
1625 *** Redeclarations are reported in proper order
1633 bison used to report:
1635 foo.yy:2.10-11: error: %printer redeclaration for FOO
1638 foo.yy:3.10-11: previous declaration
1642 Now, the "previous" declaration is always the first one.
1647 Bison now installs various files in its docdir (which defaults to
1648 '/usr/local/share/doc/bison'), including the three fully blown examples
1649 extracted from the documentation:
1652 Reverse Polish Calculator, a simple introductory example.
1654 Multi-function Calc, a calculator with memory and functions and located
1657 a calculator in C++ using variant support and token constructors.
1660 * Noteworthy changes in release 3.0.2 (2013-12-05) [stable]
1664 *** Generated source files when errors are reported
1666 When warnings are issued and -Werror is set, bison would still generate
1667 the source files (*.c, *.h...). As a consequence, some runs of "make"
1668 could fail the first time, but not the second (as the files were generated
1671 This is fixed: bison no longer generates this source files, but, of
1672 course, still produces the various reports (*.output, *.xml, etc.).
1674 *** %empty is used in reports
1676 Empty right-hand sides are denoted by '%empty' in all the reports (text,
1677 dot, XML and formats derived from it).
1679 *** YYERROR and variants
1681 When C++ variant support is enabled, an error triggered via YYERROR, but
1682 not caught via error recovery, resulted in a double deletion.
1685 * Noteworthy changes in release 3.0.1 (2013-11-12) [stable]
1689 *** Errors in caret diagnostics
1691 On some platforms, some errors could result in endless diagnostics.
1693 *** Fixes of the -Werror option
1695 Options such as "-Werror -Wno-error=foo" were still turning "foo"
1696 diagnostics into errors instead of warnings. This is fixed.
1698 Actually, for consistency with GCC, "-Wno-error=foo -Werror" now also
1699 leaves "foo" diagnostics as warnings. Similarly, with "-Werror=foo
1700 -Wno-error", "foo" diagnostics are now errors.
1704 As demonstrated in the documentation, one can now leave spaces between
1709 The yacc.1 man page is no longer installed if --disable-yacc was
1712 *** Fixes in the test suite
1714 Bugs and portability issues.
1717 * Noteworthy changes in release 3.0 (2013-07-25) [stable]
1719 ** WARNING: Future backward-incompatibilities!
1721 Like other GNU packages, Bison will start using some of the C99 features
1722 for its own code, especially the definition of variables after statements.
1723 The generated C parsers still aim at C90.
1725 ** Backward incompatible changes
1727 *** Obsolete features
1729 Support for YYFAIL is removed (deprecated in Bison 2.4.2): use YYERROR.
1731 Support for yystype and yyltype is removed (deprecated in Bison 1.875):
1732 use YYSTYPE and YYLTYPE.
1734 Support for YYLEX_PARAM and YYPARSE_PARAM is removed (deprecated in Bison
1735 1.875): use %lex-param, %parse-param, or %param.
1737 Missing semicolons at the end of actions are no longer added (as announced
1738 in the release 2.5).
1740 *** Use of YACC='bison -y'
1742 TL;DR: With Autoconf <= 2.69, pass -Wno-yacc to (AM_)YFLAGS if you use
1745 Traditional Yacc generates 'y.tab.c' whatever the name of the input file.
1746 Therefore Makefiles written for Yacc expect 'y.tab.c' (and possibly
1747 'y.tab.h' and 'y.output') to be generated from 'foo.y'.
1749 To this end, for ages, AC_PROG_YACC, Autoconf's macro to look for an
1750 implementation of Yacc, was using Bison as 'bison -y'. While it does
1751 ensure compatible output file names, it also enables warnings for
1752 incompatibilities with POSIX Yacc. In other words, 'bison -y' triggers
1753 warnings for Bison extensions.
1755 Autoconf 2.70+ fixes this incompatibility by using YACC='bison -o y.tab.c'
1756 (which also generates 'y.tab.h' and 'y.output' when needed).
1757 Alternatively, disable Yacc warnings by passing '-Wno-yacc' to your Yacc
1758 flags (YFLAGS, or AM_YFLAGS with Automake).
1762 *** The epilogue is no longer affected by internal #defines (glr.c)
1764 The glr.c skeleton uses defines such as #define yylval (yystackp->yyval) in
1765 generated code. These weren't properly undefined before the inclusion of
1766 the user epilogue, so functions such as the following were butchered by the
1767 preprocessor expansion:
1769 int yylex (YYSTYPE *yylval);
1771 This is fixed: yylval, yynerrs, yychar, and yylloc are now valid
1772 identifiers for user-provided variables.
1774 *** stdio.h is no longer needed when locations are enabled (yacc.c)
1776 Changes in Bison 2.7 introduced a dependency on FILE and fprintf when
1777 locations are enabled. This is fixed.
1779 *** Warnings about useless %pure-parser/%define api.pure are restored
1781 ** Diagnostics reported by Bison
1783 Most of these features were contributed by Théophile Ranquet and Victor
1788 Version 2.7 introduced caret errors, for a prettier output. These are now
1789 activated by default. The old format can still be used by invoking Bison
1790 with -fno-caret (or -fnone).
1792 Some error messages that reproduced excerpts of the grammar are now using
1793 the caret information only. For instance on:
1800 in.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
1801 in.y:2.12-14: warning: rule useless in parser due to conflicts: exp: 'a' [-Wother]
1805 in.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
1806 in.y:2.12-14: warning: rule useless in parser due to conflicts [-Wother]
1810 and "bison -fno-caret" reports:
1812 in.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
1813 in.y:2.12-14: warning: rule useless in parser due to conflicts [-Wother]
1815 *** Enhancements of the -Werror option
1817 The -Werror=CATEGORY option is now recognized, and will treat specified
1818 warnings as errors. The warnings need not have been explicitly activated
1819 using the -W option, this is similar to what GCC 4.7 does.
1821 For example, given the following command line, Bison will treat both
1822 warnings related to POSIX Yacc incompatibilities and S/R conflicts as
1823 errors (and only those):
1825 $ bison -Werror=yacc,error=conflicts-sr input.y
1827 If no categories are specified, -Werror will make all active warnings into
1828 errors. For example, the following line does the same the previous example:
1830 $ bison -Werror -Wnone -Wyacc -Wconflicts-sr input.y
1832 (By default -Wconflicts-sr,conflicts-rr,deprecated,other is enabled.)
1834 Note that the categories in this -Werror option may not be prefixed with
1835 "no-". However, -Wno-error[=CATEGORY] is valid.
1837 Note that -y enables -Werror=yacc. Therefore it is now possible to require
1838 Yacc-like behavior (e.g., always generate y.tab.c), but to report
1839 incompatibilities as warnings: "-y -Wno-error=yacc".
1841 *** The display of warnings is now richer
1843 The option that controls a given warning is now displayed:
1845 foo.y:4.6: warning: type clash on default action: <foo> != <bar> [-Wother]
1847 In the case of warnings treated as errors, the prefix is changed from
1848 "warning: " to "error: ", and the suffix is displayed, in a manner similar
1849 to GCC, as [-Werror=CATEGORY].
1851 For instance, where the previous version of Bison would report (and exit
1854 bison: warnings being treated as errors
1855 input.y:1.1: warning: stray ',' treated as white space
1859 input.y:1.1: error: stray ',' treated as white space [-Werror=other]
1861 *** Deprecated constructs
1863 The new 'deprecated' warning category flags obsolete constructs whose
1864 support will be discontinued. It is enabled by default. These warnings
1865 used to be reported as 'other' warnings.
1867 *** Useless semantic types
1869 Bison now warns about useless (uninhabited) semantic types. Since
1870 semantic types are not declared to Bison (they are defined in the opaque
1871 %union structure), it is %printer/%destructor directives about useless
1872 types that trigger the warning:
1876 %printer {} <type1> <type3>
1877 %destructor {} <type2> <type4>
1879 nterm: term { $$ = $1; };
1881 3.28-34: warning: type <type3> is used, but is not associated to any symbol
1882 4.28-34: warning: type <type4> is used, but is not associated to any symbol
1884 *** Undefined but unused symbols
1886 Bison used to raise an error for undefined symbols that are not used in
1887 the grammar. This is now only a warning.
1890 %destructor {} symbol2
1891 %type <type> symbol3
1895 *** Useless destructors or printers
1897 Bison now warns about useless destructors or printers. In the following
1898 example, the printer for <type1>, and the destructor for <type2> are
1899 useless: all symbols of <type1> (token1) already have a printer, and all
1900 symbols of type <type2> (token2) already have a destructor.
1902 %token <type1> token1
1906 %printer {} token1 <type1> <type3>
1907 %destructor {} token2 <type2> <type4>
1911 The warnings and error messages about shift/reduce and reduce/reduce
1912 conflicts have been normalized. For instance on the following foo.y file:
1916 exp: exp '+' exp | '0' | '0';
1918 compare the previous version of bison:
1921 foo.y: conflicts: 1 shift/reduce, 2 reduce/reduce
1922 $ bison -Werror foo.y
1923 bison: warnings being treated as errors
1924 foo.y: conflicts: 1 shift/reduce, 2 reduce/reduce
1926 with the new behavior:
1929 foo.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
1930 foo.y: warning: 2 reduce/reduce conflicts [-Wconflicts-rr]
1931 $ bison -Werror foo.y
1932 foo.y: error: 1 shift/reduce conflict [-Werror=conflicts-sr]
1933 foo.y: error: 2 reduce/reduce conflicts [-Werror=conflicts-rr]
1935 When %expect or %expect-rr is used, such as with bar.y:
1940 exp: exp '+' exp | '0' | '0';
1945 bar.y: conflicts: 1 shift/reduce, 2 reduce/reduce
1946 bar.y: expected 0 shift/reduce conflicts
1947 bar.y: expected 0 reduce/reduce conflicts
1952 bar.y: error: shift/reduce conflicts: 1 found, 0 expected
1953 bar.y: error: reduce/reduce conflicts: 2 found, 0 expected
1955 ** Incompatibilities with POSIX Yacc
1957 The 'yacc' category is no longer part of '-Wall', enable it explicitly
1960 ** Additional yylex/yyparse arguments
1962 The new directive %param declares additional arguments to both yylex and
1963 yyparse. The %lex-param, %parse-param, and %param directives support one
1964 or more arguments. Instead of
1966 %lex-param {arg1_type *arg1}
1967 %lex-param {arg2_type *arg2}
1968 %parse-param {arg1_type *arg1}
1969 %parse-param {arg2_type *arg2}
1973 %param {arg1_type *arg1} {arg2_type *arg2}
1975 ** Types of values for %define variables
1977 Bison used to make no difference between '%define foo bar' and '%define
1978 foo "bar"'. The former is now called a 'keyword value', and the latter a
1979 'string value'. A third kind was added: 'code values', such as '%define
1982 Keyword variables are used for fixed value sets, e.g.,
1984 %define lr.type lalr
1986 Code variables are used for value in the target language, e.g.,
1988 %define api.value.type {struct semantic_type}
1990 String variables are used remaining cases, e.g. file names.
1992 ** Variable api.token.prefix
1994 The variable api.token.prefix changes the way tokens are identified in
1995 the generated files. This is especially useful to avoid collisions
1996 with identifiers in the target language. For instance
1998 %token FILE for ERROR
1999 %define api.token.prefix {TOK_}
2001 start: FILE for ERROR;
2003 will generate the definition of the symbols TOK_FILE, TOK_for, and
2004 TOK_ERROR in the generated sources. In particular, the scanner must
2005 use these prefixed token names, although the grammar itself still
2006 uses the short names (as in the sample rule given above).
2008 ** Variable api.value.type
2010 This new %define variable supersedes the #define macro YYSTYPE. The use
2011 of YYSTYPE is discouraged. In particular, #defining YYSTYPE *and* either
2012 using %union or %defining api.value.type results in undefined behavior.
2014 Either define api.value.type, or use "%union":
2021 %token <ival> INT "integer"
2022 %token <sval> STRING "string"
2023 %printer { fprintf (yyo, "%d", $$); } <ival>
2024 %destructor { free ($$); } <sval>
2027 yylval.ival = 42; return INT;
2028 yylval.sval = "42"; return STRING;
2030 The %define variable api.value.type supports both keyword and code values.
2032 The keyword value 'union' means that the user provides genuine types, not
2033 union member names such as "ival" and "sval" above (WARNING: will fail if
2034 -y/--yacc/%yacc is enabled).
2036 %define api.value.type union
2037 %token <int> INT "integer"
2038 %token <char *> STRING "string"
2039 %printer { fprintf (yyo, "%d", $$); } <int>
2040 %destructor { free ($$); } <char *>
2043 yylval.INT = 42; return INT;
2044 yylval.STRING = "42"; return STRING;
2046 The keyword value variant is somewhat equivalent, but for C++ special
2047 provision is made to allow classes to be used (more about this below).
2049 %define api.value.type variant
2050 %token <int> INT "integer"
2051 %token <std::string> STRING "string"
2053 Code values (in braces) denote user defined types. This is where YYSTYPE
2071 %define api.value.type {struct my_value}
2072 %token <u.ival> INT "integer"
2073 %token <u.sval> STRING "string"
2074 %printer { fprintf (yyo, "%d", $$); } <u.ival>
2075 %destructor { free ($$); } <u.sval>
2078 yylval.u.ival = 42; return INT;
2079 yylval.u.sval = "42"; return STRING;
2081 ** Variable parse.error
2083 This variable controls the verbosity of error messages. The use of the
2084 %error-verbose directive is deprecated in favor of "%define parse.error
2087 ** Deprecated %define variable names
2089 The following variables have been renamed for consistency. Backward
2090 compatibility is ensured, but upgrading is recommended.
2092 lr.default-reductions -> lr.default-reduction
2093 lr.keep-unreachable-states -> lr.keep-unreachable-state
2094 namespace -> api.namespace
2095 stype -> api.value.type
2097 ** Semantic predicates
2099 Contributed by Paul Hilfinger.
2101 The new, experimental, semantic-predicate feature allows actions of the
2102 form "%?{ BOOLEAN-EXPRESSION }", which cause syntax errors (as for
2103 YYERROR) if the expression evaluates to 0, and are evaluated immediately
2104 in GLR parsers, rather than being deferred. The result is that they allow
2105 the programmer to prune possible parses based on the values of run-time
2108 ** The directive %expect-rr is now an error in non GLR mode
2110 It used to be an error only if used in non GLR mode, _and_ if there are
2111 reduce/reduce conflicts.
2113 ** Tokens are numbered in their order of appearance
2115 Contributed by Valentin Tolmer.
2117 With '%token A B', A had a number less than the one of B. However,
2118 precedence declarations used to generate a reversed order. This is now
2119 fixed, and introducing tokens with any of %token, %left, %right,
2120 %precedence, or %nonassoc yields the same result.
2122 When mixing declarations of tokens with a literal character (e.g., 'a') or
2123 with an identifier (e.g., B) in a precedence declaration, Bison numbered
2124 the literal characters first. For example
2128 would lead to the tokens declared in this order: 'c' 'd' A B. Again, the
2129 input order is now preserved.
2131 These changes were made so that one can remove useless precedence and
2132 associativity declarations (i.e., map %nonassoc, %left or %right to
2133 %precedence, or to %token) and get exactly the same output.
2135 ** Useless precedence and associativity
2137 Contributed by Valentin Tolmer.
2139 When developing and maintaining a grammar, useless associativity and
2140 precedence directives are common. They can be a nuisance: new ambiguities
2141 arising are sometimes masked because their conflicts are resolved due to
2142 the extra precedence or associativity information. Furthermore, it can
2143 hinder the comprehension of a new grammar: one will wonder about the role
2144 of a precedence, where in fact it is useless. The following changes aim
2145 at detecting and reporting these extra directives.
2147 *** Precedence warning category
2149 A new category of warning, -Wprecedence, was introduced. It flags the
2150 useless precedence and associativity directives.
2152 *** Useless associativity
2154 Bison now warns about symbols with a declared associativity that is never
2155 used to resolve conflicts. In that case, using %precedence is sufficient;
2156 the parsing tables will remain unchanged. Solving these warnings may raise
2157 useless precedence warnings, as the symbols no longer have associativity.
2171 warning: useless associativity for '+', use %precedence [-Wprecedence]
2175 *** Useless precedence
2177 Bison now warns about symbols with a declared precedence and no declared
2178 associativity (i.e., declared with %precedence), and whose precedence is
2179 never used. In that case, the symbol can be safely declared with %token
2180 instead, without modifying the parsing tables. For example:
2184 exp: "var" '=' "number";
2188 warning: useless precedence for '=' [-Wprecedence]
2192 *** Useless precedence and associativity
2194 In case of both useless precedence and associativity, the issue is flagged
2199 exp: "var" '=' "number";
2203 warning: useless precedence and associativity for '=' [-Wprecedence]
2209 With help from Joel E. Denny and Gabriel Rassoul.
2211 Empty rules (i.e., with an empty right-hand side) can now be explicitly
2212 marked by the new %empty directive. Using %empty on a non-empty rule is
2213 an error. The new -Wempty-rule warning reports empty rules without
2214 %empty. On the following grammar:
2224 3.4-5: warning: empty rule without %empty [-Wempty-rule]
2227 5.8-13: error: %empty on non-empty rule
2231 ** Java skeleton improvements
2233 The constants for token names were moved to the Lexer interface. Also, it
2234 is possible to add code to the parser's constructors using "%code init"
2235 and "%define init_throws".
2236 Contributed by Paolo Bonzini.
2238 The Java skeleton now supports push parsing.
2239 Contributed by Dennis Heimbigner.
2241 ** C++ skeletons improvements
2243 *** The parser header is no longer mandatory (lalr1.cc, glr.cc)
2245 Using %defines is now optional. Without it, the needed support classes
2246 are defined in the generated parser, instead of additional files (such as
2247 location.hh, position.hh and stack.hh).
2249 *** Locations are no longer mandatory (lalr1.cc, glr.cc)
2251 Both lalr1.cc and glr.cc no longer require %location.
2253 *** syntax_error exception (lalr1.cc)
2255 The C++ parser features a syntax_error exception, which can be
2256 thrown from the scanner or from user rules to raise syntax errors.
2257 This facilitates reporting errors caught in sub-functions (e.g.,
2258 rejecting too large integral literals from a conversion function
2259 used by the scanner, or rejecting invalid combinations from a
2260 factory invoked by the user actions).
2262 *** %define api.value.type variant
2264 This is based on a submission from Michiel De Wilde. With help
2265 from Théophile Ranquet.
2267 In this mode, complex C++ objects can be used as semantic values. For
2270 %token <::std::string> TEXT;
2271 %token <int> NUMBER;
2272 %token SEMICOLON ";"
2273 %type <::std::string> item;
2274 %type <::std::list<std::string>> list;
2277 list { std::cout << $1 << std::endl; }
2281 %empty { /* Generates an empty string list. */ }
2282 | list item ";" { std::swap ($$, $1); $$.push_back ($2); }
2286 TEXT { std::swap ($$, $1); }
2287 | NUMBER { $$ = string_cast ($1); }
2290 *** %define api.token.constructor
2292 When variants are enabled, Bison can generate functions to build the
2293 tokens. This guarantees that the token type (e.g., NUMBER) is consistent
2294 with the semantic value (e.g., int):
2296 parser::symbol_type yylex ()
2298 parser::location_type loc = ...;
2300 return parser::make_TEXT ("Hello, world!", loc);
2302 return parser::make_NUMBER (42, loc);
2304 return parser::make_SEMICOLON (loc);
2310 There are operator- and operator-= for 'location'. Negative line/column
2311 increments can no longer underflow the resulting value.
2314 * Noteworthy changes in release 2.7.1 (2013-04-15) [stable]
2318 *** Fix compiler attribute portability (yacc.c)
2320 With locations enabled, __attribute__ was used unprotected.
2322 *** Fix some compiler warnings (lalr1.cc)
2325 * Noteworthy changes in release 2.7 (2012-12-12) [stable]
2329 Warnings about uninitialized yylloc in yyparse have been fixed.
2331 Restored C90 compliance (yet no report was ever made).
2333 ** Diagnostics are improved
2335 Contributed by Théophile Ranquet.
2337 *** Changes in the format of error messages
2339 This used to be the format of many error reports:
2341 input.y:2.7-12: %type redeclaration for exp
2342 input.y:1.7-12: previous declaration
2346 input.y:2.7-12: error: %type redeclaration for exp
2347 input.y:1.7-12: previous declaration
2349 *** New format for error reports: carets
2351 Caret errors have been added to Bison:
2353 input.y:2.7-12: error: %type redeclaration for exp
2356 input.y:1.7-12: previous declaration
2362 input.y:3.20-23: error: ambiguous reference: '$exp'
2363 exp: exp '+' exp { $exp = $1 + $3; };
2365 input.y:3.1-3: refers to: $exp at $$
2366 exp: exp '+' exp { $exp = $1 + $3; };
2368 input.y:3.6-8: refers to: $exp at $1
2369 exp: exp '+' exp { $exp = $1 + $3; };
2371 input.y:3.14-16: refers to: $exp at $3
2372 exp: exp '+' exp { $exp = $1 + $3; };
2375 The default behavior for now is still not to display these unless
2376 explicitly asked with -fcaret (or -fall). However, in a later release, it
2377 will be made the default behavior (but may still be deactivated with
2380 ** New value for %define variable: api.pure full
2382 The %define variable api.pure requests a pure (reentrant) parser. However,
2383 for historical reasons, using it in a location-tracking Yacc parser
2384 resulted in a yyerror function that did not take a location as a
2385 parameter. With this new value, the user may request a better pure parser,
2386 where yyerror does take a location as a parameter (in location-tracking
2389 The use of "%define api.pure true" is deprecated in favor of this new
2390 "%define api.pure full".
2392 ** New %define variable: api.location.type (glr.cc, lalr1.cc, lalr1.java)
2394 The %define variable api.location.type defines the name of the type to use
2395 for locations. When defined, Bison no longer generates the position.hh
2396 and location.hh files, nor does the parser will include them: the user is
2397 then responsible to define her type.
2399 This can be used in programs with several parsers to factor their location
2400 and position files: let one of them generate them, and the others just use
2403 This feature was actually introduced, but not documented, in Bison 2.5,
2404 under the name "location_type" (which is maintained for backward
2407 For consistency, lalr1.java's %define variables location_type and
2408 position_type are deprecated in favor of api.location.type and
2411 ** Exception safety (lalr1.cc)
2413 The parse function now catches exceptions, uses the %destructors to
2414 release memory (the lookahead symbol and the symbols pushed on the stack)
2415 before re-throwing the exception.
2417 This feature is somewhat experimental. User feedback would be
2420 ** Graph improvements in DOT and XSLT
2422 Contributed by Théophile Ranquet.
2424 The graphical presentation of the states is more readable: their shape is
2425 now rectangular, the state number is clearly displayed, and the items are
2426 numbered and left-justified.
2428 The reductions are now explicitly represented as transitions to other
2429 diamond shaped nodes.
2431 These changes are present in both --graph output and xml2dot.xsl XSLT
2432 processing, with minor (documented) differences.
2434 ** %language is no longer an experimental feature.
2436 The introduction of this feature, in 2.4, was four years ago. The
2437 --language option and the %language directive are no longer experimental.
2441 The sections about shift/reduce and reduce/reduce conflicts resolution
2442 have been fixed and extended.
2444 Although introduced more than four years ago, XML and Graphviz reports
2445 were not properly documented.
2447 The translation of midrule actions is now described.
2450 * Noteworthy changes in release 2.6.5 (2012-11-07) [stable]
2452 We consider compiler warnings about Bison generated parsers to be bugs.
2453 Rather than working around them in your own project, please consider
2454 reporting them to us.
2458 Warnings about uninitialized yylval and/or yylloc for push parsers with a
2459 pure interface have been fixed for GCC 4.0 up to 4.8, and Clang 2.9 to
2462 Other issues in the test suite have been addressed.
2464 Null characters are correctly displayed in error messages.
2466 When possible, yylloc is correctly initialized before calling yylex. It
2467 is no longer necessary to initialize it in the %initial-action.
2470 * Noteworthy changes in release 2.6.4 (2012-10-23) [stable]
2472 Bison 2.6.3's --version was incorrect. This release fixes this issue.
2475 * Noteworthy changes in release 2.6.3 (2012-10-22) [stable]
2479 Bugs and portability issues in the test suite have been fixed.
2481 Some errors in translations have been addressed, and --help now directs
2482 users to the appropriate place to report them.
2484 Stray Info files shipped by accident are removed.
2486 Incorrect definitions of YY_, issued by yacc.c when no parser header is
2487 generated, are removed.
2489 All the generated headers are self-contained.
2491 ** Header guards (yacc.c, glr.c, glr.cc)
2493 In order to avoid collisions, the header guards are now
2494 YY_<PREFIX>_<FILE>_INCLUDED, instead of merely <PREFIX>_<FILE>.
2495 For instance the header generated from
2497 %define api.prefix "calc"
2498 %defines "lib/parse.h"
2500 will use YY_CALC_LIB_PARSE_H_INCLUDED as guard.
2502 ** Fix compiler warnings in the generated parser (yacc.c, glr.c)
2504 The compilation of pure parsers (%define api.pure) can trigger GCC
2507 input.c: In function 'yyparse':
2508 input.c:1503:12: warning: 'yylval' may be used uninitialized in this
2509 function [-Wmaybe-uninitialized]
2513 This is now fixed; pragmas to avoid these warnings are no longer needed.
2515 Warnings from clang ("equality comparison with extraneous parentheses" and
2516 "function declared 'noreturn' should not return") have also been
2520 * Noteworthy changes in release 2.6.2 (2012-08-03) [stable]
2524 Buffer overruns, complaints from Flex, and portability issues in the test
2525 suite have been fixed.
2527 ** Spaces in %lex- and %parse-param (lalr1.cc, glr.cc)
2529 Trailing end-of-lines in %parse-param or %lex-param would result in
2530 invalid C++. This is fixed.
2532 ** Spurious spaces and end-of-lines
2534 The generated files no longer end (nor start) with empty lines.
2537 * Noteworthy changes in release 2.6.1 (2012-07-30) [stable]
2539 Bison no longer executes user-specified M4 code when processing a grammar.
2543 In addition to the removal of the features announced in Bison 2.6, the
2544 next major release will remove the "Temporary hack for adding a semicolon
2545 to the user action", as announced in the release 2.5. Instead of:
2547 exp: exp "+" exp { $$ = $1 + $3 };
2551 exp: exp "+" exp { $$ = $1 + $3; };
2555 *** Type names are now properly escaped.
2557 *** glr.cc: set_debug_level and debug_level work as expected.
2559 *** Stray @ or $ in actions
2561 While Bison used to warn about stray $ or @ in action rules, it did not
2562 for other actions such as printers, destructors, or initial actions. It
2565 ** Type names in actions
2567 For consistency with rule actions, it is now possible to qualify $$ by a
2568 type-name in destructors, printers, and initial actions. For instance:
2570 %printer { fprintf (yyo, "(%d, %f)", $<ival>$, $<fval>$); } <*> <>;
2572 will display two values for each typed and untyped symbol (provided
2573 that YYSTYPE has both "ival" and "fval" fields).
2576 * Noteworthy changes in release 2.6 (2012-07-19) [stable]
2580 The next major release of Bison will drop support for the following
2581 deprecated features. Please report disagreements to bug-bison@gnu.org.
2585 Support for generating parsers in K&R C will be removed. Parsers
2586 generated for C support ISO C90, and are tested with ISO C99 and ISO C11
2589 *** Features deprecated since Bison 1.875
2591 The definitions of yystype and yyltype will be removed; use YYSTYPE and
2594 YYPARSE_PARAM and YYLEX_PARAM, deprecated in favor of %parse-param and
2595 %lex-param, will no longer be supported.
2597 Support for the preprocessor symbol YYERROR_VERBOSE will be removed, use
2600 *** The generated header will be included (yacc.c)
2602 Instead of duplicating the content of the generated header (definition of
2603 YYSTYPE, yyparse declaration etc.), the generated parser will include it,
2604 as is already the case for GLR or C++ parsers. This change is deferred
2605 because existing versions of ylwrap (e.g., Automake 1.12.1) do not support
2608 ** Generated Parser Headers
2610 *** Guards (yacc.c, glr.c, glr.cc)
2612 The generated headers are now guarded, as is already the case for C++
2613 parsers (lalr1.cc). For instance, with --defines=foo.h:
2618 #endif /* !YY_FOO_H */
2620 *** New declarations (yacc.c, glr.c)
2622 The generated header now declares yydebug and yyparse. Both honor
2623 --name-prefix=bar_, and yield
2625 int bar_parse (void);
2629 #define yyparse bar_parse
2632 in order to facilitate the inclusion of several parser headers inside a
2633 single compilation unit.
2635 *** Exported symbols in C++
2637 The symbols YYTOKEN_TABLE and YYERROR_VERBOSE, which were defined in the
2638 header, are removed, as they prevent the possibility of including several
2639 generated headers from a single compilation unit.
2643 For the same reasons, the undocumented and unused macro YYLSP_NEEDED is no
2646 ** New %define variable: api.prefix
2648 Now that the generated headers are more complete and properly protected
2649 against multiple inclusions, constant names, such as YYSTYPE are a
2650 problem. While yyparse and others are properly renamed by %name-prefix,
2651 YYSTYPE, YYDEBUG and others have never been affected by it. Because it
2652 would introduce backward compatibility issues in projects not expecting
2653 YYSTYPE to be renamed, instead of changing the behavior of %name-prefix,
2654 it is deprecated in favor of a new %define variable: api.prefix.
2656 The following examples compares both:
2658 %name-prefix "bar_" | %define api.prefix "bar_"
2659 %token <ival> FOO %token <ival> FOO
2660 %union { int ival; } %union { int ival; }
2666 #ifndef BAR_FOO_H #ifndef BAR_FOO_H
2667 # define BAR_FOO_H # define BAR_FOO_H
2669 /* Enabling traces. */ /* Enabling traces. */
2670 # ifndef YYDEBUG | # ifndef BAR_DEBUG
2671 > # if defined YYDEBUG
2673 > # define BAR_DEBUG 1
2675 > # define BAR_DEBUG 0
2678 # define YYDEBUG 0 | # define BAR_DEBUG 0
2682 # if YYDEBUG | # if BAR_DEBUG
2683 extern int bar_debug; extern int bar_debug;
2686 /* Tokens. */ /* Tokens. */
2687 # ifndef YYTOKENTYPE | # ifndef BAR_TOKENTYPE
2688 # define YYTOKENTYPE | # define BAR_TOKENTYPE
2689 enum yytokentype { | enum bar_tokentype {
2694 #if ! defined YYSTYPE \ | #if ! defined BAR_STYPE \
2695 && ! defined YYSTYPE_IS_DECLARED | && ! defined BAR_STYPE_IS_DECLARED
2696 typedef union YYSTYPE | typedef union BAR_STYPE
2699 } YYSTYPE; | } BAR_STYPE;
2700 # define YYSTYPE_IS_DECLARED 1 | # define BAR_STYPE_IS_DECLARED 1
2703 extern YYSTYPE bar_lval; | extern BAR_STYPE bar_lval;
2705 int bar_parse (void); int bar_parse (void);
2707 #endif /* !BAR_FOO_H */ #endif /* !BAR_FOO_H */
2710 * Noteworthy changes in release 2.5.1 (2012-06-05) [stable]
2714 The next major release will drop support for generating parsers in K&R C.
2716 ** yacc.c: YYBACKUP works as expected.
2718 ** glr.c improvements:
2720 *** Location support is eliminated when not requested:
2722 GLR parsers used to include location-related code even when locations were
2723 not requested, and therefore not even usable.
2725 *** __attribute__ is preserved:
2727 __attribute__ is no longer disabled when __STRICT_ANSI__ is defined (i.e.,
2728 when -std is passed to GCC).
2730 ** lalr1.java: several fixes:
2732 The Java parser no longer throws ArrayIndexOutOfBoundsException if the
2733 first token leads to a syntax error. Some minor clean ups.
2737 *** C++11 compatibility:
2739 C and C++ parsers use "nullptr" instead of "0" when __cplusplus is 201103L
2744 The header files such as "parser.hh", "location.hh", etc. used a constant
2745 name for preprocessor guards, for instance:
2747 #ifndef BISON_LOCATION_HH
2748 # define BISON_LOCATION_HH
2750 #endif // !BISON_LOCATION_HH
2752 The inclusion guard is now computed from "PREFIX/FILE-NAME", where lower
2753 case characters are converted to upper case, and series of
2754 non-alphanumerical characters are converted to an underscore.
2756 With "bison -o lang++/parser.cc", "location.hh" would now include:
2758 #ifndef YY_LANG_LOCATION_HH
2759 # define YY_LANG_LOCATION_HH
2761 #endif // !YY_LANG_LOCATION_HH
2765 The position and location constructors (and their initialize methods)
2766 accept new arguments for line and column. Several issues in the
2767 documentation were fixed.
2769 ** liby is no longer asking for "rpl_fprintf" on some platforms.
2771 ** Changes in the manual:
2773 *** %printer is documented
2775 The "%printer" directive, supported since at least Bison 1.50, is finally
2776 documented. The "mfcalc" example is extended to demonstrate it.
2778 For consistency with the C skeletons, the C++ parsers now also support
2779 "yyoutput" (as an alias to "debug_stream ()").
2781 *** Several improvements have been made:
2783 The layout for grammar excerpts was changed to a more compact scheme.
2784 Named references are motivated. The description of the automaton
2785 description file (*.output) is updated to the current format. Incorrect
2786 index entries were fixed. Some other errors were fixed.
2790 *** Conflicting prototypes with recent/modified Flex.
2792 Fixed build problems with the current, unreleased, version of Flex, and
2793 some modified versions of 2.5.35, which have modified function prototypes.
2795 *** Warnings during the build procedure have been eliminated.
2797 *** Several portability problems in the test suite have been fixed:
2799 This includes warnings with some compilers, unexpected behavior of tools
2800 such as diff, warning messages from the test suite itself, etc.
2802 *** The install-pdf target works properly:
2804 Running "make install-pdf" (or -dvi, -html, -info, and -ps) no longer
2805 halts in the middle of its course.
2808 * Noteworthy changes in release 2.5 (2011-05-14)
2810 ** Grammar symbol names can now contain non-initial dashes:
2812 Consistently with directives (such as %error-verbose) and with
2813 %define variables (e.g. push-pull), grammar symbol names may contain
2814 dashes in any position except the beginning. This is a GNU
2815 extension over POSIX Yacc. Thus, use of this extension is reported
2816 by -Wyacc and rejected in Yacc mode (--yacc).
2818 ** Named references:
2820 Historically, Yacc and Bison have supported positional references
2821 ($n, $$) to allow access to symbol values from inside of semantic
2824 Starting from this version, Bison can also accept named references.
2825 When no ambiguity is possible, original symbol names may be used
2826 as named references:
2828 if_stmt : "if" cond_expr "then" then_stmt ';'
2829 { $if_stmt = mk_if_stmt($cond_expr, $then_stmt); }
2831 In the more common case, explicit names may be declared:
2833 stmt[res] : "if" expr[cond] "then" stmt[then] "else" stmt[else] ';'
2834 { $res = mk_if_stmt($cond, $then, $else); }
2836 Location information is also accessible using @name syntax. When
2837 accessing symbol names containing dots or dashes, explicit bracketing
2838 ($[sym.1]) must be used.
2840 These features are experimental in this version. More user feedback
2841 will help to stabilize them.
2842 Contributed by Alex Rozenman.
2844 ** IELR(1) and canonical LR(1):
2846 IELR(1) is a minimal LR(1) parser table generation algorithm. That
2847 is, given any context-free grammar, IELR(1) generates parser tables
2848 with the full language-recognition power of canonical LR(1) but with
2849 nearly the same number of parser states as LALR(1). This reduction
2850 in parser states is often an order of magnitude. More importantly,
2851 because canonical LR(1)'s extra parser states may contain duplicate
2852 conflicts in the case of non-LR(1) grammars, the number of conflicts
2853 for IELR(1) is often an order of magnitude less as well. This can
2854 significantly reduce the complexity of developing of a grammar.
2856 Bison can now generate IELR(1) and canonical LR(1) parser tables in
2857 place of its traditional LALR(1) parser tables, which remain the
2858 default. You can specify the type of parser tables in the grammar
2859 file with these directives:
2861 %define lr.type lalr
2862 %define lr.type ielr
2863 %define lr.type canonical-lr
2865 The default-reduction optimization in the parser tables can also be
2866 adjusted using "%define lr.default-reductions". For details on both
2867 of these features, see the new section "Tuning LR" in the Bison
2870 These features are experimental. More user feedback will help to
2873 ** LAC (Lookahead Correction) for syntax error handling
2875 Contributed by Joel E. Denny.
2877 Canonical LR, IELR, and LALR can suffer from a couple of problems
2878 upon encountering a syntax error. First, the parser might perform
2879 additional parser stack reductions before discovering the syntax
2880 error. Such reductions can perform user semantic actions that are
2881 unexpected because they are based on an invalid token, and they
2882 cause error recovery to begin in a different syntactic context than
2883 the one in which the invalid token was encountered. Second, when
2884 verbose error messages are enabled (with %error-verbose or the
2885 obsolete "#define YYERROR_VERBOSE"), the expected token list in the
2886 syntax error message can both contain invalid tokens and omit valid
2889 The culprits for the above problems are %nonassoc, default
2890 reductions in inconsistent states, and parser state merging. Thus,
2891 IELR and LALR suffer the most. Canonical LR can suffer only if
2892 %nonassoc is used or if default reductions are enabled for
2893 inconsistent states.
2895 LAC is a new mechanism within the parsing algorithm that solves
2896 these problems for canonical LR, IELR, and LALR without sacrificing
2897 %nonassoc, default reductions, or state merging. When LAC is in
2898 use, canonical LR and IELR behave almost exactly the same for both
2899 syntactically acceptable and syntactically unacceptable input.
2900 While LALR still does not support the full language-recognition
2901 power of canonical LR and IELR, LAC at least enables LALR's syntax
2902 error handling to correctly reflect LALR's language-recognition
2905 Currently, LAC is only supported for deterministic parsers in C.
2906 You can enable LAC with the following directive:
2908 %define parse.lac full
2910 See the new section "LAC" in the Bison manual for additional
2911 details including a few caveats.
2913 LAC is an experimental feature. More user feedback will help to
2916 ** %define improvements:
2918 *** Can now be invoked via the command line:
2920 Each of these command-line options
2923 --define=NAME[=VALUE]
2926 --force-define=NAME[=VALUE]
2928 is equivalent to this grammar file declaration
2930 %define NAME ["VALUE"]
2932 except that the manner in which Bison processes multiple definitions
2933 for the same NAME differs. Most importantly, -F and --force-define
2934 quietly override %define, but -D and --define do not. For further
2935 details, see the section "Bison Options" in the Bison manual.
2937 *** Variables renamed:
2939 The following %define variables
2942 lr.keep_unreachable_states
2944 have been renamed to
2947 lr.keep-unreachable-states
2949 The old names are now deprecated but will be maintained indefinitely
2950 for backward compatibility.
2952 *** Values no longer need to be quoted in the grammar file:
2954 If a %define value is an identifier, it no longer needs to be placed
2955 within quotations marks. For example,
2957 %define api.push-pull "push"
2961 %define api.push-pull push
2963 *** Unrecognized variables are now errors not warnings.
2965 *** Multiple invocations for any variable is now an error not a warning.
2967 ** Unrecognized %code qualifiers are now errors not warnings.
2969 ** Character literals not of length one:
2971 Previously, Bison quietly converted all character literals to length
2972 one. For example, without warning, Bison interpreted the operators in
2973 the following grammar to be the same token:
2979 Bison now warns when a character literal is not of length one. In
2980 some future release, Bison will start reporting an error instead.
2982 ** Destructor calls fixed for lookaheads altered in semantic actions:
2984 Previously for deterministic parsers in C, if a user semantic action
2985 altered yychar, the parser in some cases used the old yychar value to
2986 determine which destructor to call for the lookahead upon a syntax
2987 error or upon parser return. This bug has been fixed.
2989 ** C++ parsers use YYRHSLOC:
2991 Similarly to the C parsers, the C++ parsers now define the YYRHSLOC
2992 macro and use it in the default YYLLOC_DEFAULT. You are encouraged
2993 to use it. If, for instance, your location structure has "first"
2994 and "last" members, instead of
2996 # define YYLLOC_DEFAULT(Current, Rhs, N) \
3000 (Current).first = (Rhs)[1].location.first; \
3001 (Current).last = (Rhs)[N].location.last; \
3005 (Current).first = (Current).last = (Rhs)[0].location.last; \
3011 # define YYLLOC_DEFAULT(Current, Rhs, N) \
3015 (Current).first = YYRHSLOC (Rhs, 1).first; \
3016 (Current).last = YYRHSLOC (Rhs, N).last; \
3020 (Current).first = (Current).last = YYRHSLOC (Rhs, 0).last; \
3024 ** YYLLOC_DEFAULT in C++:
3026 The default implementation of YYLLOC_DEFAULT used to be issued in
3027 the header file. It is now output in the implementation file, after
3028 the user %code sections so that its #ifndef guard does not try to
3029 override the user's YYLLOC_DEFAULT if provided.
3031 ** YYFAIL now produces warnings and Java parsers no longer implement it:
3033 YYFAIL has existed for many years as an undocumented feature of
3034 deterministic parsers in C generated by Bison. More recently, it was
3035 a documented feature of Bison's experimental Java parsers. As
3036 promised in Bison 2.4.2's NEWS entry, any appearance of YYFAIL in a
3037 semantic action now produces a deprecation warning, and Java parsers
3038 no longer implement YYFAIL at all. For further details, including a
3039 discussion of how to suppress C preprocessor warnings about YYFAIL
3040 being unused, see the Bison 2.4.2 NEWS entry.
3042 ** Temporary hack for adding a semicolon to the user action:
3044 Previously, Bison appended a semicolon to every user action for
3045 reductions when the output language defaulted to C (specifically, when
3046 neither %yacc, %language, %skeleton, or equivalent command-line
3047 options were specified). This allowed actions such as
3049 exp: exp "+" exp { $$ = $1 + $3 };
3053 exp: exp "+" exp { $$ = $1 + $3; };
3055 As a first step in removing this misfeature, Bison now issues a
3056 warning when it appends a semicolon. Moreover, in cases where Bison
3057 cannot easily determine whether a semicolon is needed (for example, an
3058 action ending with a cpp directive or a braced compound initializer),
3059 it no longer appends one. Thus, the C compiler might now complain
3060 about a missing semicolon where it did not before. Future releases of
3061 Bison will cease to append semicolons entirely.
3063 ** Verbose syntax error message fixes:
3065 When %error-verbose or the obsolete "#define YYERROR_VERBOSE" is
3066 specified, syntax error messages produced by the generated parser
3067 include the unexpected token as well as a list of expected tokens.
3068 The effect of %nonassoc on these verbose messages has been corrected
3069 in two ways, but a more complete fix requires LAC, described above:
3071 *** When %nonassoc is used, there can exist parser states that accept no
3072 tokens, and so the parser does not always require a lookahead token
3073 in order to detect a syntax error. Because no unexpected token or
3074 expected tokens can then be reported, the verbose syntax error
3075 message described above is suppressed, and the parser instead
3076 reports the simpler message, "syntax error". Previously, this
3077 suppression was sometimes erroneously triggered by %nonassoc when a
3078 lookahead was actually required. Now verbose messages are
3079 suppressed only when all previous lookaheads have already been
3080 shifted or discarded.
3082 *** Previously, the list of expected tokens erroneously included tokens
3083 that would actually induce a syntax error because conflicts for them
3084 were resolved with %nonassoc in the current parser state. Such
3085 tokens are now properly omitted from the list.
3087 *** Expected token lists are still often wrong due to state merging
3088 (from LALR or IELR) and default reductions, which can both add
3089 invalid tokens and subtract valid tokens. Canonical LR almost
3090 completely fixes this problem by eliminating state merging and
3091 default reductions. However, there is one minor problem left even
3092 when using canonical LR and even after the fixes above. That is,
3093 if the resolution of a conflict with %nonassoc appears in a later
3094 parser state than the one at which some syntax error is
3095 discovered, the conflicted token is still erroneously included in
3096 the expected token list. Bison's new LAC implementation,
3097 described above, eliminates this problem and the need for
3098 canonical LR. However, LAC is still experimental and is disabled
3101 ** Java skeleton fixes:
3103 *** A location handling bug has been fixed.
3105 *** The top element of each of the value stack and location stack is now
3106 cleared when popped so that it can be garbage collected.
3108 *** Parser traces now print the top element of the stack.
3110 ** -W/--warnings fixes:
3112 *** Bison now properly recognizes the "no-" versions of categories:
3114 For example, given the following command line, Bison now enables all
3115 warnings except warnings for incompatibilities with POSIX Yacc:
3117 bison -Wall,no-yacc gram.y
3119 *** Bison now treats S/R and R/R conflicts like other warnings:
3121 Previously, conflict reports were independent of Bison's normal
3122 warning system. Now, Bison recognizes the warning categories
3123 "conflicts-sr" and "conflicts-rr". This change has important
3124 consequences for the -W and --warnings command-line options. For
3127 bison -Wno-conflicts-sr gram.y # S/R conflicts not reported
3128 bison -Wno-conflicts-rr gram.y # R/R conflicts not reported
3129 bison -Wnone gram.y # no conflicts are reported
3130 bison -Werror gram.y # any conflict is an error
3132 However, as before, if the %expect or %expect-rr directive is
3133 specified, an unexpected number of conflicts is an error, and an
3134 expected number of conflicts is not reported, so -W and --warning
3135 then have no effect on the conflict report.
3137 *** The "none" category no longer disables a preceding "error":
3139 For example, for the following command line, Bison now reports
3140 errors instead of warnings for incompatibilities with POSIX Yacc:
3142 bison -Werror,none,yacc gram.y
3144 *** The "none" category now disables all Bison warnings:
3146 Previously, the "none" category disabled only Bison warnings for
3147 which there existed a specific -W/--warning category. However,
3148 given the following command line, Bison is now guaranteed to
3149 suppress all warnings:
3153 ** Precedence directives can now assign token number 0:
3155 Since Bison 2.3b, which restored the ability of precedence
3156 directives to assign token numbers, doing so for token number 0 has
3157 produced an assertion failure. For example:
3161 This bug has been fixed.
3164 * Noteworthy changes in release 2.4.3 (2010-08-05)
3166 ** Bison now obeys -Werror and --warnings=error for warnings about
3167 grammar rules that are useless in the parser due to conflicts.
3169 ** Problems with spawning M4 on at least FreeBSD 8 and FreeBSD 9 have
3172 ** Failures in the test suite for GCC 4.5 have been fixed.
3174 ** Failures in the test suite for some versions of Sun Studio C++ have
3177 ** Contrary to Bison 2.4.2's NEWS entry, it has been decided that
3178 warnings about undefined %prec identifiers will not be converted to
3179 errors in Bison 2.5. They will remain warnings, which should be
3180 sufficient for POSIX while avoiding backward compatibility issues.
3182 ** Minor documentation fixes.
3185 * Noteworthy changes in release 2.4.2 (2010-03-20)
3187 ** Some portability problems that resulted in failures and livelocks
3188 in the test suite on some versions of at least Solaris, AIX, HP-UX,
3189 RHEL4, and Tru64 have been addressed. As a result, fatal Bison
3190 errors should no longer cause M4 to report a broken pipe on the
3193 ** "%prec IDENTIFIER" requires IDENTIFIER to be defined separately.
3195 POSIX specifies that an error be reported for any identifier that does
3196 not appear on the LHS of a grammar rule and that is not defined by
3197 %token, %left, %right, or %nonassoc. Bison 2.3b and later lost this
3198 error report for the case when an identifier appears only after a
3199 %prec directive. It is now restored. However, for backward
3200 compatibility with recent Bison releases, it is only a warning for
3201 now. In Bison 2.5 and later, it will return to being an error.
3202 [Between the 2.4.2 and 2.4.3 releases, it was decided that this
3203 warning will not be converted to an error in Bison 2.5.]
3205 ** Detection of GNU M4 1.4.6 or newer during configure is improved.
3207 ** Warnings from gcc's -Wundef option about undefined YYENABLE_NLS,
3208 YYLTYPE_IS_TRIVIAL, and __STRICT_ANSI__ in C/C++ parsers are now
3211 ** %code is now a permanent feature.
3213 A traditional Yacc prologue directive is written in the form:
3217 To provide a more flexible alternative, Bison 2.3b introduced the
3218 %code directive with the following forms for C/C++:
3221 %code requires {CODE}
3222 %code provides {CODE}
3225 These forms are now considered permanent features of Bison. See the
3226 %code entries in the section "Bison Declaration Summary" in the Bison
3227 manual for a summary of their functionality. See the section
3228 "Prologue Alternatives" for a detailed discussion including the
3229 advantages of %code over the traditional Yacc prologue directive.
3231 Bison's Java feature as a whole including its current usage of %code
3232 is still considered experimental.
3234 ** YYFAIL is deprecated and will eventually be removed.
3236 YYFAIL has existed for many years as an undocumented feature of
3237 deterministic parsers in C generated by Bison. Previously, it was
3238 documented for Bison's experimental Java parsers. YYFAIL is no longer
3239 documented for Java parsers and is formally deprecated in both cases.
3240 Users are strongly encouraged to migrate to YYERROR, which is
3243 Like YYERROR, you can invoke YYFAIL from a semantic action in order to
3244 induce a syntax error. The most obvious difference from YYERROR is
3245 that YYFAIL will automatically invoke yyerror to report the syntax
3246 error so that you don't have to. However, there are several other
3247 subtle differences between YYERROR and YYFAIL, and YYFAIL suffers from
3248 inherent flaws when %error-verbose or "#define YYERROR_VERBOSE" is
3249 used. For a more detailed discussion, see:
3251 http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html
3253 The upcoming Bison 2.5 will remove YYFAIL from Java parsers, but
3254 deterministic parsers in C will continue to implement it. However,
3255 because YYFAIL is already flawed, it seems futile to try to make new
3256 Bison features compatible with it. Thus, during parser generation,
3257 Bison 2.5 will produce a warning whenever it discovers YYFAIL in a
3258 rule action. In a later release, YYFAIL will be disabled for
3259 %error-verbose and "#define YYERROR_VERBOSE". Eventually, YYFAIL will
3260 be removed altogether.
3262 There exists at least one case where Bison 2.5's YYFAIL warning will
3263 be a false positive. Some projects add phony uses of YYFAIL and other
3264 Bison-defined macros for the sole purpose of suppressing C
3265 preprocessor warnings (from GCC cpp's -Wunused-macros, for example).
3266 To avoid Bison's future warning, such YYFAIL uses can be moved to the
3267 epilogue (that is, after the second "%%") in the Bison input file. In
3268 this release (2.4.2), Bison already generates its own code to suppress
3269 C preprocessor warnings for YYFAIL, so projects can remove their own
3270 phony uses of YYFAIL if compatibility with Bison releases prior to
3271 2.4.2 is not necessary.
3273 ** Internationalization.
3275 Fix a regression introduced in Bison 2.4: Under some circumstances,
3276 message translations were not installed although supported by the
3280 * Noteworthy changes in release 2.4.1 (2008-12-11)
3282 ** In the GLR defines file, unexpanded M4 macros in the yylval and yylloc
3283 declarations have been fixed.
3285 ** Temporary hack for adding a semicolon to the user action.
3287 Bison used to prepend a trailing semicolon at the end of the user
3288 action for reductions. This allowed actions such as
3290 exp: exp "+" exp { $$ = $1 + $3 };
3294 exp: exp "+" exp { $$ = $1 + $3; };
3296 Some grammars still depend on this "feature". Bison 2.4.1 restores
3297 the previous behavior in the case of C output (specifically, when
3298 neither %language or %skeleton or equivalent command-line options
3299 are used) to leave more time for grammars depending on the old
3300 behavior to be adjusted. Future releases of Bison will disable this
3303 ** A few minor improvements to the Bison manual.
3306 * Noteworthy changes in release 2.4 (2008-11-02)
3308 ** %language is an experimental feature.
3310 We first introduced this feature in test release 2.3b as a cleaner
3311 alternative to %skeleton. Since then, we have discussed the possibility of
3312 modifying its effect on Bison's output file names. Thus, in this release,
3313 we consider %language to be an experimental feature that will likely evolve
3316 ** Forward compatibility with GNU M4 has been improved.
3318 ** Several bugs in the C++ skeleton and the experimental Java skeleton have been
3322 * Noteworthy changes in release 2.3b (2008-05-27)
3324 ** The quotes around NAME that used to be required in the following directive
3327 %define NAME "VALUE"
3329 ** The directive "%pure-parser" is now deprecated in favor of:
3333 which has the same effect except that Bison is more careful to warn about
3334 unreasonable usage in the latter case.
3338 Bison can now generate an LALR(1) parser in C with a push interface. That
3339 is, instead of invoking "yyparse", which pulls tokens from "yylex", you can
3340 push one token at a time to the parser using "yypush_parse", which will
3341 return to the caller after processing each token. By default, the push
3342 interface is disabled. Either of the following directives will enable it:
3344 %define api.push_pull "push" // Just push; does not require yylex.
3345 %define api.push_pull "both" // Push and pull; requires yylex.
3347 See the new section "A Push Parser" in the Bison manual for details.
3349 The current push parsing interface is experimental and may evolve. More user
3350 feedback will help to stabilize it.
3352 ** The -g and --graph options now output graphs in Graphviz DOT format,
3353 not VCG format. Like --graph, -g now also takes an optional FILE argument
3354 and thus cannot be bundled with other short options.
3358 Bison can now generate an LALR(1) parser in Java. The skeleton is
3359 "data/lalr1.java". Consider using the new %language directive instead of
3360 %skeleton to select it.
3362 See the new section "Java Parsers" in the Bison manual for details.
3364 The current Java interface is experimental and may evolve. More user
3365 feedback will help to stabilize it.
3366 Contributed by Paolo Bonzini.
3370 This new directive specifies the programming language of the generated
3371 parser, which can be C (the default), C++, or Java. Besides the skeleton
3372 that Bison uses, the directive affects the names of the generated files if
3373 the grammar file's name ends in ".y".
3375 ** XML Automaton Report
3377 Bison can now generate an XML report of the LALR(1) automaton using the new
3378 "--xml" option. The current XML schema is experimental and may evolve. More
3379 user feedback will help to stabilize it.
3380 Contributed by Wojciech Polak.
3382 ** The grammar file may now specify the name of the parser header file using
3383 %defines. For example:
3387 ** When reporting useless rules, useless nonterminals, and unused terminals,
3388 Bison now employs the terms "useless in grammar" instead of "useless",
3389 "useless in parser" instead of "never reduced", and "unused in grammar"
3390 instead of "unused".
3392 ** Unreachable State Removal
3394 Previously, Bison sometimes generated parser tables containing unreachable
3395 states. A state can become unreachable during conflict resolution if Bison
3396 disables a shift action leading to it from a predecessor state. Bison now:
3398 1. Removes unreachable states.
3400 2. Does not report any conflicts that appeared in unreachable states.
3401 WARNING: As a result, you may need to update %expect and %expect-rr
3402 directives in existing grammar files.
3404 3. For any rule used only in such states, Bison now reports the rule as
3405 "useless in parser due to conflicts".
3407 This feature can be disabled with the following directive:
3409 %define lr.keep_unreachable_states
3411 See the %define entry in the "Bison Declaration Summary" in the Bison manual
3412 for further discussion.
3414 ** Lookahead Set Correction in the ".output" Report
3416 When instructed to generate a ".output" file including lookahead sets
3417 (using "--report=lookahead", for example), Bison now prints each reduction's
3418 lookahead set only next to the associated state's one item that (1) is
3419 associated with the same rule as the reduction and (2) has its dot at the end
3420 of its RHS. Previously, Bison also erroneously printed the lookahead set
3421 next to all of the state's other items associated with the same rule. This
3422 bug affected only the ".output" file and not the generated parser source
3425 ** --report-file=FILE is a new option to override the default ".output" file
3428 ** The "=" that used to be required in the following directives is now
3431 %file-prefix "parser"
3435 ** An Alternative to "%{...%}" -- "%code QUALIFIER {CODE}"
3437 Bison 2.3a provided a new set of directives as a more flexible alternative to
3438 the traditional Yacc prologue blocks. Those have now been consolidated into
3439 a single %code directive with an optional qualifier field, which identifies
3440 the purpose of the code and thus the location(s) where Bison should generate
3443 1. "%code {CODE}" replaces "%after-header {CODE}"
3444 2. "%code requires {CODE}" replaces "%start-header {CODE}"
3445 3. "%code provides {CODE}" replaces "%end-header {CODE}"
3446 4. "%code top {CODE}" replaces "%before-header {CODE}"
3448 See the %code entries in section "Bison Declaration Summary" in the Bison
3449 manual for a summary of the new functionality. See the new section "Prologue
3450 Alternatives" for a detailed discussion including the advantages of %code
3451 over the traditional Yacc prologues.
3453 The prologue alternatives are experimental. More user feedback will help to
3454 determine whether they should become permanent features.
3456 ** Revised warning: unset or unused midrule values
3458 Since Bison 2.2, Bison has warned about midrule values that are set but not
3459 used within any of the actions of the parent rule. For example, Bison warns
3462 exp: '1' { $$ = 1; } '+' exp { $$ = $1 + $4; };
3464 Now, Bison also warns about midrule values that are used but not set. For
3465 example, Bison warns about unset $$ in the midrule action in:
3467 exp: '1' { $1 = 1; } '+' exp { $$ = $2 + $4; };
3469 However, Bison now disables both of these warnings by default since they
3470 sometimes prove to be false alarms in existing grammars employing the Yacc
3471 constructs $0 or $-N (where N is some positive integer).
3473 To enable these warnings, specify the option "--warnings=midrule-values" or
3474 "-W", which is a synonym for "--warnings=all".
3476 ** Default %destructor or %printer with "<*>" or "<>"
3478 Bison now recognizes two separate kinds of default %destructor's and
3481 1. Place "<*>" in a %destructor/%printer symbol list to define a default
3482 %destructor/%printer for all grammar symbols for which you have formally
3483 declared semantic type tags.
3485 2. Place "<>" in a %destructor/%printer symbol list to define a default
3486 %destructor/%printer for all grammar symbols without declared semantic
3489 Bison no longer supports the "%symbol-default" notation from Bison 2.3a.
3490 "<*>" and "<>" combined achieve the same effect with one exception: Bison no
3491 longer applies any %destructor to a midrule value if that midrule value is
3492 not actually ever referenced using either $$ or $n in a semantic action.
3494 The default %destructor's and %printer's are experimental. More user
3495 feedback will help to determine whether they should become permanent
3498 See the section "Freeing Discarded Symbols" in the Bison manual for further
3501 ** %left, %right, and %nonassoc can now declare token numbers. This is required
3502 by POSIX. However, see the end of section "Operator Precedence" in the Bison
3503 manual for a caveat concerning the treatment of literal strings.
3505 ** The nonfunctional --no-parser, -n, and %no-parser options have been
3506 completely removed from Bison.
3509 * Noteworthy changes in release 2.3a (2006-09-13)
3511 ** Instead of %union, you can define and use your own union type
3512 YYSTYPE if your grammar contains at least one <type> tag.
3513 Your YYSTYPE need not be a macro; it can be a typedef.
3514 This change is for compatibility with other Yacc implementations,
3515 and is required by POSIX.
3517 ** Locations columns and lines start at 1.
3518 In accordance with the GNU Coding Standards and Emacs.
3520 ** You may now declare per-type and default %destructor's and %printer's:
3524 %union { char *string; }
3525 %token <string> STRING1
3526 %token <string> STRING2
3527 %type <string> string1
3528 %type <string> string2
3529 %union { char character; }
3530 %token <character> CHR
3531 %type <character> chr
3532 %destructor { free ($$); } %symbol-default
3533 %destructor { free ($$); printf ("%d", @$.first_line); } STRING1 string1
3534 %destructor { } <character>
3536 guarantees that, when the parser discards any user-defined symbol that has a
3537 semantic type tag other than "<character>", it passes its semantic value to
3538 "free". However, when the parser discards a "STRING1" or a "string1", it
3539 also prints its line number to "stdout". It performs only the second
3540 "%destructor" in this case, so it invokes "free" only once.
3542 [Although we failed to mention this here in the 2.3a release, the default
3543 %destructor's and %printer's were experimental, and they were rewritten in
3546 ** Except for LALR(1) parsers in C with POSIX Yacc emulation enabled (with "-y",
3547 "--yacc", or "%yacc"), Bison no longer generates #define statements for
3548 associating token numbers with token names. Removing the #define statements
3549 helps to sanitize the global namespace during preprocessing, but POSIX Yacc
3550 requires them. Bison still generates an enum for token names in all cases.
3552 ** Handling of traditional Yacc prologue blocks is now more consistent but
3553 potentially incompatible with previous releases of Bison.
3555 As before, you declare prologue blocks in your grammar file with the
3556 "%{ ... %}" syntax. To generate the pre-prologue, Bison concatenates all
3557 prologue blocks that you've declared before the first %union. To generate
3558 the post-prologue, Bison concatenates all prologue blocks that you've
3559 declared after the first %union.
3561 Previous releases of Bison inserted the pre-prologue into both the header
3562 file and the code file in all cases except for LALR(1) parsers in C. In the
3563 latter case, Bison inserted it only into the code file. For parsers in C++,
3564 the point of insertion was before any token definitions (which associate
3565 token numbers with names). For parsers in C, the point of insertion was
3566 after the token definitions.
3568 Now, Bison never inserts the pre-prologue into the header file. In the code
3569 file, it always inserts it before the token definitions.
3571 ** Bison now provides a more flexible alternative to the traditional Yacc
3572 prologue blocks: %before-header, %start-header, %end-header, and
3575 For example, the following declaration order in the grammar file reflects the
3576 order in which Bison will output these code blocks. However, you are free to
3577 declare these code blocks in your grammar file in whatever order is most
3581 /* Bison treats this block like a pre-prologue block: it inserts it into
3582 * the code file before the contents of the header file. It does *not*
3583 * insert it into the header file. This is a good place to put
3584 * #include's that you want at the top of your code file. A common
3585 * example is '#include "system.h"'. */
3588 /* Bison inserts this block into both the header file and the code file.
3589 * In both files, the point of insertion is before any Bison-generated
3590 * token, semantic type, location type, and class definitions. This is a
3591 * good place to define %union dependencies, for example. */
3594 /* Unlike the traditional Yacc prologue blocks, the output order for the
3595 * new %*-header blocks is not affected by their declaration position
3596 * relative to any %union in the grammar file. */
3599 /* Bison inserts this block into both the header file and the code file.
3600 * In both files, the point of insertion is after the Bison-generated
3601 * definitions. This is a good place to declare or define public
3602 * functions or data structures that depend on the Bison-generated
3606 /* Bison treats this block like a post-prologue block: it inserts it into
3607 * the code file after the contents of the header file. It does *not*
3608 * insert it into the header file. This is a good place to declare or
3609 * define internal functions or data structures that depend on the
3610 * Bison-generated definitions. */
3613 If you have multiple occurrences of any one of the above declarations, Bison
3614 will concatenate the contents in declaration order.
3616 [Although we failed to mention this here in the 2.3a release, the prologue
3617 alternatives were experimental, and they were rewritten in future versions.]
3619 ** The option "--report=look-ahead" has been changed to "--report=lookahead".
3620 The old spelling still works, but is not documented and may be removed
3621 in a future release.
3624 * Noteworthy changes in release 2.3 (2006-06-05)
3626 ** GLR grammars should now use "YYRECOVERING ()" instead of "YYRECOVERING",
3627 for compatibility with LALR(1) grammars.
3629 ** It is now documented that any definition of YYSTYPE or YYLTYPE should
3630 be to a type name that does not contain parentheses or brackets.
3633 * Noteworthy changes in release 2.2 (2006-05-19)
3635 ** The distribution terms for all Bison-generated parsers now permit
3636 using the parsers in nonfree programs. Previously, this permission
3637 was granted only for Bison-generated LALR(1) parsers in C.
3639 ** %name-prefix changes the namespace name in C++ outputs.
3641 ** The C++ parsers export their token_type.
3643 ** Bison now allows multiple %union declarations, and concatenates
3644 their contents together.
3646 ** New warning: unused values
3647 Right-hand side symbols whose values are not used are reported,
3648 if the symbols have destructors. For instance:
3650 exp: exp "?" exp ":" exp { $1 ? $1 : $3; }
3654 will trigger a warning about $$ and $5 in the first rule, and $3 in
3655 the second ($1 is copied to $$ by the default rule). This example
3656 most likely contains three errors, and could be rewritten as:
3658 exp: exp "?" exp ":" exp
3659 { $$ = $1 ? $3 : $5; free ($1 ? $5 : $3); free ($1); }
3661 { $$ = $1 ? $1 : $3; if ($1) free ($3); }
3664 However, if the original actions were really intended, memory leaks
3665 and all, the warnings can be suppressed by letting Bison believe the
3666 values are used, e.g.:
3668 exp: exp "?" exp ":" exp { $1 ? $1 : $3; (void) ($$, $5); }
3669 | exp "+" exp { $$ = $1; (void) $3; }
3672 If there are midrule actions, the warning is issued if no action
3673 uses it. The following triggers no warning: $1 and $3 are used.
3675 exp: exp { push ($1); } '+' exp { push ($3); sum (); };
3677 The warning is intended to help catching lost values and memory leaks.
3678 If a value is ignored, its associated memory typically is not reclaimed.
3680 ** %destructor vs. YYABORT, YYACCEPT, and YYERROR.
3681 Destructors are now called when user code invokes YYABORT, YYACCEPT,
3682 and YYERROR, for all objects on the stack, other than objects
3683 corresponding to the right-hand side of the current rule.
3685 ** %expect, %expect-rr
3686 Incorrect numbers of expected conflicts are now actual errors,
3687 instead of warnings.
3689 ** GLR, YACC parsers.
3690 The %parse-params are available in the destructors (and the
3691 experimental printers) as per the documentation.
3693 ** Bison now warns if it finds a stray "$" or "@" in an action.
3695 ** %require "VERSION"
3696 This specifies that the grammar file depends on features implemented
3697 in Bison version VERSION or higher.
3699 ** lalr1.cc: The token and value types are now class members.
3700 The tokens were defined as free form enums and cpp macros. YYSTYPE
3701 was defined as a free form union. They are now class members:
3702 tokens are enumerations of the "yy::parser::token" struct, and the
3703 semantic values have the "yy::parser::semantic_type" type.
3705 If you do not want or can update to this scheme, the directive
3706 '%define "global_tokens_and_yystype" "1"' triggers the global
3707 definition of tokens and YYSTYPE. This change is suitable both
3708 for previous releases of Bison, and this one.
3710 If you wish to update, then make sure older version of Bison will
3711 fail using '%require "2.2"'.
3713 ** DJGPP support added.
3716 * Noteworthy changes in release 2.1 (2005-09-16)
3718 ** The C++ lalr1.cc skeleton supports %lex-param.
3720 ** Bison-generated parsers now support the translation of diagnostics like
3721 "syntax error" into languages other than English. The default
3722 language is still English. For details, please see the new
3723 Internationalization section of the Bison manual. Software
3724 distributors should also see the new PACKAGING file. Thanks to
3725 Bruno Haible for this new feature.
3727 ** Wording in the Bison-generated parsers has been changed slightly to
3728 simplify translation. In particular, the message "memory exhausted"
3729 has replaced "parser stack overflow", as the old message was not
3730 always accurate for modern Bison-generated parsers.
3732 ** Destructors are now called when the parser aborts, for all symbols left
3733 behind on the stack. Also, the start symbol is now destroyed after a
3734 successful parse. In both cases, the behavior was formerly inconsistent.
3736 ** When generating verbose diagnostics, Bison-generated parsers no longer
3737 quote the literal strings associated with tokens. For example, for
3738 a syntax error associated with '%token NUM "number"' they might
3739 print 'syntax error, unexpected number' instead of 'syntax error,
3740 unexpected "number"'.
3743 * Noteworthy changes in release 2.0 (2004-12-25)
3745 ** Possibly-incompatible changes
3747 - Bison-generated parsers no longer default to using the alloca function
3748 (when available) to extend the parser stack, due to widespread
3749 problems in unchecked stack-overflow detection. You can "#define
3750 YYSTACK_USE_ALLOCA 1" to require the use of alloca, but please read
3751 the manual to determine safe values for YYMAXDEPTH in that case.
3753 - Error token location.
3754 During error recovery, the location of the syntax error is updated
3755 to cover the whole sequence covered by the error token: it includes
3756 the shifted symbols thrown away during the first part of the error
3757 recovery, and the lookahead rejected during the second part.
3759 - Semicolon changes:
3760 . Stray semicolons are no longer allowed at the start of a grammar.
3761 . Semicolons are now required after in-grammar declarations.
3763 - Unescaped newlines are no longer allowed in character constants or
3764 string literals. They were never portable, and GCC 3.4.0 has
3765 dropped support for them. Better diagnostics are now generated if
3766 forget a closing quote.
3768 - NUL bytes are no longer allowed in Bison string literals, unfortunately.
3772 - GLR grammars now support locations.
3774 - New directive: %initial-action.
3775 This directive allows the user to run arbitrary code (including
3776 initializing @$) from yyparse before parsing starts.
3778 - A new directive "%expect-rr N" specifies the expected number of
3779 reduce/reduce conflicts in GLR parsers.
3781 - %token numbers can now be hexadecimal integers, e.g., "%token FOO 0x12d".
3782 This is a GNU extension.
3784 - The option "--report=lookahead" was changed to "--report=look-ahead".
3785 [However, this was changed back after 2.3.]
3787 - Experimental %destructor support has been added to lalr1.cc.
3789 - New configure option --disable-yacc, to disable installation of the
3790 yacc command and -ly library introduced in 1.875 for POSIX conformance.
3794 - For now, %expect-count violations are now just warnings, not errors.
3795 This is for compatibility with Bison 1.75 and earlier (when there are
3796 reduce/reduce conflicts) and with Bison 1.30 and earlier (when there
3797 are too many or too few shift/reduce conflicts). However, in future
3798 versions of Bison we plan to improve the %expect machinery so that
3799 these violations will become errors again.
3801 - Within Bison itself, numbers (e.g., goto numbers) are no longer
3802 arbitrarily limited to 16-bit counts.
3804 - Semicolons are now allowed before "|" in grammar rules, as POSIX requires.
3807 * Noteworthy changes in release 1.875 (2003-01-01)
3809 ** The documentation license has been upgraded to version 1.2
3810 of the GNU Free Documentation License.
3812 ** syntax error processing
3814 - In Yacc-style parsers YYLLOC_DEFAULT is now used to compute error
3815 locations too. This fixes bugs in error-location computation.
3818 It is now possible to reclaim the memory associated to symbols
3819 discarded during error recovery. This feature is still experimental.
3822 This new directive is preferred over YYERROR_VERBOSE.
3824 - #defining yyerror to steal internal variables is discouraged.
3825 It is not guaranteed to work forever.
3827 ** POSIX conformance
3829 - Semicolons are once again optional at the end of grammar rules.
3830 This reverts to the behavior of Bison 1.33 and earlier, and improves
3831 compatibility with Yacc.
3833 - "parse error" -> "syntax error"
3834 Bison now uniformly uses the term "syntax error"; formerly, the code
3835 and manual sometimes used the term "parse error" instead. POSIX
3836 requires "syntax error" in diagnostics, and it was thought better to
3839 - The documentation now emphasizes that yylex and yyerror must be
3840 declared before use. C99 requires this.
3842 - Bison now parses C99 lexical constructs like UCNs and
3843 backslash-newline within C escape sequences, as POSIX 1003.1-2001 requires.
3845 - File names are properly escaped in C output. E.g., foo\bar.y is
3846 output as "foo\\bar.y".
3848 - Yacc command and library now available
3849 The Bison distribution now installs a "yacc" command, as POSIX requires.
3850 Also, Bison now installs a small library liby.a containing
3851 implementations of Yacc-compatible yyerror and main functions.
3852 This library is normally not useful, but POSIX requires it.
3854 - Type clashes now generate warnings, not errors.
3856 - If the user does not define YYSTYPE as a macro, Bison now declares it
3857 using typedef instead of defining it as a macro.
3858 For consistency, YYLTYPE is also declared instead of defined.
3860 ** Other compatibility issues
3862 - %union directives can now have a tag before the "{", e.g., the
3863 directive "%union foo {...}" now generates the C code
3864 "typedef union foo { ... } YYSTYPE;"; this is for Yacc compatibility.
3865 The default union tag is "YYSTYPE", for compatibility with Solaris 9 Yacc.
3866 For consistency, YYLTYPE's struct tag is now "YYLTYPE" not "yyltype".
3867 This is for compatibility with both Yacc and Bison 1.35.
3869 - ";" is output before the terminating "}" of an action, for
3870 compatibility with Bison 1.35.
3872 - Bison now uses a Yacc-style format for conflict reports, e.g.,
3873 "conflicts: 2 shift/reduce, 1 reduce/reduce".
3875 - "yystype" and "yyltype" are now obsolescent macros instead of being
3876 typedefs or tags; they are no longer documented and are planned to be
3877 withdrawn in a future release.
3882 Users of Bison have to decide how they handle the portability of the
3885 - "parsing stack overflow..." -> "parser stack overflow"
3886 GLR parsers now report "parser stack overflow" as per the Bison manual.
3888 ** %parse-param and %lex-param
3889 The macros YYPARSE_PARAM and YYLEX_PARAM provide a means to pass
3890 additional context to yyparse and yylex. They suffer from several
3893 - a single argument only can be added,
3894 - their types are weak (void *),
3895 - this context is not passed to ancillary functions such as yyerror,
3896 - only yacc.c parsers support them.
3898 The new %parse-param/%lex-param directives provide a more precise control.
3901 %parse-param {int *nastiness}
3902 %lex-param {int *nastiness}
3903 %parse-param {int *randomness}
3905 results in the following signatures:
3907 int yylex (int *nastiness);
3908 int yyparse (int *nastiness, int *randomness);
3910 or, if both %pure-parser and %locations are used:
3912 int yylex (YYSTYPE *lvalp, YYLTYPE *llocp, int *nastiness);
3913 int yyparse (int *nastiness, int *randomness);
3915 ** Bison now warns if it detects conflicting outputs to the same file,
3916 e.g., it generates a warning for "bison -d -o foo.h foo.y" since
3917 that command outputs both code and header to foo.h.
3919 ** #line in output files
3920 - --no-line works properly.
3922 ** Bison can no longer be built by a K&R C compiler; it requires C89 or
3923 later to be built. This change originally took place a few versions
3924 ago, but nobody noticed until we recently asked someone to try
3925 building Bison with a K&R C compiler.
3928 * Noteworthy changes in release 1.75 (2002-10-14)
3930 ** Bison should now work on 64-bit hosts.
3932 ** Indonesian translation thanks to Tedi Heriyanto.
3935 Fix spurious parse errors.
3938 Some people redefine yyerror to steal yyparse' private variables.
3939 Reenable this trick until an official feature replaces it.
3942 In agreement with POSIX and with other Yaccs, leaving a default
3943 action is valid when $$ is untyped, and $1 typed:
3947 but the converse remains an error:
3951 ** Values of midrule actions
3954 foo: { ... } { $$ = $1; } ...
3956 was incorrectly rejected: $1 is defined in the second midrule
3957 action, and is equal to the $$ of the first midrule action.
3960 * Noteworthy changes in release 1.50 (2002-10-04)
3965 causes Bison to produce a Generalized LR (GLR) parser, capable of handling
3966 almost any context-free grammar, ambiguous or not. The new declarations
3967 %dprec and %merge on grammar rules allow parse-time resolution of
3968 ambiguities. Contributed by Paul Hilfinger.
3970 Unfortunately Bison 1.50 does not work properly on 64-bit hosts
3971 like the Alpha, so please stick to 32-bit hosts for now.
3974 When not in Yacc compatibility mode, when the output file was not
3975 specified, running "bison foo/bar.y" created "foo/bar.c". It
3976 now creates "bar.c".
3979 The undefined token was systematically mapped to 2 which prevented
3980 the use of 2 by the user. This is no longer the case.
3982 ** Unknown token numbers
3983 If yylex returned an out of range value, yyparse could die. This is
3987 According to POSIX, the error token must be 256.
3988 Bison extends this requirement by making it a preference: *if* the
3989 user specified that one of her tokens is numbered 256, then error
3990 will be mapped onto another number.
3992 ** Verbose error messages
3993 They no longer report "..., expecting error or..." for states where
3994 error recovery is possible.
3997 Defaults to "$end" instead of "$".
3999 ** Error recovery now conforms to documentation and to POSIX
4000 When a Bison-generated parser encounters a syntax error, it now pops
4001 the stack until it finds a state that allows shifting the error
4002 token. Formerly, it popped the stack until it found a state that
4003 allowed some non-error action other than a default reduction on the
4004 error token. The new behavior has long been the documented behavior,
4005 and has long been required by POSIX. For more details, please see
4006 Paul Eggert, "Reductions during Bison error handling" (2002-05-20)
4007 <http://lists.gnu.org/archive/html/bug-bison/2002-05/msg00038.html>.
4010 Popped tokens and nonterminals are now reported.
4013 Larger grammars are now supported (larger token numbers, larger grammar
4014 size (= sum of the LHS and RHS lengths), larger LALR tables).
4015 Formerly, many of these numbers ran afoul of 16-bit limits;
4016 now these limits are 32 bits on most hosts.
4018 ** Explicit initial rule
4019 Bison used to play hacks with the initial rule, which the user does
4020 not write. It is now explicit, and visible in the reports and
4024 Before, Bison reported the useless rules, but, although not used,
4025 included them in the parsers. They are now actually removed.
4027 ** Useless rules, useless nonterminals
4028 They are now reported, as a warning, with their locations.
4030 ** Rules never reduced
4031 Rules that can never be reduced because of conflicts are now
4034 ** Incorrect "Token not used"
4035 On a grammar such as
4037 %token useless useful
4039 exp: '0' %prec useful;
4041 where a token was used to set the precedence of the last rule,
4042 bison reported both "useful" and "useless" as useless tokens.
4044 ** Revert the C++ namespace changes introduced in 1.31
4045 as they caused too many portability hassles.
4047 ** Default locations
4048 By an accident of design, the default computation of @$ was
4049 performed after another default computation was performed: @$ = @1.
4050 The latter is now removed: YYLLOC_DEFAULT is fully responsible of
4051 the computation of @$.
4053 ** Token end-of-file
4054 The token end of file may be specified by the user, in which case,
4055 the user symbol is used in the reports, the graphs, and the verbose
4056 error messages instead of "$end", which remains being the default.
4060 %token MYEOF 0 "end of file"
4063 This old option, which has been broken for ages, is removed.
4066 Brazilian Portuguese, thanks to Alexandre Folle de Menezes.
4067 Croatian, thanks to Denis Lackovic.
4069 ** Incorrect token definitions
4072 bison used to output
4075 ** Token definitions as enums
4076 Tokens are output both as the traditional #define's, and, provided
4077 the compiler supports ANSI C or is a C++ compiler, as enums.
4078 This lets debuggers display names instead of integers.
4081 In addition to --verbose, bison supports --report=THINGS, which
4082 produces additional information:
4084 complete the core item sets with their closure
4085 - lookahead [changed to "look-ahead" in 1.875e through 2.3, but changed back]
4086 explicitly associate lookahead tokens to items
4088 describe shift/reduce conflicts solving.
4089 Bison used to systematically output this information on top of
4090 the report. Solved conflicts are now attached to their states.
4093 Previous versions don't complain when there is a type clash on
4094 the default action if the rule has a midrule action, such as in:
4102 ** GNU M4 is now required when using Bison.
4105 * Noteworthy changes in release 1.35 (2002-03-25)
4108 Some projects use Bison's C parser with C++ compilers, and define
4109 YYSTYPE as a class. The recent adjustment of C parsers for data
4110 alignment and 64 bit architectures made this impossible.
4112 Because for the time being no real solution for C++ parser
4113 generation exists, kludges were implemented in the parser to
4114 maintain this use. In the future, when Bison has C++ parsers, this
4115 kludge will be disabled.
4117 This kludge also addresses some C++ problems when the stack was
4121 * Noteworthy changes in release 1.34 (2002-03-12)
4123 ** File name clashes are detected
4124 $ bison foo.y -d -o foo.x
4125 fatal error: header and parser would both be named "foo.x"
4127 ** A missing ";" at the end of a rule triggers a warning
4128 In accordance with POSIX, and in agreement with other
4129 Yacc implementations, Bison will mandate this semicolon in the near
4130 future. This eases the implementation of a Bison parser of Bison
4131 grammars by making this grammar LALR(1) instead of LR(2). To
4132 facilitate the transition, this release introduces a warning.
4134 ** Revert the C++ namespace changes introduced in 1.31, as they caused too
4135 many portability hassles.
4137 ** DJGPP support added.
4139 ** Fix test suite portability problems.
4142 * Noteworthy changes in release 1.33 (2002-02-07)
4145 Groff could not be compiled for the definition of size_t was lacking
4146 under some conditions.
4152 * Noteworthy changes in release 1.32 (2002-01-23)
4154 ** Fix Yacc output file names
4156 ** Portability fixes
4158 ** Italian, Dutch translations
4161 * Noteworthy changes in release 1.31 (2002-01-14)
4165 ** GNU Gettext and %expect
4166 GNU Gettext asserts 10 s/r conflicts, but there are 7. Now that
4167 Bison dies on incorrect %expectations, we fear there will be
4168 too many bug reports for Gettext, so _for the time being_, %expect
4169 does not trigger an error when the input file is named "plural.y".
4171 ** Use of alloca in parsers
4172 If YYSTACK_USE_ALLOCA is defined to 0, then the parsers will use
4173 malloc exclusively. Since 1.29, but was not NEWS'ed.
4175 alloca is used only when compiled with GCC, to avoid portability
4178 ** yyparse now returns 2 if memory is exhausted; formerly it dumped core.
4180 ** When the generated parser lacks debugging code, YYDEBUG is now 0
4181 (as POSIX requires) instead of being undefined.
4184 Bison has always permitted actions such as { $$ = $1 }: it adds the
4185 ending semicolon. Now if in Yacc compatibility mode, the semicolon
4186 is no longer output: one has to write { $$ = $1; }.
4188 ** Better C++ compliance
4189 The output parsers try to respect C++ namespaces.
4190 [This turned out to be a failed experiment, and it was reverted later.]
4193 Fixed bugs when reporting useless nonterminals.
4196 The parsers work properly on 64 bit hosts.
4199 Some calls to strerror resulted in scrambled or missing error messages.
4202 When the number of shift/reduce conflicts is correct, don't issue
4205 ** The verbose report includes the rule line numbers.
4207 ** Rule line numbers are fixed in traces.
4209 ** Swedish translation
4212 Verbose parse error messages from the parsers are better looking.
4213 Before: parse error: unexpected `'/'', expecting `"number"' or `'-'' or `'(''
4214 Now: parse error: unexpected '/', expecting "number" or '-' or '('
4216 ** Fixed parser memory leaks.
4217 When the generated parser was using malloc to extend its stacks, the
4218 previous allocations were not freed.
4220 ** Fixed verbose output file.
4221 Some newlines were missing.
4222 Some conflicts in state descriptions were missing.
4224 ** Fixed conflict report.
4225 Option -v was needed to get the result.
4229 Mismatches are errors, not warnings.
4231 ** Fixed incorrect processing of some invalid input.
4233 ** Fixed CPP guards: 9foo.h uses BISON_9FOO_H instead of 9FOO_H.
4235 ** Fixed some typos in the documentation.
4237 ** %token MY_EOF 0 is supported.
4238 Before, MY_EOF was silently renumbered as 257.
4240 ** doc/refcard.tex is updated.
4242 ** %output, %file-prefix, %name-prefix.
4246 New, aliasing "--output-file".
4249 * Noteworthy changes in release 1.30 (2001-10-26)
4251 ** "--defines" and "--graph" have now an optional argument which is the
4252 output file name. "-d" and "-g" do not change; they do not take any
4255 ** "%source_extension" and "%header_extension" are removed, failed
4258 ** Portability fixes.
4261 * Noteworthy changes in release 1.29 (2001-09-07)
4263 ** The output file does not define const, as this caused problems when used
4264 with common autoconfiguration schemes. If you still use ancient compilers
4265 that lack const, compile with the equivalent of the C compiler option
4266 "-Dconst=". Autoconf's AC_C_CONST macro provides one way to do this.
4268 ** Added "-g" and "--graph".
4270 ** The Bison manual is now distributed under the terms of the GNU FDL.
4272 ** The input and the output files has automatically a similar extension.
4274 ** Russian translation added.
4276 ** NLS support updated; should hopefully be less troublesome.
4278 ** Added the old Bison reference card.
4280 ** Added "--locations" and "%locations".
4282 ** Added "-S" and "--skeleton".
4284 ** "%raw", "-r", "--raw" is disabled.
4286 ** Special characters are escaped when output. This solves the problems
4287 of the #line lines with path names including backslashes.
4290 "%yacc", "%fixed_output_files", "%defines", "%no_parser", "%verbose",
4291 "%debug", "%source_extension" and "%header_extension".
4294 Automatic location tracking.
4297 * Noteworthy changes in release 1.28 (1999-07-06)
4299 ** Should compile better now with K&R compilers.
4303 ** Fixed a problem with escaping the double quote character.
4305 ** There is now a FAQ.
4308 * Noteworthy changes in release 1.27
4310 ** The make rule which prevented bison.simple from being created on
4311 some systems has been fixed.
4314 * Noteworthy changes in release 1.26
4316 ** Bison now uses Automake.
4318 ** New mailing lists: <bug-bison@gnu.org> and <help-bison@gnu.org>.
4320 ** Token numbers now start at 257 as previously documented, not 258.
4322 ** Bison honors the TMPDIR environment variable.
4324 ** A couple of buffer overruns have been fixed.
4326 ** Problems when closing files should now be reported.
4328 ** Generated parsers should now work even on operating systems which do
4329 not provide alloca().
4332 * Noteworthy changes in release 1.25 (1995-10-16)
4334 ** Errors in the input grammar are not fatal; Bison keeps reading
4335 the grammar file, and reports all the errors found in it.
4337 ** Tokens can now be specified as multiple-character strings: for
4338 example, you could use "<=" for a token which looks like <=, instead
4339 of choosing a name like LESSEQ.
4341 ** The %token_table declaration says to write a table of tokens (names
4342 and numbers) into the parser file. The yylex function can use this
4343 table to recognize multiple-character string tokens, or for other
4346 ** The %no_lines declaration says not to generate any #line preprocessor
4347 directives in the parser file.
4349 ** The %raw declaration says to use internal Bison token numbers, not
4350 Yacc-compatible token numbers, when token names are defined as macros.
4352 ** The --no-parser option produces the parser tables without including
4353 the parser engine; a project can now use its own parser engine.
4354 The actions go into a separate file called NAME.act, in the form of
4355 a switch statement body.
4358 * Noteworthy changes in release 1.23
4360 The user can define YYPARSE_PARAM as the name of an argument to be
4361 passed into yyparse. The argument should have type void *. It should
4362 actually point to an object. Grammar actions can access the variable
4363 by casting it to the proper pointer type.
4365 Line numbers in output file corrected.
4368 * Noteworthy changes in release 1.22
4370 --help option added.
4373 * Noteworthy changes in release 1.20
4375 Output file does not redefine const for C++.
4379 LocalWords: yacc YYBACKUP glr GCC lalr ArrayIndexOutOfBoundsException nullptr
4380 LocalWords: cplusplus liby rpl fprintf mfcalc Wyacc stmt cond expr mk sym lr
4381 LocalWords: IELR ielr Lookahead YYERROR nonassoc LALR's api lookaheads yychar
4382 LocalWords: destructor lookahead YYRHSLOC YYLLOC Rhs ifndef YYFAIL cpp sr rr
4383 LocalWords: preprocessor initializer Wno Wnone Werror FreeBSD prec livelocks
4384 LocalWords: Solaris AIX UX RHEL Tru LHS gcc's Wundef YYENABLE NLS YYLTYPE VCG
4385 LocalWords: yyerror cpp's Wunused yylval yylloc prepend yyparse yylex yypush
4386 LocalWords: Graphviz xml nonterminals midrule destructor's YYSTYPE typedef ly
4387 LocalWords: CHR chr printf stdout namespace preprocessing enum pre include's
4388 LocalWords: YYRECOVERING nonfree destructors YYABORT YYACCEPT params enums de
4389 LocalWords: struct yystype DJGPP lex param Haible NUM alloca YYSTACK NUL goto
4390 LocalWords: YYMAXDEPTH Unescaped UCNs YYLTYPE's yyltype typedefs inline Yaccs
4391 LocalWords: Heriyanto Reenable dprec Hilfinger Eggert MYEOF Folle Menezes EOF
4392 LocalWords: Lackovic define's itemset Groff Gettext malloc NEWS'ed YYDEBUG YY
4393 LocalWords: namespaces strerror const autoconfiguration Dconst Autoconf's FDL
4394 LocalWords: Automake TMPDIR LESSEQ ylwrap endif yydebug YYTOKEN YYLSP ival hh
4395 LocalWords: extern YYTOKENTYPE TOKENTYPE yytokentype tokentype STYPE lval pdf
4396 LocalWords: lang yyoutput dvi html ps POSIX lvalp llocp Wother nterm arg init
4397 LocalWords: TOK calc yyo fval Wconflicts parsers yystackp yyval yynerrs
4398 LocalWords: Théophile Ranquet Santet fno fnone stype associativity Tolmer
4399 LocalWords: Wprecedence Rassoul Wempty Paolo Bonzini parser's Michiel loc
4400 LocalWords: redeclaration sval fcaret reentrant XSLT xsl Wmaybe yyvsp Tedi
4401 LocalWords: pragmas noreturn untyped Rozenman unexpanded Wojciech Polak
4402 LocalWords: Alexandre MERCHANTABILITY yytype emplace ptr automove lvalues
4403 LocalWords: nonterminal yy args Pragma dereference yyformat rhs docdir bw
4404 LocalWords: Redeclarations rpcalc Autoconf YFLAGS Makefiles PROG DECL num
4405 LocalWords: Heimbigner AST src ast Makefile srcdir MinGW xxlex XXSTYPE
4406 LocalWords: XXLTYPE strictfp IDEs ffixit fdiagnostics parseable fixits
4407 LocalWords: Wdeprecated yytext Variadic variadic yyrhs yyphrs RCS README
4408 LocalWords: noexcept constexpr ispell american deprecations backend Teoh
4409 LocalWords: YYPRINT Mangold Bonzini's Wdangling exVal baz checkable gcc
4410 LocalWords: fsanitize Vogelsgesang lis redeclared stdint automata yytname
4411 LocalWords: yysymbol yytnamerr yyreport ctx ARGMAX yysyntax stderr LPAREN
4412 LocalWords: symrec yypcontext TOKENMAX yyexpected YYEMPTY yypstate YYEOF
4413 LocalWords: autocompletion bistromathic submessages Cayuela lexcalc hoc
4414 LocalWords: yytoken YYUNDEF YYerror basename Automake's UTF ifdef ffile
4415 LocalWords: gotos readline Imbimbo Wcounterexamples
4418 ispell-dictionary: "american"
4423 Copyright (C) 1995-2015, 2018-2020 Free Software Foundation, Inc.
4425 This file is part of Bison, the GNU Parser Generator.
4427 Permission is granted to copy, distribute and/or modify this document
4428 under the terms of the GNU Free Documentation License, Version 1.3 or
4429 any later version published by the Free Software Foundation; with no
4430 Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
4431 Texts. A copy of the license is included in the "GNU Free
4432 Documentation License" file as part of this distribution.