feat(pproc): 实现预处理器条件编译和可变参数宏支持

- 添加了完整的条件编译功能,包括 #if、#elif、#else、#endif 指令
- 实现了数值常量表达式的解析和求值
- 支持嵌套条件编译和与其他指令混合使用
- 实现了可变参数宏定义和 __VA_ARGS__ 替换功能
- 改进了宏展开机制以正确处理可变参数宏
- 重构了预处理器指令处理逻辑,提高了代码可维护性
- 添加了相应的单元测试用例验证新功能
This commit is contained in:
zzy
2026-02-21 15:59:31 +08:00
parent b705e5d0ad
commit 8007825800
7 changed files with 317 additions and 134 deletions

View File

@@ -67,7 +67,14 @@ static inline void scc_pproc_add_include_path_cstr(scc_pproc_t *pp,
}
void scc_pproc_handle_directive(scc_pproc_t *pp);
void scc_pproc_parse_include(scc_pproc_t *pp, scc_lexer_tok_t *include_tok);
cbool scc_pproc_parse_if_defined(scc_pproc_t *pp, scc_tok_type_t type,
const scc_lexer_tok_t *tok);
cbool scc_pproc_parse_if_condition(scc_pproc_t *pp, scc_tok_type_t type,
scc_lexer_tok_ring_t *tok_ring);
void scc_pproc_parse_include(scc_pproc_t *pp, scc_lexer_tok_t *include_tok,
scc_lexer_tok_ring_t *tok_ring);
void scc_pproc_parse_macro_arguments(scc_lexer_tok_ring_t *ring,
scc_lexer_tok_vec_t *args, int need_full);
void scc_pproc_parse_function_macro(scc_pproc_t *pp,