# gweiermann/your-language architecture

> Architecture diagram of the GitHub repository gweiermann/your-language, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gweiermann/your-language
- Repository: https://github.com/gweiermann/your-language

## Overview

YL is a declarative language-building toolkit. Its main workflow takes a language definition through compilation into a reusable executable image, then parses target-language programs into ASTs and diagnostics. Semantic queries and scheduling enrich analysis; host-controlled backend hooks let Rust consumers interpret, transpile, or compile programs. Project commands, language-server support, and the VS Code extension are additional user-facing capabilities. Some subsystem links are documented rather than visible in sampled implementation excerpts.

Main entry points: [`src/runtime.rs`](https://github.com/gweiermann/your-language/blob/main/src/runtime.rs) (Grammar interpreter), [`src/main.rs`](https://github.com/gweiermann/your-language/blob/main/src/main.rs) (YL CLI), [`src/compiler.rs`](https://github.com/gweiermann/your-language/blob/main/src/compiler.rs) (Language compiler), [`src/semantics.rs`](https://github.com/gweiermann/your-language/blob/main/src/semantics.rs) (Semantic analysis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_authoring["Language authoring"]
  node_frontend["Definition syntax<br/>[frontend.rs]"]
  node_lexer["Lexer<br/>[lexer.rs]"]
  node_syntax["Syntax model<br/>[syntax.rs]"]
end

subgraph group_execution["Compilation and execution"]
  node_compiler["Language compiler<br/>[compiler.rs]"]
  node_compile_phases["Compile phases<br/>[pipeline.rs]"]
  node_image["Executable image<br/>[mod.rs]"]
  node_parser_image["Parser image<br/>[parser.rs]"]
  node_runtime["Grammar interpreter<br/>[runtime.rs]"]
  node_backend["Backend hooks<br/>[backend.rs]"]
end

subgraph group_semantics["Semantic analysis"]
  node_query_image["Query image<br/>[query.rs]"]
  node_semantic_engine["Semantic analysis<br/>[semantics.rs]"]
  node_queries["Semantic queries<br/>[queries.rs]"]
  node_structural_queries["Structural queries<br/>[structural.rs]"]
  node_query_lifetimes["Query lifetimes<br/>[lifetimes.rs]"]
  node_scheduler["Semantic scheduler<br/>[scheduler.rs]"]
end

subgraph group_tools["Developer tools"]
  node_cli["YL CLI<br/>[main.rs]"]
  node_diagnostics["Diagnostics<br/>[diagnostic.rs]"]
  node_language_server["Language server<br/>[language_server.rs]"]
  node_project["Project runner<br/>[project.rs]"]
  node_examples["Example previews<br/>[examples.rs]"]
  node_vscode["VS Code extension<br/>[extension.ts]"]
end

node_author(("Language author"))
node_rust_host(("Rust consumer"))
node_target_programmer(("Target-language author"))
node_target_program["Target program"]

node_author -->|"invokes"| node_cli
node_cli -->|"compiles definitions"| node_compiler
node_author -->|"writes definitions"| node_frontend
node_frontend -.->|"provides definitions"| node_compiler
node_compiler -->|"runs phases"| node_compile_phases
node_compile_phases -->|"assembles image"| node_image
node_image -->|"compiles parser"| node_parser_image
node_image -->|"compiles queries"| node_query_image
node_rust_host -->|"interprets programs"| node_runtime
node_rust_host -->|"supplies hooks"| node_backend
node_target_programmer -->|"writes"| node_target_program
node_target_program -->|"provides source"| node_runtime
node_runtime -->|"executes grammar"| node_parser_image
node_runtime -->|"records occurrences"| node_semantic_engine
node_semantic_engine -->|"evaluates queries"| node_queries
node_queries -->|"reads query image"| node_query_image
node_queries -->|"delegates"| node_structural_queries
node_query_image -->|"uses lifetime logic"| node_query_lifetimes
node_semantic_engine -->|"schedules semantics"| node_scheduler
node_cli -->|"runs project commands"| node_project
node_project -->|"checks programs"| node_semantic_engine
node_cli -.->|"serves editor requests"| node_language_server
node_language_server -->|"reads syntax"| node_syntax
node_language_server -->|"discovers projects"| node_project
node_vscode -.->|"requests live diagnostics"| node_language_server
node_compiler -->|"validates previews"| node_examples
node_runtime -->|"returns diagnostics"| node_diagnostics

click node_cli "https://github.com/gweiermann/your-language/blob/main/src/main.rs"
click node_frontend "https://github.com/gweiermann/your-language/blob/main/src/frontend.rs"
click node_lexer "https://github.com/gweiermann/your-language/blob/main/src/lexer.rs"
click node_syntax "https://github.com/gweiermann/your-language/blob/main/src/syntax.rs"
click node_compiler "https://github.com/gweiermann/your-language/blob/main/src/compiler.rs"
click node_compile_phases "https://github.com/gweiermann/your-language/blob/main/src/compiler/pipeline.rs"
click node_image "https://github.com/gweiermann/your-language/blob/main/src/image/mod.rs"
click node_parser_image "https://github.com/gweiermann/your-language/blob/main/src/image/parser.rs"
click node_query_image "https://github.com/gweiermann/your-language/blob/main/src/image/query.rs"
click node_runtime "https://github.com/gweiermann/your-language/blob/main/src/runtime.rs"
click node_backend "https://github.com/gweiermann/your-language/blob/main/src/backend.rs"
click node_semantic_engine "https://github.com/gweiermann/your-language/blob/main/src/semantics.rs"
click node_queries "https://github.com/gweiermann/your-language/blob/main/src/semantics/queries.rs"
click node_structural_queries "https://github.com/gweiermann/your-language/blob/main/src/semantics/queries/structural.rs"
click node_query_lifetimes "https://github.com/gweiermann/your-language/blob/main/src/image/query/lifetimes.rs"
click node_scheduler "https://github.com/gweiermann/your-language/blob/main/src/semantics/scheduler.rs"
click node_diagnostics "https://github.com/gweiermann/your-language/blob/main/src/diagnostic.rs"
click node_language_server "https://github.com/gweiermann/your-language/blob/main/src/language_server.rs"
click node_project "https://github.com/gweiermann/your-language/blob/main/src/project.rs"
click node_examples "https://github.com/gweiermann/your-language/blob/main/src/examples.rs"
click node_vscode "https://github.com/gweiermann/your-language/blob/main/editors/vscode/src/extension.ts"

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_frontend,node_lexer,node_syntax toneBlue
class node_compiler,node_compile_phases,node_image,node_parser_image,node_runtime,node_backend toneAmber
class node_query_image,node_semantic_engine,node_queries,node_structural_queries,node_query_lifetimes,node_scheduler toneMint
class node_cli,node_diagnostics,node_language_server,node_project,node_examples,node_vscode toneRose
class node_author,node_rust_host,node_target_programmer,node_target_program toneIndigo
```

## Components

### Language authoring

- [Definition syntax](https://github.com/gweiermann/your-language/blob/main/src/frontend.rs): `src/frontend.rs`
- [Lexer](https://github.com/gweiermann/your-language/blob/main/src/lexer.rs): `src/lexer.rs`
- [Syntax model](https://github.com/gweiermann/your-language/blob/main/src/syntax.rs): `src/syntax.rs`

### Compilation and execution

- [Language compiler](https://github.com/gweiermann/your-language/blob/main/src/compiler.rs): `src/compiler.rs`
- [Compile phases](https://github.com/gweiermann/your-language/blob/main/src/compiler/pipeline.rs): `src/compiler/pipeline.rs`
- [Executable image](https://github.com/gweiermann/your-language/blob/main/src/image/mod.rs): `src/image/mod.rs`
- [Parser image](https://github.com/gweiermann/your-language/blob/main/src/image/parser.rs): `src/image/parser.rs`
- [Grammar interpreter](https://github.com/gweiermann/your-language/blob/main/src/runtime.rs): `src/runtime.rs`
- [Backend hooks](https://github.com/gweiermann/your-language/blob/main/src/backend.rs): `src/backend.rs`

### Semantic analysis

- [Query image](https://github.com/gweiermann/your-language/blob/main/src/image/query.rs): `src/image/query.rs`
- [Semantic analysis](https://github.com/gweiermann/your-language/blob/main/src/semantics.rs): `src/semantics.rs`
- [Semantic queries](https://github.com/gweiermann/your-language/blob/main/src/semantics/queries.rs): `src/semantics/queries.rs`
- [Structural queries](https://github.com/gweiermann/your-language/blob/main/src/semantics/queries/structural.rs): `src/semantics/queries/structural.rs`
- [Query lifetimes](https://github.com/gweiermann/your-language/blob/main/src/image/query/lifetimes.rs): `src/image/query/lifetimes.rs`
- [Semantic scheduler](https://github.com/gweiermann/your-language/blob/main/src/semantics/scheduler.rs): `src/semantics/scheduler.rs`

### Developer tools

- [YL CLI](https://github.com/gweiermann/your-language/blob/main/src/main.rs): `src/main.rs`
- [Diagnostics](https://github.com/gweiermann/your-language/blob/main/src/diagnostic.rs): `src/diagnostic.rs`
- [Language server](https://github.com/gweiermann/your-language/blob/main/src/language_server.rs): `src/language_server.rs`
- [Project runner](https://github.com/gweiermann/your-language/blob/main/src/project.rs): `src/project.rs`
- [Example previews](https://github.com/gweiermann/your-language/blob/main/src/examples.rs): `src/examples.rs`
- [VS Code extension](https://github.com/gweiermann/your-language/blob/main/editors/vscode/src/extension.ts): `editors/vscode/src/extension.ts`

### Other components

- **Language author**
- **Rust consumer**
- **Target-language author**
- **Target program**

## Connections

- Language author → YL CLI: invokes
- YL CLI → Language compiler: compiles definitions
- Language author → Definition syntax: writes definitions
- Definition syntax → Language compiler: provides definitions
- Language compiler → Compile phases: runs phases (evidence: `src/compiler/pipeline.rs`)
- Compile phases → Executable image: assembles image (evidence: `src/compiler/pipeline.rs`)
- Executable image → Parser image: compiles parser (evidence: `src/image/mod.rs`)
- Executable image → Query image: compiles queries (evidence: `src/image/mod.rs`)
- Rust consumer → Grammar interpreter: interprets programs
- Rust consumer → Backend hooks: supplies hooks
- Target-language author → Target program: writes
- Target program → Grammar interpreter: provides source
- Grammar interpreter → Parser image: executes grammar (evidence: `src/runtime.rs`)
- Grammar interpreter → Semantic analysis: records occurrences (evidence: `src/runtime.rs`)
- Semantic analysis → Semantic queries: evaluates queries (evidence: `src/semantics.rs`)
- Semantic queries → Query image: reads query image (evidence: `src/semantics/queries.rs`)
- Semantic queries → Structural queries: delegates (evidence: `src/semantics/queries.rs`)
- Query image → Query lifetimes: uses lifetime logic (evidence: `src/image/query.rs`)
- Semantic analysis → Semantic scheduler: schedules semantics (evidence: `src/semantics.rs`)
- YL CLI → Project runner: runs project commands (evidence: `src/main.rs`)
- Project runner → Semantic analysis: checks programs
- YL CLI → Language server: serves editor requests
- Language server → Syntax model: reads syntax (evidence: `src/language_server.rs`)
- Language server → Project runner: discovers projects (evidence: `src/language_server.rs`)
- VS Code extension → Language server: requests live diagnostics
- Language compiler → Example previews: validates previews
- Grammar interpreter → Diagnostics: returns diagnostics (evidence: `src/runtime.rs`)
