Deriving Parsers and Quasi-Quoters from BNF Grammars

Version on this page:0.6.1@rev:2
LTS Haskell 22.29:0.6.1@rev:5
Stackage Nightly 2024-07-18:0.6.1@rev:5
Latest on Hackage:0.6.1@rev:5

See all snapshots BNFC-meta appears in

GPL-2.0-only licensed by Jonas Duregård
Maintained by Artem Pelenitsyn
This version can be pinned in stack with:BNFC-meta-0.6.1@sha256:f02643d7d9876f599d7d6f33f3eb3fdf9d59faa82f7b137894e543399032e9f5,2585

Module documentation for 0.6.1

This package provides a very simple way of defining a compiler front-end for a language by embedding a BNF grammar directly into a Haskell source file. Specifically, given a quasi-quoted LBNF grammar (as used by the BNF Converter) it generates (using Template Haskell) a LALR parser and pretty pretty printer for the language. The parser is then used to automatically define a quasi-quoter for the defined language so it can also be seamlessly embedded in Haskell source code. With a simple addition to the gramwmar, the user can define a universal syntax for anti-quoting. This means that any grammar non-terminal can be replaced by a quoted Haskell expression of the appropriate type. A few example languages are included in the source tarball.

The LBNF grammar formalism is described thoroughly in the BNF Converter documentation:

This library and the additions it makes to LBNF is described in a 2011 Haskell Symposium paper titled "Embedded Parser Generators":