Introducing the PlayPen Compiler Tutorial

Creating even a primitive compiler is difficult. There many tools involved and many points of error. I can compile a language of my own creation now. Unfortunately, I still need another compiler like g++ or clang to do the linking. So after writing this compiler, I will attempt to write a linker.

I’m not through with the compiler at the time of this writing. I haven’t implemented branching or looping. LLVM provides documentation for those two subject matters. The problem I’m struggling with now is creating strings. I don’t know how to use the heap yet.

Another thing I struggled with was creating the instructions for setting up the development environment for developing a custom compiler. I must have gotten lucky the first time I set one up, because it took me a week to make the process repeatable. It took another week to simplify the process. “Simplify” is a very generous term for what I’ve done. Mistakes are costly in terms of your time.

Regarding the last post where I mentioned that it took me 23 hours to build LLVM. It now takes me less than an hour. When I first learned “make” dual processors were just coming out. I assume there wasn’t a -j option, or if so, there wasn’t a use for it. Regardless, it makes a miraculous difference in build time.

I wanted to name this compiler: “Toy,” but everyone else had the same idea. I choice “PlayPen,” because they are filled with toys, and “.toy” is the extension of the source files.

For now, just the prologue is ready. It will instruct you on how to setup everything for future development. It also comes with a working parser that reads .toy files limited as they are. Subsquently we will examine the files and I will show you how to make changes.

It all starts with: PLAYPEN Chapter 0: Compiler Setup

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.