basic101 is a circa 1980 BASIC interpreter written in Ruby. It supports a modified subset of Microsoft's BASIC-80 v. 5 and runs the games published in Basic Computer Games, Microcomputer Edition by David H. Ahl
Compilers and interpreters are great fun. I wanted to experiment with a modern parser, but needed a target language. The target language of "something that properly runs the programs in Basic Computer Games, Microcomputer Edition is perfect because:
BASIC is a relatively simple language.
The book's programs are all for the same dialect of BASIC.
The book's programs are available in electronic form.
The book contains short transcripts of each program running.
Parse and transform rules are expressed in an internal DSL. This makes possible the dynamic generation of parse and transform rules.
gem install basic101
How to use
Most of these programs are included with this gem, in the directory:
A few of these programs have had minor changes to work with basic101. This is not unusual in the world of BASIC. Because Microcomputer BASICs were not written to any single specification, they all vary in small details. It was usual, in the day, to have to change a BASIC program to get it to run on the interpreter you were using.
The basic101 interpreter is released under the MIT License.
The BASIC programs which originally appeared in Basic Computer Games, Microcomputer Edition are not under the MIT license. They are included with the kind permission of David H. Ahl. David makes these programs "available to people who want to reprint them, convert them to other languages or forms of Basic, or analyze the code."
basic101 requires Ruby 2.0 or greater.
basic101 was developed in Linux. While it does not knowingly use any Unix-only features, it has not been tested under Windows. I would be grateful for any reports of success or failure running basic101 under Windows (or any other operating system).
To run all tests:
To run the rspec (unit) tests:
To run the integration tests:
The integration tests are driven by
tests/integration/integration_test.rb. During development, you
often want to run just one test, not all of them; to do so, bypass the
rake task and run
To run only the print test:
To run only the fast tests:
If you change how the interpreter behaves, the tests will notice. If you want the new behavior to become the expected behavior, then train the test or tests that are affected. Training causes the current behavior to become the expected behavior in the future. To train the print test:
integration_test.rb -t print
To train all tests:
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request
- Basic Computer Games, Microcomputer Edition
- Basic-80 Reference Manual, v. 5
- Vintage BASIC and its source
- Classic Basic Games
David H. Ahl
This program was inspired by Basic Computer Games, Microcomputer Edition by David H. Ahl. David, Thank you for inspiring us to tinker, learn, and have fun with these wonderful machines.
Lyle Kopnicky wrote Vintage BASIC, an open source BASIC written in Haskell. Vintage BASIC is a valuable resource for any vintage-BASIC author, even if you don't know Haskell. It is a good reference model when you are wondering how some ambiguous part of the language behaves. Be sure to check out the interpreter test for examples in the form of "this program produces that output". You don't have to know Haskell to understand them.
That's a lot of typing. Thank you, Lyle.
Classic Basic Games
Most of the programs from "Basic Computer Games" are available at Classic Basic Games, a wonderful resource for aspiring interpreter writers.
Wayne Conrad email@example.com