{ "info": { "author": "Tom Wiesing", "author_email": "tkw01536@gmail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries", "Topic :: Utilities" ], "description": "=======\nPreJsPy\n=======\n\n.. image:: https://travis-ci.org/tkw1536/PreJsPy.svg?branch=master\n :alt: Build Status\n :target: https://travis-ci.org/tkw1536/PreJsPy\n\nWhat is this?\n=============\n\nPreJsPy is highly configurable a precedence-based parser written in both Python and JavaScript.\nThe default grammar is based on a subset of JavaScript but can be adapted to a lot of different scenarios.\n\n.. code:: python\n\n >>> from PreJsPy import PreJsPy\n >>> parser = PreJsPy()\n >>> parser.parse(\"6 * 9 == 42\")\n {'type': 'BinaryExpression', 'operator': '==', 'right': {'type': 'Literal', 'raw': '42', 'value': 42.0}, 'left': {'type': 'BinaryExpression', 'operator': '*', 'right': {'type': 'Literal', 'raw': '9', 'value': 9.0}, 'left': {'type': 'Literal', 'raw': '6', 'value': 6.0}}}\n\n.. code:: js\n\n > var PreJsPy = require('pre-js-py').PreJsPy;\n > parser = new PreJsPy()\n > parser.parse('6 * 9 == 42')\n { type: 'BinaryExpression',\n operator: '==',\n left:\n { type: 'BinaryExpression',\n operator: '*',\n left: { type: 'Literal', value: 6, raw: '6' },\n right: { type: 'Literal', value: 9, raw: '9' } },\n right: { type: 'Literal', value: 42, raw: '42' } }\n\nThe JavaScript version of this library has been adapted from the JavaScript library JSEP which is (c) 2013 Stephen Oney, http://jsep.from.so/ and has been published under the terms of the MIT license. The code has been ported to Python and a lot of utility functions have been added.\n\nGrammar Features\n=================\n\n* Symbolic Values\n * Constants\n * such as ```true```, ```false``` and ```null```\n * configurable: Arbitrary constants can be added\n * Identifiers\n * may contain $,\\_ or alphanumeric chacraters but may not start with a number\n * can include property names and accessors, for example `foo`, `bar.baz`, `foo['bar'].baz`\n* Various types of literals\n * Numeric Literals (```42.001```)\n * decimal notation (```-42```)\n * exponential notation (```6.7E-10```)\n * String Literals (```\"Hello world\"```)\n * can be either double or single quotes\n * special characters can be escaped\n * Array Literals (```[1, 2, 3]```)\n * must be surrounded by square brackets\n * can be nested\n* Multiple types of operators\n * Unary operators\n * by default ```-```, ```!```, ```~``` and ```+```\n * custom operators can be added, existing ones can be removed\n * Binary operators\n * precedence based\n * by default contains all JavaScript operators\n * custom ones can be added with custom precedences\n * brackets can be used to override precedences\n * JavaScript Conditional operator\n * single ternary operator ```a ? b : c```\n* Call Expressions\n * must use round brackets\n * for example ```Math.cos(x)```\n\nAPI\n===\n\nThe API in JavaScript and python are almost identical. The only differences come from the features of the languages themselves.\n\n.. code:: javascript\n\n var parser = new PreJsPy(); // creates a new parser\n\n parser.getConstants() // returns an object containing constants\n parser.setConstants(d) // sets the current constants know to the parser\n\n parser.getUnaryOperators() // gets an array of unary operators\n parser.setUnaryOperators(ary) // sets an array of unary operators\n\n parser.getBinaryOperators() // returns an object mapping binary operators to their precedence\n parser.setBinaryOperators(ary) // sets the binary operators to precedence mapping\n\n parser.parse(s) // parses a string into a AST\n\n.. code:: python\n\n parser = PreJsPy() # creates a new parser\n\n parser.getConstants() # returns an object containing constants\n parser.setConstants(d) # sets the current constants know to the parser\n\n parser.getUnaryOperators() # gets an array of unary operators\n parser.setUnaryOperators(ary) # sets an array of unary operators\n\n parser.getBinaryOperators() # returns an object mapping binary operators to their precedence\n parser.setBinaryOperators(ary) # sets the binary operators to precedence mapping\n\n parser.parse(s) # parses a string into a AST\n\nInstall\n=======\n\nThis package is published on the\n`Python Package Index `_\nInstallation can be done simply via pip:\n\n.. code:: bash\n\n pip install pre_js_py\n\nIt is also published on\n`Nodejs Package Manager `_\nInstallation can be done simply via npm:\n\n.. code:: bash\n\n npm install pre-js-py\n\n\nLicense + Acknowledgements\n==========================\n\nThis module and associated documentation is Copyright (c) Tom Wiesing 2016\nand licensed under the MIT license, see `license `_ for details.\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/tkw1536/PreJsPy", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "pre-js-py", "package_url": "https://pypi.org/project/pre-js-py/", "platform": "", "project_url": "https://pypi.org/project/pre-js-py/", "project_urls": { "Homepage": "https://github.com/tkw1536/PreJsPy" }, "release_url": "https://pypi.org/project/pre-js-py/1.2.0/", "requires_dist": null, "requires_python": "", "summary": "Highly configurable precedence-based parser written in both Python and JavaScript", "version": "1.2.0" }, "last_serial": 4917006, "releases": { "1.1.0": [ { "comment_text": "", "digests": { "md5": "f0f56149155e0eccf15478416e5b39e1", "sha256": "bbc20bb60125dc8684cead13022e23dd77a96f4dabec8d2d1226f94a267fb65a" }, "downloads": -1, "filename": "pre_js_py-1.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "f0f56149155e0eccf15478416e5b39e1", "packagetype": "bdist_wheel", "python_version": "3.5", "requires_python": null, "size": 11452, "upload_time": "2016-11-25T15:37:34", "url": "https://files.pythonhosted.org/packages/62/b8/cc0367444d4c13c3020b208377405ed48b594d88180e97a42b5a30d035df/pre_js_py-1.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fc4e7c7d75f44748edde95e45c19e47e", "sha256": "1d421920008c1d5342b3ab9db451adad89050538862fbc00903419b4473874e2" }, "downloads": -1, "filename": "pre_js_py-1.1.0.tar.gz", "has_sig": false, "md5_digest": "fc4e7c7d75f44748edde95e45c19e47e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8422, "upload_time": "2016-11-25T15:37:32", "url": "https://files.pythonhosted.org/packages/93/f3/530b15625dd3a6d06b655ff0365119a00ab511ab9445327efdebd36d1eb2/pre_js_py-1.1.0.tar.gz" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "7378c1a19eb74c2fb1df709dd566d6ba", "sha256": "9b8462d4884edd9b7c1087786c7f87f8545781a974418f247945d3279147d6e3" }, "downloads": -1, "filename": "pre_js_py-1.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "7378c1a19eb74c2fb1df709dd566d6ba", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8872, "upload_time": "2019-03-08T20:27:48", "url": "https://files.pythonhosted.org/packages/82/2e/1f11a651deb16ce7a1ee476edfd31fd5822385ea6f49af7db15a0eb440f0/pre_js_py-1.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d658fdd1faf1014d2cbc1dfbcf8fa6e3", "sha256": "e25af075da814be0bb3845998e1cf2760ce4381ae6aede4a5016cc32c5af1ccb" }, "downloads": -1, "filename": "pre_js_py-1.2.0.tar.gz", "has_sig": false, "md5_digest": "d658fdd1faf1014d2cbc1dfbcf8fa6e3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9972, "upload_time": "2019-03-08T20:27:50", "url": "https://files.pythonhosted.org/packages/9d/02/cb9250050b320328a1ce2cd7895c7c51ec0f8af072368105889c52290233/pre_js_py-1.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7378c1a19eb74c2fb1df709dd566d6ba", "sha256": "9b8462d4884edd9b7c1087786c7f87f8545781a974418f247945d3279147d6e3" }, "downloads": -1, "filename": "pre_js_py-1.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "7378c1a19eb74c2fb1df709dd566d6ba", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8872, "upload_time": "2019-03-08T20:27:48", "url": "https://files.pythonhosted.org/packages/82/2e/1f11a651deb16ce7a1ee476edfd31fd5822385ea6f49af7db15a0eb440f0/pre_js_py-1.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d658fdd1faf1014d2cbc1dfbcf8fa6e3", "sha256": "e25af075da814be0bb3845998e1cf2760ce4381ae6aede4a5016cc32c5af1ccb" }, "downloads": -1, "filename": "pre_js_py-1.2.0.tar.gz", "has_sig": false, "md5_digest": "d658fdd1faf1014d2cbc1dfbcf8fa6e3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9972, "upload_time": "2019-03-08T20:27:50", "url": "https://files.pythonhosted.org/packages/9d/02/cb9250050b320328a1ce2cd7895c7c51ec0f8af072368105889c52290233/pre_js_py-1.2.0.tar.gz" } ] }