Skip to main content
Warning: You are using the test version of PyPI. This is a pre-production deployment of Warehouse. Changes made here affect the production instance of TestPyPI (
Help us improve Python packaging - Donate today!

A C compiler written in Python

Project Description

ShivyC is a C compiler written purely in Python 3, targeting Linux x86-64 machines. ShivyC seeks to eventually support the entire C11 standard and produce reasonably efficient code. For ShivyC’s current feature set, see the test files in the tests/general_tests and tests/feature_tests directories.

ShivyC is a rewrite from scratch of my older attempt at a C compiler, ShivC, with much more emphasis on feature completeness and code quality. See the ShivC README for more details on the target improvements.


Requires Python 3 and the GNU binutils for assembling and linking. Run ./ for usage info. To run the tests:

python3 -m unittest discover

Implementation Overview


ShivyC currently has a very limited preprocessor that parses out comments and expands #include directives. These features are implemented between and A more complete preprocessor will be implemented.


The ShivyC lexer is implemented primarily in Additionally, contains definitions of the token classes used in the lexer and contains instances of recognized keyword and symbol tokens.


The ShivyC parser uses recursive descent techniques for all parsing. It is implented in parser/*.py and creates a parse tree of nodes defined in tree/ and tree/

IL generation

ShivyC traverses the parse tree to generate a flat custom IL (intermediate language). The commands for this IL are in il_cmds/*.py. Objects used for IL generation are in, but most of the IL generating code is in the make_code function of each tree node in tree/*.py.

ASM generation

ShivyC sequentially reads the IL commands, converting each into x86-64 assembly code. ShivyC performs register allocation using George and Appel’s iterated register coalescing algorithm; see References below. The general ASM generation functionality is in, but much of the ASM generating code is in the make_asm function of each IL command in il_cmds/*.py.


ShivyC has so far been an entirely individual project. That said, pull requests are welcome if they pass flake8 and are well-tested.

Release History

Release History

This version
History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
shivyc-0.1.2-py3-none-any.whl (5.3 kB) Copy SHA256 Checksum SHA256 py3 Wheel May 1, 2017
shivyc-0.1.2.tar.gz (3.3 kB) Copy SHA256 Checksum SHA256 Source May 1, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting