tdk: initial rewrite of the compiler