TI-Basic interpreter, compatible with TI-83 and TI-83+.
I built this interpreter because I had some old TI-BASIC scripts sitting on my computer that I felt like running again but my TI-83+ is buried in a box somewhere. Figured it was a good excuse to learn a few new things.
Note
This interpreter does not replicate the original calculator's execution timing.
.\TI83Sharp.exe --scripttext ":5(2^4-6)/3"
.\TI83Sharp.exe --scriptfile "program.bas"Numbers, strings, lists and matrices are supported and have all their native operations implemented.
I’ve tried to preserve the optimizations available on the original calculator:
- Closing quotes, brackets, or parentheses can be omitted when they appear at the end of a line or just before a store token
- DelVar commands can be used without separating them with a colon
Currently not supported:
- Possibility to omit the starting character of custom list names in certain scenarios
| Category | Token |
|---|---|
| Control Flow | If, Then, Else, For(, While, Repeat, End, Pause, Lbl, Goto, Menu, Return, Stop, DelVar, Ans |
| Test | =, ≠, ≥, <, ≤ |
| Logic | and, or, xor, not( |
| I/O | Input, Disp, Output(, getKey, ClrHome, Menu, Pause |
| Matrices | dim(, Fill(, augment(, cumSum( |
| List | dim(, Fill(, augment(, cumSum(, ClrList, ClrAllLists, SortA(, SortD(, seq(, ΔList(, min(, max(, sum( |
| Number | abs(, round(, iPart(, fPart(, int(, min(, max( |
| String | sub(, inString( |
| Probability | rand, randInt( |
| Math | cos(, cos⁻¹(, cosh(, cosh⁻¹(, sin(, sinh(, sin⁻¹(, sinh⁻¹(, tan(, tan⁻¹(, tanh(, tanh⁻¹(, ln(, log(, √(, ³√(, ᴇ |
- Eliminate the
Scanner#NormalizeSourcefunction, which currently exists to support theDelVaroptimization and the optional colon at the beginning of new lines. This logic should be integrated directly into theScannerandParserrather than handled by a utility function. - Numbers are currently converted into a custom struct named
TiNumber, which leads to excessive allocations and garbage generation.
- Crafting Interpreters by @munificent
- Let's Build A Simple Interpreter by @rspivak
- Used to learn to write an interpreter, very interesting stuff!
- TI-Basic Developer
- Used to get hardware and software specs
- TI 84 Calculator Online
- Used to compare my interpreter with a complete emulator
- Texas Instruments TI-83 Manual Book
