Dusan,<br><br>Excellent point. To close it off, you need to add an &quot;empty&quot; alternative. Thus, the corrected form would be<br><br>N0 ::= TEmpty | T0 N1 | T1 N1 N0 | T2 N0 N0<br>N1 ::= T3 N0<br><br>In the lambda calculus, this would show up as a constant term, say 0, that would have to be treated in the operational semantics. See my 
<a href="http://lambda-the-ultimate.org/node/1930">ltu posting</a> of a year ago.<br><br>Best wishes,<br><br>--greg<br><br><div class="gmail_quote">On Dec 11, 2007 11:33 AM, Dušan Kolář &lt;<a href="mailto:kolar@fit.vutbr.cz">
kolar@fit.vutbr.cz</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hello,<br><br> &nbsp;I can&#39;t help you with the Haskell question as I&#39;m not really in that
<br>much. Nevertheless, your grammar is non-generating one - that means, it<br>cannot generate any sentence. If the starting non-terminal is N0 then<br>there is no production generating a string of terminals, thus, both<br>
non-terminals (even if reachable from the staring one) are so called<br>non-generating ones (they can be freely removed from the grammar and all<br>involved productions too).<br>Thus, you get empty grammar. Isn&#39;t that the problem? Shouldn&#39;t the
<br>grammar be like:<br><div class="Ih2E3d"><br>N0 ::= T0 N1 | T1 N1 N0 | T2 N0 N0<br></div>N1 ::= T3 T4<br><br>?<br><br>Best regards<br><br>Dusan<br><div><div></div><div class="Wj3C7c"><br><br>Greg Meredith wrote:<br>&gt; Haskellians,
<br>&gt;<br>&gt; Here is an idea so obvious that someone else must have already thought<br>&gt; of it and worked it all out. Consider the following grammar.<br>&gt;<br>&gt; N0 ::= T0 N1 | T1 N1 N0 | T2 N0 N0<br>&gt; N1 ::= T3 N0
<br>&gt;<br>&gt; where Ti (0 &lt;= i &lt; 4) are understood to be terminals.<br>&gt;<br>&gt; Using generics we can translate each production independently of the<br>&gt; others. Like so:<br>&gt;<br>&gt; [| N0 ::= T0 N1 | T1 N1 N0 | T2 N0 N0 &nbsp;|]
<br>&gt; =<br>&gt; data N0 n1 = T0 n1 | T1 n1 (N0 n1) | T2 (N0 n1) (N0 n1) deriving (Eq,<br>&gt; Show)<br>&gt;<br>&gt; [| N1 ::= T3 N0 |]<br>&gt; =<br>&gt; data N1 n0 = T3 n0 deriving (Eq, Show)<br>&gt;<br>&gt; Then, we can compose the types to get the recursive grammar.
<br>&gt;<br>&gt; data G = N0 (N1 G) deriving (Eq, Show)<br>&gt;<br>&gt; This approach has the apparent advantage of treating each production<br>&gt; independently and yet being compositional.<br>&gt;<br>&gt; Now, let me de-obfuscate the grammar above. The first production
<br>&gt; should be very familiar.<br>&gt;<br>&gt; Term ::= Var Name | Abstraction Name Term | Application Term Term<br>&gt;<br>&gt; The generics-based translation of this grammar yields something we<br>&gt; already know: we can use lots of different types to work as
<br>&gt; identifiers. This is something that the nominal of Gabbay, Pitts, et<br>&gt; al, have factored out nicely.<br>&gt;<br>&gt; The second production can be treated independently, but composes well<br>&gt; with the first.
<br>&gt;<br>&gt; Name ::= Quote Term<br>&gt;<br>&gt; This illustrates that a particularly interesting class of names is one<br>&gt; that requires we look no further than our original (parametric) data<br>&gt; type.<br>&gt;
<br>&gt; So, my question is this. Does anyone have a reference for this<br>&gt; approach to translation of grammars?<br>&gt;<br>&gt; Best wishes,<br>&gt;<br>&gt; --greg<br>&gt;<br>&gt;<br>&gt; --<br>&gt; L.G. Meredith<br>
&gt; Managing Partner<br>&gt; Biosimilarity LLC<br>&gt; 505 N 72nd St<br>&gt; Seattle, WA 98103<br>&gt;<br>&gt; +1 206.650.3740<br>&gt;<br>&gt; <a href="http://biosimilarity.blogspot.com" target="_blank">http://biosimilarity.blogspot.com
</a><br></div></div>&gt; ------------------------------------------------------------------------<br>&gt;<br>&gt; _______________________________________________<br>&gt; Haskell-Cafe mailing list<br>&gt; <a href="mailto:Haskell-Cafe@haskell.org">
Haskell-Cafe@haskell.org</a><br>&gt; <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>&gt;<br><br>--<br><br> &nbsp;Dusan Kolar &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;tel: +420 54 114 1238
<br> &nbsp;UIFS FIT VUT Brno &nbsp; &nbsp; &nbsp;fax: +420 54 114 1270<br> &nbsp;Bozetechova 2 &nbsp; &nbsp; &nbsp; e-mail: <a href="mailto:kolar@fit.vutbr.cz">kolar@fit.vutbr.cz</a><br> &nbsp;Brno 612 66<br> &nbsp;Czech Republic<br><font color="#888888"><br>--<br><br></font>
</blockquote></div><br><br clear="all"><br>-- <br>L.G. Meredith<br>Managing Partner<br>Biosimilarity LLC<br>505 N 72nd St<br>Seattle, WA 98103<br><br>+1 206.650.3740<br><br><a href="http://biosimilarity.blogspot.com">http://biosimilarity.blogspot.com
</a>