<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've sucessfully implemented the lexer using Parsec. It has the type String -> Parser [MJVal], where MJVal are all the possible tokens.</div>
</blockquote><div><br>Great! You'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 "Haskell way"?<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't used Parsec myself, but perhaps you want something of type 'GenParser MJVal s r' for some state s and return type r?<br>
<br>There'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's not Parsec, but there's plenty of useful general information in there, cf. 4.5.1, 4.5.2.<br><br>Regards,<br>Sean<br></div></div>