{ "info": { "author": "Juan Pablo Ortiz", "author_email": "me@pablasso.com", "bugtrack_url": null, "classifiers": [], "description": "# Chelodina\n\n[![PyPI](https://raw.githubusercontent.com/pablasso/chelodina/master/pypi.svg?sanitize=true)](https://pypi.org/project/chelodina/) [![LICENSE](https://raw.githubusercontent.com/pablasso/chelodina/master/license.png)](https://github.com/pablasso/chelodina/blob/master/LICENSE) [![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)\n\nChelodina is a transpiler that converts LOGO:\n\n```logo\nTO triangle :length\n REPEAT 3 [ FORWARD :length RIGHT 120 ]\nEND\n\nTO flower :length :count\n REPEAT 150 [\n triangle :length\n RIGHT 360 / :count\n ]\nEND\n\nTO web\n REPEAT 6 [ flower 150 18 ]\nEND\n\nweb\n\n```\n\nInto Python:\n\n```python\nimport turtle\n\n\ndef triangle(p_length):\n for _ in range(3):\n turtle.forward(p_length)\n turtle.right(120.0)\n\n\ndef flower(p_length, p_count):\n for _ in range(150):\n triangle(p_length)\n turtle.right(360.0 / p_count)\n\n\ndef web():\n for _ in range(6):\n flower(150.0, 18.0)\n\n\nweb()\nturtle.done()\n```\n\n## Installation\n\n```\npip install chelodina\n```\n\n## Usage\n\n```\nusage: chelodina [-h] --input INPUT [--run]\n\narguments:\n -h, --help show this help message and exit\n --input INPUT Logo source file\n --run Run the transpiled code\n```\n\nThere's some ready [examples](/examples) to try if you clone the repository:\n\n```\nchelodina --input examples/example1.logo\n```\n\nYou can also trigger the program to run in a GUI:\n\n```\nchelodina --input examples/example1.logo --run\n```\n\n## Status\n\n- Implemented:\n\t- Motion functions: `FORWARD`, `BACK`, `LEFT`, `RIGHT`, `SETPOS`, `SETX`, `SETY`, `SETHEADING`, `SETH`, `HOME`\n\t- Screen functions: `DONE`, `CLEARSCREEN`\n\t- Control structures: `REPEAT`\n\t- Function calls and definitions with optional parameters\n\t- Binary operations\n\nThis is still on an early stage, I focused on making some [examples](/examples) work. Functions with similar structure are trivial to implement, but I want to focus on improving the tests first.\n\nFor grammar reference look at [grammar.bnf](grammar.bnf).\n\n### Known quirks\n\n- Validations for a valid AST (e.g. to make sure a function parameter exists before trying to use it on a statement) are not user friendly yet. I suggest double-checking your programs [elsewhere](https://calormen.com/jslogo/) first.\n- Only tested on Python 3.6+ so far.\n\n## Development\n\nUse [pipenv](https://pipenv.readthedocs.io/en/latest/) to install dependencies:\n\n```\npipenv install --dev\n```\n\n### Running tests\n\nRun tests with:\n\n```\npipenv run tests\n```\n\nAutomatically run tests after detecting changes with:\n\n```\npipenv run tests-watch\n```\n\n### Debug\n\n- The easy way is to write tests to debug your code. Feel free to use `assert False` where necessary.\n- If you need to run tests along anything that sends to or needs the standard output (a debugger like pdb or pudb), you'll need to run `pytest` directly: `pytest --capture=no`.\n- There's a library to pretty-print your AST in the `utils` package. Usage example:\n\n```python\nfrom chelodina import compiler\nfrom chelodina.utils.debug import parseprint\n\nlogo_code = \"\"\"\nto myfunction\n forward 51.0\n left 91\nend\n\"\"\"\n\nparsed_ast = compiler.get_ast(logo_code)\nparseprint(parsed)\n```\n\nAnd you'll see the resulting AST:\n\n```python\nModule(body=[\n Import(names=[\n alias(name='turtle', asname=None),\n ]),\n FunctionDef(name='myfunction', args=arguments(args=[], vararg=None, kwonlyargs=[], kw_defaults=[], kwarg=None, defaults=[]), body=[\n Expr(value=Call(func=Attribute(value=Name(id='turtle', ctx=Load()), attr='forward', ctx=Load()), args=[\n Num(n=51.0),\n ], keywords=[])),\n Expr(value=Call(func=Attribute(value=Name(id='turtle', ctx=Load()), attr='left', ctx=Load()), args=[\n Num(n=91.0),\n ], keywords=[])),\n ], decorator_list=[], returns=None),\n Expr(value=Call(func=Attribute(value=Name(id='turtle', ctx=Load()), attr='done', ctx=Load()), args=[], keywords=[])),\n ])\n```\n\n\n### Code style\n\nI use [black](https://github.com/ambv/black) for code formatting, please install the [pre-commit hook](https://github.com/ambv/black#version-control-integration) before doing a PR. This will be enforced with a linter check in the future.\n\nYou can run the command manually too:\n\n```\nblack .\n```\n\nNot required, but if you install [EditorConfig](https://editorconfig.org) in your editor of choice it will make your life easier.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/pablasso/chelodina", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "chelodina", "package_url": "https://pypi.org/project/chelodina/", "platform": "", "project_url": "https://pypi.org/project/chelodina/", "project_urls": { "Homepage": "http://github.com/pablasso/chelodina" }, "release_url": "https://pypi.org/project/chelodina/0.5.5/", "requires_dist": [ "ply", "astor" ], "requires_python": "", "summary": "A Logo to Python transpiler", "version": "0.5.5" }, "last_serial": 4307809, "releases": { "0.5.2": [ { "comment_text": "", "digests": { "md5": "00174602b1cb83c23f3baa6507dcc9d0", "sha256": "b7bfa6ddcfe00672a3fb7f475d469998a65e5d0226927bc71e1d5f39cb9275d5" }, "downloads": -1, "filename": "chelodina-0.5.2-py3-none-any.whl", "has_sig": false, "md5_digest": "00174602b1cb83c23f3baa6507dcc9d0", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7386, "upload_time": "2018-09-25T08:44:39", "url": "https://files.pythonhosted.org/packages/59/52/dd07167a3089c87821ba482a1c2951af4e9c20a08c69160dc211728afdb0/chelodina-0.5.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5fbace0edde554f6cf1aa7fc0123d495", "sha256": "a8a7355fde859b40b618ab5f8a5d699fa28c109cc6c7721019c35ca809bbf946" }, "downloads": -1, "filename": "chelodina-0.5.2.tar.gz", "has_sig": false, "md5_digest": "5fbace0edde554f6cf1aa7fc0123d495", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6228, "upload_time": "2018-09-25T08:44:41", "url": "https://files.pythonhosted.org/packages/51/56/22404a7a14832c8362fb24ce9b47bcc8d9d6bbde42f7bc45f4c50a0788eb/chelodina-0.5.2.tar.gz" } ], "0.5.3": [ { "comment_text": "", "digests": { "md5": "51490f4a2b427d2544e5a175e30fe133", "sha256": "4a3cf8e6793d3610ec9d01dcbb254b57dbc9fca7027f60645719cba09046c1c1" }, "downloads": -1, "filename": "chelodina-0.5.3-py3-none-any.whl", "has_sig": false, "md5_digest": "51490f4a2b427d2544e5a175e30fe133", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7401, "upload_time": "2018-09-25T08:47:40", "url": "https://files.pythonhosted.org/packages/2c/76/40d64a7511c1b538bccb4ac86589e0dfb7384ea2ba4e68b7cb916d1d0104/chelodina-0.5.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4134f42fa0d561f4fc56fe5c13029d87", "sha256": "e6f8d07cf9f829adad60c3531ac87df1abf6af582c48a7eef122beb60e64aeab" }, "downloads": -1, "filename": "chelodina-0.5.3.tar.gz", "has_sig": false, "md5_digest": "4134f42fa0d561f4fc56fe5c13029d87", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6240, "upload_time": "2018-09-25T08:47:41", "url": "https://files.pythonhosted.org/packages/98/59/5a4b4723b477fbe8b737bdc5e4c0d4fbd25839897656f222a59ad062c19f/chelodina-0.5.3.tar.gz" } ], "0.5.4": [ { "comment_text": "", "digests": { "md5": "2fed43ccc1952603036b4c8c164ed848", "sha256": "7ecf014657f9e8c51abcda515bb927441260540b35699d3bd8bc216623f8da29" }, "downloads": -1, "filename": "chelodina-0.5.4-py3-none-any.whl", "has_sig": false, "md5_digest": "2fed43ccc1952603036b4c8c164ed848", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7404, "upload_time": "2018-09-25T08:53:47", "url": "https://files.pythonhosted.org/packages/20/5e/ceb1d3bcb42356f575e39e6d002e13e62ab453c0b1d053783015d890e6ae/chelodina-0.5.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "eedb362485b411ebd765bd578cc85d59", "sha256": "45938bab86189221e8ec99285e56869965d172fc007d4215c5274072d5d593f3" }, "downloads": -1, "filename": "chelodina-0.5.4.tar.gz", "has_sig": false, "md5_digest": "eedb362485b411ebd765bd578cc85d59", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6240, "upload_time": "2018-09-25T08:53:48", "url": "https://files.pythonhosted.org/packages/92/36/958c40d401fd874d86b2af0e92c062ba299b9d8cc65f500db44461113b27/chelodina-0.5.4.tar.gz" } ], "0.5.5": [ { "comment_text": "", "digests": { "md5": "50d0fc0cee19087f19a46e467fb0b39f", "sha256": "4b87542a300e87ea7c1dc24193d576cd6053dd991bef1cb2c8b7b84addfb4673" }, "downloads": -1, "filename": "chelodina-0.5.5-py3-none-any.whl", "has_sig": false, "md5_digest": "50d0fc0cee19087f19a46e467fb0b39f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10226, "upload_time": "2018-09-25T09:15:40", "url": "https://files.pythonhosted.org/packages/3b/a7/568195ab5165ee450fafcb6e405491d1b9aec4d09fa855e96c5f52c30afe/chelodina-0.5.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3b3304c9c8c72d5623cd138e17c03ede", "sha256": "70876bec3e3dad992450dadfc19a1a4d170c05d6eadeb63815b5abb370325dfe" }, "downloads": -1, "filename": "chelodina-0.5.5.tar.gz", "has_sig": false, "md5_digest": "3b3304c9c8c72d5623cd138e17c03ede", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8104, "upload_time": "2018-09-25T09:15:41", "url": "https://files.pythonhosted.org/packages/58/25/47b62cae278dc56c4c130659966ebe6980fcebb9f7939478156e54cde324/chelodina-0.5.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "50d0fc0cee19087f19a46e467fb0b39f", "sha256": "4b87542a300e87ea7c1dc24193d576cd6053dd991bef1cb2c8b7b84addfb4673" }, "downloads": -1, "filename": "chelodina-0.5.5-py3-none-any.whl", "has_sig": false, "md5_digest": "50d0fc0cee19087f19a46e467fb0b39f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10226, "upload_time": "2018-09-25T09:15:40", "url": "https://files.pythonhosted.org/packages/3b/a7/568195ab5165ee450fafcb6e405491d1b9aec4d09fa855e96c5f52c30afe/chelodina-0.5.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3b3304c9c8c72d5623cd138e17c03ede", "sha256": "70876bec3e3dad992450dadfc19a1a4d170c05d6eadeb63815b5abb370325dfe" }, "downloads": -1, "filename": "chelodina-0.5.5.tar.gz", "has_sig": false, "md5_digest": "3b3304c9c8c72d5623cd138e17c03ede", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8104, "upload_time": "2018-09-25T09:15:41", "url": "https://files.pythonhosted.org/packages/58/25/47b62cae278dc56c4c130659966ebe6980fcebb9f7939478156e54cde324/chelodina-0.5.5.tar.gz" } ] }