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); } // 获取当前层级深度