Bison 2.7 is released

Akim Demaille <>
Wed, 12 Dec 2012 17:12:51 +0100

          From comp.compilers

Related articles
Bison 2.7 is released (Akim Demaille) (2012-12-12)
| List of all articles for this month |

From: Akim Demaille <>
Newsgroups: comp.compilers
Date: Wed, 12 Dec 2012 17:12:51 +0100
Organization: Compilers Central
Keywords: bison, available
Posted-Date: 12 Dec 2012 12:44:26 EST

The Bison team is happy to announce the release of Bison 2.7. There are
many nice new features (especially in the way the diagnostics are produced,
and in the graph representation of the parser), implemented by Thiophile
Ranquet for most of them. See the list below.


Here are the compressed sources: (3.0MB) (1.7MB)

Here are the GPG detached signatures[*]:

Use a mirror for higher download bandwidth:

[*] Use a .sig file to verify that the corresponding file (without the
.sig suffix) is intact. First, be sure to download both the .sig file
and the corresponding tarball. Then, run a command like this:

    gpg --verify bison-2.7.tar.gz.sig

If that command fails because you don't have the required public key,
then run this command to import it:

    gpg --keyserver --recv-keys 0DDCAA3278D5264E

and rerun the 'gpg --verify' command.

This release was bootstrapped with the following tools:
    Autoconf 2.69
    Automake 1.12.5
    Flex 2.5.37
    Gettext 0.18.1
    Gnulib v0.0-7741-g4a8c422

Since I believe the latest announcement here was about Bison 2.5,
please find below the user visible changes since then.

* Noteworthy changes in release 2.7 (2012-12-12) [stable]

** Bug fixes

    Warnings about uninitialized yylloc in yyparse have been fixed.

    Restored C90 compliance (yet no report was ever made).

** Diagnostics are improved

*** Changes in the format of error messages

    This used to be the format of many error reports:

        input.y:2.7-12: %type redeclaration for exp
        input.y:1.7-12: previous declaration

    It is now:

        input.y:2.7-12: error: %type redeclaration for exp
        input.y:1.7-12: previous declaration

*** New format for error reports: carets

    Caret errors have been added to Bison:

        input.y:2.7-12: error: %type redeclaration for exp
          %type <sval> exp
        input.y:1.7-12: previous declaration
          %type <ival> exp


        input.y:3.20-23: error: ambiguous reference: '$exp'
          exp: exp '+' exp { $exp = $1 + $3; };
        input.y:3.1-3: refers to: $exp at $$
          exp: exp '+' exp { $exp = $1 + $3; };
        input.y:3.6-8: refers to: $exp at $1
          exp: exp '+' exp { $exp = $1 + $3; };
        input.y:3.14-16: refers to: $exp at $3
          exp: exp '+' exp { $exp = $1 + $3; };

    The default behaviour for now is still not to display these unless
    explictly asked with -fcaret (or -fall). However, in a later release, it
    will be made the default behavior (but may still be deactivated with

** New value for %define variable: api.pure full

    The %define variable api.pure requests a pure (reentrant) parser. However,
    for historical reasons, using it in a location-tracking Yacc parser
    resulted in a yyerror function that did not take a location as a
    parameter. With this new value, the user may request a better pure parser,
    where yyerror does take a location as a parameter (in location-tracking

    The use of "%define api.pure true" is deprecated in favor of this new
    "%define api.pure full".

** New %define variable: api.location.type (,,

    The %define variable api.location.type defines the name of the type to use
    for locations. When defined, Bison no longer generates the position.hh
    and location.hh files, nor does the parser will include them: the user is
    then responsible to define her type.

    This can be used in programs with several parsers to factor their location
    and position files: let one of them generate them, and the others just use

    This feature was actually introduced, but not documented, in Bison 2.5,
    under the name "location_type" (which is maintained for backward

    For consistency,'s %define variables location_type and
    position_type are deprecated in favor of api.location.type and

** Exception safety (

    The parse function now catches exceptions, uses the %destructors to
    release memory (the lookahead symbol and the symbols pushed on the stack)
    before re-throwing the exception.

    This feature is somewhat experimental. User feedback would be

** Graph improvements in DOT and XSLT

    The graphical presentation of the states is more readable: their shape is
    now rectangular, the state number is clearly displayed, and the items are
    numbered and left-justified.

    The reductions are now explicitly represented as transitions to other
    diamond shaped nodes.

    These changes are present in both --graph output and xml2dot.xsl XSLT
    processing, with minor (documented) differences.

** %language is no longer an experimental feature.

    The introduction of this feature, in 2.4, was four years ago. The
    --language option and the %language directive are no longer experimental.

** Documentation

    The sections about shift/reduce and reduce/reduce conflicts resolution
    have been fixed and extended.

    Although introduced more than four years ago, XML and Graphviz reports
    were not properly documented.

    The translation of mid-rule actions is now described.

* Noteworthy changes in release 2.6.5 (2012-11-07) [stable]

    We consider compiler warnings about Bison generated parsers to be bugs.
    Rather than working around them in your own project, please consider
    reporting them to us.

** Bug fixes

    Warnings about uninitialized yylval and/or yylloc for push parsers with a
    pure interface have been fixed for GCC 4.0 up to 4.8, and Clang 2.9 to

    Other issues in the test suite have been addressed.

    Nul characters are correctly displayed in error messages.

    When possible, yylloc is correctly initialized before calling yylex. It
    is no longer necessary to initialize it in the %initial-action.

* Noteworthy changes in release 2.6.4 (2012-10-23) [stable]

    Bison 2.6.3's --version was incorrect. This release fixes this issue.

* Noteworthy changes in release 2.6.3 (2012-10-22) [stable]

** Bug fixes

    Bugs and portability issues in the test suite have been fixed.

    Some errors in translations have been addressed, and --help now directs
    users to the appropriate place to report them.

    Stray Info files shipped by accident are removed.

    Incorrect definitions of YY_, issued by yacc.c when no parser header is
    generated, are removed.

    All the generated headers are self-contained.

** Header guards (yacc.c, glr.c,

    In order to avoid collisions, the header guards are now
    YY_<PREFIX>_<FILE>_INCLUDED, instead of merely <PREFIX>_<FILE>.
    For instance the header generated from

        %define api.prefix "calc"
        %defines "lib/parse.h"

    will use YY_CALC_LIB_PARSE_H_INCLUDED as guard.

** Fix compiler warnings in the generated parser (yacc.c, glr.c)

    The compilation of pure parsers (%define api.pure) can trigger GCC
    warnings such as:

        input.c: In function 'yyparse':
        input.c:1503:12: warning: 'yylval' may be used uninitialized in this
                                                            function [-Wmaybe-uninitialized]
              *++yyvsp = yylval;

    This is now fixed; pragmas to avoid these warnings are no longer needed.

    Warnings from clang ("equality comparison with extraneous parentheses" and
    "function declared 'noreturn' should not return") have also been

* Noteworthy changes in release 2.6.2 (2012-08-03) [stable]

** Bug fixes

    Buffer overruns, complaints from Flex, and portability issues in the test
    suite have been fixed.

** Spaces in %lex- and %parse-param (,

    Trailing end-of-lines in %parse-param or %lex-param would result in
    invalid C++. This is fixed.

** Spurious spaces and end-of-lines

    The generated files no longer end (nor start) with empty lines.

* Noteworthy changes in release 2.6.1 (2012-07-30) [stable]

    Bison no longer executes user-specified M4 code when processing a grammar.

** Future Changes

    In addition to the removal of the features announced in Bison 2.6, the
    next major release will remove the "Temporary hack for adding a semicolon
    to the user action", as announced in the release 2.5. Instead of:

        exp: exp "+" exp { $$ = $1 + $3 };


        exp: exp "+" exp { $$ = $1 + $3; };

** Bug fixes

*** Type names are now properly escaped.

*** set_debug_level and debug_level work as expected.

*** Stray @ or $ in actions

    While Bison used to warn about stray $ or @ in action rules, it did not
    for other actions such as printers, destructors, or initial actions. It
    now does.

** Type names in actions

    For consistency with rule actions, it is now possible to qualify $$ by a
    type-name in destructors, printers, and initial actions. For instance:

        %printer { fprintf (yyo, "(%d, %f)", $<ival>$, $<fval>$); } <*> <>;

    will display two values for each typed and untyped symbol (provided
    that YYSTYPE has both "ival" and "fval" fields).

* Noteworthy changes in release 2.6 (2012-07-19) [stable]

** Future Changes

    The next major release of Bison will drop support for the following
    deprecated features. Please report disagreements to

*** K&R C parsers

    Support for generating parsers in K&R C will be removed. Parsers
    generated for C support ISO C90, and are tested with ISO C99 and ISO C11

*** Features deprecated since Bison 1.875

    The definitions of yystype and yyltype will be removed; use YYSTYPE and

    YYPARSE_PARAM and YYLEX_PARAM, deprecated in favor of %parse-param and
    %lex-param, will no longer be supported.

    Support for the preprocessor symbol YYERROR_VERBOSE will be removed, use

*** The generated header will be included (yacc.c)

    Instead of duplicating the content of the generated header (definition of
    YYSTYPE, yyparse declaration etc.), the generated parser will include it,
    as is already the case for GLR or C++ parsers. This change is deferred
    because existing versions of ylwrap (e.g., Automake 1.12.1) do not support

** Generated Parser Headers

*** Guards (yacc.c, glr.c,

    The generated headers are now guarded, as is already the case for C++
    parsers ( For instance, with --defines=foo.h:

        #ifndef YY_FOO_H
        # define YY_FOO_H
        #endif /* !YY_FOO_H */

*** New declarations (yacc.c, glr.c)

    The generated header now declares yydebug and yyparse. Both honor
    --name-prefix=bar_, and yield

        int bar_parse (void);

    rather than

        #define yyparse bar_parse
        int yyparse (void);

    in order to facilitate the inclusion of several parser headers inside a
    single compilation unit.

*** Exported symbols in C++

    The symbols YYTOKEN_TABLE and YYERROR_VERBOSE, which were defined in the
    header, are removed, as they prevent the possibility of including several
    generated headers from a single compilation unit.


    For the same reasons, the undocumented and unused macro YYLSP_NEEDED is no
    longer defined.

** New %define variable: api.prefix

    Now that the generated headers are more complete and properly protected
    against multiple inclusions, constant names, such as YYSTYPE are a
    problem. While yyparse and others are properly renamed by %name-prefix,
    YYSTYPE, YYDEBUG and others have never been affected by it. Because it
    would introduce backward compatibility issues in projects not expecting
    YYSTYPE to be renamed, instead of changing the behavior of %name-prefix,
    it is deprecated in favor of a new %define variable: api.prefix.

    The following examples compares both:

        %name-prefix "bar_" | %define api.prefix "bar_"
        %token <ival> FOO %token <ival> FOO
        %union { int ival; } %union { int ival; }
        %% %%
        exp: 'a'; exp: 'a';

    bison generates:

        #ifndef BAR_FOO_H #ifndef BAR_FOO_H
        # define BAR_FOO_H # define BAR_FOO_H

        /* Enabling traces. */ /* Enabling traces. */
        # ifndef YYDEBUG | # ifndef BAR_DEBUG
                                                                            > # if defined YYDEBUG
                                                                            > # if YYDEBUG
                                                                            > # define BAR_DEBUG 1
                                                                            > # else
                                                                            > # define BAR_DEBUG 0
                                                                            > # endif
                                                                            > # else
        # define YYDEBUG 0 | # define BAR_DEBUG 0
                                                                            > # endif
        # endif | # endif

        # if YYDEBUG | # if BAR_DEBUG
        extern int bar_debug; extern int bar_debug;
        # endif # endif

        /* Tokens. */ /* Tokens. */
        # ifndef YYTOKENTYPE | # ifndef BAR_TOKENTYPE
        # define YYTOKENTYPE | # define BAR_TOKENTYPE
              enum yytokentype { | enum bar_tokentype {
                  FOO = 258 FOO = 258
              }; };
        # endif # endif

        #if ! defined YYSTYPE \ | #if ! defined BAR_STYPE \
          && ! defined YYSTYPE_IS_DECLARED | && ! defined BAR_STYPE_IS_DECLARED
        typedef union YYSTYPE | typedef union BAR_STYPE
        { {
          int ival; int ival;
        } YYSTYPE; | } BAR_STYPE;
        # define YYSTYPE_IS_DECLARED 1 | # define BAR_STYPE_IS_DECLARED 1
        #endif #endif

        extern YYSTYPE bar_lval; | extern BAR_STYPE bar_lval;

        int bar_parse (void); int bar_parse (void);

        #endif /* !BAR_FOO_H */ #endif /* !BAR_FOO_H */

* Noteworthy changes in release 2.5.1 (2012-06-05) [stable]

** Future changes:

    The next major release will drop support for generating parsers in K&R C.

** yacc.c: YYBACKUP works as expected.

** glr.c improvements:

*** Location support is eliminated when not requested:

    GLR parsers used to include location-related code even when locations were
    not requested, and therefore not even usable.

*** __attribute__ is preserved:

    __attribute__ is no longer disabled when __STRICT_ANSI__ is defined (i.e.,
    when -std is passed to GCC).

** several fixes:

    The Java parser no longer throws ArrayIndexOutOfBoundsException if the
    first token leads to a syntax error. Some minor clean ups.

** Changes for C++:

*** C++11 compatibility:

    C and C++ parsers use "nullptr" instead of "0" when __cplusplus is 201103L
    or higher.

*** Header guards

    The header files such as "parser.hh", "location.hh", etc. used a constant
    name for preprocessor guards, for instance:

        #ifndef BISON_LOCATION_HH
        # define BISON_LOCATION_HH
        #endif // !BISON_LOCATION_HH

    The inclusion guard is now computed from "PREFIX/FILE-NAME", where lower
    case characters are converted to upper case, and series of
    non-alphanumerical characters are converted to an underscore.

    With "bison -o lang++/", "location.hh" would now include:

        #ifndef YY_LANG_LOCATION_HH
        # define YY_LANG_LOCATION_HH
        #endif // !YY_LANG_LOCATION_HH

*** C++ locations:

    The position and location constructors (and their initialize methods)
    accept new arguments for line and column. Several issues in the
    documentation were fixed.

** liby is no longer asking for "rpl_fprintf" on some platforms.

** Changes in the manual:

*** %printer is documented

    The "%printer" directive, supported since at least Bison 1.50, is finally
    documented. The "mfcalc" example is extended to demonstrate it.

    For consistency with the C skeletons, the C++ parsers now also support
    "yyoutput" (as an alias to "debug_stream ()").

*** Several improvements have been made:

    The layout for grammar excerpts was changed to a more compact scheme.
    Named references are motivated. The description of the automaton
    description file (*.output) is updated to the current format. Incorrect
    index entries were fixed. Some other errors were fixed.

** Building bison:

*** Conflicting prototypes with recent/modified Flex.

    Fixed build problems with the current, unreleased, version of Flex, and
    some modified versions of 2.5.35, which have modified function prototypes.

*** Warnings during the build procedure have been eliminated.

*** Several portability problems in the test suite have been fixed:

    This includes warnings with some compilers, unexpected behavior of tools
    such as diff, warning messages from the test suite itself, etc.

*** The install-pdf target works properly:

    Running "make install-pdf" (or -dvi, -html, -info, and -ps) no longer
    halts in the middle of its course.

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.