{ "info": { "author": "Sam Henry", "author_email": "samuel.e.henry97@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# gramutil\n\nGramUtil is a utility for grammars in computer science. Currently, context-free grammars (CFG) and pushdown automatas (PDA) are supported.\n\n## Installation\n\n```\npip install gramutil\n```\n\n## Overview\n\n### ContextFreeGrammar\n\nThis class provides initialization and methods for a context free grammar. Common operations are demonstrated below:\n\n```python\nfrom gramutil import cfg\n\ngrammarString = \"\"\"\nS -> 0 S 0 | T\nT -> 1 T 1\n -> $\n\"\"\"\n\n# Create the grammar from the string\ngrammar = cfg.ContextFreeGrammar(grammarString)\n\n# Simplify the grammar (simplifies using basic rules)\ngrammar.simplify()\n\n# Removes any duplicate productions from any state\ngrammar.removeDuplicates()\n\n# Converts the grammar to a pushdown automata object\npda = grammar.toPDA()\n\n# Prints a textual representation of the grammar\nprint(grammar)\n```\n\nThe rules for a grammar string are as follows:\n* Start state must be `S`\n* Multiple productions for one state may be separated by the `|` character\n* Multiple productions for one state may also be on multiple lines, as shown above\n* The epsilon (empty string) character is signified with a `$`\n* Terminals may be an underscore or lowercase alphanumeric\n* Nonterminals have the same rules, but must start with an uppercase character and allow uppercase throughout\n* All terms (terminals and nonterminals) must be space-separated\n\n### PushdownAutomata\n\nThis class provides initialization and method for a pushdown automata. Currently, creation is only supported from a `ContextFreeGrammar`.\n\n```python\nfrom gramutil import cfg\n\ngrammar = cfg.ContextFreeGrammar('S -> 0 S 0 | $')\n\n# Two options for creating the PDA\npda = cfg.PushdownAutomata(grammar)\npda = grammar.toPDA()\n\n# Prints a textual representation of the PDA\nprint(pda)\n\n# Converts the PDA back to a CFG\ngrammar = pda.toCFG()\ngrammar.simplify()\nprint(grammar)\n```\n\n## Examples\n\nCheck out `examples/convert.py` for an example use\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Samhenry97/GrammarUtil.git", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "gramutil", "package_url": "https://pypi.org/project/gramutil/", "platform": "", "project_url": "https://pypi.org/project/gramutil/", "project_urls": { "Homepage": "https://github.com/Samhenry97/GrammarUtil.git" }, "release_url": "https://pypi.org/project/gramutil/0.0.2/", "requires_dist": null, "requires_python": "", "summary": "A utility package for editing grammars (CFG, PDA, etc)", "version": "0.0.2" }, "last_serial": 4901238, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "6b7d0c75534f455fbe6900f9b237f599", "sha256": "eaa23e839d27e2eb0961e55676d6964e6d5fc2a7b8c4b4547c532b4088923b7c" }, "downloads": -1, "filename": "gramutil-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "6b7d0c75534f455fbe6900f9b237f599", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5188, "upload_time": "2019-02-27T16:41:37", "url": "https://files.pythonhosted.org/packages/ae/a4/a011af8a7cafed110adf1f9a5a5d5eb52157c09b663c03446d6fb2b614df/gramutil-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a38ac35bff73d94c19f72181ba2d72d5", "sha256": "de95cfc59296ee2b552f30d6d0bcf0906397ff24a383fd518b5be5d7a94b8ca4" }, "downloads": -1, "filename": "gramutil-0.0.1.tar.gz", "has_sig": false, "md5_digest": "a38ac35bff73d94c19f72181ba2d72d5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3905, "upload_time": "2019-02-27T16:41:38", "url": "https://files.pythonhosted.org/packages/42/6f/c92673a45e8b73ef19dd95d6213f656434ade6a6d64437ff762ef5519d60/gramutil-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "cd033d80463f518ac3edca5f8b9b17be", "sha256": "c9106f359cb2c06ddc9e7d325f232b47295e5d22486f410913b701c192f4c317" }, "downloads": -1, "filename": "gramutil-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "cd033d80463f518ac3edca5f8b9b17be", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6398, "upload_time": "2019-03-05T18:38:41", "url": "https://files.pythonhosted.org/packages/28/e8/f4b452104ea54023f913e3a0bd7007936c6f13a92164464ba44a6927d924/gramutil-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "da0b2e03f062c3fd5b05cf2390fdd075", "sha256": "3d3fb30882993be6eca67928d74bba3ab94c0f8a71d29a6245a0dc46855295a6" }, "downloads": -1, "filename": "gramutil-0.0.2.tar.gz", "has_sig": false, "md5_digest": "da0b2e03f062c3fd5b05cf2390fdd075", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5010, "upload_time": "2019-03-05T18:38:42", "url": "https://files.pythonhosted.org/packages/54/d9/0dbbde30183f22066ae6bae5d63d39b7e9ca4f44ce307b54e32b4ce998c5/gramutil-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "cd033d80463f518ac3edca5f8b9b17be", "sha256": "c9106f359cb2c06ddc9e7d325f232b47295e5d22486f410913b701c192f4c317" }, "downloads": -1, "filename": "gramutil-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "cd033d80463f518ac3edca5f8b9b17be", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6398, "upload_time": "2019-03-05T18:38:41", "url": "https://files.pythonhosted.org/packages/28/e8/f4b452104ea54023f913e3a0bd7007936c6f13a92164464ba44a6927d924/gramutil-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "da0b2e03f062c3fd5b05cf2390fdd075", "sha256": "3d3fb30882993be6eca67928d74bba3ab94c0f8a71d29a6245a0dc46855295a6" }, "downloads": -1, "filename": "gramutil-0.0.2.tar.gz", "has_sig": false, "md5_digest": "da0b2e03f062c3fd5b05cf2390fdd075", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5010, "upload_time": "2019-03-05T18:38:42", "url": "https://files.pythonhosted.org/packages/54/d9/0dbbde30183f22066ae6bae5d63d39b7e9ca4f44ce307b54e32b4ce998c5/gramutil-0.0.2.tar.gz" } ] }