[Haskell-cafe] Announcing Pinchot - builds data types and Earley grammars for context-free grammars
omari at smileystation.com
Sat Dec 5 17:54:31 UTC 2015
I have just uploaded to Hackage the Pinchot library:
I also have a pull request to get it into Stackage so hopefully it should
be there in a few days as well.
Pinchot provides a simple monadic language that you use to describe a
context-free grammar. Using this language you build a value that represents
your grammar. Then, using this value and Template Haskell, you can
automatically generate a complete set of data types that correspond to the
rules in your context-free grammar.
You also use Template Haskell to generate an Earley grammar for your
language, using the Haskell Earley library:
Unlike parsers such as Parsec and Happy, Earley parses all context-free
grammars, regardless of the amount of necessary look-ahead or the presence
of left recursion. Earley does not, however, parse context-sensitive
Pinchot is documented and comes with several examples. It passes several
simple tests but it has not yet been used in anger.
I wrote Pinchot because I was excited to see Earley when it was released.
Finally we had a parser that would simply parse context-free grammars.
Give a grammar, get a parser. Parsec and its ilk, on the other hand, are
libraries allowing you to write a recursive-descent parser by hand. That's
useful, but if you know you have a context-free grammar it's easier to use
a tool tailored to that.
So when using Earley I found myself writing the data types and then writing
the Earley grammar specification. This was a rote process ripe for
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe