Pure python compiler infrastructure
Project description
The ppci (pure python compiler infrastructure) project is a compiler written entirely in python.
The project contains the following:
A Compiler, an assembler, a linker and a build system
Language front-ends: Brainfuck, c3
Backends: 6500, arm, avr, msp430, risc-v, x86_64
Api
Api example to compile c3 code:
>>> import io
>>> from ppci.api import c3c, link
>>> source_file = io.StringIO("""
... module main;
... function void print(string txt) {
... }
... function void main() {
... print("Hello world");
... }""")
>>> obj = c3c([source_file], [], 'arm')
>>> obj = link([obj])
Example how to assemble some assembly code:
>>> import io
>>> from ppci.api import asm
>>> source_file = io.StringIO("""section code
... pop rbx
... push r10
... mov rdi, 42""")
>>> obj = asm(source_file, 'x86_64')
>>> obj.get_section('code').data
bytearray(b'[ARH\xbf*\x00\x00\x00\x00\x00\x00\x00')
Example of the low level api usage:
>>> from ppci.arch.x86_64 import instructions, registers
>>> i = instructions.Pop(registers.rbx)
>>> i.encode()
b'['
Documentation
Documentation can be found here:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ppci-0.5.tar.gz
(219.8 kB
view hashes)
Built Distribution
ppci-0.5-py3-none-any.whl
(237.2 kB
view hashes)