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 --
APPLE BEFUNGE EDITOR.basis a 'session transcript' intended to be pasted into an emulator;
- The original version of Bubble Escape --
bubble escape.basis a text file detokenized from the original tokenized program;
- Dungeons of Ekileugor -- an original text file, intended to be
checked and stripped by
yucca, then passed to a tokenizer such as
petcator hatoucan to create a loadable VIC-20 BASIC program file.
fileinput module is used, so the BASIC source can also be piped
yucca, and so forth. Error messages are printed on the standard error
yucca checks that each line number in the program source is
given in strictly ascending order. Some tokenizers (e.g.
happily tokenize a program source into a tokenized program with
out-of-sequence and/or duplicate line numbers, and this option prevents
that from happening. To suppress this check, give the
-A option on the
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.
-x option allows symbol constants to be defined in, and expanded in,
a yucca source. A symbolic constant is any alphanumeric token inside
square bracket. A symbolic constant is defined by placing it as the first
thing on a line, followed immediately by an equals sign, followed immediately
by the value it represents. Such lines will be stripped, and the values for
those constants expanded in other lines, when
-x is given.
-t option runs
yucca through its internal test suite and exits
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.
git clone https://git.catseye.tc/yucca/
- Test w/either Python 2, or 3, or both, depending on what's installed. Chris Pressey 2 months ago
- Bump minor version number, update copyright year. Chris Pressey 2 months ago
- Mercurial is no longer supported in this repository. Chris Pressey 2 months ago
- Merge pull request #5 from catseye/support-python-3 Chris Pressey (commit: GitHub) 2 months ago
- Repository cleanup. Chris Pressey 2 months ago
- Fix some pep8 complaints. Chris Pressey 2 months ago
- Update source to run under both Python 2 and Python 3. Chris Pressey 2 months ago
- Add "See-also bar" to the top of README. Chris Pressey (commit: GitHub) 11 months ago
- Remove some obsolete information from the "Case Studies" section. Chris Pressey 4 years ago
- Added tag rel_1_1 for changeset a61f6387e62f Cat's Eye Technologies 7 years ago