Implement the compiler.

Still largely untested and probably quite buggy.