:  baZic


a minimal Basic interpreter for the Z-machine

Published: 2016 November 3

One day in early 2001 I suffered a mental breakdown and decided to write a Basic interpreter for the Z-machine. At least, I think I suffered a mental breakdown; I can't think of any other reason why I would want to do that.

By the time I recovered, baZic (as I called it) was mostly finished. It features:

  • Dynamic memory allocation, complete with block coalescing
  • A full mark/sweep garbage collector
  • Dynamic typing
  • Full tokenisation for fast(!) execution of programs
  • Full detokenisation when listing them again
  • An interactive Basic development environment (cough, cough)
  • State-of-the-art implementations of Hunt the Wumpus and Guess the Number built in to the very interpreter
  • Pseudo arrays
What it doesn't feature:
  • String operators (the hooks are there, I just need to write the code)
  • Subroutines (GOSUB & friends)
  • Procedures (SUB/PROC & friends)
  • Proper arrays
I am unlikely ever to finish this; the Basic language is just too annoying for words. It's even more annoying to implement than to write in. (It uses the Parser from Hell.) If you wish to continue it, be my guest.

baZic is written in 100% Inform code. It does, however, make certain horrible assumptions about the memory map that means it's unlikely to compile for the Glulx platform. It is mostly useful as an example of just what you can do on the Z-machine if you bend it sufficiently. Oh, and the memory allocator and garbage collector are modular and can be easily ripped out and reused if you are so inclined.

The program is licensed under the MIT open source license. The full text is available in the source package.