Hello again.<div><br></div><div>First, I&#39;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&#39;m missing here. I&#39;ve coded most of the parser, and I have a feeling I&#39;m doing some great mistake. Not only my code won&#39;t compile, I don&#39;t know how to deal with multiple &quot;possible return values&quot; and worse yet - I don&#39;t know how I&#39;ll proceed from this to Semantic Analysis and, later, code generation. Honestly, I&#39;m thinking I&#39;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&#39;s a lot of code and I feel I&#39;m far from reaching the solution to my problem. This code is getting ugly, and I&#39;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">&lt;<a href="mailto:jason.dusek@gmail.com">jason.dusek@gmail.com</a>&gt;</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>