<div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div>I&#39;ve sucessfully implemented the lexer using Parsec. It has the type String -&gt; Parser [MJVal], where MJVal are all the possible tokens.</div>


</blockquote><div><br>Great! You&#39;re partway there.<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">How should I implement the parser separated from the lexer? That is, how should I parse Tokens instead of Strings in the &quot;Haskell way&quot;?<div>


<div></div></div></blockquote><div><br>AFAIK, the difference is between having an input stream of type [Char] vs. having a stream of tokens, e.g. [MJVal]. I haven&#39;t used Parsec myself, but perhaps you want something of type &#39;GenParser MJVal s r&#39; for some state s and return type r?<br>

<br>There&#39;s an excellent set of lecture notes from a class we have at Utrecht, formerly called Grammars and Parsing and now Languages and Compilers, in which we use parser combinators in Haskell .<br><br>  <a href="http://people.cs.uu.nl/johanj/publications/MAIN.pdf">http://people.cs.uu.nl/johanj/publications/MAIN.pdf</a><br>

<br>It&#39;s not Parsec, but there&#39;s plenty of useful general information in there, cf. 4.5.1, 4.5.2.<br><br>Regards,<br>Sean<br></div></div>