BNF Converter

Markus Forsberg and Aarne Ranta

Haskell Mode

Requirements

You need the following programs installed on your system to be able to run BNF Converter in Haskell mode:

To use Hugs: use Alex v1.1, and give the flag -alex1 to bnfc.

Running the BNF Converter in Haskell mode

Example file JavaletteLight.cf.

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

If this is run on the example file, the output looks like this:

$ bnfc -haskell JavaletteLight.cf

The BNF Converter, 2.2
(c) Bjorn Bringert, Paul Callaghan, Markus Forsberg, Peter Gammie,
    Patrik Jansson, Antti-Juhani Kaijanaho, Michael Pellauer,
    and Aarne Ranta 2002 - 2004.
Free software under GNU General Public License (GPL).
Bug reports to {markus,aarne}@cs.chalmers.se.


Reading grammar from JavaletteLight
21 rules accepted

wrote file AbsJavaletteLight.hs
wrote file LexJavaletteLight.x
   (Use Alex 2.0 to compile.)
wrote file ParJavaletteLight.y
   (Tested with Happy 1.15)
wrote file DocJavaletteLight.tex
wrote file SkelJavaletteLight.hs
wrote file PrintJavaletteLight.hs
wrote file TestJavaletteLight.hs
wrote file ErrM.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 -haskell -m JavaletteLight.cf.

When you have produced the makefile, you can:

You can now test to parse a Javalette file:

[shell]$ testJavaletteLight 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.