Skip to main content

Pyfdev transpiler and CLI

Project description

Pyfdev

Pyfdev is a minimal, statically‑typed subset of Python that compiles to C via Tiny C Compiler (TCC). It offers Python‑like syntax with the performance of native C, right out of the box.


🚀 Features Implemented So Far

Basic Types & Declarations

  • numint (e.g. num x = 5)
  • realdouble (e.g. real pi = 3.14)
  • textchar* (e.g. text msg = "hello")
  • yesnobool (e.g. yesno flag = true)
  • list → homogeneous arrays + length (e.g. list nums = [1,2,3] or list words = ["a","b"])

Arithmetic & Boolean Expressions

  • Operators: +, -, *, /, %
  • Comparisons: ==, !=, <, >, <=, >=
  • Logical: &&, ||, !
  • Mixed numeric/float expressions infer %d or %f automatically in print()

Printing

  • print(expr) handles:

    • String literals and text variables (%s)
    • Numeric and boolean (num/yesno) (%d)
    • Floating-point (real) (%f)
    • Lists: prints [elem0, elem1, …]

Control Flow Extensions

  1. if / elif / else blocks with Python‑style indentation

  2. unless cond: inverse-if sugar

  3. Guarded clauses: if cond when guard:

  4. Early-exit guard: guard cond else:

  5. Ternary expressions: cond ? val1 : val2

  6. Range membership: x in a..bx >= a && x <= b

  7. Pattern matching:

    match x {
      case 0:       print("zero")
      case 1:       print("one")
      default:      print("many")
    }
    

⚙️ Installation

Pyfdev provides a one‑step installer that sets up the CLI and automatically installs Tiny C Compiler (TCC) on your system.

Requirements

  • Python 3.7+ installed
  • On Linux/macOS: a system package manager (apt, dnf, brew, etc.)
  • On Windows: PowerShell with administrative privileges (for package manager install)

Install via pip

pip install Pyfdev
Pyfdev --install-tcc    # automatically installs TCC if missing

The --install-tcc flag will detect your OS and run:

  • Debian/Ubuntu: sudo apt-get update && sudo apt-get install tcc
  • Fedora/Red Hat: sudo dnf install tcc
  • macOS (Homebrew): brew install tcc
  • Windows (Chocolatey): choco install tcc

Or combine into one command:

pip install Pyfdev && Pyfdev --install-tcc

📦 Usage

  1. Write your Pyfdev code in a .pf file, e.g. hello.pf:

    num x = 10
    if x > 5:
        print("big")
    else:
        print("small")
    
  2. Compile & Run in one step:

    Pyfdev hello.pf
    

    This generates hello.c, compiles it with TCC, and runs the executable.

  3. Separate Steps (optional):

    Pyfdev --transpile hello.pf    # emits hello.c
    Pyfdev --compile hello.c       # emits hello.exe or ./hello
    Pyfdev --run hello.exe         # runs the binary
    

🧪 Testing Features

  • Expressions & Prints:

    num a = 5 + 3 * 2
    real ratio = a / 2.0
    print(a)
    print(ratio)
    
  • Control Flow:

    num x = 3
    unless x > 5:
        print("x is small")
    guard x < 0 else:
        print("x >= 0")
        return
    
  • Ternary & Ranges:

    num y = 7
    print((y % 2 == 0) ? "even" : "odd")
    print(y in 1..10)
    
  • Match/Case:

    num code = 2
    match code {
      case 1: print("one")
      case 2: print("two")
      default: print("other")
    }
    

📚 Further Development

  • Add while and for loops
  • User-defined functions and modules
  • Enhanced error reporting with line numbers
  • Standard library built-ins (e.g. len(), append())

Contributions welcome! Submit issues and pull requests on GitHub: https://github.com/yourusername/Pyfdev


Happy coding with Pyfdev!

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

pyfdev-0.1.5.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

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

pyfdev-0.1.5-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file pyfdev-0.1.5.tar.gz.

File metadata

  • Download URL: pyfdev-0.1.5.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for pyfdev-0.1.5.tar.gz
Algorithm Hash digest
SHA256 edfcf6dd434e1a268e26e656df9163af673faffa5b1c0b6aaed4eaaeb8b1ff11
MD5 523b43051cb5abebb22fa17940b15f62
BLAKE2b-256 950173936027d6fb447c5d2104832d33120f790cea4c31a517f4dbc275679203

See more details on using hashes here.

File details

Details for the file pyfdev-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: pyfdev-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for pyfdev-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 07c7203b5e4fb28b64608e31507a945d2c38ef99e67f1125d43d37f90ab2c372
MD5 80d4050830b5346788edf30972dad722
BLAKE2b-256 32d940cd5c4c416ac9a720d1f9f87b1a5d78a54c4fea5a6717f0a8088fba3566

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