Hi.<div><br></div><div>I believe I&#39;m using parsec 3.0.1, although I already fixed the imports (even thou they were working).</div><div><br></div><div>Thanks for the references, specially the parsec User Guide - it saved my life, in 30 minutes I actually *understood* my mistake and fixed it. Now my code and it compiles and makes sense, even though it&#39;s a bit useless, since it has no return values [yet].</div>
<div><br></div><div>I&#39;ll take a look at UUAG and Tiger. However, since this is a simple college assignment, I want my compiler to be as simple as possible but in a way I understand what I&#39;m doing, so I&#39;ll probably be doing it by hand.</div>
<div><br clear="all">Fernando Henrique Sanches<br>
<br><br><div class="gmail_quote">On Mon, Nov 30, 2009 at 2:58 PM, Stephen Tetley <span dir="ltr">&lt;<a href="mailto:stephen.tetley@gmail.com">stephen.tetley@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;">
Hi Fernando<br>
<br>
Which version of Parsec are you using, the one that ships with GHC or Parsec 3?<br>
<br>
I would imagine whichever you one you are using you have the imports<br>
wrong for these modules:<br>
<br>
import Text.Parsec.Pos<br>
import Text.Parsec.Prim<br>
<br>
should be ...<br>
<br>
import Text.ParserCombinators.Parsec.Pos<br>
import Text.ParserCombinators.Parsec.Prim<br>
<br>
<br>
Also it seems like an applicative instance for Parsec&#39;s GenParser<br>
monad is missing. This isn&#39;t defined for parsec-2.1.0.1, people seem<br>
to define it themselves:<br>
<br>
-- The Applicative instance for every Monad looks like this.<br>
instance Applicative (GenParser s a) where<br>
    pure  = return<br>
    (&lt;*&gt;) = ap<br>
<br>
... you will need `ap` from Control.Monad in scope.<br>
<br>
Also there is a pdf document for Parsec (should be available from Daan<br>
Leijen&#39;s home page) that covers separate scanners, it has quite a lot<br>
more documentation than Parsec&#39;s Haddock docs.<br>
<br>
For semantic analysis I&#39;d highly recommend UUAG, it is well documented<br>
and used for a large compiler (EHC). There is also a version of Andrew<br>
Appel&#39;s Tiger language written with it that is much smaller and more<br>
comprehensible, the version on Hackage doesn&#39;t seem to contain the<br>
attribute grammar source but it is available here:<br>
<br>
<a href="http://www.cs.uu.nl/wiki/bin/view/HUT/TigerCompiler" target="_blank">http://www.cs.uu.nl/wiki/bin/view/HUT/TigerCompiler</a><br>
<br>
<a href="http://www.cs.uu.nl/wiki/bin/view/HUT/AttributeGrammarSystem" target="_blank">http://www.cs.uu.nl/wiki/bin/view/HUT/AttributeGrammarSystem</a><br>
<br>
Best wishes<br>
<font color="#888888"><br>
Stephen<br>
</font></blockquote></div><br></div>