Tiny BASIC Road Block Cleared
Saturday, 14th September 2019
It's been a while since I posted about the Tiny BASIC Interpreter and Compiler project. After I finished writing Intergalactic Space Rescue, I returned to the compiler itself and started on some tidying up. What was meant to be a simple task resulted in a bug that stalled me for two weeks.
When I started on Tiny BASIC, I adopted and adapted the tokeniser I'd written for BOOPL. In BOOPL, end-of-line (EOL) characters aren't hugely significant. An EOL followed by a command keyword signifies a new statement, but EOLs can also be scattered throughout the statements themselves if readability demands it. Passing EOL characters to the parser would necessitate tiresome checks in lots of places to make sure that those characters were skipped, so the BOOPL tokeniser stripped them out. If the parser wanted to detect a new statement, it could check the line numbers embedded in the tokens and watch for a change.
Tiny BASIC, on the other hand, places more imporance on the EOL character. The presence of an EOL is a hard terminator required for every statement, like the semicolon in C. Checking for changing line numbers in the tokens to make sure that statements ended where they should became tiresome; in Tiny BASIC things are easier if the parser gets to see the EOLs.
This should be a simple change; the only complication is comments, which are still stripped. The parser previously had no need to be aware of them; now it will see the empty lines where a comment has been stripped out, and it will have to deal with them accordingly. And this is where a bug crept in. I won't go into exactly what the bug was, but it kept me entertained over the last two weeks, causing me to take a break from the project at one point.
Now it's fixed, and I turned to cross-compilation. One of my colleagues who's interested in the project doesn't have a C compiler installed, so I promised I'd build a Windows executable for him to try. MinGW made light work of this. I didn't bother to create a special Makefile (yet) but just compiling the C files straight into an executable worked like a charm.
On a roll, I thought I'd try a DOS cross-compile so I could play with Tiny BASIC on my old HP100LX palmtop. But no such luck. It seems that Watcom C needs a bit more setting up before I can use it; the first hurdle is that it can't find its own header files. So the DOS compilation I'll leave for another day.