Converts SDF to Haskell

Latest on Hackage:

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow to host generated Haddocks.

BSD3 licensed by Ralf Laemmel, Joost Visser


Sdf2Haskell version 1.0, November 2002

Ralf Laemmel Joost Visser
CWI & VU, Amsterdam CWI, Amsterdam

This package contains Sdf2Haskell, a generator that takes an SDF
grammar as input and produces a corresponding set of Haskell datatype
definitions as output.

--- GENERAL ------------------------------------------------------------------

For information see:

Contents of this package:

- generator Directory with the files that make up the generator
- examples Directory with examples of using the generator
- scripts Directory with sets of reusable make rules

--- PREREQUISITES ------------------------------------------------------------


I. Your path must contain the following programs:

- GHC (version 6.4 or higher)
- DrIFT (version 2.1.2)
- sdf2table (version 1.10)
- sglr (version 3.4.1 or higher)
- implodePT (version 1.1 is known to work)

II. The following Strafunski packages must be available:

- StrategyLib-5.0
- haterm-1.5

Preferably, these packages should be placed in the same directory
as this Sdf2Haskell package.

GHC and DrIFT can easily be found via the Haskell organization home
page at:

The programs sdf2haskell, sglr, and implodePT can be obtained in various

- by installing the "sdf2" package from the Online Package Base at (source
distribution only).

- by installing StrategoXT's prerequisite package "sdf2-bundle"
from (source and bindary
distributions available).

- by installing the ASF+SDF Meta-Environment, which can be obtained
as "asfsdf-meta" from

The required Strafunski packages can be downloaded from the
Strafunfski home page

--- INSTALL ------------------------------------------------------------------

The Sdf2Haskell generator can be configured, built, and installed IN PLACE,
as follows:

./configure [flags]

For help on the configuration flags, type:

./configure --help

In particular, you might want to use the --with-haterm and --with-StrategyLib
flags to point out where the required Strafunksi packages are.

--- RUN ----------------------------------------------------------------------

After configuration and builing, the Sdf2Haskell generator is available in:


You may want to extend your PATH to include ./generator.

You can now run the generator as follows:

sdf2haskell -i <grammarfile> -m <modulename> -o <haskellfile>

where the <grammarfile> is a file containing the SDF grammar you want to feed
to the generator as input, <modulename> is the name of the Haskell module
you want to be generated, and <haskellfile> is the name of the file into which
you want the generated Haskell file to be written. Use the -p option if you
want to generate customizable pretty-print functions instead of datatypes
that represent abstract syntax trees.

--- EXAMPLES -----------------------------------------------------------------

To see the examples in action, you can type:

gmake check

Do this in the top level directory to run all examples, or in a
specific example directory to run a single one. The example in
examples/twosorts is the most simple one which only invokes the
generator. The other examples (for Java and Cobol) also involve
compilation of code depending on the generated Haskell datatypes
as well as parser generation and parser invocation.



November 2005: Joost Visser
* Bumped to version 2.3.
* Upgraded to GHC 6.4.1.

* Version number increased to 2.2.
* Now includes support for generating Cfg grammars for HaGLR
* Improved implosion support.

* Added functionality to generate customizable pretty printers.

* Modified to work with latest StrategyLib (version 4.0) and with
latest GHC (version 6.0.1) and latest Hugs (November 2002).

* Debugged, cleaned up for distribution.

* Started to make the package distributable.
comments powered byDisqus