Crate joulec

Crate joulec 

Source
Expand description

Joule Compiler Library

Provides the programmatic API for invoking the Joule compiler pipeline. This allows other tools (LSP, REPL, test harness, documentation generator) to compile Joule source code without spawning a subprocess.

§Pipeline Stages

The compilation pipeline proceeds through these stages:

  1. Lexing — Source text → token stream
  2. Parsing — Token stream → AST
  3. Type checking — AST → HIR (with type resolution and energy budget verification)
  4. MIR lowering — HIR → MIR (control flow graph with ownership info)
  5. Borrow checking — MIR validation (ownership, lifetimes, initialization)
  6. Code generation — MIR → target code (Cranelift, LLVM, MLIR, or C)

§Example

use joulec::{CompileOptions, compile_source};

let source = r#"
    pub fn add(a: i32, b: i32) -> i32 {
        a + b
    }
"#;

let options = CompileOptions::default();
let result = compile_source(source, "example.joule", &options);

Structs§

CompileOptions
Options controlling the compilation pipeline.
CompileOutput
The result of a successful compilation through the full pipeline.

Functions§

compile_multi_file
Compile multiple source files together (multi-file compilation).
compile_source
Compile a single source string through the full pipeline (lex → parse → typecheck → MIR → borrowck).
compile_to_c
Compile source and emit C code (the bootstrap self-hosting path).
parse_source
Parse source code into an AST without type checking.
type_check_source
Type check source code and return the HIR.