ti842py


Nameti842py JSON
Version 0.9.10 PyPI version JSON
download
home_pagehttps://github.com/TabulateJarl8/ti842py
SummaryTI-BASIC to Python 3 Transpiler
upload_time2023-05-13 01:51:44
maintainer
docs_urlNone
authorTabulate
requires_python>=3.6
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
<p align="center">
<img src="https://raw.githubusercontent.com/TabulateJarl8/ti842py/master/imgs/ti842py-logo.svg" alt="ti842py Logo" width="70%" />
</p>
<p align="center">
<a href="https://badge.fury.io/py/ti842py"><img alt="PyPI" src="https://img.shields.io/pypi/v/ti842py" /></a>
<a href="https://pepy.tech/project/ti842py"><img alt="Downloads" src="https://pepy.tech/badge/ti842py" /></a>
<a href="https://pypi.python.org/pypi/ti842py/"><img alt="PyPI license" src="https://img.shields.io/pypi/l/ti842py.svg" /></a>
<a href="https://GitHub.com/TabulateJarl8/ti842py/graphs/commit-activity"><img alt="Maintenance" src="https://img.shields.io/badge/Maintained%3F-yes-green.svg" /></a>
<a href="https://GitHub.com/TabulateJarl8/ti842py/issues/"><img alt="GitHub Issues" src="https://img.shields.io/github/issues/TabulateJarl8/ti842py.svg" /></a>
<a href="https://github.com/TabulateJarl8"><img alt="GitHub followers" src="https://img.shields.io/github/followers/TabulateJarl8?style=social" /></a>
<a href="https://github.com/TabulateJarl8/ti842py"><img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/TabulateJarl8/ti842py?style=social" /></a>
</p>

----

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](https://github.com/TabulateJarl8/basically-ti-basic). Note that this software is in beta and may produce inaccurate results.

# Features

----

 - Converts string literals to comments
 - Attempts to interpret implicit multiplication
 - Attempts to fix floating point arithmetic errors
 - `Disp`/`Output()`
 - Variable assignment
 - `If/Then/Else` statements, including `Else If`
 - `ClrHome`
 - `Input`/`Prompt`
 - For, While, and Repeat loops
 - `Pause`
 - `Wait`
 - `Stop`
 - `DelVar`
 - `getKey`
 - `Goto`/`Lbl`
 - `getDate`, `getTime`, and `dayOfWk`
 - `IS>(`/`DS<(`
 - `Menu()`
 - `toString()`
 - `randInt()`/`rand`
 - Most drawing functions
 - List subscripting
 - Matrices
 - `Ans`
 - `prgm`
 - `round()`

### Planned Features
 - `Return`
 - `eval()`/`expr()`

### Known issues

Issues can be found at [https://github.com/TabulateJarl8/ti842py/issues](https://github.com/TabulateJarl8/ti842py/issues)

# 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

----

Feel free to use the programs found at [https://github.com/TabulateJarl8/tiprograms](https://github.com/TabulateJarl8/tiprograms) to test this project out.

## CLI 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 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 OUTFILE] [-n] [-d] [--no-fix-multiplication] [--no-fix-floating-point] [--turbo-draw] [-r] [-V] [infile]

TI-BASIC to Python 3 Transpiler

positional arguments:
  infile                Input file (filename or stdin).

optional arguments:
  -h, --help            show this help message and exit
  -o OUTFILE, --out OUTFILE
                        Optional output file to write to. Defaults to standard out.
  -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
  --no-fix-multiplication
                        Do not attempt to fix implicit multiplication. For example, AB -> A*B and A(1) -> A*(1)
  --no-fix-floating-point
                        Do not attempt to fix floating point arithmetic errors. For example, 1.1 * 3 would normally say 3.3000000000000003 instead of 3.3
  --turbo-draw          Remove the 0.1 second delay between drawing actions
  -r, --run             Runs the program after it's done transpiling. Will not print to stdout
  -V, --version         show program's version number and exit
```

### Advanced terminal usage

You can use ti842py by piping files to it's stdin. This can be done via pipes or redirects, and the files can be either 8Xp or plain text files, just like normal. Here's some examples:

```sh
$ cat BAR.8Xp | ti842py --run
$ ti842py -o bar.py < BAR.8Xp
$ cat CLOCK.bas | ti842py -nr
$ ti842py --no-fix-floating-point --run < CLOCK.bas
```

## Programmatic Usage

ti842py can also be imported and used in a program. Here is an example program to convert `tiprogram.txt` to `tiprogram.py`:

```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 optional arguments. `decompileFile`, `multiplication`, and `floating_point` default to `True`, and `forceDecompile`, `run`, and `turbo_draw` 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 inputfile.txt`. You can supply any arguments that you would supply with the `ti842py` command.

# Special functions
----

 - `getKey` - The `getKey` function 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, `2nd` is grave `` ` ``, and `alpha` is tilda `~`. `mode` is F6, `stat` is f7, `vars` is F8, the `X,T,θ,n` key is F9, and `clear` is backspace.

 - `If` - `If` blocks with `Then` after the `If` must be ended with `End`, they cannot be left open. `If` blocks on 2 lines without a `Then` cannot be closed with `End`

 - `prgm` - `prgm` will search the current directory for a file matching the provided name (case insensitive; extension of `.8xp`). If found, the file will be passed to the command `ti842py {filename} --run`, where `{filename}` is the name of the file. If a path is given that contains `.` or `~`, or if the path is not all uppercase, the transpiler will assume that the path has been manually provided by the user (this will be useful once I implement a TI-BASIC shell).

# Libraries used

----

 - [My fork of basically-ti-basic](https://github.com/TabulateJarl8/basically-ti-basic) - for decompiling `.8Xp` files

 - [graphics.py](https://anh.cs.luc.edu/handsonPythonTutorial/graphics.html) - for drawing features

 - [insignification's fork of the goto module](https://github.com/insignification/python-goto/tree/fix2) - for `goto`/`lbl` support

 - [pynput](https://github.com/moses-palmer/pynput) - for non-blocking input support

 - [pythondialog](http://pythondialog.sourceforge.net/doc/) - Python wrapper around `dialog` for `Menu` support

 - [token_utils](https://github.com/aroberge/token-utils) - Support for fixing implicit multiplication



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/TabulateJarl8/ti842py",
    "name": "ti842py",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "Tabulate",
    "author_email": "tabulatejarl8@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/bd/c9/1ed814c5dd2f189f4c7650544244853bc4cf780d9bcc763165c62760ce35/ti842py-0.9.10.tar.gz",
    "platform": null,
    "description": "\n<p align=\"center\">\n<img src=\"https://raw.githubusercontent.com/TabulateJarl8/ti842py/master/imgs/ti842py-logo.svg\" alt=\"ti842py Logo\" width=\"70%\" />\n</p>\n<p align=\"center\">\n<a href=\"https://badge.fury.io/py/ti842py\"><img alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/ti842py\" /></a>\n<a href=\"https://pepy.tech/project/ti842py\"><img alt=\"Downloads\" src=\"https://pepy.tech/badge/ti842py\" /></a>\n<a href=\"https://pypi.python.org/pypi/ti842py/\"><img alt=\"PyPI license\" src=\"https://img.shields.io/pypi/l/ti842py.svg\" /></a>\n<a href=\"https://GitHub.com/TabulateJarl8/ti842py/graphs/commit-activity\"><img alt=\"Maintenance\" src=\"https://img.shields.io/badge/Maintained%3F-yes-green.svg\" /></a>\n<a href=\"https://GitHub.com/TabulateJarl8/ti842py/issues/\"><img alt=\"GitHub Issues\" src=\"https://img.shields.io/github/issues/TabulateJarl8/ti842py.svg\" /></a>\n<a href=\"https://github.com/TabulateJarl8\"><img alt=\"GitHub followers\" src=\"https://img.shields.io/github/followers/TabulateJarl8?style=social\" /></a>\n<a href=\"https://github.com/TabulateJarl8/ti842py\"><img alt=\"GitHub Repo stars\" src=\"https://img.shields.io/github/stars/TabulateJarl8/ti842py?style=social\" /></a>\n</p>\n\n----\n\nti842py 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](https://github.com/TabulateJarl8/basically-ti-basic). Note that this software is in beta and may produce inaccurate results.\n\n# Features\n\n----\n\n - Converts string literals to comments\n - Attempts to interpret implicit multiplication\n - Attempts to fix floating point arithmetic errors\n - `Disp`/`Output()`\n - Variable assignment\n - `If/Then/Else` statements, including `Else If`\n - `ClrHome`\n - `Input`/`Prompt`\n - For, While, and Repeat loops\n - `Pause`\n - `Wait`\n - `Stop`\n - `DelVar`\n - `getKey`\n - `Goto`/`Lbl`\n - `getDate`, `getTime`, and `dayOfWk`\n - `IS>(`/`DS<(`\n - `Menu()`\n - `toString()`\n - `randInt()`/`rand`\n - Most drawing functions\n - List subscripting\n - Matrices\n - `Ans`\n - `prgm`\n - `round()`\n\n### Planned Features\n - `Return`\n - `eval()`/`expr()`\n\n### Known issues\n\nIssues can be found at [https://github.com/TabulateJarl8/ti842py/issues](https://github.com/TabulateJarl8/ti842py/issues)\n\n# Installation\n\n----\n\nti842py 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`.\n\n# Usage\n\n----\n\nFeel free to use the programs found at [https://github.com/TabulateJarl8/tiprograms](https://github.com/TabulateJarl8/tiprograms) to test this project out.\n\n## CLI Usage\n\nti842py 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 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\n\n```\nusage: ti842py [-h] [-o OUTFILE] [-n] [-d] [--no-fix-multiplication] [--no-fix-floating-point] [--turbo-draw] [-r] [-V] [infile]\n\nTI-BASIC to Python 3 Transpiler\n\npositional arguments:\n  infile                Input file (filename or stdin).\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -o OUTFILE, --out OUTFILE\n                        Optional output file to write to. Defaults to standard out.\n  -n, --force-normal    Forces the program to not attempt and decompile the input file. Useful for false positives\n  -d, --force-decompile\n                        Forces the program to attempt to decompile the input file\n  --no-fix-multiplication\n                        Do not attempt to fix implicit multiplication. For example, AB -> A*B and A(1) -> A*(1)\n  --no-fix-floating-point\n                        Do not attempt to fix floating point arithmetic errors. For example, 1.1 * 3 would normally say 3.3000000000000003 instead of 3.3\n  --turbo-draw          Remove the 0.1 second delay between drawing actions\n  -r, --run             Runs the program after it's done transpiling. Will not print to stdout\n  -V, --version         show program's version number and exit\n```\n\n### Advanced terminal usage\n\nYou can use ti842py by piping files to it's stdin. This can be done via pipes or redirects, and the files can be either 8Xp or plain text files, just like normal. Here's some examples:\n\n```sh\n$ cat BAR.8Xp | ti842py --run\n$ ti842py -o bar.py < BAR.8Xp\n$ cat CLOCK.bas | ti842py -nr\n$ ti842py --no-fix-floating-point --run < CLOCK.bas\n```\n\n## Programmatic Usage\n\nti842py can also be imported and used in a program. Here is an example program to convert `tiprogram.txt` to `tiprogram.py`:\n\n```py\nfrom ti842py import transpile\n\ntranspile(\"tiprogram.txt\", \"tiprogram.py\")\n```\nAgain, if the second argument is not supplied, the program will be written to `stdout`. The `transpile` command can be supplied with optional arguments. `decompileFile`, `multiplication`, and `floating_point` default to `True`, and `forceDecompile`, `run`, and `turbo_draw` default to `False`\n\nThe 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 inputfile.txt`. You can supply any arguments that you would supply with the `ti842py` command.\n\n# Special functions\n----\n\n - `getKey` - The `getKey` function 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, `2nd` is grave `` ` ``, and `alpha` is tilda `~`. `mode` is F6, `stat` is f7, `vars` is F8, the `X,T,\u03b8,n` key is F9, and `clear` is backspace.\n\n - `If` - `If` blocks with `Then` after the `If` must be ended with `End`, they cannot be left open. `If` blocks on 2 lines without a `Then` cannot be closed with `End`\n\n - `prgm` - `prgm` will search the current directory for a file matching the provided name (case insensitive; extension of `.8xp`). If found, the file will be passed to the command `ti842py {filename} --run`, where `{filename}` is the name of the file. If a path is given that contains `.` or `~`, or if the path is not all uppercase, the transpiler will assume that the path has been manually provided by the user (this will be useful once I implement a TI-BASIC shell).\n\n# Libraries used\n\n----\n\n - [My fork of basically-ti-basic](https://github.com/TabulateJarl8/basically-ti-basic) - for decompiling `.8Xp` files\n\n - [graphics.py](https://anh.cs.luc.edu/handsonPythonTutorial/graphics.html) - for drawing features\n\n - [insignification's fork of the goto module](https://github.com/insignification/python-goto/tree/fix2) - for `goto`/`lbl` support\n\n - [pynput](https://github.com/moses-palmer/pynput) - for non-blocking input support\n\n - [pythondialog](http://pythondialog.sourceforge.net/doc/) - Python wrapper around `dialog` for `Menu` support\n\n - [token_utils](https://github.com/aroberge/token-utils) - Support for fixing implicit multiplication\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "TI-BASIC to Python 3 Transpiler",
    "version": "0.9.10",
    "project_urls": {
        "Homepage": "https://github.com/TabulateJarl8/ti842py"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7726d9446cc5fb3829314b59f7264524902511803e46ce05e2996a6aa126ffb7",
                "md5": "c5f5ab9d2fcc8f17d7a0ed1732eab086",
                "sha256": "56cfc109e43cc84a15cefbe6d43d5373379cb24b5aea40ccd455b2e5f9b50800"
            },
            "downloads": -1,
            "filename": "ti842py-0.9.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c5f5ab9d2fcc8f17d7a0ed1732eab086",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 44949,
            "upload_time": "2023-05-13T01:51:42",
            "upload_time_iso_8601": "2023-05-13T01:51:42.896495Z",
            "url": "https://files.pythonhosted.org/packages/77/26/d9446cc5fb3829314b59f7264524902511803e46ce05e2996a6aa126ffb7/ti842py-0.9.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bdc91ed814c5dd2f189f4c7650544244853bc4cf780d9bcc763165c62760ce35",
                "md5": "f033b500369fa7919e55a4b79e20daef",
                "sha256": "3b31bad1a448c454d022f50f9766449b4f8258b40020f9a6048e921e54101bcb"
            },
            "downloads": -1,
            "filename": "ti842py-0.9.10.tar.gz",
            "has_sig": false,
            "md5_digest": "f033b500369fa7919e55a4b79e20daef",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 54535,
            "upload_time": "2023-05-13T01:51:44",
            "upload_time_iso_8601": "2023-05-13T01:51:44.815824Z",
            "url": "https://files.pythonhosted.org/packages/bd/c9/1ed814c5dd2f189f4c7650544244853bc4cf780d9bcc763165c62760ce35/ti842py-0.9.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-13 01:51:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "TabulateJarl8",
    "github_project": "ti842py",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "ti842py"
}
        
Elapsed time: 0.07902s