docs: CLAUDE.md 数据同步 — 197单元+36集成,架构图反映文件拆分
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## 项目概述
|
## 项目概述
|
||||||
|
|
||||||
L Language v0.5 — 用 C17 实现的静态类型编译型编程语言,Rust 风格语法,LLVM 22.x 后端。经典 5 阶段流水线:词法 → 语法 → 语义 → IR → 可执行文件。145 单元测试 + 23 集成程序。
|
L Language v0.6 — 用 C17 实现的静态类型编译型编程语言,Rust 风格语法,LLVM 22.x 后端。经典 5 阶段流水线:词法 → 语法 → 语义 → IR → 可执行文件。197 单元测试 + 36 集成程序。
|
||||||
|
|
||||||
## 语言设计哲学
|
## 语言设计哲学
|
||||||
|
|
||||||
@@ -134,14 +134,20 @@ L Language/
|
|||||||
│ │ ├── token.h/c Token {kind, start, length, line, col}
|
│ │ ├── token.h/c Token {kind, start, length, line, col}
|
||||||
│ │ └── lexer.h/c 手写状态机,72 种 Token 类型
|
│ │ └── lexer.h/c 手写状态机,72 种 Token 类型
|
||||||
│ ├── parser/
|
│ ├── parser/
|
||||||
│ │ └── parser.h/c Pratt 表达式 (9 级优先级) + 递归下降语句
|
│ │ ├── parse_internal.h 共享 Parser struct + 内联辅助
|
||||||
|
│ │ ├── parser.h/c 语句/声明/程序入口 (662 行)
|
||||||
|
│ │ └── expr.c 表达式/类型解析 (498 行, Pratt 主循环)
|
||||||
│ ├── ast/
|
│ ├── ast/
|
||||||
│ │ └── ast.h/c 27 种 AST 节点 + 工厂函数
|
│ │ └── ast.h/c 27 种 AST 节点 + 工厂函数
|
||||||
│ ├── sema/
|
│ ├── sema/
|
||||||
|
│ │ ├── sema_internal.h 共享声明 + 向前声明
|
||||||
│ │ ├── symbol.h/c 作用域链 (Scope* parent 链表)
|
│ │ ├── symbol.h/c 作用域链 (Scope* parent 链表)
|
||||||
│ │ └── sema.h/c 类型推断 + 类型检查 + 5 个内建函数注册
|
│ │ ├── sema.h/c 语义分析入口 + analyze_node (499 行)
|
||||||
|
│ │ └── typeck.c 表达式类型检查 + 泛型单态化 (629 行)
|
||||||
│ ├── codegen/
|
│ ├── codegen/
|
||||||
│ │ └── codegen.h/c AST → LLVM-C API → LLVMModuleRef
|
│ │ ├── codegen_internal.h 共享 CgCtx + 表操作声明
|
||||||
|
│ │ ├── codegen.h/c 语句生成 + 模块入口 (453 行)
|
||||||
|
│ │ └── cg_expr.c LLVM 表达式生成 + 类型映射 (440 行)
|
||||||
│ ├── driver/
|
│ ├── driver/
|
||||||
│ │ ├── main.c 入口 + 命令行解析 + 流水线串联
|
│ │ ├── main.c 入口 + 命令行解析 + 流水线串联
|
||||||
│ │ └── error.h/c ErrorInfo / ErrorList 错误报告
|
│ │ └── error.h/c ErrorInfo / ErrorList 错误报告
|
||||||
@@ -149,10 +155,11 @@ L Language/
|
|||||||
│ └── arena.h/c Bump allocator (8MB, 8 字节对齐)
|
│ └── arena.h/c Bump allocator (8MB, 8 字节对齐)
|
||||||
├── test/
|
├── test/
|
||||||
│ ├── test_utils.h 断言宏 (ASSERT / TEST_RUN / test_summary)
|
│ ├── test_utils.h 断言宏 (ASSERT / TEST_RUN / test_summary)
|
||||||
│ ├── test_lexer.c 词法测试 (41 tests)
|
│ ├── test_lexer.c 词法测试 (41 tests, 3 functions)
|
||||||
│ ├── test_parser.c 语法测试 (15 tests)
|
│ ├── test_parser.c 语法测试 (54 tests, 20 functions)
|
||||||
│ ├── test_sema.c 语义测试 (74 tests)
|
│ ├── test_sema.c 语义测试 (74 tests, 24 functions)
|
||||||
│ └── programs/ .l 集成测试 (34 个程序)
|
│ ├── test_codegen.c 代码生成测试 (28 tests, 10 functions)
|
||||||
|
│ └── programs/ .l 集成测试 (36 个程序)
|
||||||
├── docs/
|
├── docs/
|
||||||
│ ├── PRD.md 产品需求文档
|
│ ├── PRD.md 产品需求文档
|
||||||
│ └── superpowers/plans/ 实现计划
|
│ └── superpowers/plans/ 实现计划
|
||||||
@@ -245,9 +252,10 @@ LLVMModuleRef codegen_module(AstNode* ast, const char* module_name,
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 单元测试 (每个 test_*.c 独立编译运行,各有自己的 main)
|
# 单元测试 (每个 test_*.c 独立编译运行,各有自己的 main)
|
||||||
./l_lang_lexer_test.exe # 41 个断言
|
./l_lang_lexer_test.exe # 41 tests (3 functions)
|
||||||
./l_lang_test.exe # 15 个断言
|
./l_lang_test.exe # 54 tests (20 functions)
|
||||||
./l_lang_sema_test.exe # 9 个断言
|
./l_lang_sema_test.exe # 74 tests (24 functions)
|
||||||
|
./l_lang_codegen_test.exe # 28 tests (10 functions)
|
||||||
|
|
||||||
# 集成测试 (编译 .l → 运行 .exe → 检查输出)
|
# 集成测试 (编译 .l → 运行 .exe → 检查输出)
|
||||||
for f in ../test/programs/*.l; do
|
for f in ../test/programs/*.l; do
|
||||||
|
|||||||
Reference in New Issue
Block a user