From c8bf98525dfbbf38a229148b249d3b08c7b78b3a Mon Sep 17 00:00:00 2001 From: zzy <2450266535@qq.com> Date: Fri, 30 Jan 2026 14:18:07 +0800 Subject: [PATCH] =?UTF-8?q?chore(build):=20=E6=9B=B4=E6=96=B0=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E8=84=9A=E6=9C=AC=E5=92=8C=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改justfile中的构建命令,将build-lexer重命名为build_lexer - 添加count命令用于统计代码行数 - 更新docs命令依赖关系 feat(docs): 完善README文档内容 - 更新项目名称为Simple C Compiler,简化为`scc` - 添加详细的构建说明,介绍cbuild构建工具 - 补充标准C语言文档链接 - 重新组织项目特点描述 refactor(tree_dump): 修复未使用的返回值警告 - 在tree_dump_pop_level函数中添加(void)强制转换 - 解决scc_vec_pop返回值未被使用的问题 chore(gitignore): 添加新的忽略文件类型 - 增加.dot和.svg文件类型的忽略规则 - 保持.gitignore文件结构清晰 --- .gitignore | 4 ++++ README.md | 36 +++++++++++++++++++++++------- justfile | 14 +++++++----- libs/tree_dump/include/tree_dump.h | 2 +- 4 files changed, 42 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 43bea61..ac73a47 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,7 @@ build # external external/ + +# dot file and svg file +*.dot +*.svg diff --git a/README.md b/README.md index 2627de5..df3d8b5 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,35 @@ -# Simple Models C Compiler +# Simple C Compiler -> Smaller Compiler(SMCC) +> `scc` -This is a simple C compiler that generates executable code from a simple c99 sub programming language. The language supports basic operations such as arithmetic, logical, conditional statements and if else while for switch case statements and function calls and system calls. +这是一个简单的C语言编译器,可以从C99子集编程语言生成可执行代码。该语言支持基本操作,如算术运算、逻辑运算、条件语句(if/else)、循环语句(while/for)、分支语句(switch/case)、函数调用以及内联汇编调用(asm)。 -## Features +## Builder -- 隔离标准库 +该编译器使用`cbuild` 构建,设计思路来源于`rust`的构建工具`cargo`,以默认行为代替掉`make`、`cmake`等构建工具。 -- 轻量化 +> 由于整个项目除了测试代码,完全没有任何依赖,真正做到`0依赖`,所以无需复杂的依赖管理 +TODO 未来构建工具本身也会使用c或者lua等可轻松自举的系统重构 -- 模块化 +### [cbuild](./tools/cbuild/cbuild.py) -- 自举构建 +常用命令: + +- 构建项目: `cbuild build` +- 运行程序: `cbuild run` +- 运行测试: `cbuild test` +- 清理构建产物: `cbuild clean` +- 查看依赖树: `cbuild tree` + +## 标准C语言文档链接 + +- [open-std](https://www.open-std.org/) +- [C - Project status and milestones](https://www.open-std.org/JTC1/SC22/WG14/www/projects#9899) +- [ISO/IEC 9899:1999](https://www.open-std.org/JTC1/SC22/WG14/www/docs/n1256.pdf) + +## 项目特点 + +- **隔离标准库**: 不直接依赖标准库实现,提高可移植性 +- **轻量化**: 专注于核心功能,减少冗余组件 +- **模块化**: 采用模块化设计,易于扩展和维护 +- **自举构建**: 支持通过自身编译器构建项目 diff --git a/justfile b/justfile index 7723bb7..1b37b2b 100644 --- a/justfile +++ b/justfile @@ -1,11 +1,15 @@ list: just --list -build-lexer: - python build.py build -p libs/lexer - -build-docs: +build_docs: doxygen Doxyfile -docs: build-docs +docs: build_docs python -m http.server -d docs/html + +count: + # you need download `tokei` it can download by cargo + tokei libs runtime src -e tests + +build_lexer: + python ./tools/cbuild/cbuild.py --path libs/lexer build diff --git a/libs/tree_dump/include/tree_dump.h b/libs/tree_dump/include/tree_dump.h index 18bac72..d6392be 100644 --- a/libs/tree_dump/include/tree_dump.h +++ b/libs/tree_dump/include/tree_dump.h @@ -80,7 +80,7 @@ static inline void scc_tree_dump_push_level(scc_tree_dump_ctx_t *ctx, // 弹出当前层级 static inline void scc_tree_dump_pop_level(scc_tree_dump_ctx_t *ctx) { - scc_vec_pop(ctx->stack); + (void)scc_vec_pop(ctx->stack); } // 获取当前层级深度