# darthdeus/rock-lang architecture

> Architecture diagram of the GitHub repository darthdeus/rock-lang, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/darthdeus/rock-lang
- Repository: https://github.com/darthdeus/rock-lang

## Overview

Rock is an experimental statically typed language compiler targeting LuaJIT and GLSL, with a JavaScript backend and developer tooling. Its primary workflow takes a Rock program through parsing, semantic analysis and MIR lowering to backend output, which can then run under LuaJIT or be emitted as GLSL. The repository also includes an LSP and Stone game-engine support. Some source excerpts are incomplete or unsampled, so edges for those implementation details are marked unverified rather than asserted.

Main entry points: [`crates/rock-cli/src/main.rs`](https://github.com/darthdeus/rock-lang/blob/master/crates/rock-cli/src/main.rs) (Rock CLI), [`crates/bone-core/src/workspace.rs`](https://github.com/darthdeus/rock-lang/blob/master/crates/bone-core/src/workspace.rs) (Workspace), [`crates/skull-mir/src/lower/mod.rs`](https://github.com/darthdeus/rock-lang/blob/master/crates/skull-mir/src/lower/mod.rs) (MIR Lowering), [`crates/skull/src/pipeline.rs`](https://github.com/darthdeus/rock-lang/blob/master/crates/skull/src/pipeline.rs) (Codegen Pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_front["Language Front End"]
  node_parser["Parser<br/>[parser.rs]"]
  node_hir["HIR<br/>[hir.rs]"]
  node_workspace["Workspace<br/>[workspace.rs]"]
  node_modules["Module Namespaces<br/>[modules.rs]"]
end

subgraph group_analysis["Semantic Analysis"]
  node_lowerresolve["Name Resolution<br/>[resolve.rs]"]
  node_inference["Type Inference<br/>[lib.rs]"]
  node_semantic["Semantic Passes<br/>[semantic_passes.rs]"]
end

subgraph group_compiler["Compiler Back End"]
  node_mir["MIR Lowering<br/>[mod.rs]"]
  node_identity["Type Identity<br/>[code_identity.rs]"]
  node_monoty["Mono Types<br/>[monoty.rs]"]
  node_storage["MIR Storage<br/>[storage.rs]"]
  node_transforms["MIR Transforms<br/>[lib.rs]"]
  node_pipeline["Codegen Pipeline<br/>[pipeline.rs]"]
  node_lua["Lua Backend<br/>[lib.rs]"]
  node_js["JavaScript Backend<br/>[session.rs]"]
  node_glsl["GLSL Backend<br/>[pipeline.rs]"]
end

subgraph group_tools["Developer Tools"]
  node_cli["Rock CLI<br/>[main.rs]"]
  node_query["Editor Queries<br/>[query.rs]"]
  node_lsp["Language Server<br/>[lib.rs]"]
  node_lint["Linting<br/>[lib.rs]"]
  node_formatter["Formatter<br/>[printer.rs]"]
end

subgraph group_runtime["Execution and Engine"]
  node_luajit["LuaJIT"]
  node_stone["Stone Engine<br/>[lib.rs]"]
  node_enginehost["Engine Host<br/>[engine_build.rs]"]
end

node_author(("Rock Programmer"))

node_author -->|"runs commands"| node_cli
node_cli -.->|"compiles source"| node_parser
node_parser -.->|"produces syntax"| node_hir
node_hir -->|"stored in"| node_workspace
node_workspace -->|"uses namespaces"| node_modules
node_workspace -.->|"resolved by"| node_lowerresolve
node_lowerresolve -.->|"resolves names"| node_semantic
node_semantic -.->|"infers types"| node_inference
node_workspace -->|"stores results"| node_inference
node_workspace -.->|"queried by"| node_query
node_lsp -.->|"requests queries"| node_query
node_workspace -->|"lowers HIR"| node_mir
node_mir -->|"uses identities"| node_identity
node_mir -->|"uses types"| node_monoty
node_mir -.->|"lowers storage"| node_storage
node_mir -.->|"transformed by"| node_transforms
node_pipeline -->|"emits MIR"| node_mir
node_pipeline -.->|"selects backend"| node_lua
node_pipeline -.->|"selects backend"| node_js
node_pipeline -.->|"selects backend"| node_glsl
node_lua -->|"runs output"| node_luajit
node_cli -->|"prints shaders"| node_glsl
node_cli -->|"offers backend"| node_js
node_cli -->|"runs lint"| node_lint
node_cli -->|"formats code"| node_formatter
node_cli -->|"starts server"| node_lsp
node_cli -.->|"builds games"| node_enginehost
node_enginehost -->|"stages engine"| node_stone

click node_cli "https://github.com/darthdeus/rock-lang/blob/master/crates/rock-cli/src/main.rs"
click node_parser "https://github.com/darthdeus/rock-lang/blob/master/crates/skull-parser/src/parser.rs"
click node_hir "https://github.com/darthdeus/rock-lang/blob/master/crates/bone-core/src/hir.rs"
click node_workspace "https://github.com/darthdeus/rock-lang/blob/master/crates/bone-core/src/workspace.rs"
click node_modules "https://github.com/darthdeus/rock-lang/blob/master/crates/bone-core/src/modules.rs"
click node_lowerresolve "https://github.com/darthdeus/rock-lang/blob/master/crates/bone-lower/src/resolve.rs"
click node_inference "https://github.com/darthdeus/rock-lang/blob/master/crates/bone-inference/src/lib.rs"
click node_semantic "https://github.com/darthdeus/rock-lang/blob/master/crates/bone-semantic/src/semantic_passes.rs"
click node_query "https://github.com/darthdeus/rock-lang/blob/master/crates/bone-query/src/query.rs"
click node_lsp "https://github.com/darthdeus/rock-lang/blob/master/crates/rock-lsp/src/lib.rs"
click node_lint "https://github.com/darthdeus/rock-lang/blob/master/crates/bone-lints/src/lib.rs"
click node_formatter "https://github.com/darthdeus/rock-lang/blob/master/crates/skull-fmt/src/printer.rs"
click node_mir "https://github.com/darthdeus/rock-lang/blob/master/crates/skull-mir/src/lower/mod.rs"
click node_identity "https://github.com/darthdeus/rock-lang/blob/master/crates/skull-mir/src/code_identity.rs"
click node_monoty "https://github.com/darthdeus/rock-lang/blob/master/crates/skull-mir/src/monoty.rs"
click node_storage "https://github.com/darthdeus/rock-lang/blob/master/crates/skull-mir/src/lower/storage.rs"
click node_transforms "https://github.com/darthdeus/rock-lang/blob/master/crates/skull-transform/src/lib.rs"
click node_pipeline "https://github.com/darthdeus/rock-lang/blob/master/crates/skull/src/pipeline.rs"
click node_lua "https://github.com/darthdeus/rock-lang/blob/master/crates/skull-codegen-lua/src/lib.rs"
click node_js "https://github.com/darthdeus/rock-lang/blob/master/crates/skull-codegen-js/src/emit/session.rs"
click node_glsl "https://github.com/darthdeus/rock-lang/blob/master/crates/skull-codegen-glsl/src/pipeline.rs"
click node_stone "https://github.com/darthdeus/rock-lang/blob/master/stone-rs/src/lib.rs"
click node_enginehost "https://github.com/darthdeus/rock-lang/blob/master/crates/rock-engine-host/src/engine_build.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_parser,node_hir,node_workspace,node_modules toneBlue
class node_lowerresolve,node_inference,node_semantic toneAmber
class node_mir,node_identity,node_monoty,node_storage,node_transforms,node_pipeline,node_lua,node_js,node_glsl toneMint
class node_cli,node_query,node_lsp,node_lint,node_formatter toneRose
class node_luajit,node_stone,node_enginehost,node_author toneIndigo
```

## Components

### Language Front End

- [Parser](https://github.com/darthdeus/rock-lang/blob/master/crates/skull-parser/src/parser.rs): `crates/skull-parser/src/parser.rs`
- [HIR](https://github.com/darthdeus/rock-lang/blob/master/crates/bone-core/src/hir.rs): `crates/bone-core/src/hir.rs`
- [Workspace](https://github.com/darthdeus/rock-lang/blob/master/crates/bone-core/src/workspace.rs): `crates/bone-core/src/workspace.rs`
- [Module Namespaces](https://github.com/darthdeus/rock-lang/blob/master/crates/bone-core/src/modules.rs): `crates/bone-core/src/modules.rs`

### Semantic Analysis

- [Name Resolution](https://github.com/darthdeus/rock-lang/blob/master/crates/bone-lower/src/resolve.rs): `crates/bone-lower/src/resolve.rs`
- [Type Inference](https://github.com/darthdeus/rock-lang/blob/master/crates/bone-inference/src/lib.rs): `crates/bone-inference/src/lib.rs`
- [Semantic Passes](https://github.com/darthdeus/rock-lang/blob/master/crates/bone-semantic/src/semantic_passes.rs): `crates/bone-semantic/src/semantic_passes.rs`

### Compiler Back End

- [MIR Lowering](https://github.com/darthdeus/rock-lang/blob/master/crates/skull-mir/src/lower/mod.rs): `crates/skull-mir/src/lower/mod.rs`
- [Type Identity](https://github.com/darthdeus/rock-lang/blob/master/crates/skull-mir/src/code_identity.rs): `crates/skull-mir/src/code_identity.rs`
- [Mono Types](https://github.com/darthdeus/rock-lang/blob/master/crates/skull-mir/src/monoty.rs): `crates/skull-mir/src/monoty.rs`
- [MIR Storage](https://github.com/darthdeus/rock-lang/blob/master/crates/skull-mir/src/lower/storage.rs): `crates/skull-mir/src/lower/storage.rs`
- [MIR Transforms](https://github.com/darthdeus/rock-lang/blob/master/crates/skull-transform/src/lib.rs): `crates/skull-transform/src/lib.rs`
- [Codegen Pipeline](https://github.com/darthdeus/rock-lang/blob/master/crates/skull/src/pipeline.rs): `crates/skull/src/pipeline.rs`
- [Lua Backend](https://github.com/darthdeus/rock-lang/blob/master/crates/skull-codegen-lua/src/lib.rs): `crates/skull-codegen-lua/src/lib.rs`
- [JavaScript Backend](https://github.com/darthdeus/rock-lang/blob/master/crates/skull-codegen-js/src/emit/session.rs): `crates/skull-codegen-js/src/emit/session.rs`
- [GLSL Backend](https://github.com/darthdeus/rock-lang/blob/master/crates/skull-codegen-glsl/src/pipeline.rs): `crates/skull-codegen-glsl/src/pipeline.rs`

### Developer Tools

- [Rock CLI](https://github.com/darthdeus/rock-lang/blob/master/crates/rock-cli/src/main.rs): `crates/rock-cli/src/main.rs`
- [Editor Queries](https://github.com/darthdeus/rock-lang/blob/master/crates/bone-query/src/query.rs): `crates/bone-query/src/query.rs`
- [Language Server](https://github.com/darthdeus/rock-lang/blob/master/crates/rock-lsp/src/lib.rs): `crates/rock-lsp/src/lib.rs`
- [Linting](https://github.com/darthdeus/rock-lang/blob/master/crates/bone-lints/src/lib.rs): `crates/bone-lints/src/lib.rs`
- [Formatter](https://github.com/darthdeus/rock-lang/blob/master/crates/skull-fmt/src/printer.rs): `crates/skull-fmt/src/printer.rs`

### Execution and Engine

- **LuaJIT**
- [Stone Engine](https://github.com/darthdeus/rock-lang/blob/master/stone-rs/src/lib.rs): `stone-rs/src/lib.rs`
- [Engine Host](https://github.com/darthdeus/rock-lang/blob/master/crates/rock-engine-host/src/engine_build.rs): `crates/rock-engine-host/src/engine_build.rs`

### Other components

- **Rock Programmer**

## Connections

- Rock Programmer → Rock CLI: runs commands (evidence: `README.md`)
- Rock CLI → Parser: compiles source
- Parser → HIR: produces syntax
- HIR → Workspace: stored in (evidence: `crates/bone-core/src/workspace.rs`)
- Workspace → Module Namespaces: uses namespaces (evidence: `crates/bone-core/src/workspace.rs`)
- Workspace → Name Resolution: resolved by
- Name Resolution → Semantic Passes: resolves names
- Semantic Passes → Type Inference: infers types
- Workspace → Type Inference: stores results (evidence: `crates/bone-core/src/workspace.rs`)
- Workspace → Editor Queries: queried by
- Language Server → Editor Queries: requests queries
- Workspace → MIR Lowering: lowers HIR (evidence: `crates/skull-mir/src/lower/mod.rs`)
- MIR Lowering → Type Identity: uses identities (evidence: `crates/skull-mir/src/code_identity.rs`)
- MIR Lowering → Mono Types: uses types (evidence: `crates/skull-mir/src/lower/mod.rs`)
- MIR Lowering → MIR Storage: lowers storage (evidence: `crates/skull-mir/src/lower/mod.rs`)
- MIR Lowering → MIR Transforms: transformed by
- Codegen Pipeline → MIR Lowering: emits MIR (evidence: `crates/skull/src/pipeline.rs`)
- Codegen Pipeline → Lua Backend: selects backend
- Codegen Pipeline → JavaScript Backend: selects backend
- Codegen Pipeline → GLSL Backend: selects backend
- Lua Backend → LuaJIT: runs output (evidence: `README.md`)
- Rock CLI → GLSL Backend: prints shaders (evidence: `README.md`)
- Rock CLI → JavaScript Backend: offers backend (evidence: `README.md`)
- Rock CLI → Linting: runs lint (evidence: `README.md`)
- Rock CLI → Formatter: formats code (evidence: `README.md`)
- Rock CLI → Language Server: starts server (evidence: `README.md`)
- Rock CLI → Engine Host: builds games
- Engine Host → Stone Engine: stages engine (evidence: `crates/rock-engine-host/src/engine_build.rs`)
