Backus naur form online

Chalmers University of Technology and University of Gothenburg

What is the BNF Converter?

The BNF Converter is a compiler construction tool generating a compiler front-end from a Labelled BNF grammar. It is currently generating code for the target languages Haskell, Agda, C, C++, Java, and OCaml, as well as XML representations and Pygment syntax highlighters.

Given a Labelled BNF grammar the tool produces:

Download

Install via stack from Stackage:

$ stack install BNFC

Install by Cabal from Hackage:

$ cabal install BNFC

Current development version (source repository on GitHub)

$ git clone https://github.com/BNFC/bnfc

News

Resources

Documentation

Mailing list

Send questions, bug reports, usage news, etc, to our Google group.

Book

Book cover

A small example

Content of file Calc.cf : Generate a parser (choose your backend): bnfc and make : -->
bnfc --haskell -d -m Calc.cf && make bnfc --agda -d -m Calc.cf && make bnfc --c -m Calc.cf && make bnfc --cpp -m Calc.cf && make bnfc --java -m Calc.cf && make bnfc --java-antlr -m Calc.cf && make bnfc --ocaml -m Calc.cf && make bnfc --ocaml-menhir -m Calc.cf && make
Run the test parser, generated e.g. with `--haskell`:
echo "1 + 2 * 3 - 4 / 5" | Calc/Test

<a href=BNFC code generator graph" width="200" />

BNFC functionality overview:

Large examples

A grammar of LBNF. It is at the same time an example LBNF file. The development version of this grammar is used in the implementation of the BNF Converter.

Authors

© Andreas Abel, Jonas Almström Duregård, Krasimir Angelov, Jean-Philippe Bernardy, Björn Bringert, Johan Broberg, Kyle Butt, Paul Callaghan, Grégoire Détrez, Markus Forsberg, Ola Frid, Peter Gammie, Thomas Hallgren, Pascal Hof, Simon Huber, Patrik Jansson, Kristofer Johannisson, Antti-Juhani Kaijanaho, Andreas Lööw, Justin Meiners, Kent Mein, Ulf Norell, Gabriele Paganelli, Michael Pellauer, Fabian Ruch, and Aarne Ranta 2002 - 2021.

License

Free software under the BSD 3-clause license.

Versions until 2.8.4 released under the GNU General Public License (GPL).