Skip to content
Go to file


Failed to load latest commit information.
Latest commit message
Commit time
Jan 18, 2020

Hackage version Stackage version Build Status Documentation Status

The BNF Converter

What is the BNF Converter?

The BNF Converter (bnfc) is a compiler construction tool generating a compiler front-end from a Labelled BNF grammar. It is currently able to generate C, C++, C#, Haskell, Java, and OCaml, as well as XML representations.

Given a Labelled BNF grammar the tool produces:

  • an abstract syntax implementation
  • a case skeleton for the abstract syntax in the same language
  • an Alex, Ocamllex, JLex, or Flex lexer generator file
  • a Happy, Ocamlyacc, Menhir, ANTLR, CUP, or Bison parser generator file
  • a pretty-printer as a Haskell/Ocaml/Java/C++/C module
  • a Latex file containing a readable specification of the language

More information:


Everything needed to build bnfc is available in the haskell platform.

On Debian, you can install the dependencies as follows

sudo apt-get install haskell-platform

On Fedora:

yum install haskell-platform

Then proceed with the installation.


Some binaries are available at .

To install bnfc from

cabal install BNFC

To install the development version of bnfc:

git clone
cd bnfc/source
cabal install


Run tests

Here is how to build and run the different test suites for bnfc.

cabal sandbox init # Cabal >= 1.18 only
cabal install --only-dependencies --enable-tests
cabal configure --enable-tests
cabal build
cabal test



If you are having issues, please let us know. We have a mailing list located at:


The project is licensed under the GNU GENERAL PUBLIC LICENSE Version 2.

You can’t perform that action at this time.