Make BASIC great again
this project was abandoned years ago; you'd have better luck backporting my other BASIC (that actually works, unlike this crap) into Lua instead.
This is a BASIC language and its interpreter written in Lua, which can be used with Plain Lua/OpenComputers/ComputerCraft.
The program will work with any Lua implementation that supports Lua 5.2 and higher (and Lua 5.1 with bit32 library). Tested with official Lua, LuaJIT, ComputerCraft (LuaJ) and OpenComputers (JNLua).
TBASIC.lua
: Terran BASIC shellTBASEXEC.lua
: Terran BASIC interpreterTBASINCL.lua
: Terran BASIC interpreter libraryTBASEXTN.lua
: Terran BASIC extensiondoc/TBASMAN.pdf
: Language manual. READ ITdoc/TBASMAN.tex
: Source for the manualREADME.md
: What you are reading right nowLICENSE.md
: It's MIT
Run TBASIC.lua
to get started.
- Prefix line numbers to input multiple-lined commands.
- Enter command without line number to execute the one-liner command right away. Any input program will left untouched.
- Enter
RUN
to execute the program you have written, enterLIST
to see what you have entered to the buffer. - After the
RUN
, your program will still be there. EnterNEW
to wipe out them. - Made some mistakes? No worries, you can just overwrite by re-writing the line you wish to correct.
- Line numbers too messy? Try
RENUM
, your GOTOs and GOSUBs will be updated accordingly.
Syntax of the TBASIC is heavily influenced by Commodore 64 BASIC; Line number based, GOTO-controlled (uh-oh, sounds harmful), has GOSUB, etc. What doesn't work is direct memory controls (PEEK/POKE, SYS) and graphic/sound related commands.
You clone it, make it great, and make a pull request.
You can also help improving the documentation by adding missing texts, correcting my bad English (if any), or making a translation for non-English speaker like me. Don't know how to use TeX? Just leave them as plain text/MS Word/Rich Text Format and I'll take care of them. (Note: HWP is not to be accepted. C'mon, what the f--k is HWP?)
If you have suggestions/bugs, feel free to report them on the Issue Tracker.
The interpreter is basically a stack-based machine, much like FORTH. Input commands are converted into Reverse Polish Notation using _G._TBASIC.TORPN()
, TORPN notates type of each token (function, operator, variable, string and number), and the interpreter executes RPN'd command token by token. More details are on the comments of the code.
This project is in its early stages, meaning most of the keywords are not implemented, already implemented features are buggy.
Reference manual is work-in-progress.
If you are to distribute this Software to be used on the OpenComputers/ComputerCraft, AND ONLY WHEN YOU DISTRIBUTE THE VERBATIM COPY OF THE ESSENTIAL PARTS OF THIS SOFTWARE (following three files: TBASINCL.lua
, TBASEXEC.lua
and TBASIC.lua
), you can distribute without the license file. If not (made some modifications and/or to be used on other software/games, even if you are the contributor of this Software), the copyright notice and the permission notice shall be included in all copies or substantial portions of the Software.