Skip to content

maurymarkowitz/RetroBASIC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

554 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RetroBASIC

Copyright © 2020 Maury Markowitz

GPL license

Contents

Introduction

RetroBASIC is an interpreter for programs written using 1970s/80s variations of BASIC. It is patterned mostly on MS-BASIC as seen on Commodore machines and Apple II (and many others). It also includes the alternate string manipulation methods from Dartmouth BASIC v4 and HP Timeshared BASIC, the latter of which was widely used in early microcomputer interpreters. The ultimate goal is to support almost any dialect from the era, including Dartmouth BASIC, Tiny BASIC (including Palo Alto), MS-BASIC (Altair, Commodore, etc.), HP Timeshared BASIC (Northstar, Apple, Atari, Sinclair, etc.) and others.

RetroBASIC also includes a simple static analyzer that (optionally) prints statistics for the program after it completes. This includes the length of the program and its line number range, the number and types of variables used, and similar details. The original impetus for RetroBASIC was to collect statistics on common programs to provide hints to the retrocomputing field, where new BASICs continue to be developed.

The installation also includes a very extensive reference manual which includes a complete list of the language and how it differs across various platforms. This is likely very useful on its own to the community, it is essentially an updated version of The BASIC Book by Lien, in Markdown format for easy searching.

RetroBASIC is based on gnbasic by James Bowman.

Installing RetroBASIC

The latest source code and any prebuilt binaries are available at:

https://github.com/maurymarkowitz/RetroBASIC/releases

Binary packages may be provided for macOS, Linux, and Windows.

On macOS and Linux, you can use Homebrew (where available):

brew tap maurymarkowitz/tap https://github.com/maurymarkowitz/homebrew-tap
brew install maurymarkowitz/tap/retrobasic

On Windows, you can use Scoop (where available):

scoop bucket add maurymarkowitz https://github.com/maurymarkowitz/scoop-bucket
scoop install retrobasic

Building RetroBASIC

The RetroBASIC interpreter is written in ANSI C using Flex/Bison for lexer/parser generation. It has no external dependencies beyond standard C libraries and build tools.

Requirements:

  • gcc or clang
  • make
  • flex
  • bison

Build steps:

make clean
make all

Optional install:

make install

Optional uninstall:

make uninstall

make install defaults to /usr/local; override with PREFIX if needed (for example make PREFIX=/opt/retrobasic install).

Running RetroBASIC

RetroBASIC is meant to be used with an existing program source file, not interactively. To run it, use a command similar to this example, replacing the "program.bas" with the name of the text file containing the BASIC program you wish to run:

./retrobasic program.bas

It will accept any text file as input and report (cryptic) errors if it cannot properly parse it. If parsing succeeds, the program (normally) begins running immediately.

Command-line options include:

--help, -h: print usage notes
--version, -v: print version info
--upper-case, -u: force input to upper-case, basically like using caps lock
--array-base, -a: set base index for arrays, normally 1 but some dialects use 0
--trace, -t: turn on line number tracing
--tabs: set the number of spaces for comma-separated items, defaults to 10
--goto-next, -g: if a branch is to a non-existent line, should it go to the next line or return an error?
--random, -r: seed the random number generator
--slicing, -s: enable string slicing like HP, Integer, Atari, etc.
--output-file, -o: redirect PRINT to the named file
--input-file, -i: redirect INPUT from the named file, one INPUT value per line
--no_run, -n: do not run the BASIC program, simply read and parse it and then exit
--print_statistics, -p: send a selection of statistics to the console
--write_statistics, -w: write the statistics to the named file in a machine readable format

If you wish to use RetroBASIC to simply check syntax or collect statistics, use the -n and -p switches.

Short options with no parameters can be ganged, for instance, -unp.

Missing features and Errata

A complete list is maintained in the TODO file, but here are some important limitations:

  • Variable names are currently limited to two characters, which is needed to support "crunched" statements without spaces in MS style.
  • The system does not support "immediate mode" (command line) input. It is not supposed to, but could potentially do so.
  • LIST, LOAD and SAVE are currently not implemented, in keeping with the use-case.

About

BASIC interpreter in lex/yacc/c, designed to run practically any early program no matter the dialect - HP, DEC, Dartmouth and others will all run in RetroBASIC.

Topics

Resources

License

Stars

Watchers

Forks

Packages