Tags Perl
I've recently completed my Perl implementation of Knuth's MIX/MIXAL (Perlmix).

It includes:

  • A compiler/assembler for the MIXAL language. Compiles MIXAL to MIX machine code. Parse::RecDescent was used for the front-end.
  • A simulator/VM of the MIX machine. Executes MIX machine code, including accesses to the imaginary devices of MIX (tapes, drums, etc.) The simulator has built-in a simple command-line debugger (ala GDB).

Perlmix can be downloaded from GitHub. I might get to making a CPAN module out of it, some day.

The package includes a test-base with a few non-trivial MIXAL programs that exercise Perlmix's abilities.

So, it's my first virtual machine, compiler and debugger (for a "real" language). Nice. It all weighs about 3 KLOC, btw.