4.5 Other Parser Generators

4.5.1 Bison

Bison is a parser generator by GNU organization, similar to yacc, written mainly by Robert Corbett and Richard Stallman. It is generally upward compatible with input files designed for yacc.

Input files should follow the yacc convention of ending in .y. Unlike yacc, the generated files do not have fixed names, but instead use the prefix of the input file. Moreover, if you need to put C++ code in the input file, you can end the name by a C++ -like extension (.ypp or .y++), then bison will follow your extension to name the output file (.cpp or .c++). For instance, a grammar description file named parse .yxx would produce the generated parser in a file named parse. tab.cxx, instead of yacc's y.tab.c.

Bison ...

Get Compilers: Principles and Practice now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.