# snazzy-d/sdc architecture

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

- Interactive diagram: https://gitdiagram.com/snazzy-d/sdc
- Repository: https://github.com/snazzy-d/sdc

## Overview

SDC is a D compiler and toolchain project. Its main workflow takes D source through parsing and semantic analysis, then LLVM-backed code generation to a compiled result; the README also identifies JIT CTFE and a supporting runtime. The repository separately provides sdunit and sdfmt. Paths reflect the tree and README; source excerpts were limited, so internal call wiring is shown only at the documented subsystem level.

Main entry points: [`src/d/llvm`](https://github.com/snazzy-d/sdc/tree/master/src/d/llvm) (LLVM backend), [`src/driver/sdc.d`](https://github.com/snazzy-d/sdc/blob/master/src/driver/sdc.d) (Compiler driver), [`src/d/semantic`](https://github.com/snazzy-d/sdc/tree/master/src/d/semantic) (Semantic analysis), [`src/source/dlexer.d`](https://github.com/snazzy-d/sdc/blob/master/src/source/dlexer.d) (D lexer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_compiler["Compiler Front End"]
  node_sdc["Compiler driver<br/>[sdc.d]"]
  node_lexer["D lexer<br/>[dlexer.d]"]
  node_parser["D parser"]
  node_ast["D AST"]
  node_semantic["Semantic analysis"]
  node_ir["Compiler IR"]
end

subgraph group_backend["Code Generation"]
  node_llvm["LLVM backend"]
  node_llvmapi["LLVM"]
  node_jit["JIT CTFE<br/>[evaluator.d]"]
end

subgraph group_runtime["Runtime Support"]
  node_runtime["D runtime"]
  node_gc["Garbage collector"]
  node_platform["Platform support"]
end

subgraph group_tools["Developer Tools"]
  node_sdunit["Unit test runner<br/>[sdunit.d]"]
  node_sdfmt["Code formatter<br/>[sdfmt.d]"]
  node_format["Formatting engine"]
end

node_developer(("D developer"))
node_executable["Compiled output"]

node_developer -->|"invokes"| node_sdc
node_sdc -->|"reads source"| node_lexer
node_lexer -->|"tokens"| node_parser
node_parser -->|"builds AST"| node_ast
node_ast -->|"analyzed by"| node_semantic
node_semantic -->|"produces IR"| node_ir
node_sdc -->|"requests codegen"| node_llvm
node_llvm -->|"uses API"| node_llvmapi
node_llvm -->|"lowers IR"| node_ir
node_llvm -->|"emits output"| node_executable
node_semantic -->|"uses for CTFE"| node_jit
node_jit -->|"uses API"| node_llvmapi
node_executable -->|"requires support"| node_runtime
node_runtime -->|"includes"| node_gc
node_gc -->|"uses platform support"| node_platform
node_developer -->|"runs tests"| node_sdunit
node_developer -->|"formats source"| node_sdfmt
node_sdfmt -->|"uses"| node_format

click node_sdc "https://github.com/snazzy-d/sdc/blob/master/src/driver/sdc.d"
click node_lexer "https://github.com/snazzy-d/sdc/blob/master/src/source/dlexer.d"
click node_parser "https://github.com/snazzy-d/sdc/tree/master/src/d/parser"
click node_ast "https://github.com/snazzy-d/sdc/tree/master/src/d/ast"
click node_semantic "https://github.com/snazzy-d/sdc/tree/master/src/d/semantic"
click node_ir "https://github.com/snazzy-d/sdc/tree/master/src/d/ir"
click node_llvm "https://github.com/snazzy-d/sdc/tree/master/src/d/llvm"
click node_llvmapi "https://github.com/snazzy-d/sdc/tree/master/import/llvm/c"
click node_jit "https://github.com/snazzy-d/sdc/blob/master/src/d/llvm/evaluator.d"
click node_runtime "https://github.com/snazzy-d/sdc/tree/master/sdlib"
click node_gc "https://github.com/snazzy-d/sdc/tree/master/sdlib/d/gc"
click node_platform "https://github.com/snazzy-d/sdc/tree/master/platform"
click node_sdunit "https://github.com/snazzy-d/sdc/blob/master/src/driver/sdunit.d"
click node_sdfmt "https://github.com/snazzy-d/sdc/blob/master/src/driver/sdfmt.d"
click node_format "https://github.com/snazzy-d/sdc/tree/master/src/format"

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_sdc,node_lexer,node_parser,node_ast,node_semantic,node_ir toneBlue
class node_llvm,node_llvmapi,node_jit toneAmber
class node_runtime,node_gc,node_platform toneMint
class node_sdunit,node_sdfmt,node_format toneRose
class node_developer,node_executable toneIndigo
```

## Components

### Compiler Front End

- [Compiler driver](https://github.com/snazzy-d/sdc/blob/master/src/driver/sdc.d): `src/driver/sdc.d`
- [D lexer](https://github.com/snazzy-d/sdc/blob/master/src/source/dlexer.d): `src/source/dlexer.d`
- [D parser](https://github.com/snazzy-d/sdc/tree/master/src/d/parser): `src/d/parser`
- [D AST](https://github.com/snazzy-d/sdc/tree/master/src/d/ast): `src/d/ast`
- [Semantic analysis](https://github.com/snazzy-d/sdc/tree/master/src/d/semantic): `src/d/semantic`
- [Compiler IR](https://github.com/snazzy-d/sdc/tree/master/src/d/ir): `src/d/ir`

### Code Generation

- [LLVM backend](https://github.com/snazzy-d/sdc/tree/master/src/d/llvm): `src/d/llvm`
- [LLVM](https://github.com/snazzy-d/sdc/tree/master/import/llvm/c): `import/llvm/c`
- [JIT CTFE](https://github.com/snazzy-d/sdc/blob/master/src/d/llvm/evaluator.d): `src/d/llvm/evaluator.d`

### Runtime Support

- [D runtime](https://github.com/snazzy-d/sdc/tree/master/sdlib): `sdlib`
- [Garbage collector](https://github.com/snazzy-d/sdc/tree/master/sdlib/d/gc): `sdlib/d/gc`
- [Platform support](https://github.com/snazzy-d/sdc/tree/master/platform): `platform`

### Developer Tools

- [Unit test runner](https://github.com/snazzy-d/sdc/blob/master/src/driver/sdunit.d): `src/driver/sdunit.d`
- [Code formatter](https://github.com/snazzy-d/sdc/blob/master/src/driver/sdfmt.d): `src/driver/sdfmt.d`
- [Formatting engine](https://github.com/snazzy-d/sdc/tree/master/src/format): `src/format`

### Other components

- **D developer**
- **Compiled output**

## Connections

- D developer → Compiler driver: invokes
- Compiler driver → D lexer: reads source
- D lexer → D parser: tokens
- D parser → D AST: builds AST
- D AST → Semantic analysis: analyzed by
- Semantic analysis → Compiler IR: produces IR
- Compiler driver → LLVM backend: requests codegen
- LLVM backend → LLVM: uses API
- LLVM backend → Compiler IR: lowers IR
- LLVM backend → Compiled output: emits output
- Semantic analysis → JIT CTFE: uses for CTFE
- JIT CTFE → LLVM: uses API
- Compiled output → D runtime: requires support
- D runtime → Garbage collector: includes
- Garbage collector → Platform support: uses platform support
- D developer → Unit test runner: runs tests
- D developer → Code formatter: formats source
- Code formatter → Formatting engine: uses
