This isn&#39;t quite what you&#39;re asking for, but by using the applicative interface to parsers, you need do little more than spell out what your AST looks like:<div><br></div><div>import Control.Applicative</div><div>import Control.Applicative.Infix</div>
<div><br></div><div>data Equation = String :=: Expression</div><div>data Expression = EApp fun arg | EInt Int | EId String</div><div><br></div><div>parseEquation :: Parser Equation</div><div>parseEquation = parseIdentifier &lt;^(:=:)^&gt; parseExpression</div>
<div><br></div><div>parseExpression :: Parser Expression</div><div>parseExpression =</div><div>      (EApp &lt;$&gt; parseExpression &lt;*&gt; parseExpression)</div><div>  &lt;|&gt; (EInt &lt;$&gt; parseInt)</div><div>  &lt;|&gt; (EId &lt;$&gt; parseIdentifier)</div>
<div><br></div><div>parseIdentifier :: Parser String</div><div>parseIdentifier = parseLowercaseChar &lt;^(:)^&gt; parseString</div><div><br></div><div>etc</div><div><br></div><div>Bob</div><div><br><div class="gmail_quote">
On Sun, Dec 27, 2009 at 10:18 AM, CK Kashyap <span dir="ltr">&lt;<a href="mailto:ck_kashyap@yahoo.com">ck_kashyap@yahoo.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi All,<br>
I recently came across the paper titled &quot;Monadic Parser Combinators&quot; - After going through it a few times, I think I am beginning to understand monads.<br>
However, the parser developed in the paper does not generate an AST - I feel, I&#39;d grasp the whole thing a lot better if I could go over a sample that generates an AST from a simple expression (or even a standard language such as C or Java) ... Can someone please point me to a sample that generates AST - preferably with the simple parser combinator given in the paper.<br>

Regards,<br>
<font color="#888888">Kashyap<br>
</font><div><div></div><div class="h5"><br>
<br>
<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br></div>