Reputation: 1117
I'm thinking of writing a compiler in haskell, and just to gain some knowledge and experience, I will try to implement compilers for existing languages. Could someone give me a list of languages which are suitable for this?
Thanks in advance
Upvotes: 4
Views: 4191
Reputation: 369420
Scheme is often used for this. There's even a tutorial called Write Yourself a Scheme in 48 hours for Haskell.
Upvotes: 7
Reputation: 81
PL/0 is a simple language that was created to teach compiler construction. Samuel Williams wrote a compiler for it in Python (along with a virtual machine) for the benefit of students: http://www.oriontransfer.co.nz/learn/pl0-language-tools/index
Upvotes: 2
Reputation: 8870
Oberon-2. Like Lua has short context-free grammar.
P.S. Here you can find Oberon-2 compiler written in Objective Caml.
Upvotes: 3
Reputation: 9714
Pascal could be a good start - you can compile it in a single pass. A subset of Lisp might be useful in order to grasp the idea of the lambda lifting. ML or even a subset of Haskell might help you in understanding the type inference. Consider using LLVM as your back-end, it will save you some time on implementing boring stuff.
Upvotes: 8
Reputation: 1012
As far as I know one of the easiest languages to compile is Forth. I think it's quite achievable to write a compiler for Forth in Forth even for a relative novice.
Upvotes: 1
Reputation: 76945
The simplest languages to write compilers for are existing "esoteric languages", like brainfuck, because they have the smallest instruction set and the simplest grammar. You can try your hand at a more complex language, but it's better to get the fundamentals down with something simple before moving any further.
Upvotes: 4