{ "info": { "author": "thautwarm", "author_email": "twshere@outlook.com", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation :: CPython" ], "description": "# rbnf-rts\nRuntime support for generated parsers of RBNF.hs\n\n# More Examples\n\nCheck the `test` directory:\n\n- test\n - multiply : parser/lexer implementation for multiplications\n - arith : parser/lexer implementation for arithmetics\n - relax : parser/lexer implementation for a full-featured programming language\n - llvmir: parser/lexer implementation for LLVM IR, nearly full-featured\n\n**In each sub-directory of test, you can run tests via directly invoking the test.sh.**, like `cd test/llvmir && bash test.sh`\n\n\n# Native Dependencies\n\n- The Haskell Stack Toolchain\n\n- The executable `rbnf-pgen` in PATH.\n\n If `~/.local/bin` is already in PATH:\n ```\n git clone https://github.com/thautwarm/RBNF.hs\n cd RBNF.hs\n stack install .\n ```\n\n# Example: Multiplications\n\n1. write a `multiply.rbnf` file:\n\n```\n# 'mul' is a python global which should be marked as 'required' in .rlex\nMul : !lhs=Mul \"*\" !rhs=Atom -> mul(lhs, rhs);\nMul : !a=Atom -> a;\nAtom : \"(\" !a=Mul \")\" -> a;\n\n# 'unwrap' should be marked as 'required', just as 'mul'\nAtom : !a= -> unwrap(a);\nSTART ::= !a=Mul -> a;\n```\n\n2. write a `multiply.rlex` file:\n```\n%require mul\n%require unwrap\n%ignore space\nnumber [+-]?\\d+\nspace \\s+\n```\n\n3. codegen\n\n```shell\nsh> rbnf-pygen multiply.rbnf multiply.rlex multiply.py --k 1 --traceback\n```\n\n4. run statically-generated parsers and lexers and enjoy its efficiency\n```python\nfrom rbnf_rts.rts import Tokens, State\nfrom multiply import run_lexer, mk_parser\nimport operator\n\ndef unwrap(x: Token):\n return int(x.value)\n\nscope = dict(mul=operator.mul, unwrap=unwrap)\n\nparse = mk_parser(**scope)\n\n\ntokens = list(run_lexer(\"\", \"-1 * 2 * (3 * 4)\"))\ngot = parse(State(), Tokens(tokens))\nprint(got)\n```\n\nGot `(True, -24)`, where `True` indicates the parsing succeeded.\n\nIf `False`, a list of errors will be given in the second element of\nthe return tuple.\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/thautwarm/rbnf-rts", "keywords": "", "license": "mit", "maintainer": "", "maintainer_email": "", "name": "rbnf-rts", "package_url": "https://pypi.org/project/rbnf-rts/", "platform": "any", "project_url": "https://pypi.org/project/rbnf-rts/", "project_urls": { "Homepage": "https://github.com/thautwarm/rbnf-rts" }, "release_url": "https://pypi.org/project/rbnf-rts/0.41/", "requires_dist": [ "prettyprinter", "wisepy2" ], "requires_python": ">=3.6.0", "summary": "", "version": "0.41" }, "last_serial": 5904748, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "9c784d8c5a6c620703b787f0216509bc", "sha256": "b8f32cf98cb325afb273596f05f8ca49feeb7707ae0c27003c14cafaf4f3c647" }, "downloads": -1, "filename": "rbnf_rts-0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "9c784d8c5a6c620703b787f0216509bc", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 22142, "upload_time": "2019-09-10T13:57:45", "url": "https://files.pythonhosted.org/packages/c6/2f/5732085f0c0dd9c5f57215fa351bae14125df4f63fb770cb86087b2a2d9a/rbnf_rts-0.1-py3-none-any.whl" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "7020bccf762f7f245bc16a3e383dff85", "sha256": "0fffae53b28e6d4114eaef5c678de239838f408b268ec4c3b1a825aa668ed888" }, "downloads": -1, "filename": "rbnf_rts-0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "7020bccf762f7f245bc16a3e383dff85", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 21706, "upload_time": "2019-09-11T10:13:18", "url": "https://files.pythonhosted.org/packages/f2/da/99f8e1f37bb16a92d3fc430a7dc5af6cbcb05a4cf7193943ce67ef0594de/rbnf_rts-0.2-py3-none-any.whl" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "5efc4d6262d402bf478ded4dec76a87a", "sha256": "9baa3ff2213aeb00efcce80953e02448d4d2eeb801711ca0c26f6a8c40f09580" }, "downloads": -1, "filename": "rbnf_rts-0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "5efc4d6262d402bf478ded4dec76a87a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 80823, "upload_time": "2019-09-27T06:42:55", "url": "https://files.pythonhosted.org/packages/b9/b1/3f22c86ec5f46c73b62056f2f36a9e4606335169e6da38ea8de2296df8ee/rbnf_rts-0.3-py3-none-any.whl" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "93342ffb5d6f2484e2ffe072e4ab012c", "sha256": "7be02ecd2998bfd2c55877efd270f42c185db80935dbb87c09a1fbd14152da5d" }, "downloads": -1, "filename": "rbnf_rts-0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "93342ffb5d6f2484e2ffe072e4ab012c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 82785, "upload_time": "2019-09-30T02:14:50", "url": "https://files.pythonhosted.org/packages/da/c1/26aab984bce4fb8ce7859a3879bd2086129e7a6a6f9ec9199a129f19f724/rbnf_rts-0.4-py3-none-any.whl" } ], "0.41": [ { "comment_text": "", "digests": { "md5": "011951481b195268bc52a12da397d3ae", "sha256": "d6c92e4a9a0bea140f245e8ce61cb8cb40dc73677d1f4922ae8a2ae7d146c027" }, "downloads": -1, "filename": "rbnf_rts-0.41-py3-none-any.whl", "has_sig": false, "md5_digest": "011951481b195268bc52a12da397d3ae", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 82806, "upload_time": "2019-09-30T04:24:40", "url": "https://files.pythonhosted.org/packages/5c/ef/6b7148037948898655556023509f1ccfb3b6c85f0d7edd5f8a778ab4ace3/rbnf_rts-0.41-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "011951481b195268bc52a12da397d3ae", "sha256": "d6c92e4a9a0bea140f245e8ce61cb8cb40dc73677d1f4922ae8a2ae7d146c027" }, "downloads": -1, "filename": "rbnf_rts-0.41-py3-none-any.whl", "has_sig": false, "md5_digest": "011951481b195268bc52a12da397d3ae", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 82806, "upload_time": "2019-09-30T04:24:40", "url": "https://files.pythonhosted.org/packages/5c/ef/6b7148037948898655556023509f1ccfb3b6c85f0d7edd5f8a778ab4ace3/rbnf_rts-0.41-py3-none-any.whl" } ] }