I’m building a compiler to pass the time and it uses ANF/monadic normal form as an intermediate language. So far it can compile if True then print(2); else print(3);;
to correct assembly that gets run with gcc. Thats the only one I have tested.
heres the code
But the instruction selection module generates code for expressions such as:
let x = 0;; while x < 4;: if x < 3; then print(x);; let x = x + 1;; else print(3);;
and it can generate ast for tuples such as (4 ; 5 ; 6)
.
I know the syntax is ugly but i wanted to skip the parsing phase as fast i could.
It uses the happy parser generator.
If you take a look at the code and if you want and have time, I will appreciate some feedback. This is my second main project in haskell so I am not sure if I wrote Haskell in a good style. I had some compiler experience with common lisp but i think haskell is better for writing compilers. thanks. have a nice day