TI-BASIC to Python 3 Transpiler
Project description
ti842py
ti842py is a TI-BASIC to Python 3 transpiler. A transpiler is a piece of software that can convert code from one language to another. This program should be able to convert a lot of programs, but if you find something that it can't convert yet, start an issue. This transpiler also has the ability to automatically decompile any 8Xp file that you supply as the input file, with the help of my other project that I contribute to, basically-ti-basic. Note that this software is in beta and may produce inaccurate results.
Features
- Converts string literals to comments
Disp/Output()- Variable assignment
If/Then/Elsestatements, includingElse IfClrHomeInput/Prompt- For, While, and Repeat loops
PauseWaitStopDelVargetKeyGoto/LblgetDate,getTime, anddayOfWkIS>(/DS<(Menu()toString()randInt()/rand- Some drawing functions
- List subscripting
Planned Features
Returneval()/expr()Ans
Known issues
- Calling
PromptafterOutputwill write to STDOUT over the Output
Installation
ti842py can be installed via PyPI or by cloning the repository. To install it with PyPI, just run pip3 install ti842py in a terminal. To install it locally, you can clone the repository and run python setup.py install --user.
Usage
ti842py can be used in 3 different ways. The first way is just running it from the command line. For example, if you wanted to convert the program in tiprogram.txt to tiprogram.py, you can this command: ti842py -i tiprogram.txt -o tiprogram.py. If no value is specified for -o, the converted program will be written to stdout. The -n flag can be added to force the transpiler to not decompile the input file, and the -d flag can be added to force the transpiler to attempt and decompile the input file. If the --run or -r argument is supplied, the resulting python file will be run after it is done transpiling
usage: ti842py [-h] [-o O] -i I [-n] [-d] [-r]
optional arguments:
-h, --help show this help message and exit
-o O Optional output file to write to. Defaults to standard out.
-i I Input file.
-n, --force-normal Forces the program to not attempt and decompile the input file. Useful for false positives
-d, --force-decompile
Forces the program to attempt to decompile the input file
-r, --run Runs the program after it's done transpiling. Will not print to stdout
ti842py can also be imported and used in a program. Here is an example program to convert tiprogram.txt to tiprogram.py:
from ti842py import transpile
transpile("tiprogram.txt", "tiprogram.py")
Again, if the second argument is not supplied, the program will be written to stdout. The transpile command can be supplied with 3 optional arguments, decompileFile, forceDecompile, and run. decompileFile defaults to True, and forceDecompile and run default to False
The last way that ti842py can be ran is by running the main python file. After cloning the repository, cd into the repository and run python ti842py/main.py -i inputfile.txt. You can supply any arguments that you would supply with the ti842py command.
Special functions
-
getKey- ThegetKeyfunction works just like it does in normal TI-BASIC, except with some special rules. Any key on the keyboard pressed will be converted to the corresponding key on the calculator. This works for letters, numbers, arrow keys, enter, delete, and symbols. As for the buttons not on a keyboard, the top 5 keys are the F1-F5 keys on the keyboard,2ndis grave`, andalphais tilda~.modeis F6,statis f7,varsis F8,clearis F9, and theX,T,θ,nkey is F10. -
If-Ifblocks withThenafter theIfmust be ended withEnd, they cannot be left open.Ifblocks on 2 lines without aThencannot be closed withEnd
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ti842py-0.4.13.tar.gz.
File metadata
- Download URL: ti842py-0.4.13.tar.gz
- Upload date:
- Size: 30.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12db1c4f6cf8d9386e0ee92b0b9b9f035edd13fa810e49057ae359635c3fd792
|
|
| MD5 |
4bd4b1ab9f1c408c89d7592be33c67b4
|
|
| BLAKE2b-256 |
aba7ae9e306e718d9ec027c5f466da15603f84ae1575b5ab66e6838ede6cefde
|
File details
Details for the file ti842py-0.4.13-py3-none-any.whl.
File metadata
- Download URL: ti842py-0.4.13-py3-none-any.whl
- Upload date:
- Size: 29.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
672edc74ecf46da8fec36b06f457610fbcf3e9d6a1ad56f24b7a13ae0b2f09cc
|
|
| MD5 |
3df6e63d89b6ad3b79dc7aac864f2a6a
|
|
| BLAKE2b-256 |
94e11f946fc1003deaa39073c7482ef0790f48d150cdd3f77be1929ae3259730
|