# jihuiyiyou/jihuiyiyou-compiler architecture

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

- Interactive diagram: https://gitdiagram.com/jihuiyiyou/jihuiyiyou-compiler
- Repository: https://github.com/jihuiyiyou/jihuiyiyou-compiler

## Overview

JHYY is a self-hosted, statically typed systems-language compiler. The main workflow takes source through lexical analysis, parsing, semantic checking, IR/code generation, target selection, and native output. The README identifies compiler/src0 as authoritative and compiler/src as a legacy parity implementation; the provided tree samples only the latter’s detailed compiler modules. MCP tools and the VS Code extension are supporting user interfaces. Dashed links mark relationships described at a high level but not verified in sampled implementation source.

Main entry points: [`compiler/src/main.c`](https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/compiler/src/main.c) (Compiler CLI), [`compiler/src/codegen.c`](https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/compiler/src/codegen.c) (Code generation), [`mcp-jhyy/server.py`](https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/mcp-jhyy/server.py) (MCP server), [`compiler/src/ast.c`](https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/compiler/src/ast.c) (AST model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_compiler["Compiler"]
  node_cli["Compiler CLI<br/>[main.c]"]
  node_lexer["Lexer<br/>[lexer.c]"]
  node_parser["Parser<br/>[parser.c]"]
  node_ast["AST model<br/>[ast.c]"]
  node_sema["Semantic analysis<br/>[sema.c]"]
  node_symbols["Symbol tables<br/>[symtab.c]"]
  node_types["Type system<br/>[types.c]"]
  node_ir["IR construction<br/>[ir.c]"]
  node_codegen["Code generation<br/>[codegen.c]"]
  node_selfhost["Self-hosted compiler"]
  node_stdlib["Standard library"]
end

subgraph group_targets["Target backends"]
  node_dispatch["Target dispatch<br/>[target_dispatch.c]"]
  node_winabi["Windows ABI<br/>[abi_amd64_win.c]"]
  node_freeabi["Freestanding ABI"]
end

subgraph group_interfaces["Developer interfaces"]
  node_vscode["VS Code extension<br/>[extension.ts]"]
end

subgraph group_mcp["MCP tools"]
  node_mcpserver["MCP server<br/>[server.py]"]
  node_runner["Compile and run<br/>[jhyy_runner.py]"]
  node_regress["Regression tools<br/>[jhyy_regress.py]"]
  node_spec["Spec search<br/>[jhyy_spec_doc.py]"]
  node_workarounds["Workaround search"]
end

node_user(("Language user"))
node_native["Native executable"]
node_assistant(("AI assistant"))

node_user -.->|"invokes"| node_cli
node_cli -->|"starts analysis"| node_lexer
node_cli -->|"parses source"| node_parser
node_parser -->|"reads tokens"| node_lexer
node_parser -->|"builds nodes"| node_ast
node_cli -->|"checks module"| node_sema
node_cli -->|"generates output"| node_codegen
node_cli -->|"selects target"| node_dispatch
node_sema -->|"checks"| node_ast
node_ast -->|"uses symbols"| node_symbols
node_ast -->|"uses types"| node_types
node_codegen -->|"emits IR"| node_ir
node_codegen -->|"uses ABI"| node_winabi
node_codegen -->|"uses ABI"| node_freeabi
node_dispatch -.->|"selects backend"| node_codegen
node_codegen -.->|"emits native code"| node_native
node_selfhost -.->|"compiles source"| node_native
node_stdlib -.->|"supports programs"| node_selfhost
node_user -->|"uses"| node_vscode
node_vscode -.->|"invokes compiler"| node_cli
node_assistant -->|"requests tools"| node_mcpserver
node_mcpserver -->|"delegates compile/run"| node_runner
node_mcpserver -->|"delegates regressions"| node_regress
node_mcpserver -->|"delegates search"| node_spec
node_mcpserver -->|"delegates search"| node_workarounds
node_runner -->|"runs compiler"| node_cli
node_regress -->|"runs compiler"| node_cli

click node_cli "https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/compiler/src/main.c"
click node_lexer "https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/compiler/src/lexer.c"
click node_parser "https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/compiler/src/parser.c"
click node_ast "https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/compiler/src/ast.c"
click node_sema "https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/compiler/src/sema.c"
click node_symbols "https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/compiler/src/symtab.c"
click node_types "https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/compiler/src/types.c"
click node_ir "https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/compiler/src/ir.c"
click node_codegen "https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/compiler/src/codegen.c"
click node_dispatch "https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/compiler/src/target/target_dispatch.c"
click node_winabi "https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/compiler/src/target/abi_amd64_win.c"
click node_freeabi "https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/compiler/src/target/abi_amd64_win_freestanding.c"
click node_selfhost "https://github.com/jihuiyiyou/jihuiyiyou-compiler/tree/main/compiler/src0"
click node_stdlib "https://github.com/jihuiyiyou/jihuiyiyou-compiler/tree/main/compiler/src0/std"
click node_vscode "https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/vscode-ext/src/extension.ts"
click node_mcpserver "https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/mcp-jhyy/server.py"
click node_runner "https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/mcp-jhyy/jhyy_runner.py"
click node_regress "https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/mcp-jhyy/jhyy_regress.py"
click node_spec "https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/mcp-jhyy/jhyy_spec_doc.py"
click node_workarounds "https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/mcp-jhyy/jhyy_workarounds.py"

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_cli,node_lexer,node_parser,node_ast,node_sema,node_symbols,node_types,node_ir,node_codegen,node_selfhost,node_stdlib,node_user toneBlue
class node_dispatch,node_winabi,node_freeabi toneAmber
class node_vscode toneMint
class node_mcpserver,node_runner,node_regress,node_spec,node_workarounds toneRose
class node_native,node_assistant toneIndigo
```

## Components

### Compiler

- [Compiler CLI](https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/compiler/src/main.c): `compiler/src/main.c`
- [Lexer](https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/compiler/src/lexer.c): `compiler/src/lexer.c`
- [Parser](https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/compiler/src/parser.c): `compiler/src/parser.c`
- [AST model](https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/compiler/src/ast.c): `compiler/src/ast.c`
- [Semantic analysis](https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/compiler/src/sema.c): `compiler/src/sema.c`
- [Symbol tables](https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/compiler/src/symtab.c): `compiler/src/symtab.c`
- [Type system](https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/compiler/src/types.c): `compiler/src/types.c`
- [IR construction](https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/compiler/src/ir.c): `compiler/src/ir.c`
- [Code generation](https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/compiler/src/codegen.c): `compiler/src/codegen.c`
- [Self-hosted compiler](https://github.com/jihuiyiyou/jihuiyiyou-compiler/tree/main/compiler/src0): `compiler/src0`
- [Standard library](https://github.com/jihuiyiyou/jihuiyiyou-compiler/tree/main/compiler/src0/std): `compiler/src0/std`

### Target backends

- [Target dispatch](https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/compiler/src/target/target_dispatch.c): `compiler/src/target/target_dispatch.c`
- [Windows ABI](https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/compiler/src/target/abi_amd64_win.c): `compiler/src/target/abi_amd64_win.c`
- [Freestanding ABI](https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/compiler/src/target/abi_amd64_win_freestanding.c): `compiler/src/target/abi_amd64_win_freestanding.c`

### Developer interfaces

- [VS Code extension](https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/vscode-ext/src/extension.ts): `vscode-ext/src/extension.ts`

### MCP tools

- [MCP server](https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/mcp-jhyy/server.py): `mcp-jhyy/server.py`
- [Compile and run](https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/mcp-jhyy/jhyy_runner.py): `mcp-jhyy/jhyy_runner.py`
- [Regression tools](https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/mcp-jhyy/jhyy_regress.py): `mcp-jhyy/jhyy_regress.py`
- [Spec search](https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/mcp-jhyy/jhyy_spec_doc.py): `mcp-jhyy/jhyy_spec_doc.py`
- [Workaround search](https://github.com/jihuiyiyou/jihuiyiyou-compiler/blob/main/mcp-jhyy/jhyy_workarounds.py): `mcp-jhyy/jhyy_workarounds.py`

### Other components

- **Language user**
- **Native executable**
- **AI assistant**

## Connections

- Language user → Compiler CLI: invokes
- Compiler CLI → Lexer: starts analysis (evidence: `compiler/src/main.c`)
- Compiler CLI → Parser: parses source (evidence: `compiler/src/main.c`)
- Parser → Lexer: reads tokens (evidence: `compiler/src/parser.c`)
- Parser → AST model: builds nodes (evidence: `compiler/src/parser.c`)
- Compiler CLI → Semantic analysis: checks module (evidence: `compiler/src/main.c`)
- Compiler CLI → Code generation: generates output (evidence: `compiler/src/main.c`)
- Compiler CLI → Target dispatch: selects target (evidence: `compiler/src/main.c`)
- Semantic analysis → AST model: checks
- AST model → Symbol tables: uses symbols
- AST model → Type system: uses types
- Code generation → IR construction: emits IR
- Code generation → Windows ABI: uses ABI (evidence: `compiler/src/codegen.c`)
- Code generation → Freestanding ABI: uses ABI (evidence: `compiler/src/codegen.c`)
- Target dispatch → Code generation: selects backend
- Code generation → Native executable: emits native code
- Self-hosted compiler → Native executable: compiles source
- Standard library → Self-hosted compiler: supports programs
- Language user → VS Code extension: uses
- VS Code extension → Compiler CLI: invokes compiler
- AI assistant → MCP server: requests tools (evidence: `mcp-jhyy/server.py`)
- MCP server → Compile and run: delegates compile/run (evidence: `mcp-jhyy/server.py`)
- MCP server → Regression tools: delegates regressions (evidence: `mcp-jhyy/server.py`)
- MCP server → Spec search: delegates search (evidence: `mcp-jhyy/server.py`)
- MCP server → Workaround search: delegates search (evidence: `mcp-jhyy/server.py`)
- Compile and run → Compiler CLI: runs compiler (evidence: `mcp-jhyy/jhyy_runner.py`)
- Regression tools → Compiler CLI: runs compiler (evidence: `mcp-jhyy/jhyy_regress.py`)
