3 * Noteworthy changes in release ?.? (????-??-??) [?]
5 ** Backward incompatible changes
7 Lone carriage-return characters (aka \r or ^M) in the grammar files are no
8 longer treated as end-of-lines. This changes the diagnostics, and in
9 particular their locations.
11 Line numbers and columns are now represented as 'int' not 'unsigned',
12 so that integer overflow on positions is easily checkable via 'gcc
13 -fsanitize=undefined' and the like. This affects the API for positions.
17 In Java, %define api.prefix was ignored. It now behaves as expected.
21 *** Lookahead correction in C++
23 Contributed by Adrian Vogelsgesang.
25 The C++ deterministic skeleton (lalr1.cc) now supports LAC, via the
26 %define variable parse.lac.
28 *** Variable api.token.raw: Optimized token numbers (all skeletons)
30 In the generated parsers, tokens have two numbers: the "external" token
31 number as returned by yylex (which starts at 257), and the "internal"
32 symbol number (which starts at 3). Each time yylex is called, a table
33 lookup maps the external token number to the internal symbol number.
35 When the %define variable api.token.raw is set, tokens are assigned their
36 internal number, which saves one table lookup per token, and also saves
37 the generation of the mapping table.
39 The gain is typically moderate, but in extreme cases (very simple user
40 actions), a 10% improvement can be observed.
42 *** Debug traces in Java
44 The Java backend no longer emits code and data for parser tracing if the
45 %define variable parse.trace is not defined.
47 *** Templates prefer signed integer types
49 Bison templates now prefer signed to unsigned integer types when
50 either will do, as the signed types are less error-prone and allow
51 for better checking with 'gcc -fsanitize=undefined'.
53 * Noteworthy changes in release 3.4.2 (2019-09-12) [stable]
57 In some cases, when warnings are disabled, bison could emit tons of white
58 spaces as diagnostics.
60 When running out of memory, bison could crash (found by fuzzing).
62 When defining twice the EOF token, bison would crash.
64 New warnings from recent compilers have been addressed in the generated
65 parsers (yacc.c, glr.c, glr.cc).
67 When lone carriage-return characters appeared in the input file,
68 diagnostics could hang forever.
70 * Noteworthy changes in release 3.4.1 (2019-05-22) [stable]
76 * Noteworthy changes in release 3.4 (2019-05-19) [stable]
78 ** Deprecated features
80 The %pure-parser directive is deprecated in favor of '%define api.pure'
81 since Bison 2.3b (2008-05-27), but no warning was issued; there is one
82 now. Note that since Bison 2.7 you are strongly encouraged to use
83 '%define api.pure full' instead of '%define api.pure'.
87 *** Colored diagnostics
89 As an experimental feature, diagnostics are now colored, controlled by the
90 new options --color and --style.
92 To use them, install the libtextstyle library before configuring Bison.
95 https://alpha.gnu.org/gnu/gettext/
99 https://alpha.gnu.org/gnu/gettext/libtextstyle-0.8.tar.gz
101 The option --color supports the following arguments:
102 - always, yes: Enable colors.
103 - never, no: Disable colors.
104 - auto, tty (default): Enable colors if the output device is a tty.
106 To customize the styles, create a CSS file similar to
110 .error { font-weight: 800; text-decoration: underline; }
113 then invoke bison with --style=bison-bw.css, or set the BISON_STYLE
114 environment variable to "bison-bw.css".
118 When given -fsyntax-only, the diagnostics are reported, but no output is
121 The name of this option is somewhat misleading as bison does more than
122 just checking the syntax: every stage is run (including checking for
123 conflicts for instance), except the generation of the output files.
125 *** Include the generated header (yacc.c)
127 Before, when --defines is used, bison generated a header, and pasted an
128 exact copy of it into the generated parser implementation file. If the
129 header name is not "y.tab.h", it is now #included instead of being
132 To use an '#include' even if the header name is "y.tab.h" (which is what
133 happens with --yacc, or when using the Autotools' ylwrap), define
134 api.header.include to the exact argument to pass to #include. For
137 %define api.header.include {"parse.h"}
141 %define api.header.include {<parser/parse.h>}
143 *** api.location.type is now supported in C (yacc.c, glr.c)
145 The %define variable api.location.type defines the name of the type to use
146 for locations. When defined, Bison no longer defines YYLTYPE.
148 This can be used in programs with several parsers to factor their
149 definition of locations: let one of them generate them, and the others
156 In conformance with the recommendations of the Graphviz team, if %require
157 "3.4" (or better) is specified, the option --graph generates a *.gv file
158 by default, instead of *.dot.
160 *** Diagnostics overhaul
162 Column numbers were wrong with multibyte characters, which would also
163 result in skewed diagnostics with carets. Beside, because we were
164 indenting the quoted source with a single space, lines with tab characters
165 were incorrectly underlined.
167 To address these issues, and to be clearer, Bison now issues diagnostics
168 as GCC9 does. For instance it used to display (there's a tab before the
171 foo.y:3.37-38: error: $2 of ‘expr’ has no declared type
172 expr: expr '+' "number" { $$ = $1 + $2; }
176 foo.y:3.37-38: error: $2 of ‘expr’ has no declared type
177 3 | expr: expr '+' "number" { $$ = $1 + $2; }
180 Other constructs now also have better locations, resulting in more precise
183 *** Fix-it hints for %empty
185 Running Bison with -Wempty-rules and --update will remove incorrect %empty
186 annotations, and add the missing ones.
188 *** Generated reports
190 The format of the reports (parse.output) was improved for readability.
192 *** Better support for --no-line.
194 When --no-line is used, the generated files are now cleaner: no lines are
195 generated instead of empty lines. Together with using api.header.include,
196 that should help people saving the generated files into version control
197 systems get smaller diffs.
201 A new example in C shows an simple infix calculator with a hand-written
202 scanner (examples/c/calc).
204 A new example in C shows a reentrant parser (capable of recursive calls)
205 built with Flex and Bison (examples/c/reccalc).
207 There is a new section about the history of Yaccs and Bison.
211 A few obscure bugs were fixed, including the second oldest (known) bug in
212 Bison: it was there when Bison was entered in the RCS version control
213 system, in December 1987. See the NEWS of Bison 3.3 for the previous
216 * Noteworthy changes in release 3.3.2 (2019-02-03) [stable]
220 Bison 3.3 failed to generate parsers for grammars with unused nonterminal
223 * Noteworthy changes in release 3.3.1 (2019-01-27) [stable]
227 The option -y/--yacc used to imply -Werror=yacc, which turns uses of Bison
228 extensions into errors. It now makes them simple warnings (-Wyacc).
230 * Noteworthy changes in release 3.3 (2019-01-26) [stable]
232 A new mailing list was created, Bison Announce. It is low traffic, and is
233 only about announcing new releases and important messages (e.g., polls
234 about major decisions to make).
236 https://lists.gnu.org/mailman/listinfo/bison-announce
238 ** Backward incompatible changes
240 Support for DJGPP, which has been unmaintained and untested for years, is
243 ** Deprecated features
245 A new feature, --update (see below) helps adjusting existing grammars to
248 *** Deprecated directives
250 The %error-verbose directive is deprecated in favor of '%define
251 parse.error verbose' since Bison 3.0, but no warning was issued.
253 The '%name-prefix "xx"' directive is deprecated in favor of '%define
254 api.prefix {xx}' since Bison 3.0, but no warning was issued. These
255 directives are slightly different, you might need to adjust your code.
256 %name-prefix renames only symbols with external linkage, while api.prefix
257 also renames types and macros, including YYDEBUG, YYTOKENTYPE,
258 yytokentype, YYSTYPE, YYLTYPE, etc.
260 Users of Flex that move from '%name-prefix "xx"' to '%define api.prefix
261 {xx}' will typically have to update YY_DECL from
263 #define YY_DECL int xxlex (YYSTYPE *yylval, YYLTYPE *yylloc)
267 #define YY_DECL int xxlex (XXSTYPE *yylval, XXLTYPE *yylloc)
269 *** Deprecated %define variable names
271 The following variables, mostly related to parsers in Java, have been
272 renamed for consistency. Backward compatibility is ensured, but upgrading
275 abstract -> api.parser.abstract
276 annotations -> api.parser.annotations
277 extends -> api.parser.extends
278 final -> api.parser.final
279 implements -> api.parser.implements
280 parser_class_name -> api.parser.class
281 public -> api.parser.public
282 strictfp -> api.parser.strictfp
286 *** Generation of fix-its for IDEs/Editors
288 When given the new option -ffixit (aka -fdiagnostics-parseable-fixits),
289 bison now generates machine readable editing instructions to fix some
290 issues. Currently, this is mostly limited to updating deprecated
291 directives and removing duplicates. For instance:
295 %define parser_class_name "Parser"
296 %define api.parser.class "Parser"
300 See the "fix-it:" lines below:
302 $ bison -ffixit foo.y
303 foo.y:1.1-14: warning: deprecated directive, use '%define parse.error verbose' [-Wdeprecated]
306 fix-it:"foo.y":{1:1-1:15}:"%define parse.error verbose"
307 foo.y:2.1-34: warning: deprecated directive, use '%define api.parser.class {Parser}' [-Wdeprecated]
308 %define parser_class_name "Parser"
309 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
310 fix-it:"foo.y":{2:1-2:35}:"%define api.parser.class {Parser}"
311 foo.y:3.1-33: error: %define variable 'api.parser.class' redefined
312 %define api.parser.class "Parser"
313 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
314 foo.y:2.1-34: previous definition
315 %define parser_class_name "Parser"
316 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
317 fix-it:"foo.y":{3:1-3:34}:""
318 foo.y: warning: fix-its can be applied. Rerun with option '--update'. [-Wother]
320 This uses the same output format as GCC and Clang.
322 *** Updating grammar files
324 Fixes can be applied on the fly. The previous example ends with the
325 suggestion to re-run bison with the option -u/--update, which results in a
326 cleaner grammar file.
328 $ bison --update foo.y
330 bison: file 'foo.y' was updated (backup: 'foo.y~')
333 %define parse.error verbose
334 %define api.parser.class {Parser}
338 *** Bison is now relocatable
340 If you pass '--enable-relocatable' to 'configure', Bison is relocatable.
342 A relocatable program can be moved or copied to a different location on
343 the file system. It can also be used through mount points for network
344 sharing. It is possible to make symbolic links to the installed and moved
345 programs, and invoke them through the symbolic link.
347 *** %expect and %expect-rr modifiers on individual rules
349 One can now document (and check) which rules participate in shift/reduce
350 and reduce/reduce conflicts. This is particularly important GLR parsers,
351 where conflicts are a normal occurrence. For example,
367 | argument_list ',' expression
372 Looking at the output from -v, one can see that the shift-reduce conflict
373 here is due to the fact that the parser does not know whether to reduce
374 arguments to argument_list until it sees the token _after_ the following
375 ','. By marking the rule with %expect 1 (because there is a conflict in
376 one state), we document the source of the 1 overall shift-reduce conflict.
378 In GLR parsers, we can use %expect-rr in a rule for reduce/reduce
379 conflicts. In this case, we mark each of the conflicting rules. For
388 target_list '=' expr ';'
394 | target ',' target_list
411 In a statement such as
415 the parser must reduce x to a target or an expr, but does not know which
416 until it sees the '='. So we notate the two possible reductions to
417 indicate that each conflicts in one rule.
419 This feature needs user feedback, and might evolve in the future.
421 *** C++: Actual token constructors
423 When variants and token constructors are enabled, in addition to the
424 type-safe named token constructors (make_ID, make_INT, etc.), we now
425 generate genuine constructors for symbol_type.
427 For instance with these declarations
433 you may use these constructors:
435 symbol_type (int token, const std::string&);
436 symbol_type (int token, const int&);
437 symbol_type (int token);
439 Correct matching between token types and value types is checked via
440 'assert'; for instance, 'symbol_type (ID, 42)' would abort. Named
441 constructors are preferable, as they offer better type safety (for
442 instance 'make_ID (42)' would not even compile), but symbol_type
443 constructors may help when token types are discovered at run-time, e.g.,
446 if (auto i = lookup_keyword (yytext))
447 return yy::parser::symbol_type (i);
449 return yy::parser::make_ID (yytext);
452 *** C++: Variadic emplace
454 If your application requires C++11 and you don't use symbol constructors,
455 you may now use a variadic emplace for semantic values:
457 %define api.value.type variant
458 %token <std::pair<int, int>> PAIR
462 int yylex (parser::semantic_type *lvalp)
464 lvalp->emplace <std::pair<int, int>> (1, 2);
465 return parser::token::PAIR;
468 *** C++: Syntax error exceptions in GLR
470 The glr.cc skeleton now supports syntax_error exceptions thrown from user
471 actions, or from the scanner.
473 *** More POSIX Yacc compatibility warnings
475 More Bison specific directives are now reported with -y or -Wyacc. This
476 change was ready since the release of Bison 3.0 in September 2015. It was
477 delayed because Autoconf used to define YACC as `bison -y`, which resulted
478 in numerous warnings for Bison users that use the GNU Build System.
480 If you still experience that problem, either redefine YACC as `bison -o
481 y.tab.c`, or pass -Wno-yacc to Bison.
483 *** The tables yyrhs and yyphrs are back
485 Because no Bison skeleton uses them, these tables were removed (no longer
486 passed to the skeletons, not even computed) in 2008. However, some users
487 have expressed interest in being able to use them in their own skeletons.
491 *** Incorrect number of reduce-reduce conflicts
495 exp: "num" | "num" | "num"
497 bison used to report a single RR conflict, instead of two. This is now
498 fixed. This was the oldest (known) bug in Bison: it was there when Bison
499 was entered in the RCS version control system, in December 1987.
501 Some grammar files might have to adjust their %expect-rr.
503 *** Parser directives that were not careful enough
505 Passing invalid arguments to %nterm, for instance character literals, used
506 to result in unclear error messages.
510 The examples/ directory (installed in .../share/doc/bison/examples) has
511 been restructured per language for clarity. The examples come with a
512 README and a Makefile. Not only can they be used to toy with Bison, they
513 can also be starting points for your own grammars.
515 There is now a Java example, and a simple example in C based on Flex and
516 Bison (examples/c/lexcalc/).
522 They now use noexcept and constexpr. Please, report missing annotations.
524 *** Symbol Declarations
526 The syntax of the variation directives to declare symbols was overhauled
527 for more consistency, and also better POSIX Yacc compliance (which, for
528 instance, allows "%type" without actually providing a type). The %nterm
529 directive, supported by Bison since its inception, is now documented and
530 officially supported.
532 The syntax is now as follows:
534 %token TAG? ( ID NUMBER? STRING? )+ ( TAG ( ID NUMBER? STRING? )+ )*
535 %left TAG? ( ID NUMBER? )+ ( TAG ( ID NUMBER? )+ )*
536 %type TAG? ( ID | CHAR | STRING )+ ( TAG ( ID | CHAR | STRING )+ )*
537 %nterm TAG? ID+ ( TAG ID+ )*
539 where TAG denotes a type tag such as ‘<ival>’, ID denotes an identifier
540 such as ‘NUM’, NUMBER a decimal or hexadecimal integer such as ‘300’ or
541 ‘0x12d’, CHAR a character literal such as ‘'+'’, and STRING a string
542 literal such as ‘"number"’. The post-fix quantifiers are ‘?’ (zero or
543 one), ‘*’ (zero or more) and ‘+’ (one or more).
545 * Noteworthy changes in release 3.2.4 (2018-12-24) [stable]
549 Fix the move constructor of symbol_type.
551 Always provide a copy constructor for symbol_type, even in modern C++.
553 * Noteworthy changes in release 3.2.3 (2018-12-18) [stable]
557 Properly support token constructors in C++ with types that include commas
558 (e.g., std::pair<int, int>). A regression introduced in Bison 3.2.
560 * Noteworthy changes in release 3.2.2 (2018-11-21) [stable]
564 C++ portability issues.
566 * Noteworthy changes in release 3.2.1 (2018-11-09) [stable]
570 Several portability issues have been fixed in the build system, in the
571 test suite, and in the generated parsers in C++.
573 * Noteworthy changes in release 3.2 (2018-10-29) [stable]
575 ** Backward incompatible changes
577 Support for DJGPP, which has been unmaintained and untested for years, is
578 obsolete. Unless there is activity to revive it, it will be removed.
582 %printers should use yyo rather than yyoutput to denote the output stream.
584 Variant-based symbols in C++ should use emplace() rather than build().
586 In C++ parsers, parser::operator() is now a synonym for the parser::parse.
590 A new section, "A Simple C++ Example", is a tutorial for parsers in C++.
592 A comment in the generated code now emphasizes that users should not
593 depend upon non-documented implementation details, such as macros starting
598 *** C++: Support for move semantics (lalr1.cc)
600 The lalr1.cc skeleton now fully supports C++ move semantics, while
601 maintaining compatibility with C++98. You may now store move-only types
602 when using Bison's variants. For instance:
610 %define api.value.type variant
614 %token <int> INT "int";
615 %type <std::unique_ptr<int>> int;
616 %type <std::vector<std::unique_ptr<int>>> list;
620 | list int { $$ = std::move($1); $$.emplace_back(std::move($2)); }
622 int: "int" { $$ = std::make_unique<int>($1); }
624 *** C++: Implicit move of right-hand side values (lalr1.cc)
626 In modern C++ (C++11 and later), you should always use 'std::move' with
627 the values of the right-hand side symbols ($1, $2, etc.), as they will be
628 popped from the stack anyway. Using 'std::move' is mandatory for
629 move-only types such as unique_ptr, and it provides a significant speedup
630 for large types such as std::string, or std::vector, etc.
632 If '%define api.value.automove' is set, every occurrence '$n' is replaced
633 by 'std::move ($n)'. The second rule in the previous grammar can be
636 list: list int { $$ = $1; $$.emplace_back($2); }
638 With automove enabled, the semantic values are no longer lvalues, so do
639 not use the swap idiom:
641 list: list int { std::swap($$, $1); $$.emplace_back($2); }
643 This idiom is anyway obsolete: it is preferable to move than to swap.
645 A warning is issued when automove is enabled, and a value is used several
648 input.yy:16.31-32: warning: multiple occurrences of $2 with api.value.automove enabled [-Wother]
649 exp: "twice" exp { $$ = $2 + $2; }
652 Enabling api.value.automove does not require support for modern C++. The
653 generated code is valid C++98/03, but will use copies instead of moves.
655 The new examples/c++/variant-11.yy shows these features in action.
657 *** C++: The implicit default semantic action is always run
659 When variants are enabled, the default action was not run, so
667 It now behaves like in all the other cases, as
669 exp: "number" { $$ = $1; }
671 possibly using std::move if automove is enabled.
673 We do not expect backward compatibility issues. However, beware of
674 forward compatibility issues: if you rely on default actions with
675 variants, be sure to '%require "3.2"' to avoid older versions of Bison to
676 generate incorrect parsers.
678 *** C++: Renaming location.hh
680 When both %defines and %locations are enabled, Bison generates a
681 location.hh file. If you don't use locations outside of the parser, you
682 may avoid its creation with:
684 %define api.location.file none
686 However this file is useful if, for instance, your parser builds an AST
687 decorated with locations: you may use Bison's location independently of
688 Bison's parser. You can now give it another name, for instance:
690 %define api.location.file "my-location.hh"
692 This name can have directory components, and even be absolute. The name
693 under which the location file is included is controlled by
694 api.location.include.
696 This way it is possible to have several parsers share the same location
699 For instance, in src/foo/parser.hh, generate the include/ast/loc.hh file:
702 %define api.namespace {foo}
703 %define api.location.file "include/ast/loc.hh"
704 %define api.location.include {<ast/loc.hh>}
706 and use it in src/bar/parser.hh:
709 %define api.namespace {bar}
710 %code requires {#include <ast/loc.hh>}
711 %define api.location.type {bar::location}
713 Absolute file names are supported, so in your Makefile, passing the flag
714 -Dapi.location.file='"$(top_srcdir)/include/ast/location.hh"' to bison is
717 *** C++: stack.hh and position.hh are deprecated
719 When asked to generate a header file (%defines), the lalr1.cc skeleton
720 generates a stack.hh file. This file had no interest for users; it is now
721 made useless: its content is included in the parser definition. It is
722 still generated for backward compatibility.
724 When in addition to %defines, location support is requested (%locations),
725 the file position.hh is also generated. It is now also useless: its
726 content is now included in location.hh.
728 These files are no longer generated when your grammar file requires at
729 least Bison 3.2 (%require "3.2").
733 Portability issues on MinGW and VS2015.
735 Portability issues in the test suite.
737 Portability/warning issues with Flex.
739 * Noteworthy changes in release 3.1 (2018-08-27) [stable]
741 ** Backward incompatible changes
743 Compiling Bison now requires a C99 compiler---as announced during the
744 release of Bison 3.0, five years ago. Generated parsers do not require a
747 Support for DJGPP, which has been unmaintained and untested for years, is
748 obsolete. Unless there is activity to revive it, the next release of Bison
749 will have it removed.
753 *** Typed midrule actions
755 Because their type is unknown to Bison, the values of midrule actions are
756 not treated like the others: they don't have %printer and %destructor
757 support. It also prevents C++ (Bison) variants to handle them properly.
759 Typed midrule actions address these issues. Instead of:
761 exp: { $<ival>$ = 1; } { $<ival>$ = 2; } { $$ = $<ival>1 + $<ival>2; }
765 exp: <ival>{ $$ = 1; } <ival>{ $$ = 2; } { $$ = $1 + $2; }
767 *** Reports include the type of the symbols
769 The sections about terminal and nonterminal symbols of the '*.output' file
770 now specify their declared type. For instance, for:
774 the report now shows '<ival>':
776 Terminals, with rules where they appear
780 *** Diagnostics about useless rules
782 In the following grammar, the 'exp' nonterminal is trivially useless. So,
783 of course, its rules are useless too.
787 exp: exp '+' exp | exp '-' exp | '(' exp ')'
789 Previously all the useless rules were reported, including those whose
790 left-hand side is the 'exp' nonterminal:
792 warning: 1 nonterminal useless in grammar [-Wother]
793 warning: 4 rules useless in grammar [-Wother]
794 2.14-16: warning: nonterminal useless in grammar: exp [-Wother]
797 2.14-16: warning: rule useless in grammar [-Wother]
800 3.6-16: warning: rule useless in grammar [-Wother]
801 exp: exp '+' exp | exp '-' exp | '(' exp ')'
803 3.20-30: warning: rule useless in grammar [-Wother]
804 exp: exp '+' exp | exp '-' exp | '(' exp ')'
806 3.34-44: warning: rule useless in grammar [-Wother]
807 exp: exp '+' exp | exp '-' exp | '(' exp ')'
810 Now, rules whose left-hand side symbol is useless are no longer reported
811 as useless. The locations of the errors have also been adjusted to point
812 to the first use of the nonterminal as a left-hand side of a rule:
814 warning: 1 nonterminal useless in grammar [-Wother]
815 warning: 4 rules useless in grammar [-Wother]
816 3.1-3: warning: nonterminal useless in grammar: exp [-Wother]
817 exp: exp '+' exp | exp '-' exp | '(' exp ')'
819 2.14-16: warning: rule useless in grammar [-Wother]
823 *** C++: Generated parsers can be compiled with -fno-exceptions (lalr1.cc)
825 When compiled with exceptions disabled, the generated parsers no longer
826 uses try/catch clauses.
828 Currently only GCC and Clang are supported.
832 *** A demonstration of variants
834 A new example was added (installed in .../share/doc/bison/examples),
835 'variant.yy', which shows how to use (Bison) variants in C++.
837 The other examples were made nicer to read.
839 *** Some features are no longer 'experimental'
841 The following features, mature enough, are no longer flagged as
842 experimental in the documentation: push parsers, default %printer and
843 %destructor (typed: <*> and untyped: <>), %define api.value.type union and
844 variant, Java parsers, XML output, LR family (lr, ielr, lalr), and
845 semantic predicates (%?).
849 *** GLR: Predicates support broken by #line directives
851 Predicates (%?) in GLR such as
854 %? {new_syntax} 'w' id new_args
855 | %?{!new_syntax} 'w' id old_args
857 were issued with #lines in the middle of C code.
859 *** Printer and destructor with broken #line directives
861 The #line directives were not properly escaped when emitting the code for
862 %printer/%destructor, which resulted in compiler errors if there are
863 backslashes or double-quotes in the grammar file name.
865 *** Portability on ICC
867 The Intel compiler claims compatibility with GCC, yet rejects its _Pragma.
868 Generated parsers now work around this.
872 There were several small fixes in the test suite and in the build system,
873 many warnings in bison and in the generated parsers were eliminated. The
874 documentation also received its share of minor improvements.
876 Useless code was removed from C++ parsers, and some of the generated
877 constructors are more 'natural'.
879 * Noteworthy changes in release 3.0.5 (2018-05-27) [stable]
883 *** C++: Fix support of 'syntax_error'
885 One incorrect 'inline' resulted in linking errors about the constructor of
886 the syntax_error exception.
888 *** C++: Fix warnings
890 GCC 7.3 (with -O1 or -O2 but not -O0 or -O3) issued null-dereference
891 warnings about yyformat being possibly null. It also warned about the
892 deprecated implicit definition of copy constructors when there's a
893 user-defined (copy) assignment operator.
895 *** Location of errors
897 In C++ parsers, out-of-bounds errors can happen when a rule with an empty
898 ride-hand side raises a syntax error. The behavior of the default parser
899 (yacc.c) in such a condition was undefined.
901 Now all the parsers match the behavior of glr.c: @$ is used as the
902 location of the error. This handles gracefully rules with and without
905 *** Portability fixes in the test suite
907 On some platforms, some Java and/or C++ tests were failing.
909 * Noteworthy changes in release 3.0.4 (2015-01-23) [stable]
913 *** C++ with Variants (lalr1.cc)
915 Fix a compiler warning when no %destructor use $$.
919 Several portability issues in tests were fixed.
921 * Noteworthy changes in release 3.0.3 (2015-01-15) [stable]
925 *** C++ with Variants (lalr1.cc)
927 Problems with %destructor and '%define parse.assert' have been fixed.
929 *** Named %union support (yacc.c, glr.c)
931 Bison 3.0 introduced a regression on named %union such as
933 %union foo { int ival; };
935 The possibility to use a name was introduced "for Yacc compatibility".
936 It is however not required by POSIX Yacc, and its usefulness is not clear.
938 *** %define api.value.type union with %defines (yacc.c, glr.c)
940 The C parsers were broken when %defines was used together with "%define
941 api.value.type union".
943 *** Redeclarations are reported in proper order
951 bison used to report:
953 /tmp/foo.yy:2.10-11: error: %printer redeclaration for FOO
956 /tmp/foo.yy:3.10-11: previous declaration
960 Now, the "previous" declaration is always the first one.
965 Bison now installs various files in its docdir (which defaults to
966 '/usr/local/share/doc/bison'), including the three fully blown examples
967 extracted from the documentation:
970 Reverse Polish Calculator, a simple introductory example.
972 Multi-function Calc, a calculator with memory and functions and located
975 a calculator in C++ using variant support and token constructors.
977 * Noteworthy changes in release 3.0.2 (2013-12-05) [stable]
981 *** Generated source files when errors are reported
983 When warnings are issued and -Werror is set, bison would still generate
984 the source files (*.c, *.h...). As a consequence, some runs of "make"
985 could fail the first time, but not the second (as the files were generated
988 This is fixed: bison no longer generates this source files, but, of
989 course, still produces the various reports (*.output, *.xml, etc.).
991 *** %empty is used in reports
993 Empty right-hand sides are denoted by '%empty' in all the reports (text,
994 dot, XML and formats derived from it).
996 *** YYERROR and variants
998 When C++ variant support is enabled, an error triggered via YYERROR, but
999 not caught via error recovery, resulted in a double deletion.
1001 * Noteworthy changes in release 3.0.1 (2013-11-12) [stable]
1005 *** Errors in caret diagnostics
1007 On some platforms, some errors could result in endless diagnostics.
1009 *** Fixes of the -Werror option
1011 Options such as "-Werror -Wno-error=foo" were still turning "foo"
1012 diagnostics into errors instead of warnings. This is fixed.
1014 Actually, for consistency with GCC, "-Wno-error=foo -Werror" now also
1015 leaves "foo" diagnostics as warnings. Similarly, with "-Werror=foo
1016 -Wno-error", "foo" diagnostics are now errors.
1020 As demonstrated in the documentation, one can now leave spaces between
1025 The yacc.1 man page is no longer installed if --disable-yacc was
1028 *** Fixes in the test suite
1030 Bugs and portability issues.
1032 * Noteworthy changes in release 3.0 (2013-07-25) [stable]
1034 ** WARNING: Future backward-incompatibilities!
1036 Like other GNU packages, Bison will start using some of the C99 features
1037 for its own code, especially the definition of variables after statements.
1038 The generated C parsers still aim at C90.
1040 ** Backward incompatible changes
1042 *** Obsolete features
1044 Support for YYFAIL is removed (deprecated in Bison 2.4.2): use YYERROR.
1046 Support for yystype and yyltype is removed (deprecated in Bison 1.875):
1047 use YYSTYPE and YYLTYPE.
1049 Support for YYLEX_PARAM and YYPARSE_PARAM is removed (deprecated in Bison
1050 1.875): use %lex-param, %parse-param, or %param.
1052 Missing semicolons at the end of actions are no longer added (as announced
1053 in the release 2.5).
1055 *** Use of YACC='bison -y'
1057 TL;DR: With Autoconf <= 2.69, pass -Wno-yacc to (AM_)YFLAGS if you use
1060 Traditional Yacc generates 'y.tab.c' whatever the name of the input file.
1061 Therefore Makefiles written for Yacc expect 'y.tab.c' (and possibly
1062 'y.tab.h' and 'y.output') to be generated from 'foo.y'.
1064 To this end, for ages, AC_PROG_YACC, Autoconf's macro to look for an
1065 implementation of Yacc, was using Bison as 'bison -y'. While it does
1066 ensure compatible output file names, it also enables warnings for
1067 incompatibilities with POSIX Yacc. In other words, 'bison -y' triggers
1068 warnings for Bison extensions.
1070 Autoconf 2.70+ fixes this incompatibility by using YACC='bison -o y.tab.c'
1071 (which also generates 'y.tab.h' and 'y.output' when needed).
1072 Alternatively, disable Yacc warnings by passing '-Wno-yacc' to your Yacc
1073 flags (YFLAGS, or AM_YFLAGS with Automake).
1077 *** The epilogue is no longer affected by internal #defines (glr.c)
1079 The glr.c skeleton uses defines such as #define yylval (yystackp->yyval) in
1080 generated code. These weren't properly undefined before the inclusion of
1081 the user epilogue, so functions such as the following were butchered by the
1082 preprocessor expansion:
1084 int yylex (YYSTYPE *yylval);
1086 This is fixed: yylval, yynerrs, yychar, and yylloc are now valid
1087 identifiers for user-provided variables.
1089 *** stdio.h is no longer needed when locations are enabled (yacc.c)
1091 Changes in Bison 2.7 introduced a dependency on FILE and fprintf when
1092 locations are enabled. This is fixed.
1094 *** Warnings about useless %pure-parser/%define api.pure are restored
1096 ** Diagnostics reported by Bison
1098 Most of these features were contributed by Théophile Ranquet and Victor
1103 Version 2.7 introduced caret errors, for a prettier output. These are now
1104 activated by default. The old format can still be used by invoking Bison
1105 with -fno-caret (or -fnone).
1107 Some error messages that reproduced excerpts of the grammar are now using
1108 the caret information only. For instance on:
1115 in.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
1116 in.y:2.12-14: warning: rule useless in parser due to conflicts: exp: 'a' [-Wother]
1120 in.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
1121 in.y:2.12-14: warning: rule useless in parser due to conflicts [-Wother]
1125 and "bison -fno-caret" reports:
1127 in.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
1128 in.y:2.12-14: warning: rule useless in parser due to conflicts [-Wother]
1130 *** Enhancements of the -Werror option
1132 The -Werror=CATEGORY option is now recognized, and will treat specified
1133 warnings as errors. The warnings need not have been explicitly activated
1134 using the -W option, this is similar to what GCC 4.7 does.
1136 For example, given the following command line, Bison will treat both
1137 warnings related to POSIX Yacc incompatibilities and S/R conflicts as
1138 errors (and only those):
1140 $ bison -Werror=yacc,error=conflicts-sr input.y
1142 If no categories are specified, -Werror will make all active warnings into
1143 errors. For example, the following line does the same the previous example:
1145 $ bison -Werror -Wnone -Wyacc -Wconflicts-sr input.y
1147 (By default -Wconflicts-sr,conflicts-rr,deprecated,other is enabled.)
1149 Note that the categories in this -Werror option may not be prefixed with
1150 "no-". However, -Wno-error[=CATEGORY] is valid.
1152 Note that -y enables -Werror=yacc. Therefore it is now possible to require
1153 Yacc-like behavior (e.g., always generate y.tab.c), but to report
1154 incompatibilities as warnings: "-y -Wno-error=yacc".
1156 *** The display of warnings is now richer
1158 The option that controls a given warning is now displayed:
1160 foo.y:4.6: warning: type clash on default action: <foo> != <bar> [-Wother]
1162 In the case of warnings treated as errors, the prefix is changed from
1163 "warning: " to "error: ", and the suffix is displayed, in a manner similar
1164 to GCC, as [-Werror=CATEGORY].
1166 For instance, where the previous version of Bison would report (and exit
1169 bison: warnings being treated as errors
1170 input.y:1.1: warning: stray ',' treated as white space
1174 input.y:1.1: error: stray ',' treated as white space [-Werror=other]
1176 *** Deprecated constructs
1178 The new 'deprecated' warning category flags obsolete constructs whose
1179 support will be discontinued. It is enabled by default. These warnings
1180 used to be reported as 'other' warnings.
1182 *** Useless semantic types
1184 Bison now warns about useless (uninhabited) semantic types. Since
1185 semantic types are not declared to Bison (they are defined in the opaque
1186 %union structure), it is %printer/%destructor directives about useless
1187 types that trigger the warning:
1191 %printer {} <type1> <type3>
1192 %destructor {} <type2> <type4>
1194 nterm: term { $$ = $1; };
1196 3.28-34: warning: type <type3> is used, but is not associated to any symbol
1197 4.28-34: warning: type <type4> is used, but is not associated to any symbol
1199 *** Undefined but unused symbols
1201 Bison used to raise an error for undefined symbols that are not used in
1202 the grammar. This is now only a warning.
1205 %destructor {} symbol2
1206 %type <type> symbol3
1210 *** Useless destructors or printers
1212 Bison now warns about useless destructors or printers. In the following
1213 example, the printer for <type1>, and the destructor for <type2> are
1214 useless: all symbols of <type1> (token1) already have a printer, and all
1215 symbols of type <type2> (token2) already have a destructor.
1217 %token <type1> token1
1221 %printer {} token1 <type1> <type3>
1222 %destructor {} token2 <type2> <type4>
1226 The warnings and error messages about shift/reduce and reduce/reduce
1227 conflicts have been normalized. For instance on the following foo.y file:
1231 exp: exp '+' exp | '0' | '0';
1233 compare the previous version of bison:
1236 foo.y: conflicts: 1 shift/reduce, 2 reduce/reduce
1237 $ bison -Werror foo.y
1238 bison: warnings being treated as errors
1239 foo.y: conflicts: 1 shift/reduce, 2 reduce/reduce
1241 with the new behavior:
1244 foo.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
1245 foo.y: warning: 2 reduce/reduce conflicts [-Wconflicts-rr]
1246 $ bison -Werror foo.y
1247 foo.y: error: 1 shift/reduce conflict [-Werror=conflicts-sr]
1248 foo.y: error: 2 reduce/reduce conflicts [-Werror=conflicts-rr]
1250 When %expect or %expect-rr is used, such as with bar.y:
1255 exp: exp '+' exp | '0' | '0';
1260 bar.y: conflicts: 1 shift/reduce, 2 reduce/reduce
1261 bar.y: expected 0 shift/reduce conflicts
1262 bar.y: expected 0 reduce/reduce conflicts
1267 bar.y: error: shift/reduce conflicts: 1 found, 0 expected
1268 bar.y: error: reduce/reduce conflicts: 2 found, 0 expected
1270 ** Incompatibilities with POSIX Yacc
1272 The 'yacc' category is no longer part of '-Wall', enable it explicitly
1275 ** Additional yylex/yyparse arguments
1277 The new directive %param declares additional arguments to both yylex and
1278 yyparse. The %lex-param, %parse-param, and %param directives support one
1279 or more arguments. Instead of
1281 %lex-param {arg1_type *arg1}
1282 %lex-param {arg2_type *arg2}
1283 %parse-param {arg1_type *arg1}
1284 %parse-param {arg2_type *arg2}
1288 %param {arg1_type *arg1} {arg2_type *arg2}
1290 ** Types of values for %define variables
1292 Bison used to make no difference between '%define foo bar' and '%define
1293 foo "bar"'. The former is now called a 'keyword value', and the latter a
1294 'string value'. A third kind was added: 'code values', such as '%define
1297 Keyword variables are used for fixed value sets, e.g.,
1299 %define lr.type lalr
1301 Code variables are used for value in the target language, e.g.,
1303 %define api.value.type {struct semantic_type}
1305 String variables are used remaining cases, e.g. file names.
1307 ** Variable api.token.prefix
1309 The variable api.token.prefix changes the way tokens are identified in
1310 the generated files. This is especially useful to avoid collisions
1311 with identifiers in the target language. For instance
1313 %token FILE for ERROR
1314 %define api.token.prefix {TOK_}
1316 start: FILE for ERROR;
1318 will generate the definition of the symbols TOK_FILE, TOK_for, and
1319 TOK_ERROR in the generated sources. In particular, the scanner must
1320 use these prefixed token names, although the grammar itself still
1321 uses the short names (as in the sample rule given above).
1323 ** Variable api.value.type
1325 This new %define variable supersedes the #define macro YYSTYPE. The use
1326 of YYSTYPE is discouraged. In particular, #defining YYSTYPE *and* either
1327 using %union or %defining api.value.type results in undefined behavior.
1329 Either define api.value.type, or use "%union":
1336 %token <ival> INT "integer"
1337 %token <sval> STRING "string"
1338 %printer { fprintf (yyo, "%d", $$); } <ival>
1339 %destructor { free ($$); } <sval>
1342 yylval.ival = 42; return INT;
1343 yylval.sval = "42"; return STRING;
1345 The %define variable api.value.type supports both keyword and code values.
1347 The keyword value 'union' means that the user provides genuine types, not
1348 union member names such as "ival" and "sval" above (WARNING: will fail if
1349 -y/--yacc/%yacc is enabled).
1351 %define api.value.type union
1352 %token <int> INT "integer"
1353 %token <char *> STRING "string"
1354 %printer { fprintf (yyo, "%d", $$); } <int>
1355 %destructor { free ($$); } <char *>
1358 yylval.INT = 42; return INT;
1359 yylval.STRING = "42"; return STRING;
1361 The keyword value variant is somewhat equivalent, but for C++ special
1362 provision is made to allow classes to be used (more about this below).
1364 %define api.value.type variant
1365 %token <int> INT "integer"
1366 %token <std::string> STRING "string"
1368 Code values (in braces) denote user defined types. This is where YYSTYPE
1386 %define api.value.type {struct my_value}
1387 %token <u.ival> INT "integer"
1388 %token <u.sval> STRING "string"
1389 %printer { fprintf (yyo, "%d", $$); } <u.ival>
1390 %destructor { free ($$); } <u.sval>
1393 yylval.u.ival = 42; return INT;
1394 yylval.u.sval = "42"; return STRING;
1396 ** Variable parse.error
1398 This variable controls the verbosity of error messages. The use of the
1399 %error-verbose directive is deprecated in favor of "%define parse.error
1402 ** Renamed %define variables
1404 The following variables have been renamed for consistency. Backward
1405 compatibility is ensured, but upgrading is recommended.
1407 lr.default-reductions -> lr.default-reduction
1408 lr.keep-unreachable-states -> lr.keep-unreachable-state
1409 namespace -> api.namespace
1410 stype -> api.value.type
1412 ** Semantic predicates
1414 Contributed by Paul Hilfinger.
1416 The new, experimental, semantic-predicate feature allows actions of the
1417 form "%?{ BOOLEAN-EXPRESSION }", which cause syntax errors (as for
1418 YYERROR) if the expression evaluates to 0, and are evaluated immediately
1419 in GLR parsers, rather than being deferred. The result is that they allow
1420 the programmer to prune possible parses based on the values of run-time
1423 ** The directive %expect-rr is now an error in non GLR mode
1425 It used to be an error only if used in non GLR mode, _and_ if there are
1426 reduce/reduce conflicts.
1428 ** Tokens are numbered in their order of appearance
1430 Contributed by Valentin Tolmer.
1432 With '%token A B', A had a number less than the one of B. However,
1433 precedence declarations used to generate a reversed order. This is now
1434 fixed, and introducing tokens with any of %token, %left, %right,
1435 %precedence, or %nonassoc yields the same result.
1437 When mixing declarations of tokens with a literal character (e.g., 'a') or
1438 with an identifier (e.g., B) in a precedence declaration, Bison numbered
1439 the literal characters first. For example
1443 would lead to the tokens declared in this order: 'c' 'd' A B. Again, the
1444 input order is now preserved.
1446 These changes were made so that one can remove useless precedence and
1447 associativity declarations (i.e., map %nonassoc, %left or %right to
1448 %precedence, or to %token) and get exactly the same output.
1450 ** Useless precedence and associativity
1452 Contributed by Valentin Tolmer.
1454 When developing and maintaining a grammar, useless associativity and
1455 precedence directives are common. They can be a nuisance: new ambiguities
1456 arising are sometimes masked because their conflicts are resolved due to
1457 the extra precedence or associativity information. Furthermore, it can
1458 hinder the comprehension of a new grammar: one will wonder about the role
1459 of a precedence, where in fact it is useless. The following changes aim
1460 at detecting and reporting these extra directives.
1462 *** Precedence warning category
1464 A new category of warning, -Wprecedence, was introduced. It flags the
1465 useless precedence and associativity directives.
1467 *** Useless associativity
1469 Bison now warns about symbols with a declared associativity that is never
1470 used to resolve conflicts. In that case, using %precedence is sufficient;
1471 the parsing tables will remain unchanged. Solving these warnings may raise
1472 useless precedence warnings, as the symbols no longer have associativity.
1486 warning: useless associativity for '+', use %precedence [-Wprecedence]
1490 *** Useless precedence
1492 Bison now warns about symbols with a declared precedence and no declared
1493 associativity (i.e., declared with %precedence), and whose precedence is
1494 never used. In that case, the symbol can be safely declared with %token
1495 instead, without modifying the parsing tables. For example:
1499 exp: "var" '=' "number";
1503 warning: useless precedence for '=' [-Wprecedence]
1507 *** Useless precedence and associativity
1509 In case of both useless precedence and associativity, the issue is flagged
1514 exp: "var" '=' "number";
1518 warning: useless precedence and associativity for '=' [-Wprecedence]
1524 With help from Joel E. Denny and Gabriel Rassoul.
1526 Empty rules (i.e., with an empty right-hand side) can now be explicitly
1527 marked by the new %empty directive. Using %empty on a non-empty rule is
1528 an error. The new -Wempty-rule warning reports empty rules without
1529 %empty. On the following grammar:
1539 3.4-5: warning: empty rule without %empty [-Wempty-rule]
1542 5.8-13: error: %empty on non-empty rule
1546 ** Java skeleton improvements
1548 The constants for token names were moved to the Lexer interface. Also, it
1549 is possible to add code to the parser's constructors using "%code init"
1550 and "%define init_throws".
1551 Contributed by Paolo Bonzini.
1553 The Java skeleton now supports push parsing.
1554 Contributed by Dennis Heimbigner.
1556 ** C++ skeletons improvements
1558 *** The parser header is no longer mandatory (lalr1.cc, glr.cc)
1560 Using %defines is now optional. Without it, the needed support classes
1561 are defined in the generated parser, instead of additional files (such as
1562 location.hh, position.hh and stack.hh).
1564 *** Locations are no longer mandatory (lalr1.cc, glr.cc)
1566 Both lalr1.cc and glr.cc no longer require %location.
1568 *** syntax_error exception (lalr1.cc)
1570 The C++ parser features a syntax_error exception, which can be
1571 thrown from the scanner or from user rules to raise syntax errors.
1572 This facilitates reporting errors caught in sub-functions (e.g.,
1573 rejecting too large integral literals from a conversion function
1574 used by the scanner, or rejecting invalid combinations from a
1575 factory invoked by the user actions).
1577 *** %define api.value.type variant
1579 This is based on a submission from Michiel De Wilde. With help
1580 from Théophile Ranquet.
1582 In this mode, complex C++ objects can be used as semantic values. For
1585 %token <::std::string> TEXT;
1586 %token <int> NUMBER;
1587 %token SEMICOLON ";"
1588 %type <::std::string> item;
1589 %type <::std::list<std::string>> list;
1592 list { std::cout << $1 << std::endl; }
1596 %empty { /* Generates an empty string list. */ }
1597 | list item ";" { std::swap ($$, $1); $$.push_back ($2); }
1601 TEXT { std::swap ($$, $1); }
1602 | NUMBER { $$ = string_cast ($1); }
1605 *** %define api.token.constructor
1607 When variants are enabled, Bison can generate functions to build the
1608 tokens. This guarantees that the token type (e.g., NUMBER) is consistent
1609 with the semantic value (e.g., int):
1611 parser::symbol_type yylex ()
1613 parser::location_type loc = ...;
1615 return parser::make_TEXT ("Hello, world!", loc);
1617 return parser::make_NUMBER (42, loc);
1619 return parser::make_SEMICOLON (loc);
1625 There are operator- and operator-= for 'location'. Negative line/column
1626 increments can no longer underflow the resulting value.
1628 * Noteworthy changes in release 2.7.1 (2013-04-15) [stable]
1632 *** Fix compiler attribute portability (yacc.c)
1634 With locations enabled, __attribute__ was used unprotected.
1636 *** Fix some compiler warnings (lalr1.cc)
1638 * Noteworthy changes in release 2.7 (2012-12-12) [stable]
1642 Warnings about uninitialized yylloc in yyparse have been fixed.
1644 Restored C90 compliance (yet no report was ever made).
1646 ** Diagnostics are improved
1648 Contributed by Théophile Ranquet.
1650 *** Changes in the format of error messages
1652 This used to be the format of many error reports:
1654 input.y:2.7-12: %type redeclaration for exp
1655 input.y:1.7-12: previous declaration
1659 input.y:2.7-12: error: %type redeclaration for exp
1660 input.y:1.7-12: previous declaration
1662 *** New format for error reports: carets
1664 Caret errors have been added to Bison:
1666 input.y:2.7-12: error: %type redeclaration for exp
1669 input.y:1.7-12: previous declaration
1675 input.y:3.20-23: error: ambiguous reference: '$exp'
1676 exp: exp '+' exp { $exp = $1 + $3; };
1678 input.y:3.1-3: refers to: $exp at $$
1679 exp: exp '+' exp { $exp = $1 + $3; };
1681 input.y:3.6-8: refers to: $exp at $1
1682 exp: exp '+' exp { $exp = $1 + $3; };
1684 input.y:3.14-16: refers to: $exp at $3
1685 exp: exp '+' exp { $exp = $1 + $3; };
1688 The default behavior for now is still not to display these unless
1689 explicitly asked with -fcaret (or -fall). However, in a later release, it
1690 will be made the default behavior (but may still be deactivated with
1693 ** New value for %define variable: api.pure full
1695 The %define variable api.pure requests a pure (reentrant) parser. However,
1696 for historical reasons, using it in a location-tracking Yacc parser
1697 resulted in a yyerror function that did not take a location as a
1698 parameter. With this new value, the user may request a better pure parser,
1699 where yyerror does take a location as a parameter (in location-tracking
1702 The use of "%define api.pure true" is deprecated in favor of this new
1703 "%define api.pure full".
1705 ** New %define variable: api.location.type (glr.cc, lalr1.cc, lalr1.java)
1707 The %define variable api.location.type defines the name of the type to use
1708 for locations. When defined, Bison no longer generates the position.hh
1709 and location.hh files, nor does the parser will include them: the user is
1710 then responsible to define her type.
1712 This can be used in programs with several parsers to factor their location
1713 and position files: let one of them generate them, and the others just use
1716 This feature was actually introduced, but not documented, in Bison 2.5,
1717 under the name "location_type" (which is maintained for backward
1720 For consistency, lalr1.java's %define variables location_type and
1721 position_type are deprecated in favor of api.location.type and
1724 ** Exception safety (lalr1.cc)
1726 The parse function now catches exceptions, uses the %destructors to
1727 release memory (the lookahead symbol and the symbols pushed on the stack)
1728 before re-throwing the exception.
1730 This feature is somewhat experimental. User feedback would be
1733 ** Graph improvements in DOT and XSLT
1735 Contributed by Théophile Ranquet.
1737 The graphical presentation of the states is more readable: their shape is
1738 now rectangular, the state number is clearly displayed, and the items are
1739 numbered and left-justified.
1741 The reductions are now explicitly represented as transitions to other
1742 diamond shaped nodes.
1744 These changes are present in both --graph output and xml2dot.xsl XSLT
1745 processing, with minor (documented) differences.
1747 ** %language is no longer an experimental feature.
1749 The introduction of this feature, in 2.4, was four years ago. The
1750 --language option and the %language directive are no longer experimental.
1754 The sections about shift/reduce and reduce/reduce conflicts resolution
1755 have been fixed and extended.
1757 Although introduced more than four years ago, XML and Graphviz reports
1758 were not properly documented.
1760 The translation of midrule actions is now described.
1762 * Noteworthy changes in release 2.6.5 (2012-11-07) [stable]
1764 We consider compiler warnings about Bison generated parsers to be bugs.
1765 Rather than working around them in your own project, please consider
1766 reporting them to us.
1770 Warnings about uninitialized yylval and/or yylloc for push parsers with a
1771 pure interface have been fixed for GCC 4.0 up to 4.8, and Clang 2.9 to
1774 Other issues in the test suite have been addressed.
1776 Null characters are correctly displayed in error messages.
1778 When possible, yylloc is correctly initialized before calling yylex. It
1779 is no longer necessary to initialize it in the %initial-action.
1781 * Noteworthy changes in release 2.6.4 (2012-10-23) [stable]
1783 Bison 2.6.3's --version was incorrect. This release fixes this issue.
1785 * Noteworthy changes in release 2.6.3 (2012-10-22) [stable]
1789 Bugs and portability issues in the test suite have been fixed.
1791 Some errors in translations have been addressed, and --help now directs
1792 users to the appropriate place to report them.
1794 Stray Info files shipped by accident are removed.
1796 Incorrect definitions of YY_, issued by yacc.c when no parser header is
1797 generated, are removed.
1799 All the generated headers are self-contained.
1801 ** Header guards (yacc.c, glr.c, glr.cc)
1803 In order to avoid collisions, the header guards are now
1804 YY_<PREFIX>_<FILE>_INCLUDED, instead of merely <PREFIX>_<FILE>.
1805 For instance the header generated from
1807 %define api.prefix "calc"
1808 %defines "lib/parse.h"
1810 will use YY_CALC_LIB_PARSE_H_INCLUDED as guard.
1812 ** Fix compiler warnings in the generated parser (yacc.c, glr.c)
1814 The compilation of pure parsers (%define api.pure) can trigger GCC
1817 input.c: In function 'yyparse':
1818 input.c:1503:12: warning: 'yylval' may be used uninitialized in this
1819 function [-Wmaybe-uninitialized]
1823 This is now fixed; pragmas to avoid these warnings are no longer needed.
1825 Warnings from clang ("equality comparison with extraneous parentheses" and
1826 "function declared 'noreturn' should not return") have also been
1829 * Noteworthy changes in release 2.6.2 (2012-08-03) [stable]
1833 Buffer overruns, complaints from Flex, and portability issues in the test
1834 suite have been fixed.
1836 ** Spaces in %lex- and %parse-param (lalr1.cc, glr.cc)
1838 Trailing end-of-lines in %parse-param or %lex-param would result in
1839 invalid C++. This is fixed.
1841 ** Spurious spaces and end-of-lines
1843 The generated files no longer end (nor start) with empty lines.
1845 * Noteworthy changes in release 2.6.1 (2012-07-30) [stable]
1847 Bison no longer executes user-specified M4 code when processing a grammar.
1851 In addition to the removal of the features announced in Bison 2.6, the
1852 next major release will remove the "Temporary hack for adding a semicolon
1853 to the user action", as announced in the release 2.5. Instead of:
1855 exp: exp "+" exp { $$ = $1 + $3 };
1859 exp: exp "+" exp { $$ = $1 + $3; };
1863 *** Type names are now properly escaped.
1865 *** glr.cc: set_debug_level and debug_level work as expected.
1867 *** Stray @ or $ in actions
1869 While Bison used to warn about stray $ or @ in action rules, it did not
1870 for other actions such as printers, destructors, or initial actions. It
1873 ** Type names in actions
1875 For consistency with rule actions, it is now possible to qualify $$ by a
1876 type-name in destructors, printers, and initial actions. For instance:
1878 %printer { fprintf (yyo, "(%d, %f)", $<ival>$, $<fval>$); } <*> <>;
1880 will display two values for each typed and untyped symbol (provided
1881 that YYSTYPE has both "ival" and "fval" fields).
1883 * Noteworthy changes in release 2.6 (2012-07-19) [stable]
1887 The next major release of Bison will drop support for the following
1888 deprecated features. Please report disagreements to bug-bison@gnu.org.
1892 Support for generating parsers in K&R C will be removed. Parsers
1893 generated for C support ISO C90, and are tested with ISO C99 and ISO C11
1896 *** Features deprecated since Bison 1.875
1898 The definitions of yystype and yyltype will be removed; use YYSTYPE and
1901 YYPARSE_PARAM and YYLEX_PARAM, deprecated in favor of %parse-param and
1902 %lex-param, will no longer be supported.
1904 Support for the preprocessor symbol YYERROR_VERBOSE will be removed, use
1907 *** The generated header will be included (yacc.c)
1909 Instead of duplicating the content of the generated header (definition of
1910 YYSTYPE, yyparse declaration etc.), the generated parser will include it,
1911 as is already the case for GLR or C++ parsers. This change is deferred
1912 because existing versions of ylwrap (e.g., Automake 1.12.1) do not support
1915 ** Generated Parser Headers
1917 *** Guards (yacc.c, glr.c, glr.cc)
1919 The generated headers are now guarded, as is already the case for C++
1920 parsers (lalr1.cc). For instance, with --defines=foo.h:
1925 #endif /* !YY_FOO_H */
1927 *** New declarations (yacc.c, glr.c)
1929 The generated header now declares yydebug and yyparse. Both honor
1930 --name-prefix=bar_, and yield
1932 int bar_parse (void);
1936 #define yyparse bar_parse
1939 in order to facilitate the inclusion of several parser headers inside a
1940 single compilation unit.
1942 *** Exported symbols in C++
1944 The symbols YYTOKEN_TABLE and YYERROR_VERBOSE, which were defined in the
1945 header, are removed, as they prevent the possibility of including several
1946 generated headers from a single compilation unit.
1950 For the same reasons, the undocumented and unused macro YYLSP_NEEDED is no
1953 ** New %define variable: api.prefix
1955 Now that the generated headers are more complete and properly protected
1956 against multiple inclusions, constant names, such as YYSTYPE are a
1957 problem. While yyparse and others are properly renamed by %name-prefix,
1958 YYSTYPE, YYDEBUG and others have never been affected by it. Because it
1959 would introduce backward compatibility issues in projects not expecting
1960 YYSTYPE to be renamed, instead of changing the behavior of %name-prefix,
1961 it is deprecated in favor of a new %define variable: api.prefix.
1963 The following examples compares both:
1965 %name-prefix "bar_" | %define api.prefix "bar_"
1966 %token <ival> FOO %token <ival> FOO
1967 %union { int ival; } %union { int ival; }
1973 #ifndef BAR_FOO_H #ifndef BAR_FOO_H
1974 # define BAR_FOO_H # define BAR_FOO_H
1976 /* Enabling traces. */ /* Enabling traces. */
1977 # ifndef YYDEBUG | # ifndef BAR_DEBUG
1978 > # if defined YYDEBUG
1980 > # define BAR_DEBUG 1
1982 > # define BAR_DEBUG 0
1985 # define YYDEBUG 0 | # define BAR_DEBUG 0
1989 # if YYDEBUG | # if BAR_DEBUG
1990 extern int bar_debug; extern int bar_debug;
1993 /* Tokens. */ /* Tokens. */
1994 # ifndef YYTOKENTYPE | # ifndef BAR_TOKENTYPE
1995 # define YYTOKENTYPE | # define BAR_TOKENTYPE
1996 enum yytokentype { | enum bar_tokentype {
2001 #if ! defined YYSTYPE \ | #if ! defined BAR_STYPE \
2002 && ! defined YYSTYPE_IS_DECLARED | && ! defined BAR_STYPE_IS_DECLARED
2003 typedef union YYSTYPE | typedef union BAR_STYPE
2006 } YYSTYPE; | } BAR_STYPE;
2007 # define YYSTYPE_IS_DECLARED 1 | # define BAR_STYPE_IS_DECLARED 1
2010 extern YYSTYPE bar_lval; | extern BAR_STYPE bar_lval;
2012 int bar_parse (void); int bar_parse (void);
2014 #endif /* !BAR_FOO_H */ #endif /* !BAR_FOO_H */
2016 * Noteworthy changes in release 2.5.1 (2012-06-05) [stable]
2020 The next major release will drop support for generating parsers in K&R C.
2022 ** yacc.c: YYBACKUP works as expected.
2024 ** glr.c improvements:
2026 *** Location support is eliminated when not requested:
2028 GLR parsers used to include location-related code even when locations were
2029 not requested, and therefore not even usable.
2031 *** __attribute__ is preserved:
2033 __attribute__ is no longer disabled when __STRICT_ANSI__ is defined (i.e.,
2034 when -std is passed to GCC).
2036 ** lalr1.java: several fixes:
2038 The Java parser no longer throws ArrayIndexOutOfBoundsException if the
2039 first token leads to a syntax error. Some minor clean ups.
2043 *** C++11 compatibility:
2045 C and C++ parsers use "nullptr" instead of "0" when __cplusplus is 201103L
2050 The header files such as "parser.hh", "location.hh", etc. used a constant
2051 name for preprocessor guards, for instance:
2053 #ifndef BISON_LOCATION_HH
2054 # define BISON_LOCATION_HH
2056 #endif // !BISON_LOCATION_HH
2058 The inclusion guard is now computed from "PREFIX/FILE-NAME", where lower
2059 case characters are converted to upper case, and series of
2060 non-alphanumerical characters are converted to an underscore.
2062 With "bison -o lang++/parser.cc", "location.hh" would now include:
2064 #ifndef YY_LANG_LOCATION_HH
2065 # define YY_LANG_LOCATION_HH
2067 #endif // !YY_LANG_LOCATION_HH
2071 The position and location constructors (and their initialize methods)
2072 accept new arguments for line and column. Several issues in the
2073 documentation were fixed.
2075 ** liby is no longer asking for "rpl_fprintf" on some platforms.
2077 ** Changes in the manual:
2079 *** %printer is documented
2081 The "%printer" directive, supported since at least Bison 1.50, is finally
2082 documented. The "mfcalc" example is extended to demonstrate it.
2084 For consistency with the C skeletons, the C++ parsers now also support
2085 "yyoutput" (as an alias to "debug_stream ()").
2087 *** Several improvements have been made:
2089 The layout for grammar excerpts was changed to a more compact scheme.
2090 Named references are motivated. The description of the automaton
2091 description file (*.output) is updated to the current format. Incorrect
2092 index entries were fixed. Some other errors were fixed.
2096 *** Conflicting prototypes with recent/modified Flex.
2098 Fixed build problems with the current, unreleased, version of Flex, and
2099 some modified versions of 2.5.35, which have modified function prototypes.
2101 *** Warnings during the build procedure have been eliminated.
2103 *** Several portability problems in the test suite have been fixed:
2105 This includes warnings with some compilers, unexpected behavior of tools
2106 such as diff, warning messages from the test suite itself, etc.
2108 *** The install-pdf target works properly:
2110 Running "make install-pdf" (or -dvi, -html, -info, and -ps) no longer
2111 halts in the middle of its course.
2113 * Changes in version 2.5 (2011-05-14):
2115 ** Grammar symbol names can now contain non-initial dashes:
2117 Consistently with directives (such as %error-verbose) and with
2118 %define variables (e.g. push-pull), grammar symbol names may contain
2119 dashes in any position except the beginning. This is a GNU
2120 extension over POSIX Yacc. Thus, use of this extension is reported
2121 by -Wyacc and rejected in Yacc mode (--yacc).
2123 ** Named references:
2125 Historically, Yacc and Bison have supported positional references
2126 ($n, $$) to allow access to symbol values from inside of semantic
2129 Starting from this version, Bison can also accept named references.
2130 When no ambiguity is possible, original symbol names may be used
2131 as named references:
2133 if_stmt : "if" cond_expr "then" then_stmt ';'
2134 { $if_stmt = mk_if_stmt($cond_expr, $then_stmt); }
2136 In the more common case, explicit names may be declared:
2138 stmt[res] : "if" expr[cond] "then" stmt[then] "else" stmt[else] ';'
2139 { $res = mk_if_stmt($cond, $then, $else); }
2141 Location information is also accessible using @name syntax. When
2142 accessing symbol names containing dots or dashes, explicit bracketing
2143 ($[sym.1]) must be used.
2145 These features are experimental in this version. More user feedback
2146 will help to stabilize them.
2147 Contributed by Alex Rozenman.
2149 ** IELR(1) and canonical LR(1):
2151 IELR(1) is a minimal LR(1) parser table generation algorithm. That
2152 is, given any context-free grammar, IELR(1) generates parser tables
2153 with the full language-recognition power of canonical LR(1) but with
2154 nearly the same number of parser states as LALR(1). This reduction
2155 in parser states is often an order of magnitude. More importantly,
2156 because canonical LR(1)'s extra parser states may contain duplicate
2157 conflicts in the case of non-LR(1) grammars, the number of conflicts
2158 for IELR(1) is often an order of magnitude less as well. This can
2159 significantly reduce the complexity of developing of a grammar.
2161 Bison can now generate IELR(1) and canonical LR(1) parser tables in
2162 place of its traditional LALR(1) parser tables, which remain the
2163 default. You can specify the type of parser tables in the grammar
2164 file with these directives:
2166 %define lr.type lalr
2167 %define lr.type ielr
2168 %define lr.type canonical-lr
2170 The default-reduction optimization in the parser tables can also be
2171 adjusted using "%define lr.default-reductions". For details on both
2172 of these features, see the new section "Tuning LR" in the Bison
2175 These features are experimental. More user feedback will help to
2178 ** LAC (Lookahead Correction) for syntax error handling
2180 Contributed by Joel E. Denny.
2182 Canonical LR, IELR, and LALR can suffer from a couple of problems
2183 upon encountering a syntax error. First, the parser might perform
2184 additional parser stack reductions before discovering the syntax
2185 error. Such reductions can perform user semantic actions that are
2186 unexpected because they are based on an invalid token, and they
2187 cause error recovery to begin in a different syntactic context than
2188 the one in which the invalid token was encountered. Second, when
2189 verbose error messages are enabled (with %error-verbose or the
2190 obsolete "#define YYERROR_VERBOSE"), the expected token list in the
2191 syntax error message can both contain invalid tokens and omit valid
2194 The culprits for the above problems are %nonassoc, default
2195 reductions in inconsistent states, and parser state merging. Thus,
2196 IELR and LALR suffer the most. Canonical LR can suffer only if
2197 %nonassoc is used or if default reductions are enabled for
2198 inconsistent states.
2200 LAC is a new mechanism within the parsing algorithm that solves
2201 these problems for canonical LR, IELR, and LALR without sacrificing
2202 %nonassoc, default reductions, or state merging. When LAC is in
2203 use, canonical LR and IELR behave almost exactly the same for both
2204 syntactically acceptable and syntactically unacceptable input.
2205 While LALR still does not support the full language-recognition
2206 power of canonical LR and IELR, LAC at least enables LALR's syntax
2207 error handling to correctly reflect LALR's language-recognition
2210 Currently, LAC is only supported for deterministic parsers in C.
2211 You can enable LAC with the following directive:
2213 %define parse.lac full
2215 See the new section "LAC" in the Bison manual for additional
2216 details including a few caveats.
2218 LAC is an experimental feature. More user feedback will help to
2221 ** %define improvements:
2223 *** Can now be invoked via the command line:
2225 Each of these command-line options
2228 --define=NAME[=VALUE]
2231 --force-define=NAME[=VALUE]
2233 is equivalent to this grammar file declaration
2235 %define NAME ["VALUE"]
2237 except that the manner in which Bison processes multiple definitions
2238 for the same NAME differs. Most importantly, -F and --force-define
2239 quietly override %define, but -D and --define do not. For further
2240 details, see the section "Bison Options" in the Bison manual.
2242 *** Variables renamed:
2244 The following %define variables
2247 lr.keep_unreachable_states
2249 have been renamed to
2252 lr.keep-unreachable-states
2254 The old names are now deprecated but will be maintained indefinitely
2255 for backward compatibility.
2257 *** Values no longer need to be quoted in the grammar file:
2259 If a %define value is an identifier, it no longer needs to be placed
2260 within quotations marks. For example,
2262 %define api.push-pull "push"
2266 %define api.push-pull push
2268 *** Unrecognized variables are now errors not warnings.
2270 *** Multiple invocations for any variable is now an error not a warning.
2272 ** Unrecognized %code qualifiers are now errors not warnings.
2274 ** Character literals not of length one:
2276 Previously, Bison quietly converted all character literals to length
2277 one. For example, without warning, Bison interpreted the operators in
2278 the following grammar to be the same token:
2284 Bison now warns when a character literal is not of length one. In
2285 some future release, Bison will start reporting an error instead.
2287 ** Destructor calls fixed for lookaheads altered in semantic actions:
2289 Previously for deterministic parsers in C, if a user semantic action
2290 altered yychar, the parser in some cases used the old yychar value to
2291 determine which destructor to call for the lookahead upon a syntax
2292 error or upon parser return. This bug has been fixed.
2294 ** C++ parsers use YYRHSLOC:
2296 Similarly to the C parsers, the C++ parsers now define the YYRHSLOC
2297 macro and use it in the default YYLLOC_DEFAULT. You are encouraged
2298 to use it. If, for instance, your location structure has "first"
2299 and "last" members, instead of
2301 # define YYLLOC_DEFAULT(Current, Rhs, N) \
2305 (Current).first = (Rhs)[1].location.first; \
2306 (Current).last = (Rhs)[N].location.last; \
2310 (Current).first = (Current).last = (Rhs)[0].location.last; \
2316 # define YYLLOC_DEFAULT(Current, Rhs, N) \
2320 (Current).first = YYRHSLOC (Rhs, 1).first; \
2321 (Current).last = YYRHSLOC (Rhs, N).last; \
2325 (Current).first = (Current).last = YYRHSLOC (Rhs, 0).last; \
2329 ** YYLLOC_DEFAULT in C++:
2331 The default implementation of YYLLOC_DEFAULT used to be issued in
2332 the header file. It is now output in the implementation file, after
2333 the user %code sections so that its #ifndef guard does not try to
2334 override the user's YYLLOC_DEFAULT if provided.
2336 ** YYFAIL now produces warnings and Java parsers no longer implement it:
2338 YYFAIL has existed for many years as an undocumented feature of
2339 deterministic parsers in C generated by Bison. More recently, it was
2340 a documented feature of Bison's experimental Java parsers. As
2341 promised in Bison 2.4.2's NEWS entry, any appearance of YYFAIL in a
2342 semantic action now produces a deprecation warning, and Java parsers
2343 no longer implement YYFAIL at all. For further details, including a
2344 discussion of how to suppress C preprocessor warnings about YYFAIL
2345 being unused, see the Bison 2.4.2 NEWS entry.
2347 ** Temporary hack for adding a semicolon to the user action:
2349 Previously, Bison appended a semicolon to every user action for
2350 reductions when the output language defaulted to C (specifically, when
2351 neither %yacc, %language, %skeleton, or equivalent command-line
2352 options were specified). This allowed actions such as
2354 exp: exp "+" exp { $$ = $1 + $3 };
2358 exp: exp "+" exp { $$ = $1 + $3; };
2360 As a first step in removing this misfeature, Bison now issues a
2361 warning when it appends a semicolon. Moreover, in cases where Bison
2362 cannot easily determine whether a semicolon is needed (for example, an
2363 action ending with a cpp directive or a braced compound initializer),
2364 it no longer appends one. Thus, the C compiler might now complain
2365 about a missing semicolon where it did not before. Future releases of
2366 Bison will cease to append semicolons entirely.
2368 ** Verbose syntax error message fixes:
2370 When %error-verbose or the obsolete "#define YYERROR_VERBOSE" is
2371 specified, syntax error messages produced by the generated parser
2372 include the unexpected token as well as a list of expected tokens.
2373 The effect of %nonassoc on these verbose messages has been corrected
2374 in two ways, but a more complete fix requires LAC, described above:
2376 *** When %nonassoc is used, there can exist parser states that accept no
2377 tokens, and so the parser does not always require a lookahead token
2378 in order to detect a syntax error. Because no unexpected token or
2379 expected tokens can then be reported, the verbose syntax error
2380 message described above is suppressed, and the parser instead
2381 reports the simpler message, "syntax error". Previously, this
2382 suppression was sometimes erroneously triggered by %nonassoc when a
2383 lookahead was actually required. Now verbose messages are
2384 suppressed only when all previous lookaheads have already been
2385 shifted or discarded.
2387 *** Previously, the list of expected tokens erroneously included tokens
2388 that would actually induce a syntax error because conflicts for them
2389 were resolved with %nonassoc in the current parser state. Such
2390 tokens are now properly omitted from the list.
2392 *** Expected token lists are still often wrong due to state merging
2393 (from LALR or IELR) and default reductions, which can both add
2394 invalid tokens and subtract valid tokens. Canonical LR almost
2395 completely fixes this problem by eliminating state merging and
2396 default reductions. However, there is one minor problem left even
2397 when using canonical LR and even after the fixes above. That is,
2398 if the resolution of a conflict with %nonassoc appears in a later
2399 parser state than the one at which some syntax error is
2400 discovered, the conflicted token is still erroneously included in
2401 the expected token list. Bison's new LAC implementation,
2402 described above, eliminates this problem and the need for
2403 canonical LR. However, LAC is still experimental and is disabled
2406 ** Java skeleton fixes:
2408 *** A location handling bug has been fixed.
2410 *** The top element of each of the value stack and location stack is now
2411 cleared when popped so that it can be garbage collected.
2413 *** Parser traces now print the top element of the stack.
2415 ** -W/--warnings fixes:
2417 *** Bison now properly recognizes the "no-" versions of categories:
2419 For example, given the following command line, Bison now enables all
2420 warnings except warnings for incompatibilities with POSIX Yacc:
2422 bison -Wall,no-yacc gram.y
2424 *** Bison now treats S/R and R/R conflicts like other warnings:
2426 Previously, conflict reports were independent of Bison's normal
2427 warning system. Now, Bison recognizes the warning categories
2428 "conflicts-sr" and "conflicts-rr". This change has important
2429 consequences for the -W and --warnings command-line options. For
2432 bison -Wno-conflicts-sr gram.y # S/R conflicts not reported
2433 bison -Wno-conflicts-rr gram.y # R/R conflicts not reported
2434 bison -Wnone gram.y # no conflicts are reported
2435 bison -Werror gram.y # any conflict is an error
2437 However, as before, if the %expect or %expect-rr directive is
2438 specified, an unexpected number of conflicts is an error, and an
2439 expected number of conflicts is not reported, so -W and --warning
2440 then have no effect on the conflict report.
2442 *** The "none" category no longer disables a preceding "error":
2444 For example, for the following command line, Bison now reports
2445 errors instead of warnings for incompatibilities with POSIX Yacc:
2447 bison -Werror,none,yacc gram.y
2449 *** The "none" category now disables all Bison warnings:
2451 Previously, the "none" category disabled only Bison warnings for
2452 which there existed a specific -W/--warning category. However,
2453 given the following command line, Bison is now guaranteed to
2454 suppress all warnings:
2458 ** Precedence directives can now assign token number 0:
2460 Since Bison 2.3b, which restored the ability of precedence
2461 directives to assign token numbers, doing so for token number 0 has
2462 produced an assertion failure. For example:
2466 This bug has been fixed.
2468 * Changes in version 2.4.3 (2010-08-05):
2470 ** Bison now obeys -Werror and --warnings=error for warnings about
2471 grammar rules that are useless in the parser due to conflicts.
2473 ** Problems with spawning M4 on at least FreeBSD 8 and FreeBSD 9 have
2476 ** Failures in the test suite for GCC 4.5 have been fixed.
2478 ** Failures in the test suite for some versions of Sun Studio C++ have
2481 ** Contrary to Bison 2.4.2's NEWS entry, it has been decided that
2482 warnings about undefined %prec identifiers will not be converted to
2483 errors in Bison 2.5. They will remain warnings, which should be
2484 sufficient for POSIX while avoiding backward compatibility issues.
2486 ** Minor documentation fixes.
2488 * Changes in version 2.4.2 (2010-03-20):
2490 ** Some portability problems that resulted in failures and livelocks
2491 in the test suite on some versions of at least Solaris, AIX, HP-UX,
2492 RHEL4, and Tru64 have been addressed. As a result, fatal Bison
2493 errors should no longer cause M4 to report a broken pipe on the
2496 ** "%prec IDENTIFIER" requires IDENTIFIER to be defined separately.
2498 POSIX specifies that an error be reported for any identifier that does
2499 not appear on the LHS of a grammar rule and that is not defined by
2500 %token, %left, %right, or %nonassoc. Bison 2.3b and later lost this
2501 error report for the case when an identifier appears only after a
2502 %prec directive. It is now restored. However, for backward
2503 compatibility with recent Bison releases, it is only a warning for
2504 now. In Bison 2.5 and later, it will return to being an error.
2505 [Between the 2.4.2 and 2.4.3 releases, it was decided that this
2506 warning will not be converted to an error in Bison 2.5.]
2508 ** Detection of GNU M4 1.4.6 or newer during configure is improved.
2510 ** Warnings from gcc's -Wundef option about undefined YYENABLE_NLS,
2511 YYLTYPE_IS_TRIVIAL, and __STRICT_ANSI__ in C/C++ parsers are now
2514 ** %code is now a permanent feature.
2516 A traditional Yacc prologue directive is written in the form:
2520 To provide a more flexible alternative, Bison 2.3b introduced the
2521 %code directive with the following forms for C/C++:
2524 %code requires {CODE}
2525 %code provides {CODE}
2528 These forms are now considered permanent features of Bison. See the
2529 %code entries in the section "Bison Declaration Summary" in the Bison
2530 manual for a summary of their functionality. See the section
2531 "Prologue Alternatives" for a detailed discussion including the
2532 advantages of %code over the traditional Yacc prologue directive.
2534 Bison's Java feature as a whole including its current usage of %code
2535 is still considered experimental.
2537 ** YYFAIL is deprecated and will eventually be removed.
2539 YYFAIL has existed for many years as an undocumented feature of
2540 deterministic parsers in C generated by Bison. Previously, it was
2541 documented for Bison's experimental Java parsers. YYFAIL is no longer
2542 documented for Java parsers and is formally deprecated in both cases.
2543 Users are strongly encouraged to migrate to YYERROR, which is
2546 Like YYERROR, you can invoke YYFAIL from a semantic action in order to
2547 induce a syntax error. The most obvious difference from YYERROR is
2548 that YYFAIL will automatically invoke yyerror to report the syntax
2549 error so that you don't have to. However, there are several other
2550 subtle differences between YYERROR and YYFAIL, and YYFAIL suffers from
2551 inherent flaws when %error-verbose or "#define YYERROR_VERBOSE" is
2552 used. For a more detailed discussion, see:
2554 http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html
2556 The upcoming Bison 2.5 will remove YYFAIL from Java parsers, but
2557 deterministic parsers in C will continue to implement it. However,
2558 because YYFAIL is already flawed, it seems futile to try to make new
2559 Bison features compatible with it. Thus, during parser generation,
2560 Bison 2.5 will produce a warning whenever it discovers YYFAIL in a
2561 rule action. In a later release, YYFAIL will be disabled for
2562 %error-verbose and "#define YYERROR_VERBOSE". Eventually, YYFAIL will
2563 be removed altogether.
2565 There exists at least one case where Bison 2.5's YYFAIL warning will
2566 be a false positive. Some projects add phony uses of YYFAIL and other
2567 Bison-defined macros for the sole purpose of suppressing C
2568 preprocessor warnings (from GCC cpp's -Wunused-macros, for example).
2569 To avoid Bison's future warning, such YYFAIL uses can be moved to the
2570 epilogue (that is, after the second "%%") in the Bison input file. In
2571 this release (2.4.2), Bison already generates its own code to suppress
2572 C preprocessor warnings for YYFAIL, so projects can remove their own
2573 phony uses of YYFAIL if compatibility with Bison releases prior to
2574 2.4.2 is not necessary.
2576 ** Internationalization.
2578 Fix a regression introduced in Bison 2.4: Under some circumstances,
2579 message translations were not installed although supported by the
2582 * Changes in version 2.4.1 (2008-12-11):
2584 ** In the GLR defines file, unexpanded M4 macros in the yylval and yylloc
2585 declarations have been fixed.
2587 ** Temporary hack for adding a semicolon to the user action.
2589 Bison used to prepend a trailing semicolon at the end of the user
2590 action for reductions. This allowed actions such as
2592 exp: exp "+" exp { $$ = $1 + $3 };
2596 exp: exp "+" exp { $$ = $1 + $3; };
2598 Some grammars still depend on this "feature". Bison 2.4.1 restores
2599 the previous behavior in the case of C output (specifically, when
2600 neither %language or %skeleton or equivalent command-line options
2601 are used) to leave more time for grammars depending on the old
2602 behavior to be adjusted. Future releases of Bison will disable this
2605 ** A few minor improvements to the Bison manual.
2607 * Changes in version 2.4 (2008-11-02):
2609 ** %language is an experimental feature.
2611 We first introduced this feature in test release 2.3b as a cleaner
2612 alternative to %skeleton. Since then, we have discussed the possibility of
2613 modifying its effect on Bison's output file names. Thus, in this release,
2614 we consider %language to be an experimental feature that will likely evolve
2617 ** Forward compatibility with GNU M4 has been improved.
2619 ** Several bugs in the C++ skeleton and the experimental Java skeleton have been
2622 * Changes in version 2.3b (2008-05-27):
2624 ** The quotes around NAME that used to be required in the following directive
2627 %define NAME "VALUE"
2629 ** The directive "%pure-parser" is now deprecated in favor of:
2633 which has the same effect except that Bison is more careful to warn about
2634 unreasonable usage in the latter case.
2638 Bison can now generate an LALR(1) parser in C with a push interface. That
2639 is, instead of invoking "yyparse", which pulls tokens from "yylex", you can
2640 push one token at a time to the parser using "yypush_parse", which will
2641 return to the caller after processing each token. By default, the push
2642 interface is disabled. Either of the following directives will enable it:
2644 %define api.push_pull "push" // Just push; does not require yylex.
2645 %define api.push_pull "both" // Push and pull; requires yylex.
2647 See the new section "A Push Parser" in the Bison manual for details.
2649 The current push parsing interface is experimental and may evolve. More user
2650 feedback will help to stabilize it.
2652 ** The -g and --graph options now output graphs in Graphviz DOT format,
2653 not VCG format. Like --graph, -g now also takes an optional FILE argument
2654 and thus cannot be bundled with other short options.
2658 Bison can now generate an LALR(1) parser in Java. The skeleton is
2659 "data/lalr1.java". Consider using the new %language directive instead of
2660 %skeleton to select it.
2662 See the new section "Java Parsers" in the Bison manual for details.
2664 The current Java interface is experimental and may evolve. More user
2665 feedback will help to stabilize it.
2666 Contributed by Paolo Bonzini.
2670 This new directive specifies the programming language of the generated
2671 parser, which can be C (the default), C++, or Java. Besides the skeleton
2672 that Bison uses, the directive affects the names of the generated files if
2673 the grammar file's name ends in ".y".
2675 ** XML Automaton Report
2677 Bison can now generate an XML report of the LALR(1) automaton using the new
2678 "--xml" option. The current XML schema is experimental and may evolve. More
2679 user feedback will help to stabilize it.
2680 Contributed by Wojciech Polak.
2682 ** The grammar file may now specify the name of the parser header file using
2683 %defines. For example:
2687 ** When reporting useless rules, useless nonterminals, and unused terminals,
2688 Bison now employs the terms "useless in grammar" instead of "useless",
2689 "useless in parser" instead of "never reduced", and "unused in grammar"
2690 instead of "unused".
2692 ** Unreachable State Removal
2694 Previously, Bison sometimes generated parser tables containing unreachable
2695 states. A state can become unreachable during conflict resolution if Bison
2696 disables a shift action leading to it from a predecessor state. Bison now:
2698 1. Removes unreachable states.
2700 2. Does not report any conflicts that appeared in unreachable states.
2701 WARNING: As a result, you may need to update %expect and %expect-rr
2702 directives in existing grammar files.
2704 3. For any rule used only in such states, Bison now reports the rule as
2705 "useless in parser due to conflicts".
2707 This feature can be disabled with the following directive:
2709 %define lr.keep_unreachable_states
2711 See the %define entry in the "Bison Declaration Summary" in the Bison manual
2712 for further discussion.
2714 ** Lookahead Set Correction in the ".output" Report
2716 When instructed to generate a ".output" file including lookahead sets
2717 (using "--report=lookahead", for example), Bison now prints each reduction's
2718 lookahead set only next to the associated state's one item that (1) is
2719 associated with the same rule as the reduction and (2) has its dot at the end
2720 of its RHS. Previously, Bison also erroneously printed the lookahead set
2721 next to all of the state's other items associated with the same rule. This
2722 bug affected only the ".output" file and not the generated parser source
2725 ** --report-file=FILE is a new option to override the default ".output" file
2728 ** The "=" that used to be required in the following directives is now
2731 %file-prefix "parser"
2735 ** An Alternative to "%{...%}" -- "%code QUALIFIER {CODE}"
2737 Bison 2.3a provided a new set of directives as a more flexible alternative to
2738 the traditional Yacc prologue blocks. Those have now been consolidated into
2739 a single %code directive with an optional qualifier field, which identifies
2740 the purpose of the code and thus the location(s) where Bison should generate
2743 1. "%code {CODE}" replaces "%after-header {CODE}"
2744 2. "%code requires {CODE}" replaces "%start-header {CODE}"
2745 3. "%code provides {CODE}" replaces "%end-header {CODE}"
2746 4. "%code top {CODE}" replaces "%before-header {CODE}"
2748 See the %code entries in section "Bison Declaration Summary" in the Bison
2749 manual for a summary of the new functionality. See the new section "Prologue
2750 Alternatives" for a detailed discussion including the advantages of %code
2751 over the traditional Yacc prologues.
2753 The prologue alternatives are experimental. More user feedback will help to
2754 determine whether they should become permanent features.
2756 ** Revised warning: unset or unused midrule values
2758 Since Bison 2.2, Bison has warned about midrule values that are set but not
2759 used within any of the actions of the parent rule. For example, Bison warns
2762 exp: '1' { $$ = 1; } '+' exp { $$ = $1 + $4; };
2764 Now, Bison also warns about midrule values that are used but not set. For
2765 example, Bison warns about unset $$ in the midrule action in:
2767 exp: '1' { $1 = 1; } '+' exp { $$ = $2 + $4; };
2769 However, Bison now disables both of these warnings by default since they
2770 sometimes prove to be false alarms in existing grammars employing the Yacc
2771 constructs $0 or $-N (where N is some positive integer).
2773 To enable these warnings, specify the option "--warnings=midrule-values" or
2774 "-W", which is a synonym for "--warnings=all".
2776 ** Default %destructor or %printer with "<*>" or "<>"
2778 Bison now recognizes two separate kinds of default %destructor's and
2781 1. Place "<*>" in a %destructor/%printer symbol list to define a default
2782 %destructor/%printer for all grammar symbols for which you have formally
2783 declared semantic type tags.
2785 2. Place "<>" in a %destructor/%printer symbol list to define a default
2786 %destructor/%printer for all grammar symbols without declared semantic
2789 Bison no longer supports the "%symbol-default" notation from Bison 2.3a.
2790 "<*>" and "<>" combined achieve the same effect with one exception: Bison no
2791 longer applies any %destructor to a midrule value if that midrule value is
2792 not actually ever referenced using either $$ or $n in a semantic action.
2794 The default %destructor's and %printer's are experimental. More user
2795 feedback will help to determine whether they should become permanent
2798 See the section "Freeing Discarded Symbols" in the Bison manual for further
2801 ** %left, %right, and %nonassoc can now declare token numbers. This is required
2802 by POSIX. However, see the end of section "Operator Precedence" in the Bison
2803 manual for a caveat concerning the treatment of literal strings.
2805 ** The nonfunctional --no-parser, -n, and %no-parser options have been
2806 completely removed from Bison.
2808 * Changes in version 2.3a, 2006-09-13:
2810 ** Instead of %union, you can define and use your own union type
2811 YYSTYPE if your grammar contains at least one <type> tag.
2812 Your YYSTYPE need not be a macro; it can be a typedef.
2813 This change is for compatibility with other Yacc implementations,
2814 and is required by POSIX.
2816 ** Locations columns and lines start at 1.
2817 In accordance with the GNU Coding Standards and Emacs.
2819 ** You may now declare per-type and default %destructor's and %printer's:
2823 %union { char *string; }
2824 %token <string> STRING1
2825 %token <string> STRING2
2826 %type <string> string1
2827 %type <string> string2
2828 %union { char character; }
2829 %token <character> CHR
2830 %type <character> chr
2831 %destructor { free ($$); } %symbol-default
2832 %destructor { free ($$); printf ("%d", @$.first_line); } STRING1 string1
2833 %destructor { } <character>
2835 guarantees that, when the parser discards any user-defined symbol that has a
2836 semantic type tag other than "<character>", it passes its semantic value to
2837 "free". However, when the parser discards a "STRING1" or a "string1", it
2838 also prints its line number to "stdout". It performs only the second
2839 "%destructor" in this case, so it invokes "free" only once.
2841 [Although we failed to mention this here in the 2.3a release, the default
2842 %destructor's and %printer's were experimental, and they were rewritten in
2845 ** Except for LALR(1) parsers in C with POSIX Yacc emulation enabled (with "-y",
2846 "--yacc", or "%yacc"), Bison no longer generates #define statements for
2847 associating token numbers with token names. Removing the #define statements
2848 helps to sanitize the global namespace during preprocessing, but POSIX Yacc
2849 requires them. Bison still generates an enum for token names in all cases.
2851 ** Handling of traditional Yacc prologue blocks is now more consistent but
2852 potentially incompatible with previous releases of Bison.
2854 As before, you declare prologue blocks in your grammar file with the
2855 "%{ ... %}" syntax. To generate the pre-prologue, Bison concatenates all
2856 prologue blocks that you've declared before the first %union. To generate
2857 the post-prologue, Bison concatenates all prologue blocks that you've
2858 declared after the first %union.
2860 Previous releases of Bison inserted the pre-prologue into both the header
2861 file and the code file in all cases except for LALR(1) parsers in C. In the
2862 latter case, Bison inserted it only into the code file. For parsers in C++,
2863 the point of insertion was before any token definitions (which associate
2864 token numbers with names). For parsers in C, the point of insertion was
2865 after the token definitions.
2867 Now, Bison never inserts the pre-prologue into the header file. In the code
2868 file, it always inserts it before the token definitions.
2870 ** Bison now provides a more flexible alternative to the traditional Yacc
2871 prologue blocks: %before-header, %start-header, %end-header, and
2874 For example, the following declaration order in the grammar file reflects the
2875 order in which Bison will output these code blocks. However, you are free to
2876 declare these code blocks in your grammar file in whatever order is most
2880 /* Bison treats this block like a pre-prologue block: it inserts it into
2881 * the code file before the contents of the header file. It does *not*
2882 * insert it into the header file. This is a good place to put
2883 * #include's that you want at the top of your code file. A common
2884 * example is '#include "system.h"'. */
2887 /* Bison inserts this block into both the header file and the code file.
2888 * In both files, the point of insertion is before any Bison-generated
2889 * token, semantic type, location type, and class definitions. This is a
2890 * good place to define %union dependencies, for example. */
2893 /* Unlike the traditional Yacc prologue blocks, the output order for the
2894 * new %*-header blocks is not affected by their declaration position
2895 * relative to any %union in the grammar file. */
2898 /* Bison inserts this block into both the header file and the code file.
2899 * In both files, the point of insertion is after the Bison-generated
2900 * definitions. This is a good place to declare or define public
2901 * functions or data structures that depend on the Bison-generated
2905 /* Bison treats this block like a post-prologue block: it inserts it into
2906 * the code file after the contents of the header file. It does *not*
2907 * insert it into the header file. This is a good place to declare or
2908 * define internal functions or data structures that depend on the
2909 * Bison-generated definitions. */
2912 If you have multiple occurrences of any one of the above declarations, Bison
2913 will concatenate the contents in declaration order.
2915 [Although we failed to mention this here in the 2.3a release, the prologue
2916 alternatives were experimental, and they were rewritten in future versions.]
2918 ** The option "--report=look-ahead" has been changed to "--report=lookahead".
2919 The old spelling still works, but is not documented and may be removed
2920 in a future release.
2922 * Changes in version 2.3, 2006-06-05:
2924 ** GLR grammars should now use "YYRECOVERING ()" instead of "YYRECOVERING",
2925 for compatibility with LALR(1) grammars.
2927 ** It is now documented that any definition of YYSTYPE or YYLTYPE should
2928 be to a type name that does not contain parentheses or brackets.
2930 * Changes in version 2.2, 2006-05-19:
2932 ** The distribution terms for all Bison-generated parsers now permit
2933 using the parsers in nonfree programs. Previously, this permission
2934 was granted only for Bison-generated LALR(1) parsers in C.
2936 ** %name-prefix changes the namespace name in C++ outputs.
2938 ** The C++ parsers export their token_type.
2940 ** Bison now allows multiple %union declarations, and concatenates
2941 their contents together.
2943 ** New warning: unused values
2944 Right-hand side symbols whose values are not used are reported,
2945 if the symbols have destructors. For instance:
2947 exp: exp "?" exp ":" exp { $1 ? $1 : $3; }
2951 will trigger a warning about $$ and $5 in the first rule, and $3 in
2952 the second ($1 is copied to $$ by the default rule). This example
2953 most likely contains three errors, and could be rewritten as:
2955 exp: exp "?" exp ":" exp
2956 { $$ = $1 ? $3 : $5; free ($1 ? $5 : $3); free ($1); }
2958 { $$ = $1 ? $1 : $3; if ($1) free ($3); }
2961 However, if the original actions were really intended, memory leaks
2962 and all, the warnings can be suppressed by letting Bison believe the
2963 values are used, e.g.:
2965 exp: exp "?" exp ":" exp { $1 ? $1 : $3; (void) ($$, $5); }
2966 | exp "+" exp { $$ = $1; (void) $3; }
2969 If there are midrule actions, the warning is issued if no action
2970 uses it. The following triggers no warning: $1 and $3 are used.
2972 exp: exp { push ($1); } '+' exp { push ($3); sum (); };
2974 The warning is intended to help catching lost values and memory leaks.
2975 If a value is ignored, its associated memory typically is not reclaimed.
2977 ** %destructor vs. YYABORT, YYACCEPT, and YYERROR.
2978 Destructors are now called when user code invokes YYABORT, YYACCEPT,
2979 and YYERROR, for all objects on the stack, other than objects
2980 corresponding to the right-hand side of the current rule.
2982 ** %expect, %expect-rr
2983 Incorrect numbers of expected conflicts are now actual errors,
2984 instead of warnings.
2986 ** GLR, YACC parsers.
2987 The %parse-params are available in the destructors (and the
2988 experimental printers) as per the documentation.
2990 ** Bison now warns if it finds a stray "$" or "@" in an action.
2992 ** %require "VERSION"
2993 This specifies that the grammar file depends on features implemented
2994 in Bison version VERSION or higher.
2996 ** lalr1.cc: The token and value types are now class members.
2997 The tokens were defined as free form enums and cpp macros. YYSTYPE
2998 was defined as a free form union. They are now class members:
2999 tokens are enumerations of the "yy::parser::token" struct, and the
3000 semantic values have the "yy::parser::semantic_type" type.
3002 If you do not want or can update to this scheme, the directive
3003 '%define "global_tokens_and_yystype" "1"' triggers the global
3004 definition of tokens and YYSTYPE. This change is suitable both
3005 for previous releases of Bison, and this one.
3007 If you wish to update, then make sure older version of Bison will
3008 fail using '%require "2.2"'.
3010 ** DJGPP support added.
3012 * Changes in version 2.1, 2005-09-16:
3014 ** The C++ lalr1.cc skeleton supports %lex-param.
3016 ** Bison-generated parsers now support the translation of diagnostics like
3017 "syntax error" into languages other than English. The default
3018 language is still English. For details, please see the new
3019 Internationalization section of the Bison manual. Software
3020 distributors should also see the new PACKAGING file. Thanks to
3021 Bruno Haible for this new feature.
3023 ** Wording in the Bison-generated parsers has been changed slightly to
3024 simplify translation. In particular, the message "memory exhausted"
3025 has replaced "parser stack overflow", as the old message was not
3026 always accurate for modern Bison-generated parsers.
3028 ** Destructors are now called when the parser aborts, for all symbols left
3029 behind on the stack. Also, the start symbol is now destroyed after a
3030 successful parse. In both cases, the behavior was formerly inconsistent.
3032 ** When generating verbose diagnostics, Bison-generated parsers no longer
3033 quote the literal strings associated with tokens. For example, for
3034 a syntax error associated with '%token NUM "number"' they might
3035 print 'syntax error, unexpected number' instead of 'syntax error,
3036 unexpected "number"'.
3038 * Changes in version 2.0, 2004-12-25:
3040 ** Possibly-incompatible changes
3042 - Bison-generated parsers no longer default to using the alloca function
3043 (when available) to extend the parser stack, due to widespread
3044 problems in unchecked stack-overflow detection. You can "#define
3045 YYSTACK_USE_ALLOCA 1" to require the use of alloca, but please read
3046 the manual to determine safe values for YYMAXDEPTH in that case.
3048 - Error token location.
3049 During error recovery, the location of the syntax error is updated
3050 to cover the whole sequence covered by the error token: it includes
3051 the shifted symbols thrown away during the first part of the error
3052 recovery, and the lookahead rejected during the second part.
3054 - Semicolon changes:
3055 . Stray semicolons are no longer allowed at the start of a grammar.
3056 . Semicolons are now required after in-grammar declarations.
3058 - Unescaped newlines are no longer allowed in character constants or
3059 string literals. They were never portable, and GCC 3.4.0 has
3060 dropped support for them. Better diagnostics are now generated if
3061 forget a closing quote.
3063 - NUL bytes are no longer allowed in Bison string literals, unfortunately.
3067 - GLR grammars now support locations.
3069 - New directive: %initial-action.
3070 This directive allows the user to run arbitrary code (including
3071 initializing @$) from yyparse before parsing starts.
3073 - A new directive "%expect-rr N" specifies the expected number of
3074 reduce/reduce conflicts in GLR parsers.
3076 - %token numbers can now be hexadecimal integers, e.g., "%token FOO 0x12d".
3077 This is a GNU extension.
3079 - The option "--report=lookahead" was changed to "--report=look-ahead".
3080 [However, this was changed back after 2.3.]
3082 - Experimental %destructor support has been added to lalr1.cc.
3084 - New configure option --disable-yacc, to disable installation of the
3085 yacc command and -ly library introduced in 1.875 for POSIX conformance.
3089 - For now, %expect-count violations are now just warnings, not errors.
3090 This is for compatibility with Bison 1.75 and earlier (when there are
3091 reduce/reduce conflicts) and with Bison 1.30 and earlier (when there
3092 are too many or too few shift/reduce conflicts). However, in future
3093 versions of Bison we plan to improve the %expect machinery so that
3094 these violations will become errors again.
3096 - Within Bison itself, numbers (e.g., goto numbers) are no longer
3097 arbitrarily limited to 16-bit counts.
3099 - Semicolons are now allowed before "|" in grammar rules, as POSIX requires.
3101 * Changes in version 1.875, 2003-01-01:
3103 ** The documentation license has been upgraded to version 1.2
3104 of the GNU Free Documentation License.
3106 ** syntax error processing
3108 - In Yacc-style parsers YYLLOC_DEFAULT is now used to compute error
3109 locations too. This fixes bugs in error-location computation.
3112 It is now possible to reclaim the memory associated to symbols
3113 discarded during error recovery. This feature is still experimental.
3116 This new directive is preferred over YYERROR_VERBOSE.
3118 - #defining yyerror to steal internal variables is discouraged.
3119 It is not guaranteed to work forever.
3121 ** POSIX conformance
3123 - Semicolons are once again optional at the end of grammar rules.
3124 This reverts to the behavior of Bison 1.33 and earlier, and improves
3125 compatibility with Yacc.
3127 - "parse error" -> "syntax error"
3128 Bison now uniformly uses the term "syntax error"; formerly, the code
3129 and manual sometimes used the term "parse error" instead. POSIX
3130 requires "syntax error" in diagnostics, and it was thought better to
3133 - The documentation now emphasizes that yylex and yyerror must be
3134 declared before use. C99 requires this.
3136 - Bison now parses C99 lexical constructs like UCNs and
3137 backslash-newline within C escape sequences, as POSIX 1003.1-2001 requires.
3139 - File names are properly escaped in C output. E.g., foo\bar.y is
3140 output as "foo\\bar.y".
3142 - Yacc command and library now available
3143 The Bison distribution now installs a "yacc" command, as POSIX requires.
3144 Also, Bison now installs a small library liby.a containing
3145 implementations of Yacc-compatible yyerror and main functions.
3146 This library is normally not useful, but POSIX requires it.
3148 - Type clashes now generate warnings, not errors.
3150 - If the user does not define YYSTYPE as a macro, Bison now declares it
3151 using typedef instead of defining it as a macro.
3152 For consistency, YYLTYPE is also declared instead of defined.
3154 ** Other compatibility issues
3156 - %union directives can now have a tag before the "{", e.g., the
3157 directive "%union foo {...}" now generates the C code
3158 "typedef union foo { ... } YYSTYPE;"; this is for Yacc compatibility.
3159 The default union tag is "YYSTYPE", for compatibility with Solaris 9 Yacc.
3160 For consistency, YYLTYPE's struct tag is now "YYLTYPE" not "yyltype".
3161 This is for compatibility with both Yacc and Bison 1.35.
3163 - ";" is output before the terminating "}" of an action, for
3164 compatibility with Bison 1.35.
3166 - Bison now uses a Yacc-style format for conflict reports, e.g.,
3167 "conflicts: 2 shift/reduce, 1 reduce/reduce".
3169 - "yystype" and "yyltype" are now obsolescent macros instead of being
3170 typedefs or tags; they are no longer documented and are planned to be
3171 withdrawn in a future release.
3176 Users of Bison have to decide how they handle the portability of the
3179 - "parsing stack overflow..." -> "parser stack overflow"
3180 GLR parsers now report "parser stack overflow" as per the Bison manual.
3182 ** %parse-param and %lex-param
3183 The macros YYPARSE_PARAM and YYLEX_PARAM provide a means to pass
3184 additional context to yyparse and yylex. They suffer from several
3187 - a single argument only can be added,
3188 - their types are weak (void *),
3189 - this context is not passed to ancillary functions such as yyerror,
3190 - only yacc.c parsers support them.
3192 The new %parse-param/%lex-param directives provide a more precise control.
3195 %parse-param {int *nastiness}
3196 %lex-param {int *nastiness}
3197 %parse-param {int *randomness}
3199 results in the following signatures:
3201 int yylex (int *nastiness);
3202 int yyparse (int *nastiness, int *randomness);
3204 or, if both %pure-parser and %locations are used:
3206 int yylex (YYSTYPE *lvalp, YYLTYPE *llocp, int *nastiness);
3207 int yyparse (int *nastiness, int *randomness);
3209 ** Bison now warns if it detects conflicting outputs to the same file,
3210 e.g., it generates a warning for "bison -d -o foo.h foo.y" since
3211 that command outputs both code and header to foo.h.
3213 ** #line in output files
3214 - --no-line works properly.
3216 ** Bison can no longer be built by a K&R C compiler; it requires C89 or
3217 later to be built. This change originally took place a few versions
3218 ago, but nobody noticed until we recently asked someone to try
3219 building Bison with a K&R C compiler.
3221 * Changes in version 1.75, 2002-10-14:
3223 ** Bison should now work on 64-bit hosts.
3225 ** Indonesian translation thanks to Tedi Heriyanto.
3228 Fix spurious parse errors.
3231 Some people redefine yyerror to steal yyparse' private variables.
3232 Reenable this trick until an official feature replaces it.
3235 In agreement with POSIX and with other Yaccs, leaving a default
3236 action is valid when $$ is untyped, and $1 typed:
3240 but the converse remains an error:
3244 ** Values of midrule actions
3247 foo: { ... } { $$ = $1; } ...
3249 was incorrectly rejected: $1 is defined in the second midrule
3250 action, and is equal to the $$ of the first midrule action.
3252 * Changes in version 1.50, 2002-10-04:
3257 causes Bison to produce a Generalized LR (GLR) parser, capable of handling
3258 almost any context-free grammar, ambiguous or not. The new declarations
3259 %dprec and %merge on grammar rules allow parse-time resolution of
3260 ambiguities. Contributed by Paul Hilfinger.
3262 Unfortunately Bison 1.50 does not work properly on 64-bit hosts
3263 like the Alpha, so please stick to 32-bit hosts for now.
3266 When not in Yacc compatibility mode, when the output file was not
3267 specified, running "bison foo/bar.y" created "foo/bar.c". It
3268 now creates "bar.c".
3271 The undefined token was systematically mapped to 2 which prevented
3272 the use of 2 by the user. This is no longer the case.
3274 ** Unknown token numbers
3275 If yylex returned an out of range value, yyparse could die. This is
3279 According to POSIX, the error token must be 256.
3280 Bison extends this requirement by making it a preference: *if* the
3281 user specified that one of her tokens is numbered 256, then error
3282 will be mapped onto another number.
3284 ** Verbose error messages
3285 They no longer report "..., expecting error or..." for states where
3286 error recovery is possible.
3289 Defaults to "$end" instead of "$".
3291 ** Error recovery now conforms to documentation and to POSIX
3292 When a Bison-generated parser encounters a syntax error, it now pops
3293 the stack until it finds a state that allows shifting the error
3294 token. Formerly, it popped the stack until it found a state that
3295 allowed some non-error action other than a default reduction on the
3296 error token. The new behavior has long been the documented behavior,
3297 and has long been required by POSIX. For more details, please see
3298 Paul Eggert, "Reductions during Bison error handling" (2002-05-20)
3299 <http://lists.gnu.org/archive/html/bug-bison/2002-05/msg00038.html>.
3302 Popped tokens and nonterminals are now reported.
3305 Larger grammars are now supported (larger token numbers, larger grammar
3306 size (= sum of the LHS and RHS lengths), larger LALR tables).
3307 Formerly, many of these numbers ran afoul of 16-bit limits;
3308 now these limits are 32 bits on most hosts.
3310 ** Explicit initial rule
3311 Bison used to play hacks with the initial rule, which the user does
3312 not write. It is now explicit, and visible in the reports and
3316 Before, Bison reported the useless rules, but, although not used,
3317 included them in the parsers. They are now actually removed.
3319 ** Useless rules, useless nonterminals
3320 They are now reported, as a warning, with their locations.
3322 ** Rules never reduced
3323 Rules that can never be reduced because of conflicts are now
3326 ** Incorrect "Token not used"
3327 On a grammar such as
3329 %token useless useful
3331 exp: '0' %prec useful;
3333 where a token was used to set the precedence of the last rule,
3334 bison reported both "useful" and "useless" as useless tokens.
3336 ** Revert the C++ namespace changes introduced in 1.31
3337 as they caused too many portability hassles.
3339 ** Default locations
3340 By an accident of design, the default computation of @$ was
3341 performed after another default computation was performed: @$ = @1.
3342 The latter is now removed: YYLLOC_DEFAULT is fully responsible of
3343 the computation of @$.
3345 ** Token end-of-file
3346 The token end of file may be specified by the user, in which case,
3347 the user symbol is used in the reports, the graphs, and the verbose
3348 error messages instead of "$end", which remains being the default.
3352 %token MYEOF 0 "end of file"
3355 This old option, which has been broken for ages, is removed.
3358 Brazilian Portuguese, thanks to Alexandre Folle de Menezes.
3359 Croatian, thanks to Denis Lackovic.
3361 ** Incorrect token definitions
3364 bison used to output
3367 ** Token definitions as enums
3368 Tokens are output both as the traditional #define's, and, provided
3369 the compiler supports ANSI C or is a C++ compiler, as enums.
3370 This lets debuggers display names instead of integers.
3373 In addition to --verbose, bison supports --report=THINGS, which
3374 produces additional information:
3376 complete the core item sets with their closure
3377 - lookahead [changed to "look-ahead" in 1.875e through 2.3, but changed back]
3378 explicitly associate lookahead tokens to items
3380 describe shift/reduce conflicts solving.
3381 Bison used to systematically output this information on top of
3382 the report. Solved conflicts are now attached to their states.
3385 Previous versions don't complain when there is a type clash on
3386 the default action if the rule has a midrule action, such as in:
3394 ** GNU M4 is now required when using Bison.
3396 * Changes in version 1.35, 2002-03-25:
3399 Some projects use Bison's C parser with C++ compilers, and define
3400 YYSTYPE as a class. The recent adjustment of C parsers for data
3401 alignment and 64 bit architectures made this impossible.
3403 Because for the time being no real solution for C++ parser
3404 generation exists, kludges were implemented in the parser to
3405 maintain this use. In the future, when Bison has C++ parsers, this
3406 kludge will be disabled.
3408 This kludge also addresses some C++ problems when the stack was
3411 * Changes in version 1.34, 2002-03-12:
3413 ** File name clashes are detected
3414 $ bison foo.y -d -o foo.x
3415 fatal error: header and parser would both be named "foo.x"
3417 ** A missing ";" at the end of a rule triggers a warning
3418 In accordance with POSIX, and in agreement with other
3419 Yacc implementations, Bison will mandate this semicolon in the near
3420 future. This eases the implementation of a Bison parser of Bison
3421 grammars by making this grammar LALR(1) instead of LR(2). To
3422 facilitate the transition, this release introduces a warning.
3424 ** Revert the C++ namespace changes introduced in 1.31, as they caused too
3425 many portability hassles.
3427 ** DJGPP support added.
3429 ** Fix test suite portability problems.
3431 * Changes in version 1.33, 2002-02-07:
3434 Groff could not be compiled for the definition of size_t was lacking
3435 under some conditions.
3440 * Changes in version 1.32, 2002-01-23:
3442 ** Fix Yacc output file names
3444 ** Portability fixes
3446 ** Italian, Dutch translations
3448 * Changes in version 1.31, 2002-01-14:
3452 ** GNU Gettext and %expect
3453 GNU Gettext asserts 10 s/r conflicts, but there are 7. Now that
3454 Bison dies on incorrect %expectations, we fear there will be
3455 too many bug reports for Gettext, so _for the time being_, %expect
3456 does not trigger an error when the input file is named "plural.y".
3458 ** Use of alloca in parsers
3459 If YYSTACK_USE_ALLOCA is defined to 0, then the parsers will use
3460 malloc exclusively. Since 1.29, but was not NEWS'ed.
3462 alloca is used only when compiled with GCC, to avoid portability
3465 ** yyparse now returns 2 if memory is exhausted; formerly it dumped core.
3467 ** When the generated parser lacks debugging code, YYDEBUG is now 0
3468 (as POSIX requires) instead of being undefined.
3471 Bison has always permitted actions such as { $$ = $1 }: it adds the
3472 ending semicolon. Now if in Yacc compatibility mode, the semicolon
3473 is no longer output: one has to write { $$ = $1; }.
3475 ** Better C++ compliance
3476 The output parsers try to respect C++ namespaces.
3477 [This turned out to be a failed experiment, and it was reverted later.]
3480 Fixed bugs when reporting useless nonterminals.
3483 The parsers work properly on 64 bit hosts.
3486 Some calls to strerror resulted in scrambled or missing error messages.
3489 When the number of shift/reduce conflicts is correct, don't issue
3492 ** The verbose report includes the rule line numbers.
3494 ** Rule line numbers are fixed in traces.
3496 ** Swedish translation
3499 Verbose parse error messages from the parsers are better looking.
3500 Before: parse error: unexpected `'/'', expecting `"number"' or `'-'' or `'(''
3501 Now: parse error: unexpected '/', expecting "number" or '-' or '('
3503 ** Fixed parser memory leaks.
3504 When the generated parser was using malloc to extend its stacks, the
3505 previous allocations were not freed.
3507 ** Fixed verbose output file.
3508 Some newlines were missing.
3509 Some conflicts in state descriptions were missing.
3511 ** Fixed conflict report.
3512 Option -v was needed to get the result.
3516 Mismatches are errors, not warnings.
3518 ** Fixed incorrect processing of some invalid input.
3520 ** Fixed CPP guards: 9foo.h uses BISON_9FOO_H instead of 9FOO_H.
3522 ** Fixed some typos in the documentation.
3524 ** %token MY_EOF 0 is supported.
3525 Before, MY_EOF was silently renumbered as 257.
3527 ** doc/refcard.tex is updated.
3529 ** %output, %file-prefix, %name-prefix.
3533 New, aliasing "--output-file".
3535 * Changes in version 1.30, 2001-10-26:
3537 ** "--defines" and "--graph" have now an optional argument which is the
3538 output file name. "-d" and "-g" do not change; they do not take any
3541 ** "%source_extension" and "%header_extension" are removed, failed
3544 ** Portability fixes.
3546 * Changes in version 1.29, 2001-09-07:
3548 ** The output file does not define const, as this caused problems when used
3549 with common autoconfiguration schemes. If you still use ancient compilers
3550 that lack const, compile with the equivalent of the C compiler option
3551 "-Dconst=". Autoconf's AC_C_CONST macro provides one way to do this.
3553 ** Added "-g" and "--graph".
3555 ** The Bison manual is now distributed under the terms of the GNU FDL.
3557 ** The input and the output files has automatically a similar extension.
3559 ** Russian translation added.
3561 ** NLS support updated; should hopefully be less troublesome.
3563 ** Added the old Bison reference card.
3565 ** Added "--locations" and "%locations".
3567 ** Added "-S" and "--skeleton".
3569 ** "%raw", "-r", "--raw" is disabled.
3571 ** Special characters are escaped when output. This solves the problems
3572 of the #line lines with path names including backslashes.
3575 "%yacc", "%fixed_output_files", "%defines", "%no_parser", "%verbose",
3576 "%debug", "%source_extension" and "%header_extension".
3579 Automatic location tracking.
3581 * Changes in version 1.28, 1999-07-06:
3583 ** Should compile better now with K&R compilers.
3587 ** Fixed a problem with escaping the double quote character.
3589 ** There is now a FAQ.
3591 * Changes in version 1.27:
3593 ** The make rule which prevented bison.simple from being created on
3594 some systems has been fixed.
3596 * Changes in version 1.26:
3598 ** Bison now uses Automake.
3600 ** New mailing lists: <bug-bison@gnu.org> and <help-bison@gnu.org>.
3602 ** Token numbers now start at 257 as previously documented, not 258.
3604 ** Bison honors the TMPDIR environment variable.
3606 ** A couple of buffer overruns have been fixed.
3608 ** Problems when closing files should now be reported.
3610 ** Generated parsers should now work even on operating systems which do
3611 not provide alloca().
3613 * Changes in version 1.25, 1995-10-16:
3615 ** Errors in the input grammar are not fatal; Bison keeps reading
3616 the grammar file, and reports all the errors found in it.
3618 ** Tokens can now be specified as multiple-character strings: for
3619 example, you could use "<=" for a token which looks like <=, instead
3620 of choosing a name like LESSEQ.
3622 ** The %token_table declaration says to write a table of tokens (names
3623 and numbers) into the parser file. The yylex function can use this
3624 table to recognize multiple-character string tokens, or for other
3627 ** The %no_lines declaration says not to generate any #line preprocessor
3628 directives in the parser file.
3630 ** The %raw declaration says to use internal Bison token numbers, not
3631 Yacc-compatible token numbers, when token names are defined as macros.
3633 ** The --no-parser option produces the parser tables without including
3634 the parser engine; a project can now use its own parser engine.
3635 The actions go into a separate file called NAME.act, in the form of
3636 a switch statement body.
3638 * Changes in version 1.23:
3640 The user can define YYPARSE_PARAM as the name of an argument to be
3641 passed into yyparse. The argument should have type void *. It should
3642 actually point to an object. Grammar actions can access the variable
3643 by casting it to the proper pointer type.
3645 Line numbers in output file corrected.
3647 * Changes in version 1.22:
3649 --help option added.
3651 * Changes in version 1.20:
3653 Output file does not redefine const for C++.
3657 Copyright (C) 1995-2015, 2018-2019 Free Software Foundation, Inc.
3659 This file is part of Bison, the GNU Parser Generator.
3661 This program is free software: you can redistribute it and/or modify
3662 it under the terms of the GNU General Public License as published by
3663 the Free Software Foundation, either version 3 of the License, or
3664 (at your option) any later version.
3666 This program is distributed in the hope that it will be useful,
3667 but WITHOUT ANY WARRANTY; without even the implied warranty of
3668 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3669 GNU General Public License for more details.
3671 You should have received a copy of the GNU General Public License
3672 along with this program. If not, see <http://www.gnu.org/licenses/>.
3674 LocalWords: yacc YYBACKUP glr GCC lalr ArrayIndexOutOfBoundsException nullptr
3675 LocalWords: cplusplus liby rpl fprintf mfcalc Wyacc stmt cond expr mk sym lr
3676 LocalWords: IELR ielr Lookahead YYERROR nonassoc LALR's api lookaheads yychar
3677 LocalWords: destructor lookahead YYRHSLOC YYLLOC Rhs ifndef YYFAIL cpp sr rr
3678 LocalWords: preprocessor initializer Wno Wnone Werror FreeBSD prec livelocks
3679 LocalWords: Solaris AIX UX RHEL Tru LHS gcc's Wundef YYENABLE NLS YYLTYPE VCG
3680 LocalWords: yyerror cpp's Wunused yylval yylloc prepend yyparse yylex yypush
3681 LocalWords: Graphviz xml nonterminals midrule destructor's YYSTYPE typedef ly
3682 LocalWords: CHR chr printf stdout namespace preprocessing enum pre include's
3683 LocalWords: YYRECOVERING nonfree destructors YYABORT YYACCEPT params enums de
3684 LocalWords: struct yystype DJGPP lex param Haible NUM alloca YYSTACK NUL goto
3685 LocalWords: YYMAXDEPTH Unescaped UCNs YYLTYPE's yyltype typedefs inline Yaccs
3686 LocalWords: Heriyanto Reenable dprec Hilfinger Eggert MYEOF Folle Menezes EOF
3687 LocalWords: Lackovic define's itemset Groff Gettext malloc NEWS'ed YYDEBUG YY
3688 LocalWords: namespaces strerror const autoconfiguration Dconst Autoconf's FDL
3689 LocalWords: Automake TMPDIR LESSEQ ylwrap endif yydebug YYTOKEN YYLSP ival hh
3690 LocalWords: extern YYTOKENTYPE TOKENTYPE yytokentype tokentype STYPE lval pdf
3691 LocalWords: lang yyoutput dvi html ps POSIX lvalp llocp Wother nterm arg init
3692 LocalWords: TOK calc yyo fval Wconflicts parsers yystackp yyval yynerrs
3693 LocalWords: Théophile Ranquet Santet fno fnone stype associativity Tolmer
3694 LocalWords: Wprecedence Rassoul Wempty Paolo Bonzini parser's Michiel loc
3695 LocalWords: redeclaration sval fcaret reentrant XSLT xsl Wmaybe yyvsp Tedi
3696 LocalWords: pragmas noreturn untyped Rozenman unexpanded Wojciech Polak
3697 LocalWords: Alexandre MERCHANTABILITY yytype emplace ptr automove lvalues
3698 LocalWords: nonterminal yy args Pragma dereference yyformat rhs docdir bw
3699 LocalWords: Redeclarations rpcalc Autoconf YFLAGS Makefiles PROG DECL num
3700 LocalWords: Heimbigner AST src ast Makefile srcdir MinGW xxlex XXSTYPE
3701 LocalWords: XXLTYPE strictfp IDEs ffixit fdiagnostics parseable fixits
3702 LocalWords: Wdeprecated yytext Variadic variadic yyrhs yyphrs RCS README
3703 LocalWords: noexcept constexpr ispell american deprecations backend
3706 ispell-dictionary: "american"