Skip to main content

okp

okp (pronounced like okapi) is a python script that processes .cpy files and generates C++ code.

if the following code makes you happy, okp might be for you:

def weird_multiply(int a, b):
    for i = 0; i < b; i++:
        a *= b
    return a


def main():
    int a, b
    read a, b

    print "WEIRD MULTIPLIED:", weird_multiply(a, b)

status

okp is not a good idea for anyone to use, but try it anyways and let me know what you've built

installation

pip install okp

motivation

i saw vrsperanza's CPY and the light hit me: a language that looks like python but compiles like C. i decided i want to write programs in it. okp is my attempt to write a pre-processor like CPY but in python.

usage

# print c++ source
okp -p file.cpy

# compile code
okp file.cpy

# compile multiple cpy files together
okp file1.cpy file2.cpy

# specify the executable file
okp file1.cpy -o ./a.out

# compile and run 
okp file.cpy -r

# compil and run (stdin is passed to the binary) 
okp file.cpy -ri < input.txt

# compile a hybrid project
okp file1.h file2.cpp file3.cpy -o ./a.out

features

from CPY

Features that okp implements from CPY are:

  • indentation based bracketing
  • automatic parenthesization of conditionals
  • auto variable declarations
  • return multiple values from functions
  • automatic variable destructuring
  • for and rof loop shorthand (to enable, use -for and -rof flags)
  • known keyword
  • #raw include directive
  • disabling auto variable declarations (-ni flag)
  • compilation of hybrid projects

Features that are not implemented yet:

  • export project + Makefile

original

Some original features of okp to make it look more pythonic are:

  • def keyword before function names
  • block keyword for creating blocks
  • pass keyword for no-ops
  • print and raw_input keywords
  • self keyword
  • lines that start with IGNORE_CHAR are not pre-processed
  • triple backticks for multi-line escapes

further resources and similar projects

Metadata

Release files for okp 0.0.54

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for okp 0.0.54
File Size Uploaded
okp-0.0.54.tar.gz 22.7 kB Details

Release files / okp-0.0.54.tar.gz

Download URL okp-0.0.54.tar.gz
Size 22.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ea4a3cb30308ee810cc62e4bb5e570391633d67c704248740b14ecdfcd4f3b03
BLAKE2b-256 checksum
How to use checksums
f41591e3357b3e76a19b823d36000947653cedb4d25e377a5b272abd80e257e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.4.2 requests/2.25.1 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.0.54 This release

1 release file

0.0.53

1 release file

0.0.52

1 release file

0.0.51

1 release file

0.0.50

1 release file

0.0.48

1 release file

0.0.47

1 release file

0.0.44

1 release file

0.0.43

1 release file

0.0.42

1 release file

0.0.41

1 release file

0.0.40

1 release file

0.0.39

1 release file

0.0.38

1 release file

0.0.37

1 release file

0.0.36

1 release file

0.0.35

1 release file

0.0.34

1 release file

0.0.31

1 release file

0.0.30

1 release file

0.0.29

1 release file

0.0.28

1 release file

0.0.27

1 release file

0.0.25

1 release file

0.0.23

1 release file

0.0.22

1 release file

0.0.21

1 release file

0.0.19

1 release file

0.0.18

1 release file

0.0.17

1 release file

0.0.16

1 release file

0.0.15

1 release file

0.0.14

1 release file

0.0.13

1 release file

0.0.12

1 release file

0.0.11

1 release file

0.0.10

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page