Version 1.0, June 10 2012
IT SO HAPPENS in the course of human events that one may find oneself cross-developing an 8-bit BASIC program from a modern development environment.
IN THESE CASES it behoves one to take advantage of the aforementioned modern development environment to increase one's confidence that the cross-developed code is correct.
IT IS FOR THIS PURPOSE that yucca was developed. It is a small Python program which can perform static analysis on 8-bit BASIC programs. Specifically, it can, at present, check that every line number which is a target of a jump is actually present in the program. If it is not, an error message describing the inconsistency is given.
WITH GENERAL APPLICABILITY in mind, yucca recognizes the common forms of
jumps available in BASIC (
ON ... GOTO,
IF ... GOTO, and
IF ... THEN followed by a line number)
while ignoring any constructs it does not understand. This allows it to
be dialect-agnostic, with the unavoidable limitation that it cannot
recognize (and thus will not check) computed
GOTOs or any
dialect-specific command that involves line numbers.
THE BASIC PROGRAM to be analyzed must be present in a textual form.
Some emulators allow such text to be pasted in, to simulate entering it
at the 8-bit computer's keyboard; other tools are available to convert a
tokenized BASIC program to a textual form and back.
both styles of text file; it can even analyze and manipulate commands in
immediate mode, in the case of the listing being a 'session transcript.'
yucca has been successfully used on:
- The editor for Apple Befunge -- this is a 'session transcript';
- The original version of Bubble Escape -- this is the textual conversion of the tokenized program.
fileinput module is used, so the BASIC source can also be piped
yucca, and so forth.
yucca checks that the target of each jump in the program is an
existing line number. This includes any jumps that may occur in immediate
mode commands (i.e. commands with no line number) given in the text
file. If this check fails, further transformations may not be performed on
the program. To suppress this check, pass the
-L option to
yucca cannot analyze the validity of any computed line number in a BASIC
program which contains computed
GOSUBs. To reduce the chance
of an computed line number going unnoticed and unanalyzed,
default behavior is to report an error if it finds any computed
GOSUBs in the input program. To acknowledge that you are aware that
the program contains computed jumps that
yucca will not be able to
analyze, pass the
-C option to have
yucca suppress these errors.
-o option may be given to dump a copy of the program to the standard
output. This option is implied by the following two options.
-I option strips all immediate mode commands from the program before
analyzing and outputting it.
-R option strips all remarks (
REM statements) from the program
before analyzing and outputting it. Note that this happens before
analysis, so that any jumps to lines which contain only a
REM will be
found and reported.
-p option causes all program transformations to act only on program
lines, not on immediate mode lines. Thus, in combination with
on immediate mode lines are not removed. It does not affect
-I at all.
-t option runs
yucca through its internal test suite and exits
- Show errors in the order they occur in the program.
- Handle duplicate and deleted lines (line number then nothing.)
GO TOform of
GOTOfound in some BASICs.
yucca could be easily extended to warn about "code smells" such as a
GOTO to the next line, a line containing another
yucca can dump the input program with (as far as I can tell) total
fidelity; it retains case and spacing of all lines, even leading and
This facility could be built upon to give
yucca the ability to
renumber a program, or to supply missing line numbers, or even transform
a program with textual labels into one with line numbers.