Skip to content

Reed

Language translation layer—source code to IR to source code.

Repository: github.com/rhizome-lab/reed

Overview

Reed provides bidirectional translation between programming languages through a common intermediate representation. Instead of N×M converters between languages, Reed uses N readers and M writers with a shared IR.

Crates

Core

CrateDescription
rhizome-reed-irCommon AST intermediate representation
rhizome-reed-sexprS-expression serialization for the IR

Readers

CrateDescription
rhizome-reed-read-luaLua source → Reed IR
rhizome-reed-read-tsTypeScript source → Reed IR

Writers

CrateDescription
rhizome-reed-write-luaReed IR → Lua source
rhizome-reed-write-tsReed IR → TypeScript source

Architecture

Source A ──→ Reader A ──→ Reed IR ──→ Writer B ──→ Source B

The IR captures common programming constructs:

  • Expressions (literals, binaries, calls, etc.)
  • Statements (assignments, conditionals, loops)
  • Functions and modules

This enables:

  • Language migration: Convert legacy code to modern languages
  • Code generation: Generate implementations in multiple targets
  • Cross-language tooling: Build tools that work on the IR

Usage

rust
use rhizome_reed_read_lua::parse_lua;
use rhizome_reed_write_ts::write_ts;

// Parse Lua source
let ir = parse_lua("function add(a, b) return a + b end")?;

// Write as TypeScript
let ts_code = write_ts(&ir)?;
// "function add(a: any, b: any): any { return a + b; }"

Integration with Spore

Reed powers verb execution in Spore's Lotus integration. Entity behaviors stored as S-expressions are translated to Lua at runtime:

S-expr (storage) → Reed IR → Lua (execution)