Skip to content

Commit e9a3684

Browse files
Update README.rst
1 parent c05c9ff commit e9a3684

File tree

1 file changed

+85
-27
lines changed

1 file changed

+85
-27
lines changed

README.rst

Lines changed: 85 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,96 @@
1-
# ShivyC
1+
ShivyC
2+
======
23

3-
[![Build Status](https://travis-ci.org/ShivamSarodia/ShivyC.svg?branch=master)](https://travis-ci.org/ShivamSarodia/ShivyC)
4-
[![Code Coverage](https://codecov.io/gh/ShivamSarodia/ShivyC/branch/master/graph/badge.svg)](https://codecov.io/gh/ShivamSarodia/ShivyC)
4+
| |Build Status|
5+
| |Code Coverage|
56
6-
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](tests/general_tests) and [tests/feature_tests](tests/feature_tests) directories.
7+
ShivyC is a C compiler written purely in Python 3, targeting Linux
8+
x86-64 machines. ShivyC seeks to eventually support the entire C11
9+
standard and produce reasonably efficient code. For ShivyC’s current
10+
feature set, see the test files in the `tests/general\_tests`_ and
11+
`tests/feature\_tests`_ directories.
712

8-
ShivyC is a rewrite from scratch of my older attempt at a C compiler, [ShivC](https://github.com/ShivamSarodia/ShivC), with much more emphasis on feature completeness and code quality. See the ShivC README for more details on the target improvements.
13+
ShivyC is a rewrite from scratch of my older attempt at a C compiler,
14+
`ShivC`_, with much more emphasis on feature completeness and code
15+
quality. See the ShivC README for more details on the target
16+
improvements.
917

10-
## Running
11-
Requires Python 3 and the GNU binutils for assembling and linking. Run `./shivyc.py` for usage info. To run the tests:
12-
```
13-
python3 -m unittest discover
14-
```
18+
Running
19+
-------
1520

16-
## Implementation Overview
17-
#### Preprocessor
18-
ShivyC currently has a very limited preprocessor that parses out comments and expands #include directives. These features are implemented between `lexer.py` and `preproc.py`. A more complete preprocessor will be implemented.
21+
Requires Python 3 and the GNU binutils for assembling and linking. Run
22+
``./shivyc.py`` for usage info. To run the tests:
1923

20-
#### Lexer
21-
The ShivyC lexer is implemented primarily in `lexer.py`. Additionally, `tokens.py` contains definitions of the token classes used in the lexer and `token_kinds.py` contains instances of recognized keyword and symbol tokens.
24+
::
2225

23-
#### Parser
24-
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/nodes.py` and `tree/expr_nodes.py`.
26+
python3 -m unittest discover
2527

26-
#### IL generation
27-
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 `il_gen.py`, but most of the IL generating code is in the `make_code` function of each tree node in `tree/*.py`.
28+
Implementation Overview
29+
-----------------------
2830

29-
#### ASM generation
30-
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 `asm_gen.py`, but much of the ASM generating code is in the `make_asm` function of each IL command in `il_cmds/*.py`.
31+
Preprocessor
32+
^^^^^^^^^^^^
3133

32-
## Contributing
33-
ShivyC has so far been an entirely individual project. That said, pull requests are welcome if they pass flake8 and are well-tested.
34+
ShivyC currently has a very limited preprocessor that parses out
35+
comments and expands #include directives. These features are implemented
36+
between ``lexer.py`` and ``preproc.py``. A more complete preprocessor
37+
will be implemented.
3438

35-
## References
36-
- C11 Specification - http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
37-
- x86_64 ABI - http://web.archive.org/web/20160801075139/http://www.x86-64.org/documentation/abi.pdf
38-
- Iterated Register Coalescing (George and Appel) - https://www.cs.purdue.edu/homes/hosking/502/george.pdf
39+
Lexer
40+
^^^^^
41+
42+
The ShivyC lexer is implemented primarily in ``lexer.py``. Additionally,
43+
``tokens.py`` contains definitions of the token classes used in the
44+
lexer and ``token_kinds.py`` contains instances of recognized keyword
45+
and symbol tokens.
46+
47+
Parser
48+
^^^^^^
49+
50+
The ShivyC parser uses recursive descent techniques for all parsing. It
51+
is implented in ``parser/*.py`` and creates a parse tree of nodes
52+
defined in ``tree/nodes.py`` and ``tree/expr_nodes.py``.
53+
54+
IL generation
55+
^^^^^^^^^^^^^
56+
57+
ShivyC traverses the parse tree to generate a flat custom IL
58+
(intermediate language). The commands for this IL are in
59+
``il_cmds/*.py``. Objects used for IL generation are in ``il_gen.py``,
60+
but most of the IL generating code is in the ``make_code`` function of
61+
each tree node in ``tree/*.py``.
62+
63+
ASM generation
64+
^^^^^^^^^^^^^^
65+
66+
ShivyC sequentially reads the IL commands, converting each into x86-64
67+
assembly code. ShivyC performs register allocation using George and
68+
Appel’s iterated register coalescing algorithm; see References below.
69+
The general ASM generation functionality is in ``asm_gen.py``, but much
70+
of the ASM generating code is in the ``make_asm`` function of each IL
71+
command in ``il_cmds/*.py``.
72+
73+
Contributing
74+
------------
75+
76+
ShivyC has so far been an entirely individual project. That said, pull
77+
requests are welcome if they pass flake8 and are well-tested.
78+
79+
References
80+
----------
81+
82+
- C11 Specification -
83+
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
84+
- x86\_64 ABI -
85+
http://web.archive.org/web/20160801075139/http://www.x86-64.org/documentation/abi.pdf
86+
- Iterated Register Coalescing (George and Appel) -
87+
https://www.cs.purdue.edu/homes/hosking/502/george.pdf
88+
89+
.. _tests/general\_tests: tests/general_tests
90+
.. _tests/feature\_tests: tests/feature_tests
91+
.. _ShivC: https://github.com/ShivamSarodia/ShivC
92+
93+
.. |Build Status| image:: https://travis-ci.org/ShivamSarodia/ShivyC.svg?branch=master
94+
:target: https://travis-ci.org/ShivamSarodia/ShivyC
95+
.. |Code Coverage| image:: https://codecov.io/gh/ShivamSarodia/ShivyC/branch/master/graph/badge.svg
96+
:target: https://codecov.io/gh/ShivamSarodia/ShivyC

0 commit comments

Comments
 (0)