Frequently Asked Questions
General Usage
-
How does tbp handle
CTRL+CandCTRL+D(CTRL+Z,ENTERon 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+Cis KeyBoardInterrupt andCTRL+Dis EOFError.When you are at a normal tbp prompt,
tbp:>or a breakpoint prompt,DEBUG(420):>,CTRL+Cdoes nothing, butCTRL+Dwill immediately terminate the application.If a Tiny BASIC program is running, both
CTRL+CandCTRL+Dwill 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+Cwill 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
LETstatements:LET M = 420 J = 240When 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 theois the variableO, 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.pyThe token type returned by the scanner. languageitems.pyThe LanguageItemtypes returned by the parser and theVisitorabstract class that is the base class for the interpreters.errors.pyThe exception types thrown on syntax and runtime errors. helpers.pyHolds the shared logger, and the input/output functions used across the project. memory.pyThe fake memory for the USRfunction.scanner.pyThe lexical scanner. symboltable.pyThe symbol table for those 26 glorious variables. parser.pyThe token parser. astprinter.pyA Visitorderived class to print the parse results. Used for testing and logging.linter.pyA Visitorderived class that does the linting analysis.interpreter.pyThe tree walking interpreter that takes care of execution and debugging. driver.py“Drives” the Interpreterclass and handles the tbp command language.__main__.pyThe entry point for the command line program. See Contributing for how to get setup for development.