

In particular the syntax of any test code is not final, and error handling of the syntax is going to be pretty rough and ready at this stage. I’ll return later to fill in the detail and refactor as necessary. I want to explore the necessary techniques and get an overview of how to write every stage of a compiler. You can think of it as rapid prototyping. The code at the moment is mostly exploratory.It’s more a diary of what I’m discovering along the way.

I am not a ‘professional’ compiler writer – don’t treat this as a lesson in how you should write a compiler.I can update the code to replace these when I move towards the self-compiling version. I am, however, re-using old code (such as my file parser class) where I already have it to hand, and using some modern data structures to save time. The need to self-compile means I’m writing this in mostly ‘old-school’ Pascal syntax and dropping things such as objects. I’d hope to confine this loss of functionality to features such as optimisations rather than core language syntax. The self-hosted version will almost certainly lose some functionality in order to be fast enough and compact enough to be practical when running on the Z80. At that point I will also have a version which runs on the Z80 and outputs Z80 code. That will, eventually, mean it will be able to compile itself. It will initially run as a cross-compiler, running on Windows and targeting the Z80.It will target the Z80 (it could, possibly, also output some form if Intermediate Language, similar to P-Code, which could the be executed by a run-time either on the Z80 or other systems).It will be coded in Delphi (which is an IDE and libraries based around Pascal).The language will be based on Pascal, but with enhancements to make it more suitable for use on low-end machines.I’ll write at some future point about my visions for the language. But, since I’ve returned to retro computing, I can see definite limitations in the options currently available for writing software for 8-bit machines. They’ve always been something of a mystery to me and, while I’ve always fancied writing one, I’ve never had a convincing reason to do so. Recently I’ve been getting increasingly broody to write a compiler.
