How Many Years? An Update
Thursday, 1st August 2019
The last time I wrote a blog entry on my compiler project must have been a few years ago. I've worked on it on and off over that time. I decided on a name (BOOPL - Basic Object Orented Programming Language), prepared some documentation and with the help of the Modern Compiler Design book, I wrote the tokeniser.
Since then I also bought a very old but very cheap copy of the "Dragon Book", Compilers: Principles, Techniques, and Tools by Aho, Lam, Sethi & Ullman which is a bit more readable. But I've realised that BOOPL might be a bit complex for my first real compiler projects.
BOOPL supports simple object-orented facilities like objects, and classes with inheritance. It supports data types which are rigidly defined but which can be easily converted from one to another. It supports array and object constants. It was fun to write the specification for it, but given that I'm still learning compiler implementation techniques I've got a bit bogged down in the details. So I decided to switch to something simpler for my first project.
Enter Tiny BASIC. It was developed in the 1970s for computers that only had a few kilobytes of RAM, to hold both the interpreter and the program it was running. For that reason it was designed to be extremely simple - almost unusably simple even by the standards of that time.
The only data type available was the integer. Strings could only be used in PRINT statements for output. Variables were represented by a single letter, so there were 26 of them. And you couldn't store more data using arrays, as they weren't supported. These are the big limitations on what you can do with Tiny BASIC.
There are other limitations too. There were no functions in the original implementation. Commands were few, and there wasn't even a FOR loop. You had to implement your own loops using IF...THEN...GOTO. There were no logical operators, so AND and OR had to be simulated using chains of IF...THEN statements. On the up side there was a GOSUB and RETURN, though, so spaghetti code was avoidable. And computed GOTOs, although not very readable, allowed a rudimentary form of "case" construct.
Very early on people did expand the language. Some implementations added FOR loops, arrays, and a couple of functions including a random number generator. But my intent is to develop the original Tiny BASIC language, first as an interpreter, then as a compiler.
I'm hoping that if I delve deep enough into various archives on the Internet I will be able to find a library of example programs to use to test my implementation. Failing that, I might prepare myself for the mental exercise or torture of developing something in this language myself.