BASIC Pre-processor in Perl
View File
Scott's dev tool prompted me to post this one.
This is a dev tool for people who write things in BASIC, but write it off-board, and like to have some more modern features.
This script runs best on a UNIX or (perhaps) a Windows environment.
It supports
(1) Labels.
(2) Long variables.
(3) Multiple source files.
(4) "Ephemeral" comments.
Your source files must not use line numbers. This script will create them for you.
Labels look like C64 LIST's:
{:this is a label}
goto {:this is a label}
Long variables are actually namespaces that work for strings, floats, or ints. They can have periods in them, so they can even vaguely resemble object field accessors. Declare and use them like this:
longvar \thing.entry
\thing.entry$ = "the thing!"
\thing.entry = 5.0
Ephemeral comments start a line with a semicolon. Their entire content is ignored and thrown away when the output BASIC source is built. I think it's useful for development documentation that's not needed in the target BASIC 2.0 code.
;
; This comment will never show up in the target code.
;
This invokes the script, passes in files 1...n (however many you have), and redirects STDOUT to a target file (here, output-file.bas). That output file is ASCII source, and is directly loadable into the emulator via the -bas flag.
perl basic-labelmaster.pl file1.list file2.list ... filen.list > output-file.bas
Submitter
Submitted
04/22/21
Category