Skip to content

Repository files navigation

Transpiler 🚀

An experimental multi-language transpiler framework. Parse source code from one language into a language-agnostic Intermediate Representation (IR), apply semantic passes, and generate source code in your target language.

CI PyPI License: MIT

✨ Features

  • Multi-Source Parsing: Support for C, Go, Java, JavaScript, and Rust via tree-sitter, and Python via the standard library ast module.
  • Language-Agnostic IR: An internal representation covering common control flow, structs, arrays, maps, and casts.
  • Intelligent Passes: A basic type-inference pass for Any-typed locals.
  • Cross-Language Generation: Code generation for all six supported target languages, covering the common subset of each language's control flow and literal syntax.

This project is under active development. It handles core control flow (if/while/for/break/continue), function calls, structs, and casts across all six languages, but does not yet support exceptions, with/context-manager blocks, or non-range iteration in for loops — unsupported constructs raise a clear error at parse time rather than silently producing wrong output. See CLAUDE.md for the current, detailed list of what is and isn't supported.

🛠 Installation

From PyPI

pip install transpiler

From Source

git clone https://github.com/ahron-maslin/transpiler.git
cd transpiler
pip install .

For development (including testing and linting tools):

pip install -e ".[dev]"

🚀 Quick Start

Use the transpiler CLI to convert code instantly:

# Convert a Python script to JavaScript
transpiler example.py --to js

# Convert a C header to Rust
transpiler header.c --to rust

Example

Input (Python):

def fib(n: int) -> int:
    if n <= 1: return n
    return fib(n - 1) + fib(n - 2)

Command:

transpiler fib.py --to js

Output (JavaScript):

function fib(n) {
    if ((n <= 1)) {
        return n;
    }
    return (fib((n - 1)) + fib((n - 2)));
}

🧪 Development

We value code quality and maintainability.

Running Tests

pytest

Linting & Formatting

We use Ruff for linting and Black for formatting.

black src/ tests/
ruff check src/ tests/

Pre-commit Hooks

Ensure your changes meet our standards before committing:

pre-commit install

📦 CI/CD

  • CI: Every PR and push to master triggers our GitHub Actions suite, testing on Python 3.10-3.12.
  • Releases: Automated PyPI publishing on tag creation (e.g., git tag v0.1.0 && git push origin v0.1.0).

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages