Simon Peyton-Jones wrote:
> > Just curious, a few questions :
> > - How long was your program?
> > - How did you do the parsing? with happy?
> > parser combinators? ...
> > - Which compiler did you use ? (Okay, i think i know ... :-))
> > - Other information you want to share with us ...
> > (eg. - which optimization algoritm did you use?
> > - how much coffee did you consume? :-))
>
> 1200 lines of Haskell.
> The parser was a Happy parser.
> We used GHC.
>
> Below is our README, written in haste in the closing 10 mins.
> One thing I didn't mention in it is that we use the exception-handling
> extensions to arrange that if an optimisation pass hit a pattern-matching
> error (usually a fatal error in Haskell), we catch it and simply throw
> away that optimisation pass, and move on to the next one. So if all
> give errors, our compiler degenerates to 'cat'. A fault-tolerant compiler.
547 lines of Haskell, 137 of those line is the "optimizer", the rest is
parsing, printing, etc.
The parser uses parsing combinators.
I used HBC (what else? :)
The optimizer itself is really simple, the list of TODO items for
improvements is endless... This is what it does
* remove redundant tests (testing same variable as outer case)
* join identical branches
* join similar branches and insert inner case to distiguish them
* split long case ranges into nested case
* convert small case to if
That's it.
--
-- Lennart