[Haskell-cafe] I want to write a compiler
rick.richardson at gmail.com
Sat Mar 7 18:45:04 EST 2009
Not sure if this is exactly what you want, but you could certainly fufill
all of your requirements using this as a baseline. Instead of evaluating the
actual statements in your eval function, you could simply render them to C.
As far as FFI, if you are statically compiling to C, you can leave your
variables unboxed. This would allow you to call C functions directly.
Hope that helps.
On Sat, Mar 7, 2009 at 6:32 PM, Loup Vaillant <loup.vaillant at gmail.com>wrote:
> This is a homework question. I am mainly looking for guidance or
> pointers. Source code, even. (Not GHC's, though, it is too complicated
> for me right now. The AST of STG is fine, but the rest kinda scares
> Ideally, I would very much like to compile to C.
> The requirements are easily stated. My language must
> -> be lazy by default,
> -> support algebraic data types and case expressions (unless I can get
> away with encoding them as functions),
> -> have some kind of FFI with C (I suppose it imply some support for
> unboxed values).
> There is also the first class functions thing, but lambda lifting is okay.
> I don't care about any kind of execution efficiency. I just want my
> compiler to be As Simple As Possible. Eventually, I intend to
> bootstrap. Then, I will start dreaming about doing better than the
> Mighty Simons. (I can dream, right?)
> I figured I would start by the back-end. I began to write 15 pathetic
> lines of code to start an STG machine. Needles to say, I am stuck. I
> don't know where to start.
> I am already familiar with some papers. In particular,  (on
> template instantiation),  and . I once wrote a simple graph
> reducer using template instantiation (about 20 lines at most).
> I have chosen the STG machine because I thought i would be easier to
> get an FFI and case exprs out of it. Maybe I am wrong, and template
> instantiation is really easier. There is also the BRISK machine, and
> GRIN. But the paper I read were less readable to me than the three
> So, If any of you can give me some pointer or guidance or advice about
> where to start, I would be very grateful.
>  http://www.cs.otago.ac.nz/cosc459/books/pjlester.pdf
>  http://research.microsoft.com/~simonpj/Papers/eval-apply/index.htm<http://research.microsoft.com/%7Esimonpj/Papers/eval-apply/index.htm>
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
We can't solve problems by using the same kind of thinking we used when we
- A. Einstein
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe