A Quick, Dirty and Ugly Basic interpreter

This is a silly BASIC interpreter, implemented in Common Lisp.

The lines are tokenized and stored as-is in an array indexed by the line number. When interpreting the program, the instructions are parsed directly from there ; the expressions are parsed into trees which are then evaluated.

The variables are stored into a hash table indexed by their identifier (symbol). Undefined variables are taken as 0 or "".

We distinguish number and string variables depending on the presence of a '$' character in the last position of the variable identifier.

Variables are reset by the command RUN. (A program can be restarted without losing the variable using the GOTO or GOSUB statements). Commands are not distinguished from statements and may occur in a program. In particular, LOAD could be used to load a subprogram overlay, and takes a line number where to jump to.

Programs are loaded and saved in source form.

| Mirror on | Mirror on |
Valid HTML 4.01!