basic101 is a circa 1980 BASIC interpreter written in Ruby
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Gem Version Dependency Status Code Climate Build Status

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.

Which parser?

This interpreter uses Parslet, a Ruby library for Parsing Expression Grammars (PEG). Parslet has several attractive properties:


gem install basic101

How to use

First, download a BASIC program such as one of those from Classic Basic Games or Vintage BASIC's archive. Then simply run the interpreter with the path of the program:

basic101 superstartrek.bas

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."

Ruby Compatability

basic101 requires Ruby 2.0 or greater.

OS Compatability

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:

rake test

or just:


To run the rspec (unit) tests:

rake test:spec

To run the integration tests:

rake test:integration

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 integration_test.rb directly.

To run only the print test:

integration_test.rb print

To run only the fast tests:

integration_test.rb fast

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:

integration_test.rb -t


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request



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

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.

Vintage BASIC's archive of programs for "Basic Computer Games" is similar to that of Classic Basic Games, except that Lyle's archive has two additional programs:

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