Frequently Asked Questions

  1. General Usage
  2. Tiny BASIC
  3. Code/Development

General Usage

  • How does tbp handle CTRL+C and CTRL+D (CTRL+Z, ENTER on Windows)?

    For tbp, the Python REPL served as a model. As a reminder, when you enter these keys, they are not entries, but generate exceptions. CTRL+C is KeyBoardInterrupt and CTRL+D is EOFError.

    When you are at a normal tbp prompt, tbp:> or a breakpoint prompt, DEBUG(420):>, CTRL+C does nothing, but CTRL+D will immediately terminate the application.

    If a Tiny BASIC program is running, both CTRL+C and CTRL+D will break the program and take you back to the normal tbp prompt.

    If you are in the middle of loading a file with %loadfile, a CTRL+C will abort file loading and clear any loaded program from memory.

    Figuring out a way to test these keystrokes was quite the adventure. You can check out the hack by reading controlkeys_test.py.

Tiny BASIC

  • Why is Syntax Error: Error #020: LET is missing an '=', but found '...' the most common error when entering code at the tbp prompt?

    Tiny BASIC allows two forms of LET statements:

     LET M = 420
    
     J = 240
    

    When you enter a statement like oto, the tbp scanner sees the first character, it looks to see if the entire statement is a keyword and if it isn’t, the scanner assumes the o is the variable O, and the assumes it’s the second form of assignment above.

  • What are some good BASIC resources if I want to learn more?

    • Tom Pittman’s Tiny BASIC page has loads of content and example programs.
    • Marco’s Retrobits has lots of cool games he has written for other BASIC platforms such as the Sinclair ZX Spectrum computer. While many of his programs don’t run in Tiny BASIC, I learned a lot from them.
    • Ronald Nicholson has a great list of BASIC resources. Additionally, he developed the free, cross-platform Chipmunk BASIC interpreter.
    • Hans Otten has a ton of awesome retro computing information. His KIM-1 Simulator recreates one of the computers that ran the original Tiny BASIC implementations.
    • J. Alan Henning has written many nice articles about BASIC. My absolute favorite article he wrote is The Tiny BASIC Interpretive Language IL—and Onions. He presents his intermediate language (IL) version of Tiny BASIC from the original specifications Dennis Allison wrote in the January 1976 issue of Dr. Dobb’s Journal of Computer Calisthenics & Orthodontia. My goal for future versions of tbp is to be able to run his IL version.
    • Damian Walker’s implementation of Tiny BASIC. It’s all in C, and he added some neat features.
    • Rosetta Code’s Tiny BASIC examples.

Code/Development

  • What is the overview of the source code files?

    Filename Description
    tokens.py The token type returned by the scanner.
    languageitems.py The LanguageItem types returned by the parser and the Visitor abstract class that is the base class for the interpreters.
    errors.py The exception types thrown on syntax and runtime errors.
    helpers.py Holds the shared logger, and the input/output functions used across the project.
    memory.py The fake memory for the USR function.
    scanner.py The lexical scanner.
    symboltable.py The symbol table for those 26 glorious variables.
    parser.py The token parser.
    astprinter.py A Visitor derived class to print the parse results. Used for testing and logging.
    linter.py A Visitor derived class that does the linting analysis.
    interpreter.py The tree walking interpreter that takes care of execution and debugging.
    driver.py “Drives” the Interpreter class and handles the tbp command language.
    __main__.py The entry point for the command line program.

    See Contributing for how to get setup for development.


Copyright © 2024 John Robbins. Distributed by an MIT license.