Skip to main content

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:

dronestate appveyor codecov docstate

Project details


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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ppci-0.5-py3-none-any.whl (237.2 kB view details)

Uploaded Python 3

File details

Details for the file ppci-0.5.tar.gz.

File metadata

  • Download URL: ppci-0.5.tar.gz
  • Upload date:
  • Size: 219.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ppci-0.5.tar.gz
Algorithm Hash digest
SHA256 520b5808a389b55d0da3ee72c9cd54fca3ac30d2d1c1540aa18ff384297fa201
MD5 ba272afb562da7ac9b7a43c2869830ad
BLAKE2b-256 d23b01c1347764213efac407772c0f79ecac62416272846f3f25def63dbb201f

See more details on using hashes here.

File details

Details for the file ppci-0.5-py3-none-any.whl.

File metadata

  • Download URL: ppci-0.5-py3-none-any.whl
  • Upload date:
  • Size: 237.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ppci-0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 6978b90b7529dfec888049f71268dad7f17bd37c2c3356f16eefd3612d118d72
MD5 de132f9889d3156b23e182df9d9f083e
BLAKE2b-256 de9e10fb778a9fbf03a059b8e5fde560db2b8f4065a010ed82ee7da86a2f2299

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page