On Wed, May 6, 2009 at 12:07 AM, Rouan van Dalen <span dir="ltr"><<a href="mailto:rvdalen@yahoo.co.uk">rvdalen@yahoo.co.uk</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Hi everyone.<br>
<br>
I am designing my own programming language.<br>
<br>
I would like to know what is the best way to go about writing my compiler in haskell.<br>
What are the tools available in haskell that can help with compiler construction?<br>
<br>
I know about Happy. Is that a good tool to use?</blockquote><div><br>I don't like Happy. Using a parser generator is like admitting defeat, when we have no defeat to admit. I would recommend a parser combinator library like Parsec (or if you like building things from the ground up, ReadP).<br>
</div><div><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<br>
The compiler is intended for serious use and I would like it to be very efficient, maybe competing </blockquote><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
with compilers written in C. It should also be very easy to extend as the languoge grows.</blockquote><div><br>I agree with minh thu; there are too many questions to consider before giving too much specific advice.<br><br>
But in almost all cases, plan on the production version of your compiler being written in the language it is compiling. This has many advantages.<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
Are there any good books that you can recommend on compiler construction in general and specific to haskell?<br>
<br>
<br>
On another note, how is the operator + implemented in haskell?<br>
<br>
is there a primitve (say #+) that is wrapped by the haskell operator +?<br>
Maybe something like:<br>
<br>
(+) :: a -> a -> a<br>
v1 + v2 = #+ v1 v2</blockquote><div><br>It varies from compiler to compiler, but in general, yes. And in GHC I think it is called +#, actually, but you need to do some digging to find it, and your code won't be portable once you do.<br>
<br>Luke<br></div></div>