How jihuiyiyou/jihuiyiyou-compiler works
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: main.c Compiler CLI · codegen.c Code generation · server.py MCP server · ast.c AST model
Components 23
Compiler
- Compiler CLI
compiler/src/main.c - Lexer
compiler/src/lexer.c - Parser
compiler/src/parser.c - AST model
compiler/src/ast.c - Semantic analysis
compiler/src/sema.c - Symbol tables
compiler/src/symtab.c - Type system
compiler/src/types.c - IR construction
compiler/src/ir.c - Code generation
compiler/src/codegen.c - Self-hosted compiler
compiler/src0 - Standard library
compiler/src0/std
Target backends
- Target dispatch
compiler/src/target/target_dispatch.c - Windows ABI
compiler/src/target/abi_amd64_win.c - Freestanding ABI
compiler/src/target/abi_amd64_win_freestanding.c
Developer interfaces
- VS Code extension
vscode-ext/src/extension.ts
MCP tools
- MCP server
mcp-jhyy/server.py - Compile and run
mcp-jhyy/jhyy_runner.py - Regression tools
mcp-jhyy/jhyy_regress.py - Spec search
mcp-jhyy/jhyy_spec_doc.py - Workaround search
mcp-jhyy/jhyy_workarounds.py
Other components
- Language user
- Native executable
- AI assistant
Connections 27
- Language user → Compiler CLI: invokes
- Compiler CLI → Lexer: starts analysis
compiler/src/main.c - Compiler CLI → Parser: parses source
compiler/src/main.c - Parser → Lexer: reads tokens
compiler/src/parser.c - Parser → AST model: builds nodes
compiler/src/parser.c - Compiler CLI → Semantic analysis: checks module
compiler/src/main.c - Compiler CLI → Code generation: generates output
compiler/src/main.c - Compiler CLI → Target dispatch: selects target
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
compiler/src/codegen.c - Code generation → Freestanding ABI: uses ABI
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
mcp-jhyy/server.py - MCP server → Compile and run: delegates compile/run
mcp-jhyy/server.py - MCP server → Regression tools: delegates regressions
mcp-jhyy/server.py - MCP server → Spec search: delegates search
mcp-jhyy/server.py - MCP server → Workaround search: delegates search
mcp-jhyy/server.py - Compile and run → Compiler CLI: runs compiler
mcp-jhyy/jhyy_runner.py - Regression tools → Compiler CLI: runs compiler
mcp-jhyy/jhyy_regress.py