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.
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.
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:When you have produced the makefile, you can:
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
TestJavaletteLight> testJavalette "koe.jll"To make this test yourself, just copy the linearization result into a file 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 ++ ;
}
}