Skip to content

seagreen/state-of-haskell-bnf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

BNF In Haskell

Backus-Naur form is technique for describing context-free grammars.

The difference in clarity between specifications using BNF and ones using informal English is enormous. The following EBNF is unlikely to translate to brief English:

number ::= "-"? (positiveInteger fraction? | "0" fraction)
         | "0"

And even if it was short it wouldn't let you generate this for free (using GrammKit):

Number

I think Haskell would be a natural fit for this kind of work, and so did a survey of the ecosystem to see what's been built so far. If no Haskell solution is available I list the best non-Haskell one.

Here are my goals:

1. Validation executable

Simply make sure a BNF file is valid.

ABNF: None yet. Perhaps a wrapper around parseABNF should be built.

EBNF: None yet. Ebnf2ps could do this, but it would also try to generate diagrams.

2. Haskell representation

A clean, general Haskell data type that can be used by other libraries.

ABNF: [Rule]

EBNF: None yet.

3. Railroad diagram generator

ABNF: None yet.

EBNF: GrammKit is great for generating SVGs if you just need an executable (it's not Haskell). Ebnf2ps generates PostScript files.

Existing Packages

abnf

Hackage / Source

Supported: ABNF

Summary: "Parse ABNF and generate parsers for the specified document"

Ebnf2ps

Hackage / Source

Supported: EBNF

Summary: "Generate PostScript diagrams from an EBNF grammar"

BNFC

Hackage / Source

Supported: Labelled BNF

Summary: "Given a Labelled BNF grammar the tool produces: an abstract syntax as a HaskellC++C module or Java directory, a case skeleton for the abstract syntax in the same language, an Alex, JLex, or Flex lexer generator file, a Happy, CUP, or Bison parser generator file, a pretty-printer as a HaskellJavaC++/C module, a Latex file containing a readable specification of the language."

BNFC-meta

Hackage

Supported: Labelled BNF

Summary: Embed LBNF within Haskell using Template Haskell

ebnf-bff

Hackage / Source

Supported: EBNF

Summary: "A library & program that builds parsers from ISO EBNF using Parsec"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published