How polybase/polylang works
Polylang compiles a TypeScript-like language into Miden assembly, which can then be run with supplied contract state and advice. Its main stages are lexing/parsing, stable-AST conversion and validation, and code generation; JavaScript/WASM bindings and a browser playground expose additional user-facing workflows. The README documents the compile-and-run path. Some implementation links beyond the sampled excerpts are therefore left unverified; dashed edges indicate those limits.
Main entry points: mod.rs Code generation · main.rs Miden runner · lib.rs Parser · stableast.rs Stable AST
Components 23
Language frontend
- Parser
parser/src/lib.rs - Lexer
parser/src/lexer.rs - Syntax AST
parser/src/ast.rs - Stable AST
src/stableast.rs - Contract validation
src/validation.rs
Miden compiler
- Compiler API
src/lib.rs - Code generation
src/compiler/mod.rs - Compiler IR
src/compiler/ir.rs - Miden encoder
src/compiler/encoder.rs - Value ABI
abi/src/lib.rs
Execution and proving
- Miden runner
miden-run/src/main.rs - Proof generation
prover/src/lib.rs - Prove route
server-routes/src/prove.rs - HTTP server
server/src/main.rs
User interfaces
- Compile CLI
src/bin/compile/main.rs - JavaScript API
js/src/index.ts - WASM bindings
src/js.rs - Browser playground
site/components/Playground.tsx
Other components
- Developer
- Polylang source
- Miden assembly
- Miden VM
- Execution result
Connections 23
- Developer → Polylang source: writes
README.md - Polylang source → Parser: parses
parser/src/lib.rs - Parser → Lexer: tokenizes with
parser/src/lib.rs - Parser → Syntax AST: produces
parser/src/lib.rs - Syntax AST → Stable AST: converts to
src/stableast.rs - Stable AST → Contract validation: validates against
src/validation.rs - Developer → Compile CLI: runs
README.md - Compile CLI → Compiler API: invokes
- Compiler API → Code generation: delegates to
src/lib.rs - Code generation → Compiler IR: uses
src/compiler/mod.rs - Code generation → Miden encoder: emits instructions
src/compiler/mod.rs - Code generation → Value ABI: uses value types
- Code generation → Miden assembly: generates
README.md - Miden assembly → Miden runner: pipes to
README.md - Developer → Miden runner: supplies state
README.md - Miden runner → Miden VM: executes on
- Miden runner → Execution result: returns result
README.md - Developer → JavaScript API: calls
js/src/index.ts - JavaScript API → WASM bindings: loads parser module
- WASM bindings → Stable AST: uses
src/js.rs - Developer → Browser playground: uses
- Prove route → Proof generation: requests proof
- HTTP server → Prove route: routes to