MCPcopy Create free account
hub / github.com/JakkuSakura/FerroPhase

github.com/JakkuSakura/FerroPhase @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
75,724 symbols 152,371 edges 20,400 files ⚖ custom 4,864 documented · 6% updated 2d ago★ 37

Browse by type

Functions 52,957 Types & classes 22,725 Endpoints 42
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

FerroPhase

FerroPhase is a multi-language compiler framework. Frontends translate source languages into one shared AST, and the compiler lowers that AST through HIR, typing, MIR, and LIR before interpretation, bytecode emission, native codegen, or source-target printing.

The project is designed for two related workflows:

  • Compile mode resolves and types the program for a concrete backend. High- level #[op = "..."] calls may be lowered to ordinary std wrappers, while #[intrinsic = "..."] declarations provide compiler-pipeline primitives.
  • Transpile mode keeps the AST/source-level shape as high-level as possible and prints the requested target language. --target fp prints FerroPhase source; other target printers include TypeScript, JavaScript, Python, Go, Zig, SYCL, Rust, and WIT when enabled.

The same semantic contract is intended to hold across AST, HIR, MIR, LIR, interpreters, bytecode, and compiled backends. A representation change must not change observable program behavior.

Quick Start

Build the CLI from the workspace:

cargo build --release -p fp-cli
export PATH="$PWD/target/release:$PATH"

Most compiler commands require a package identity:

fp check --package demo src/main.fp
fp interpret --package demo src/main.fp
fp eval "1 + 2 * 3"
fp parse src/main.fp

Compile to a native binary or inspect the shared pipeline:

fp compile src/main.fp --package demo --backend binary --output demo
fp compile src/main.fp --package demo --backend bytecode --output demo.fbc
fp compile src/main.fp --package demo --emit ast --emit ast-typed --emit hir

Print a source target through the same frontend, HIR, typing, and AST-lift pipeline (typing is always performed):

fp compile src/main.fp --package demo --target fp --output normalized.fp
fp compile src/main.fp --package demo --target typescript --output main.ts
fp compile src/main.fp --package demo --target rust --output main.rs

There is no separate transpile subcommand; source-target emission is selected with fp compile --target.

Architecture

source
  -> LanguageFrontend
  -> shared AST
  -> mode-specific intrinsic normalization
  -> package/module resolution
  -> HIR
  -> typing and HIR type information
  -> MIR
  -> LIR
  -> interpreter, bytecode, native backend, or AST printer

Package providers own package discovery. The compiler driver services package loads, including the provider-owned top-level ::libc package. Module and package resolution is an asynchronous compiler concern; lower layers consume resolved package and module identities rather than implementing their own filesystem or package lookup.

Intrinsics And Standard Library

Use #[op = "name"] for high-level operations that should remain visible to transpilers. Use #[intrinsic = "name"] for compiler-pipeline primitives. Standard-library wrappers live in std; low-level compiler hooks live under std::intrinsics::* and are marked with #[intrinsic].

The C library bindings are a separate top-level ::libc package. They are generated manually with:

scripts/codegen_libc.sh crates/fp-lang/src/libc

The script uses Clang headers and emits platform-specific modules with target cfg declarations in libc/mod.fp. The generated bindings use C ABI types and raw pointers. std::ffi provides FerroPhase-facing wrappers such as CStr. The old std::libc compatibility package is retired.

Frontends And Backends

The workspace includes frontends for FerroPhase, C, C++, TypeScript, JavaScript, Python, Go, SQL, PRQL, WIT, JSON Schema, FlatBuffers, TOML, and other languages behind feature flags. C and C++ frontends use Clang and lower declarations into the shared AST; they are separate from the C-to-Ferro source printer.

Available backend families include the interpreter, bytecode and text bytecode, native, LLVM, Cranelift, eBPF, JVM bytecode, Wasm, CIL, .NET, and source-target printers. Some backends remain experimental or require external toolchains.

Documentation

Examples are in examples/; package/workspace orchestration is provided by the magnet crate.

Extension points exported contracts — how you extend this code

browse all types & interfaces →

Core symbols most depended-on inside this repo

browse all functions →

Shape

Function 42,110
Class 12,632
Method 10,847
Interface 7,535
Enum 2,558
Route 42

Languages

Rust99%
Python1%
C1%
TypeScript1%
C++1%

Modules by API surface

crates/fp-interpret/src/engine/mod.rs400 symbols
crates/fp-backend/src/transforms/hir_to_mir/expr.rs271 symbols
crates/fp-native/src/emit/aarch64.rs249 symbols
crates/fp-native/src/emit/x86_64.rs208 symbols
crates/fp-native/src/asmir.rs179 symbols
crates/fp-lang/src/cst/expr.rs166 symbols
crates/fp-typing/src/lib.rs156 symbols
crates/fp-backend/src/transforms/ast_to_hir/mod.rs151 symbols
tests/rust/ui/const-generics/early/const_arg_trivial_macro_expansion-1.rs122 symbols
tests/rust/ui/test-attrs/terse.rs103 symbols
crates/fp-ebpf/src/lib.rs103 symbols
tests/rust/ui-fulldeps/session-diagnostic/diagnostic-derive.rs102 symbols

For agents

$ claude mcp add FerroPhase \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page