[BNF Converter]
Aarne Ranta and Markus Forsberg ,
February 1, 2002 - March 08, 2004.

Introduction

This page describes how to run the system in original Haskell mode. There is also information available on Java Mode and C++ Mode. If you want more detailed information, please read the BNF Converter report.

Requirements

To be able to use the full functionality of the BNF Converter, you need the following programs installed on your system: If you want to use Hugs, use the Alex v1.1 and give the flag -alex1 to bnfc.

Install the BNF Converter

Download source files: bnfc_2.1.tar .
extract the files with: tar -xvfz bnfc_2.1.tgz
change directory: cd ./BNFC/
type: make

You should now have a binary named bnfc.

Running the BNF Converter

Example file JavaletteLight.cf.

Producing the output files without compiling them is done by typing bnfc file.

If this is run on the example file, the output looks like this:
$ bnfc JavaletteLight.cf 
The BNF Converter (v.2.1) (c) Markus Forsberg, Peter Gammie, Michael Pellauer & Aarne Ranta 2003.
Free software under GNU General Public License (GPL).
Bug reports to {markus, aarne}@cs.chalmers.se.

Reading grammar from JavaletteLight

18 rules accepted

wrote file AbsJavaletteLight.hs
wrote file LexJavaletteLight.x
wrote file ParJavaletteLight.y
wrote file DocJavaletteLight.tex
wrote file SkelJavaletteLight.hs
wrote file PrintJavaletteLight.hs
wrote file TestJavaletteLight.hs
Done!

You could now compile LexJavaletteLight.x, ParJavaletteLight.y and DocJavaletteLight.tex by hand, using alex, happy and latex.

You can also produce a makefile, named makefile, by typing bnfc -m JavaletteLight.cf.

The contents of JavaletteLight's makefile:

all:
happy ParJavaletteLight.y
alex LexJavaletteLight.x
latex DocJavaletteLight.tex
dvips DocJavaletteLight.dvi -o DocJavaletteLight.ps
clean:
rm -f JavaletteLight.*.gf DocJavaletteLight* LexJavaletteLight* ParJavaletteLight* SkelJavaletteLight.hs PrintJavaletteLight.hs TestJavaletteLight.hs AbsJavaletteLight.hs
When you have produced the makefile, you can: Then you can test it by parsing a JavaletteLight source file:
TestJavaletteLight> testJavalette  "koe.jll"

Parse Successful!

[Abstract Syntax]

Fun TInt (Ident "main") [SDecl TInt (Ident "i"),SDecl TDouble (Ident "d"),
SAss (Ident "i") (EInt 0),SAss (Ident "d") (EDouble 1.0),SWhile (ELt (EVar
(Ident "i")) (EInt 10)) [SAss (Ident "d") (ETimes (EVar (Ident "d"))
(EDouble 0.5)),SIncr (Ident "i")]]

[Linearized tree]

int main () {
int i ;
double d ;
i = 0 ;
d = 1.0 ;
while (i < 10){
d = d * 0.5 ;
i ++ ;
}
}
To make this test yourself, just copy the linearization result into a file koe.jll.