feat(pproc): 改进宏处理器以支持括号嵌套和GNU扩展
- 实现了括号深度跟踪来正确分割带括号的宏参数 - 添加了对 GNU 扩展中 `##` 操作符逗号删除的支持 - 新增辅助函数 `got_left_non_blank` 和 `got_right_non_blank` 来优化查找非空白 token 的逻辑 - 改进了错误消息以显示预期但得到的实际值类型 fix(pproc): 修复条件编译和包含文件路径的错误消息 - 在 `scc_pproc_parse_if_condition` 中改进错误消息格式 - 修复 `switch_file_stack` 函数中的日志字符串格式问题 test(pproc): 添加宏处理相关的单元测试 - 增加了连接操作符、嵌套宏、括号处理等测试用例 - 添加了 C99 标准示例和 GNU 变参宏删除逗号的测试 - 包含了复杂的宏展开场景测试 chore(justfile): 更新构建脚本添加调试目标 - 为 `test-scc` 目标添加了 `debug-scc` 调试版本 - 更新构建命令以支持开发模式 feat(cbuild): 添加 dry-run 模式和改进编译器参数 - 为编译器类添加 dry-run 功能,只打印命令不执行 - 改进 scc 编译器的包含路径处理逻辑 - 为命令行解析器添加 dry-run 参数选项 refactor(log): 重命名 static_assert 为 StaticAssert 避免冲突 - 为了避免与标准库冲突,将自定义 static_assert 重命名为 StaticAssert style(scc_core): 移除未使用的预定义宏定义 - 删除了不再需要的基础类型前缀宏定义 fix(scc_core): 初始化 ring 测试中的未初始化变量 - 为测试函数中的字符变量添加初始化值避免未定义行为
This commit is contained in:
@@ -187,13 +187,10 @@ void log_set_handler(logger_t *logger, log_handler handler);
|
||||
* 利用数组大小不能为负的特性
|
||||
* 或使用 _Static_assert (C11)
|
||||
*/
|
||||
#ifdef static_assert
|
||||
#undef static_assert
|
||||
#endif
|
||||
#if __STDC_VERSION__ >= 201112L
|
||||
#define static_assert _Static_assert
|
||||
#define StaticAssert static_assert
|
||||
#else
|
||||
#define static_assert(cond, msg) extern char __static_assertion[(cond) ? 1 : -1]
|
||||
#define StaticAssert(cond, msg) extern char __static_assertion[(cond) ? 1 : -1]
|
||||
#endif
|
||||
|
||||
#ifdef __SCC_LOG_IMPL_IMPORT_SRC__
|
||||
|
||||
@@ -33,23 +33,6 @@ typedef bool cbool;
|
||||
static_assert(sizeof(cbool) == 1, "cbool size must 1");
|
||||
|
||||
#else
|
||||
#define __scc_i8
|
||||
#define __scc_i16
|
||||
#define __scc_i32
|
||||
#define __scc_i64
|
||||
#define __scc_u8
|
||||
#define __scc_u16
|
||||
#define __scc_u32
|
||||
#define __scc_u64
|
||||
#define __scc_f32
|
||||
#define __scc_f64
|
||||
#define __scc_bool
|
||||
#define __scc_char
|
||||
#define __scc_void
|
||||
#define __scc_null
|
||||
#define __scc_isize
|
||||
#define __scc_usize
|
||||
|
||||
/* clang-format off */
|
||||
typedef __scc_i8 i8;
|
||||
typedef __scc_i16 i16;
|
||||
|
||||
@@ -60,7 +60,7 @@ void test_char_ring_basic(void) {
|
||||
reset_char_fill();
|
||||
char_ring_t ring;
|
||||
scc_ring_init(ring, 4, char_fill, 0);
|
||||
char c;
|
||||
char c = 0;
|
||||
cbool ok;
|
||||
|
||||
scc_ring_next(ring, c, ok);
|
||||
@@ -109,7 +109,7 @@ void test_char_ring_full(void) {
|
||||
reset_char_fill();
|
||||
char_ring_t ring;
|
||||
scc_ring_init(ring, 3, char_fill, 0);
|
||||
char c;
|
||||
char c = 0;
|
||||
cbool ok;
|
||||
|
||||
scc_ring_next(ring, c, ok);
|
||||
@@ -140,7 +140,7 @@ void test_char_ring_eof(void) {
|
||||
reset_char_fill();
|
||||
char_ring_t ring;
|
||||
scc_ring_init(ring, 32, char_fill, 0);
|
||||
char c;
|
||||
char c = 0;
|
||||
cbool ok;
|
||||
|
||||
for (int i = 0; i < 26; i++) {
|
||||
@@ -160,7 +160,7 @@ void test_char_ring_back_boundary(void) {
|
||||
reset_char_fill();
|
||||
char_ring_t ring;
|
||||
scc_ring_init(ring, 4, char_fill, 0);
|
||||
char c;
|
||||
char c = 0;
|
||||
cbool ok;
|
||||
|
||||
scc_ring_next(ring, c, ok);
|
||||
@@ -186,7 +186,7 @@ void test_char_ring_consume_reset(void) {
|
||||
reset_char_fill();
|
||||
char_ring_t ring;
|
||||
scc_ring_init(ring, 5, char_fill, 0);
|
||||
char c;
|
||||
char c = 0;
|
||||
cbool ok;
|
||||
|
||||
scc_ring_next(ring, c, ok);
|
||||
@@ -219,7 +219,7 @@ void test_char_ring_wrap(void) {
|
||||
reset_char_fill();
|
||||
char_ring_t ring;
|
||||
scc_ring_init(ring, 3, char_fill, 0);
|
||||
char c;
|
||||
char c = 0;
|
||||
cbool ok;
|
||||
|
||||
for (int i = 0; i < 26; i++) {
|
||||
@@ -239,7 +239,7 @@ void test_token_ring_basic(void) {
|
||||
reset_token_fill();
|
||||
token_ring_t ring;
|
||||
scc_ring_init(ring, 3, token_fill, 0);
|
||||
test_token_t tok;
|
||||
test_token_t tok = {0};
|
||||
cbool ok;
|
||||
|
||||
scc_ring_next(ring, tok, ok);
|
||||
@@ -284,7 +284,7 @@ void test_token_ring_full(void) {
|
||||
reset_token_fill();
|
||||
token_ring_t ring;
|
||||
scc_ring_init(ring, 2, token_fill, 0);
|
||||
test_token_t tok;
|
||||
test_token_t tok = {0};
|
||||
cbool ok;
|
||||
|
||||
scc_ring_next(ring, tok, ok);
|
||||
|
||||
Reference in New Issue
Block a user