depyler-core 3.19.4

Core transpilation engine for the Depyler Python-to-Rust transpiler
Documentation

Depyler Core - Transpilation Engine

Core transpilation engine for converting Python code to Rust and other targets.

Overview

This crate provides the fundamental transpilation pipeline that converts Python source code into target languages (Rust, Ruchy) while preserving semantics and ensuring memory safety.

Example

use depyler_core::DepylerPipeline;

let pipeline = DepylerPipeline::new();
let python = r#"
def factorial(n: int) -> int:
    if n <= 1:
        return 1
    return n * factorial(n - 1)
"#;

match pipeline.transpile(python) {
    Ok(rust_code) => println!("Generated:\n{}", rust_code),
    Err(e) => eprintln!("Error: {}", e),
}

Architecture

The transpilation pipeline consists of several stages:

  1. Parsing ([ast_bridge]) - Convert Python source to AST
  2. HIR ([hir]) - Transform AST to High-level Intermediate Representation
  3. Type Analysis ([generic_inference], [const_generic_inference]) - Infer types and generics
  4. Ownership Analysis ([borrowing], [lifetime_analysis]) - Determine ownership patterns
  5. Optimization ([optimization], [string_optimization]) - Apply optimizations
  6. Code Generation ([codegen], [rust_gen]) - Generate target code

Key Types

  • [DepylerPipeline] - Main entry point for transpilation
  • [TranspileOptions] - Configuration options
  • [Hir] - High-level intermediate representation
  • [TranspilationBackend] - Backend trait for target languages