{ "info": { "author": "Shivam Sarodia", "author_email": "ssarodia@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Console", "Intended Audience :: Developers", "Intended Audience :: Education", "License :: OSI Approved :: MIT License", "Programming Language :: C", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development", "Topic :: Software Development :: Build Tools", "Topic :: Software Development :: Code Generators", "Topic :: Software Development :: Compilers" ], "description": "# ShivyC [![Build Status](https://travis-ci.org/ShivamSarodia/ShivyC.svg?branch=master)](https://travis-ci.org/ShivamSarodia/ShivyC) [![Code Coverage](https://codecov.io/gh/ShivamSarodia/ShivyC/branch/master/graph/badge.svg)](https://codecov.io/gh/ShivamSarodia/ShivyC)\n\n### A hobby C compiler created in Python.\n\n![ShivyC demo GIF.](https://raw.githubusercontent.com/ShivamSarodia/ShivyC/master/demo.gif)\n\n---\n\nShivyC is a hobby C compiler written in Python 3 that supports a subset of the C11 standard and generates reasonably efficient binaries, including some optimizations. ShivyC also generates helpful compile-time error messages.\n\nThis [implementation of a trie](tests/general_tests/trie/trie.c) is an example of what ShivyC can compile today. For a more comprehensive list of features, see the [feature test directory](tests/feature_tests).\n\n## Quickstart\n\n### x86-64 Linux\nShivyC requires only Python 3.6 or later to compile C code. Assembling and linking are done using the GNU binutils and glibc, which you almost certainly already have installed.\n\nTo install ShivyC:\n```\npip3 install shivyc\n```\nTo create, compile, and run an example program:\n```c\n$ vim hello.c\n$ cat hello.c\n\n#include \nint main() {\n printf(\"hello, world!\\n\");\n}\n\n$ shivyc hello.c\n$ ./out\nhello, world!\n```\nTo run the tests:\n```\ngit clone https://github.com/ShivamSarodia/ShivyC.git\ncd ShivyC\npython3 -m unittest discover\n```\n\n### Other Architectures\nFor the convenience of those not running Linux, the [`docker/`](docker/) directory provides a Dockerfile that sets up an x86-64 Linux Ubuntu environment with everything necessary for ShivyC. To use this, run:\n```\ngit clone https://github.com/ShivamSarodia/ShivyC.git\ncd ShivyC\ndocker build -t shivyc docker/\ndocker/shell\n```\nThis will open up a shell in an environment with ShivyC installed and ready to use with\n```\nshivyc any_c_file.c # to compile a file\npython3 -m unittest discover # to run tests\n```\nThe Docker ShivyC executable will update live with any changes made in your local ShivyC directory.\n\n## Implementation Overview\n#### Preprocessor\nShivyC today has a very limited preprocessor that parses out comments and expands `#include` directives. These features are implemented between [`lexer.py`](shivyc/lexer.py) and [`preproc.py`](shivyc/lexer.py).\n\n#### Lexer\nThe ShivyC lexer is implemented primarily in [`lexer.py`](shivyc/lexer.py). Additionally, [`tokens.py`](shivyc/tokens.py) contains definitions of the token classes used in the lexer and [`token_kinds.py`](shivyc/token_kinds.py) contains instances of recognized keyword and symbol tokens.\n\n#### Parser\nThe ShivyC parser uses recursive descent techniques for all parsing. It is implented in [`parser/*.py`](shivyc/parser/) and creates a parse tree of nodes defined in [`tree/nodes.py`](shivyc/tree/nodes.py) and [`tree/expr_nodes.py`](shivyc/tree/expr_nodes.py).\n\n#### IL generation\nShivyC traverses the parse tree to generate a flat custom IL (intermediate language). The commands for this IL are in [`il_cmds/*.py`](shivyc/il_cmds/) . Objects used for IL generation are in [`il_gen.py`](shivyc/il_gen.py) , but most of the IL generating code is in the `make_code` function of each tree node in [`tree/*.py`](shivyc/tree/).\n\n#### ASM generation\nShivyC sequentially reads the IL commands, converting each into Intel-format x86-64 assembly code. ShivyC performs register allocation using George and Appel\u2019s iterated register coalescing algorithm (see References below). The general ASM generation functionality is in [`asm_gen.py`](shivyc/asm_gen.py) , but much of the ASM generating code is in the `make_asm` function of each IL command in [`il_cmds/*.py`](shivyc/il_cmds/).\n\n## Contributing\nPull requests to ShivyC are very welcome. A good place to start is the [Issues page](https://github.com/ShivamSarodia/ShivyC/issues). All [issues labeled \"feature\"](https://github.com/ShivamSarodia/ShivyC/issues?q=is%3Aopen+is%3Aissue+label%3Afeature) are TODO tasks. [Issues labeled \"bug\"](https://github.com/ShivamSarodia/ShivyC/issues?q=is%3Aopen+is%3Aissue+label%3Abug) are individual miscompilations in ShivyC. If you have any questions, please feel free to ask in the comments of the relevant issue or create a new issue labeled \"question\". Of course, please add test(s) for all new functionality.\n\nMany thanks to our current and past contributers:\n* [ShivamSarodia](https://github.com/ShivamSarodia)\n* [cclauss](https://github.com/cclauss)\n* [TBladen](https://github.com/tbladen)\n* [christian-stephen](https://github.com/christian-stephen)\n* [jubnzv](https://github.com/jubnzv)\n\n## References\n- [ShivC](https://github.com/ShivamSarodia/ShivC) - ShivyC is a rewrite from scratch of my old C compiler, ShivC, with much more emphasis on feature completeness and code quality. See the ShivC README for more details.\n- C11 Specification - http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf\n- x86_64 ABI - https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-1.0.pdf\n- Iterated Register Coalescing (George and Appel) - https://www.cs.purdue.edu/homes/hosking/502/george.pdf", "description_content_type": "text/markdown", "docs_url": null, "download_url": "https://github.com/ShivamSarodia/ShivyC/archive/0.5.0.tar.gz", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ShivamSarodia/ShivyC", "keywords": "shivyc compiler c programming parsing", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "shivyc", "package_url": "https://pypi.org/project/shivyc/", "platform": "", "project_url": "https://pypi.org/project/shivyc/", "project_urls": { "Download": "https://github.com/ShivamSarodia/ShivyC/archive/0.5.0.tar.gz", "Homepage": "https://github.com/ShivamSarodia/ShivyC" }, "release_url": "https://pypi.org/project/shivyc/0.5.0/", "requires_dist": null, "requires_python": "", "summary": "A C compiler written in Python", "version": "0.5.0" }, "last_serial": 3779494, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "9ef5291d86f8799d122363d405a425a8", "sha256": "24251c1ae275eebc48490075b26d85587b7071a5b3af9fcbdc6dcdb38f8f1020" }, "downloads": -1, "filename": "shivyc-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "9ef5291d86f8799d122363d405a425a8", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 60213, "upload_time": "2017-05-01T06:22:24", "url": "https://files.pythonhosted.org/packages/3d/69/a49dab6a9d0a8e2a26803ff798f84ecd5aa1d4373c0e215b059d1798b662/shivyc-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "94a586358b531429a35a1b9e53e705bc", "sha256": "0050586db21a10fc602413cefbcee839a37e7e0957799eb4c8575968c2ef91ae" }, "downloads": -1, "filename": "shivyc-0.1.0.tar.gz", "has_sig": false, "md5_digest": "94a586358b531429a35a1b9e53e705bc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 48826, "upload_time": "2017-05-01T06:22:29", "url": "https://files.pythonhosted.org/packages/94/24/b31f8dea541a56f22de6981d54f870f7053e7f2bf7eb34a428dbbbf35bb9/shivyc-0.1.0.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "be0c4972c5527d1e5f4d1d1ad50f90da", "sha256": "c48a4da3eb1e98555306cd4f4271fc0d8e0f6c3d8435805aa8f770f405df9a10" }, "downloads": -1, "filename": "shivyc-0.1.2-py3.5.egg", "has_sig": false, "md5_digest": "be0c4972c5527d1e5f4d1d1ad50f90da", "packagetype": "bdist_egg", "python_version": "3.5", "requires_python": null, "size": 133354, "upload_time": "2017-05-01T06:22:31", "url": "https://files.pythonhosted.org/packages/9e/3c/d3ddbabc32b4020d04b72d6dd0091e5e8d1d592bec26a0807d04912205df/shivyc-0.1.2-py3.5.egg" }, { "comment_text": "", "digests": { "md5": "db7acd5524e44e64098d1d93e80e1aaa", "sha256": "6fd3bcd91be54d05e82c6db3c6f4c8989ff3ba2cf686fcb77c9dea11bc49be04" }, "downloads": -1, "filename": "shivyc-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "db7acd5524e44e64098d1d93e80e1aaa", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5306, "upload_time": "2017-05-01T06:22:27", "url": "https://files.pythonhosted.org/packages/54/b7/c61ec42fb1521570972eada06f46e1b7a852cad51d5b902ff7d1a99f8402/shivyc-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "af26ef0dac5232c01ba5a1a04184283c", "sha256": "184071e0fcde042c254020ca8928a8d8dde80cafd7d5bd6c34aa095c86d34277" }, "downloads": -1, "filename": "shivyc-0.1.2.tar.gz", "has_sig": false, "md5_digest": "af26ef0dac5232c01ba5a1a04184283c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3260, "upload_time": "2017-05-01T06:22:33", "url": "https://files.pythonhosted.org/packages/19/32/c5e673ec09b1366f5be94e55e22e0e8740f17560cad382cce55463dede00/shivyc-0.1.2.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "1277dc328cedf904a74c13e9e910ce61", "sha256": "73fc8a031b8e99df6248af33ce0ca01b06ceace26630cbacdb943974800e555f" }, "downloads": -1, "filename": "shivyc-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "1277dc328cedf904a74c13e9e910ce61", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 60210, "upload_time": "2017-05-01T06:25:02", "url": "https://files.pythonhosted.org/packages/98/11/4a9717267b2c1080ac0b13cfd1269983007cb57217f02e327750dbbd008e/shivyc-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1819e78062b0846a0f5a6ceb3d0bc606", "sha256": "10f8acf12e1a7c354ff47149fb2c97ecbac68993296e3d23b61e0e3a89b67951" }, "downloads": -1, "filename": "shivyc-0.2.0.tar.gz", "has_sig": false, "md5_digest": "1819e78062b0846a0f5a6ceb3d0bc606", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 48834, "upload_time": "2017-05-01T06:25:05", "url": "https://files.pythonhosted.org/packages/a1/28/aa3f7df10ba5ef11158519fb7231b92f364a9f5e651eab2150e01ee1e0e9/shivyc-0.2.0.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "f53009f788eee58b8694cafdb59a1936", "sha256": "33874db5bf2690f3be7e69693a76c69650706d3d536bb98be136dfd5d47f6a91" }, "downloads": -1, "filename": "shivyc-0.3.1.tar.gz", "has_sig": false, "md5_digest": "f53009f788eee58b8694cafdb59a1936", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 50677, "upload_time": "2017-09-12T04:44:10", "url": "https://files.pythonhosted.org/packages/91/c6/f8dc2cea0a447eac1edbb44f91ebf8a3c33f28da0d7b73c53e5f82c09e20/shivyc-0.3.1.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "8ad93962ba7cfec7dd1a3b40400a2da6", "sha256": "b4ad1b602a5d826b65e5c183373d26b5502a25d96d1b3e3fc0bef5f08affc55c" }, "downloads": -1, "filename": "shivyc-0.3.2.tar.gz", "has_sig": false, "md5_digest": "8ad93962ba7cfec7dd1a3b40400a2da6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 50671, "upload_time": "2017-09-12T04:54:00", "url": "https://files.pythonhosted.org/packages/15/b6/152e974109a88d53238627330b565596f32bfc8a54c0f47481dc6a80c4be/shivyc-0.3.2.tar.gz" } ], "0.3.3": [ { "comment_text": "", "digests": { "md5": "2124d9f4669162580f3928632e138594", "sha256": "6403c48a3b20e7f0cf4389794594e73447172d9f7f64252a7323b5d07cc34b78" }, "downloads": -1, "filename": "shivyc-0.3.3.tar.gz", "has_sig": false, "md5_digest": "2124d9f4669162580f3928632e138594", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 58926, "upload_time": "2018-03-30T00:44:09", "url": "https://files.pythonhosted.org/packages/e7/02/1cf82a2495ac372da1567622180a14575b57f7db6916f26d6ccb26ac9dc9/shivyc-0.3.3.tar.gz" } ], "0.3.5": [ { "comment_text": "", "digests": { "md5": "c3dd875e511744bf42b9a61a5350480d", "sha256": "705f6d2856cde76dd798eded8b05a0e560e33287440cf9e2651af0c983312bd8" }, "downloads": -1, "filename": "shivyc-0.3.5-py3-none-any.whl", "has_sig": false, "md5_digest": "c3dd875e511744bf42b9a61a5350480d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 68979, "upload_time": "2018-03-30T00:51:33", "url": "https://files.pythonhosted.org/packages/01/b9/e07932a96df98a7f25c7d5c2e1cbc1d78f0672804cc448aa62d1b1916b66/shivyc-0.3.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b156316f79b2ee3b59b888fff1927e85", "sha256": "6641a2e589cd093eb9fb708343bafbaa412ae8a428405f2d5353066df2179412" }, "downloads": -1, "filename": "shivyc-0.3.5.tar.gz", "has_sig": false, "md5_digest": "b156316f79b2ee3b59b888fff1927e85", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 58830, "upload_time": "2018-03-30T00:51:26", "url": "https://files.pythonhosted.org/packages/73/10/9ac4b328b8e3404f16705c8b2caad3ae2332bd1eba911765a4b75d408fbc/shivyc-0.3.5.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "96b2042ee22ef240107ee97dd9ddffc1", "sha256": "556e11ca6303f07093506be30842035d18b304bd0d7581c6f6dcd97ee34f2b73" }, "downloads": -1, "filename": "shivyc-0.4.0-py3-none-any.whl", "has_sig": false, "md5_digest": "96b2042ee22ef240107ee97dd9ddffc1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 72783, "upload_time": "2018-03-30T01:00:30", "url": "https://files.pythonhosted.org/packages/56/67/3066aa67458a276b70e439b3a96ba648f58ac097e4adf990a90c8c8bc336/shivyc-0.4.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1444582bc1eb7c862c0aa536b3896a54", "sha256": "228297ceca1a3afa1aafa713dcc6c822bdd14ba35079f686db21c8379337fb19" }, "downloads": -1, "filename": "shivyc-0.4.0.tar.gz", "has_sig": false, "md5_digest": "1444582bc1eb7c862c0aa536b3896a54", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 61114, "upload_time": "2018-03-30T01:00:18", "url": "https://files.pythonhosted.org/packages/6e/54/bf26369a075525f678e3e9a8701bfefbd8394ce162b519f36fe3d468cefd/shivyc-0.4.0.tar.gz" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "b60841c3c7833906dee666ec0a7f38c2", "sha256": "b92127a9fd54058da6fc05d684a61161e26030b3980f58c29fce6a5f289f23a9" }, "downloads": -1, "filename": "shivyc-0.4.1-py3-none-any.whl", "has_sig": false, "md5_digest": "b60841c3c7833906dee666ec0a7f38c2", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 72785, "upload_time": "2018-03-30T01:03:16", "url": "https://files.pythonhosted.org/packages/62/dd/2ad4216bc3ad136e8af92486b079fd7ea3bff197dc766ee32f054fb28f59/shivyc-0.4.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cf388ae8882aabdf968f2f06c872d8e2", "sha256": "cd6ecd9c787d886260b68e3513ddd275fe772bee094ef384f67c49eaa7e233c4" }, "downloads": -1, "filename": "shivyc-0.4.1.tar.gz", "has_sig": false, "md5_digest": "cf388ae8882aabdf968f2f06c872d8e2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 61105, "upload_time": "2018-03-30T01:02:52", "url": "https://files.pythonhosted.org/packages/25/4c/91fd8ff4b25d883d5121bce1986e0dede6a11c5fe0cc371e8cce220c67ce/shivyc-0.4.1.tar.gz" } ], "0.4.2": [ { "comment_text": "", "digests": { "md5": "8e8b28aa1e76451e9e2f1963f374b749", "sha256": "6818b2e21a177c1191bf45d0f8aade63a7267f4493b4884cd0b77e11e4ab7a12" }, "downloads": -1, "filename": "shivyc-0.4.2-py3-none-any.whl", "has_sig": false, "md5_digest": "8e8b28aa1e76451e9e2f1963f374b749", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 72749, "upload_time": "2018-03-30T20:30:22", "url": "https://files.pythonhosted.org/packages/ec/15/7ce4d7def62fd04bb4d3417e259870970635866bd181ed48324d4161b826/shivyc-0.4.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ab8a87c95986b5c730f7c8e2271bc812", "sha256": "f56b5ec8ee05e4387bebd7d7f7991c7ce934ff2f411c97b6afda762a334b3663" }, "downloads": -1, "filename": "shivyc-0.4.2.tar.gz", "has_sig": false, "md5_digest": "ab8a87c95986b5c730f7c8e2271bc812", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 61459, "upload_time": "2018-03-30T20:30:08", "url": "https://files.pythonhosted.org/packages/72/44/b4c75d54ee4cae6891c181471af3b7f6eaf550ca68479bb0431150c680c6/shivyc-0.4.2.tar.gz" } ], "0.5.0": [ { "comment_text": "", "digests": { "md5": "9101dc4b774f48bba8e0176713e8b1ec", "sha256": "0f874a0c9dc8a137c3ff208f49065ba2b8167e3c91a1face86f50f525930a2b4" }, "downloads": -1, "filename": "shivyc-0.5.0-py3-none-any.whl", "has_sig": false, "md5_digest": "9101dc4b774f48bba8e0176713e8b1ec", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 81077, "upload_time": "2018-04-19T05:48:44", "url": "https://files.pythonhosted.org/packages/c3/c1/6e42aff25bdb783a877e7d4fb417e28d4d0d19cb81d5a1ed8d354f4fb988/shivyc-0.5.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9cb06e775b66bb27158c6a103801d7d7", "sha256": "cb43ed9f4470228c60f2f41e2cdc7f63d1dffa8df0ed2c1e15faaac113e8f83a" }, "downloads": -1, "filename": "shivyc-0.5.0.tar.gz", "has_sig": false, "md5_digest": "9cb06e775b66bb27158c6a103801d7d7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 68481, "upload_time": "2018-04-19T05:48:37", "url": "https://files.pythonhosted.org/packages/d2/c3/42e8d1cd0bb51b6fe376d3af7ac815902cc4f50546d744bc9e109490ca93/shivyc-0.5.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9101dc4b774f48bba8e0176713e8b1ec", "sha256": "0f874a0c9dc8a137c3ff208f49065ba2b8167e3c91a1face86f50f525930a2b4" }, "downloads": -1, "filename": "shivyc-0.5.0-py3-none-any.whl", "has_sig": false, "md5_digest": "9101dc4b774f48bba8e0176713e8b1ec", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 81077, "upload_time": "2018-04-19T05:48:44", "url": "https://files.pythonhosted.org/packages/c3/c1/6e42aff25bdb783a877e7d4fb417e28d4d0d19cb81d5a1ed8d354f4fb988/shivyc-0.5.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9cb06e775b66bb27158c6a103801d7d7", "sha256": "cb43ed9f4470228c60f2f41e2cdc7f63d1dffa8df0ed2c1e15faaac113e8f83a" }, "downloads": -1, "filename": "shivyc-0.5.0.tar.gz", "has_sig": false, "md5_digest": "9cb06e775b66bb27158c6a103801d7d7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 68481, "upload_time": "2018-04-19T05:48:37", "url": "https://files.pythonhosted.org/packages/d2/c3/42e8d1cd0bb51b6fe376d3af7ac815902cc4f50546d744bc9e109490ca93/shivyc-0.5.0.tar.gz" } ] }