The Haskell 98 grammar in Cactus

Here is an example of how to write grammar files for Cactus.

The grammar used in this example is the grammar of Haskell 98, as given in Appendix B.4 of The Haskell 98 Report.

My main goal when creating this Cactus representation of the Haskell grammar was to follow the grammar in the report as closely as possible. (Put the Cactus file and grammar in the Haskell Report side by side and compare!). The idea is that simple visual inspection of the grammar, together with correct implementation of the parser generator tools, should be enough to obtain a Haskell parser that is ensured to be correct with respect to the Haskell Report.

Files

Input

Output

Cactus produces the following files (and some more): Note that the generated files as surprisingly readable!

Cactus can also produce output for flex, yacc and C.

Shortcomings


Thomas Hallgren
(March, 2002) (some notes added in June 2003)