Hello again.<div><br></div><div>First, I'd like to thank you both for your help. You gave me nice tips and nice material.</div><div><br></div><div>However, I think there is something I'm missing here. I've coded most of the parser, and I have a feeling I'm doing some great mistake. Not only my code won't compile, I don't know how to deal with multiple "possible return values" and worse yet - I don't know how I'll proceed from this to Semantic Analysis and, later, code generation. Honestly, I'm thinking I'll have to scrap out all of this code and use the (ugh) Java template code the teacher gave us.</div>
<div><br></div><div>My code is divided in three files:</div><div><br></div><div>Parser.hs (the real parsing, problematic):</div><div><a href="http://hpaste.org/fastcgi/hpaste.fcgi/view?id=13399#a13399">http://hpaste.org/fastcgi/hpaste.fcgi/view?id=13399#a13399</a></div>
<div><br></div><div>ParserTokens.hs (where I believe the problem arouse):</div><div><a href="http://hpaste.org/fastcgi/hpaste.fcgi/view?id=13400#a13400">http://hpaste.org/fastcgi/hpaste.fcgi/view?id=13400#a13400</a></div>
<div><br></div><div>Lexer.hs (the lexer, the only part I believe is mostly right):</div><div><a href="http://hpaste.org/fastcgi/hpaste.fcgi/view?id=13401#a13401">http://hpaste.org/fastcgi/hpaste.fcgi/view?id=13401#a13401</a></div>
<div><br></div><div>That's a lot of code and I feel I'm far from reaching the solution to my problem. This code is getting ugly, and I'm somewhat desperate. Any help will be greatly appreciated.</div><div><br clear="all">
Fernando Henrique Sanches<br>
<br><br><div class="gmail_quote">On Tue, Nov 10, 2009 at 6:21 PM, Jason Dusek <span dir="ltr"><<a href="mailto:jason.dusek@gmail.com">jason.dusek@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
You have to bootstrap your parser with something that takes<br>
an `MJVal` and updates the parser state. Here is a simple<br>
example:<br>
<br>
<a href="http://github.com/jsnx/system-uuid/blob/master/Options.hs" target="_blank">http://github.com/jsnx/system-uuid/blob/master/Options.hs</a><br>
<br>
This is a parser for command line options. It parses a list<br>
of `String`s, not `Char`s (because `argv` is `char**` and not<br>
`char*`, right?) so we introduce `stringPrim` and then build<br>
up the primitives from that.<br>
<br>
--<br>
<font color="#888888">Jason Dusek<br>
</font></blockquote></div><br></div>