<div>Hello everyone,</div><div><br></div><div>I&#39;m pleased to announce the first release of Grempa:</div><div><br></div><div> A library for expressing programming language grammars in a form similar</div><div> to BNF, which is extended with the semantic actions to take when</div>
<div> a production has been parsed. The grammars are typed and are to be be used</div><div> with the LALR(1) parser generator, also part of the library, which can</div><div> generate a parser for the language either at compile time using Template</div>
<div> Haskell, producing fast parsers with no initial runtime overhead, or</div><div> dynamically, which has the initial overhead of generating the parser, but</div><div> can be used for example when the grammar depends on an input.</div>
<div><br></div><div>Here is a small example (from Ex1 in the examples directory) of what a grammar</div><div>may look like:</div><div><br></div><div> data E = Plus E E</div><div> | Times E E</div><div> | Var</div>
<div> | ...</div><div><br></div><div> expr :: Grammar Char E</div><div> expr = do</div><div> rec</div><div> e &lt;- rule [ Plus &lt;@&gt; e &lt;# &#39;+&#39; &lt;#&gt; t</div><div> , id &lt;@&gt; t</div>
<div> ]</div><div> t &lt;- rule [ Times &lt;@&gt; t &lt;# &#39;*&#39; &lt;#&gt; f</div><div> , id &lt;@&gt; f</div><div> ]</div><div> f &lt;- rule [ id &lt;@ &#39;(&#39; &lt;#&gt; e &lt;# &#39;)&#39;</div>
<div> , Var &lt;@ &#39;x&#39;</div><div> ]</div><div> return e</div><div><br></div><div>The corresponding BNF grammar is the following:</div><div><br></div><div> E ::= E + T</div>
<div> | T</div><div> T ::= T * F</div><div> | F</div><div> F ::= ( E )</div><div> | x</div><div><br></div><div>Generating a parser from the grammar is simple:</div><div><br></div><div> parseExpr :: Parser Char E</div>
<div> parseExpr = $(mkStaticParser expr [|expr|])</div><div><br></div><div>There are a few other examples in the examples directory of the package, most</div><div>notably a grammar and parser for a simple functional language similar to</div>
<div>Haskell.</div><div><br></div><div>It is possible to generate random input strings and their expected outputs</div><div>for grammars written using Grempa which makes it possible to test the generated</div><div>parsers with QuickCheck.</div>
<div><br></div><div>The package and documentation (should be up soon) can be found here:</div><div><a href="http://hackage.haskell.org/package/Grempa-0.1.0">http://hackage.haskell.org/package/Grempa-0.1.0</a></div><div><br>
</div><div>Please get in touch with me if you have any comments, issues, questions, bug</div><div>reports or would like to contribute to the project. I would love to get some</div><div>more people involved in the project, as there are many areas of the library that</div>
<div>could be improved.</div><div><br></div><div>Thanks to Daniel Gustafsson and everyone else at Chalmers Uni for valuable</div><div>input and getting me into Haskell (respectively).</div><div><br></div><div>Regards,</div>
<div>Olle Fredriksson</div>