{ "info": { "author": "Hou Rui", "author_email": "13244639785@163.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Programming Language :: Python :: 3", "Topic :: Software Development :: Interpreters" ], "description": "# pybasic\n\nA structured BASIC interpreter written in Python.\n\n```plain\n\nusage: pybasic.py [-h] [-a] [-s AST_PATH] [program_name]\n\nExecute pybasic programs, or start an REPL session.\n\npositional arguments:\n\n program_name The path of the source program to execute. If not\n specified, an REPL session will be started.\n\noptional arguments:\n -h, --help show this help message and exit\n -a, --ast Execute a binary abstract syntax tree file rather than\n a source program. This will be ignored in REPL mode.\n -s AST_PATH, --save AST_PATH\n Save the binary abstract syntax tree of the source\n program to the given path. The source program will not\n be executed. This will be ignored in REPL mode.\n```\n\n#### expressions\n\nSupported expressions:\n\n- ``: Math expressions. Support operators: `+`, `-`, `*`,\n`/`, `\\`(exact division), `MOD`\n- ``: Logic expressions. Support operators: `AND`,\n`OR`, `NOT`, `=`(equals to), `<>`\n\nPlease notice `=` in `` is different from `=` in assignment statement.\n\nLiteral values and function calls are also treated as ``. For example:\n\n```basic\n123 ' 123\n123.5 ' 123.5\n\"123!\" ' \"123!\"\n{1, 2, 3} ' [1, 2, 3]\nSQR(5) ' 2.23606797749979\n```\n\n#### assignments\n\nUse `LET = ` or simply ` = `.\n\nDeclarations are not required, for a variable are defined immediately before it is assigned for the first time. However, you can still use `DIM` to create an array filled with initial values. For example:\n\n```basic\nDIM A(5) AS INTEGER\nPRINT A ' [0, 0, 0, 0, 0]\n```\n\n#### control structures\n\nSupported control structures:\n\n- `WHILE ... END WHILE / WEND`\n- `DO ... LOOP`\n- `DO ... LOOP WHILE / UNTIL `\n- `FOR = TO ... NEXT / END FOR`\n\nPlease notice that `GOTO` is not supported.\n\n#### data types\n\nSupported data types:\n\n- `INTEGER` (mapped to Python type `int`)\n- `DECIMAL` (mapped to Python type `float`)\n- `STRING` (mapped to Python type `str`)\n\nPlease notice that pybasic does not actually store data types, which means the type of variables can be modified at runtime.\n\nUse `AS` operator to do type conversions. For example:\n\n```basic\n2.5 AS INTEGER ' 2\n2.5 AS STRING ' \"2.5\"\n```\n\n#### functions\n\nSome inner functions are provided, like `SQR()` and etc.\n\nSingle-line functions can be defined with `DEFUN`. For example:\n\n```basic\nDEFUN F(x) = x * x\nPRINT F(5) ' 25\n```\n\nMulti-line functions can be defined with `SUB ... END SUB` or `FUNCTION ... END FUNCTION`.\n\nFunctions can be called directly by using the function name as an order. For example:\n\n```basic\nDEFUN PRTYES(s) = PRINT(\"yes! \" + s)\nSUB PRTYEAH(s)\n PRINT \"yeah! \" + s\nEND SUB\nPRTYES \"pybasic\" ' \"yes! pybasic\"\nPRTYEAH \"pybasic\" ' \"yeah! pybasic\"\n```\n\n#### I/O\n\nUnlike most BASIC dialects, pybasic provides `PRINT()` and `INPUT()` functions instead of statements. For example:\n\n```basic\nA = INPUT() AS INTEGER ' input 17\nPRINT \"My age is \" + A ' \"My age is 17\"\n\n```\n\n#### modules\n\nUse ```USE``` to import a Python module or another pybasic program. Pybasic will try finding a file ended with ```.bas``` or ```.py``` following the module's name in the current working directory. If no such file is finded, an error will be raised. For example:\n\n```basic\n' HELLO.bas\nFUNCTION PRTHELLO(A)\n PRINT \"Hello, \" + A\nEND FUNCTION\n```\n\n```python\n# MORNING.py\nfrom pybasic import global_table\n\n@global_table.reflect('PRTMORN')\ndef print_morning(a):\n print('Good morning, %s' % a)\n```\n\n```basic\n' MAIN.bas\nUSE HELLO\nUSE MORNING\n\nPRTHELLO \"Jack\" ' Hello, Jack\nPRTMORN \"Mary\" ' Good morning, Mary\n```\n\nAny code in the module will be executed. If the module is python-based, it will be executed at runtime; if it is pybasic-based, it will be compiled into the main program before being executed.", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Hou-Rui/pybasic", "keywords": "ply python BASIC interpreter", "license": "", "maintainer": "", "maintainer_email": "", "name": "ply-pybasic", "package_url": "https://pypi.org/project/ply-pybasic/", "platform": "", "project_url": "https://pypi.org/project/ply-pybasic/", "project_urls": { "Homepage": "https://github.com/Hou-Rui/pybasic" }, "release_url": "https://pypi.org/project/ply-pybasic/1.0/", "requires_dist": null, "requires_python": "", "summary": "", "version": "1.0" }, "last_serial": 5169496, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "bdf35a9781f99a291c92cc2a7afa19fb", "sha256": "f25f882be5edfd194c28c15d209b754afa62188ceb8a73b3bbdc2222a40011db" }, "downloads": -1, "filename": "ply_pybasic-1.0-py3.7.egg", "has_sig": false, "md5_digest": "bdf35a9781f99a291c92cc2a7afa19fb", "packagetype": "bdist_egg", "python_version": "3.7", "requires_python": null, "size": 39774, "upload_time": "2019-04-21T09:57:07", "url": "https://files.pythonhosted.org/packages/a7/fa/6f215b1d6825db2b5650b79c074f3f6d3a505b6e3a46bc8375be340bddab/ply_pybasic-1.0-py3.7.egg" }, { "comment_text": "", "digests": { "md5": "d8008ea0fa663b638f949378e24bea69", "sha256": "da682d9d1fa70bf8cf752e1df169efcda55a162929e998027a860386e5de47da" }, "downloads": -1, "filename": "ply-pybasic-1.0.tar.gz", "has_sig": false, "md5_digest": "d8008ea0fa663b638f949378e24bea69", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14475, "upload_time": "2019-04-21T09:57:04", "url": "https://files.pythonhosted.org/packages/eb/e5/409a36b9bac8b87a96181a78719667293dc6cbbaf5fbb92ea7b5f17dc30f/ply-pybasic-1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "bdf35a9781f99a291c92cc2a7afa19fb", "sha256": "f25f882be5edfd194c28c15d209b754afa62188ceb8a73b3bbdc2222a40011db" }, "downloads": -1, "filename": "ply_pybasic-1.0-py3.7.egg", "has_sig": false, "md5_digest": "bdf35a9781f99a291c92cc2a7afa19fb", "packagetype": "bdist_egg", "python_version": "3.7", "requires_python": null, "size": 39774, "upload_time": "2019-04-21T09:57:07", "url": "https://files.pythonhosted.org/packages/a7/fa/6f215b1d6825db2b5650b79c074f3f6d3a505b6e3a46bc8375be340bddab/ply_pybasic-1.0-py3.7.egg" }, { "comment_text": "", "digests": { "md5": "d8008ea0fa663b638f949378e24bea69", "sha256": "da682d9d1fa70bf8cf752e1df169efcda55a162929e998027a860386e5de47da" }, "downloads": -1, "filename": "ply-pybasic-1.0.tar.gz", "has_sig": false, "md5_digest": "d8008ea0fa663b638f949378e24bea69", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14475, "upload_time": "2019-04-21T09:57:04", "url": "https://files.pythonhosted.org/packages/eb/e5/409a36b9bac8b87a96181a78719667293dc6cbbaf5fbb92ea7b5f17dc30f/ply-pybasic-1.0.tar.gz" } ] }