Limited run only? GNU Bison gives D a try

GNU Bison

Bison, a parser generator hosted by the GNU project, is now available in version 3.5, reducing the footprint of small parsers and improving syntax error handling.

The latter is now only promoted for use in error messages, while the Bison team warns against applying string literals to avoid implementing keyword matching in the scanner. It is still supported though, at least for now, and the new diagnostic -Wdangling-alias helps in catching related errors.

Users working with Bison for C++ now get to enjoy lookahead correction (LAC). It has been added to the parsing algorithm and can be enabled with the %define parse.lac directive. LAC is meant to improve syntax error handling by suspending normal parsing whenever a new token is fetched from the scanner and exploring the next action. If it reaches a shift action during that exploratory parse, normal parsing resumes, while an error is reported if that isn’t the case. 

Thanks to an investigation into the use of integral types in the generator and the parsers that stem from it, small parsers now need less resources. It also helped with allowing very large automata to be generated with the default backend. Devs using the Java backend must define %define variable parse.trace in order to have it emit code and data for parser tracing.

Advertisement

To make the project accessible to a wider audience, it now comes with an experimental backend for the D programming language. Parties interested in this “skeleton” are nudged to make themselves known, since a lack of commitment since its inception means the future of the D backend remains unclear.

D is a general-purpose language that features a C-like syntax, and strong,static typing that aims at fast execution amongst other things. Its development has been driven by the D Language Foundation since 2015. D itself has been around since 2001 and counts companies such as Facebook and Netflix amongst its users.

GNU Bison meanwhile saw its first release in 1985. According to its documentation, the tool “converts an annotated context-free grammar into a deterministic LR or generalized LR (GLR) parser”. Bison can create code for C/C++ and Java out of the box, though binding tools are an option to make it work for other languages as well. It can be used as an alternative to Yacc (“yet another compiler-compiler”), which came into existence in the 1970s.

- Advertisement -