


We return to the details of the notation after trying this out in BNFC. The input language is defined with the following BNFC grammar.Ĭopy this code into a file called Calc.cf. To make it the simplest possible, we restrict ourselves to integers, with addition, subtraction, multiplication, and (lossy) division. We start with everyone's favourite: the desktop calculator. Let us now create our first application from a BNFC source file. This means that, after running bnfc, you can create an executable parser by The -m flag makes BNFC to generate a Makefile. The most common choices are:īnfc -m -cpp FILE.cf # to generate C++ with STLīnfc -m -java FILE.cf # to generate Java ≥ 1.5īnfc -m -haskell FILE.cf # to generate Haskell This gives you a list of available options. If you want to contribute to BNFC, make sure you use the latest git version: give the commandīNFC is licensed under the BSD 3-clause license. With GHC in place, just unpack the sources, cd to BNFC, and type make. If you choose the source package, you need the GHC Haskell Compiler. If you are using Debian or Ubuntu Linux, you can obtain BNFC with their package system (but it is a slightly older version).įor the binaries, it is enough to download them and put into a place where you can find executables (such as /usr/local/bin on Unix-like platforms). but some languages have rough corners (e.g.


