I don&#39;t know if you&#39;ve already used it, but Parsec includes some kind of a lexer through the <a href="http://hackage.haskell.org/packages/archive/parsec/3.1.0/doc/html/Text-Parsec-Language.html">Language</a> and <a href="http://hackage.haskell.org/packages/archive/parsec/3.1.0/doc/html/Text-Parsec-Token.html">Token</a> modules.<div>
You can start by having a look at the <a href="http://hackage.haskell.org/packages/archive/parsec/3.1.0/doc/html/Text-Parsec-Token.html#v:makeTokenParser">makeTokenParser</a> function.<div><br><div class="gmail_quote">On 31 October 2010 15:11, Nils Schweinsberg <span dir="ltr">&lt;<a href="mailto:ml@n-sch.de">ml@n-sch.de</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi!<br>
<br>
I&#39;m having a really hard time to write a correct parser for a small language I&#39;ve developed. I have been trying to write a parser using parsec, but always get a lot of error messages like &quot;unexpected &quot;\n&quot;, expected ..., new-line or...&quot; when trying to run the parser. Then I read about the happy parser and really liked the separation of lexing the text into tokens and parsing the actual logic behind those tokens. Since I couldn&#39;t get familiar with the lexer &quot;alex&quot; I gave up on the alex-happy-approach again and went back to parsec. But with that lexer-&gt;parser idea on my mind, my parser currently looks a lot like a lexer. So I came up with the idea of using a combination of parsec and happy, where I generate a list of tokens for my text via parsec and analyse it with happy.<br>

<br>
<br>
My questions would be:<br>
<br>
- Is this a valid approach?<br>
<br>
- What is your workflow on parsing complex data structures?<br>
<br>
- What about performance? Since my project is going to be an interpreted language parsing performance might be interesting aswell. I&#39;ve read that happy is in general faster than parsec, but what if I combine both of them as I said above? I guess that parsing a simple list of tokens without any nested parser structures would be pretty fast?<br>

<br>
- Do you have any other ideas on how to improve my parser?<br>
<br>
- What are your general thoughts on happy vs. parsec?<br>
<br>
<br>
Thanks for any replies,<br>
<br>
Nils<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">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>
</blockquote></div><br><br clear="all"><br>-- <br>Ozgur Akgun<br>
</div></div>