There are 10 types of programmers in the world, those who have written a compiler and those who can’t read binary.
I’ve never written a compiler. At college, I had to drop the class because of a conflict and have always wanted to write one ever since. Even if just to say that I can.
The Elements of Computing Systems has a chapter focusing on building a compiler for the computer that is built throughout the book. The compiler is for an object oriented language called Jack.
Jack, the language, is designed to be simple enough to make the compilation process easier, but that doesn’t mean that it’s not an expressive language. In later chapters in the book, Jack is used to implement parts of the OS and other applications.
The grammar is easy enough and the author claims that it’s almost an LL(0) requiring only a look-ahead token in parsing expressions. The parser for it is a simple recursive descent parser.
I tried to conform to how the book does things, but preferred to do my own thing if it made more sense. It’s also still a work-in-progress and I’ll keep on working on it as time allows.
This is not a full compiler and is definitely no where near real compilers, but it’s a start. And I’d like to dedicate it to my muse without whom I would’ve given up a long time ago.
You can find the code over at my github repository at .