refactor(argparse): 将null替换为nullptr以提高C++兼容性

- 在argparse库中将所有null指针常量替换为nullptr
- 更新头文件和源文件中的指针初始化和比较操作
- 修改测试文件中的相关断言检查
- 更新AST定义文件中的注释说明
This commit is contained in:
zzy
2026-04-05 20:18:09 +08:00
parent 27d86d5685
commit 4144f7841c
76 changed files with 1430 additions and 998 deletions

View File

@@ -193,11 +193,11 @@ scc_tok_subtype_t scc_get_tok_subtype(scc_tok_type_t type);
const char *scc_get_tok_name(scc_tok_type_t type);
static inline void scc_lexer_tok_drop(scc_lexer_tok_t *tok) {
Assert(tok != null);
Assert(tok != nullptr);
tok->type = SCC_TOK_UNKNOWN;
tok->loc.col = 0;
tok->loc.line = 0;
tok->loc.name = null;
tok->loc.name = nullptr;
tok->loc.offset = 0;
scc_str_drop(&tok->lexeme);
}
@@ -209,7 +209,7 @@ static inline cbool scc_lexer_tok_match(const scc_lexer_tok_t *tok,
// 深拷贝 token
static inline scc_lexer_tok_t scc_lexer_tok_copy(const scc_lexer_tok_t *src) {
Assert(src != null);
Assert(src != nullptr);
scc_lexer_tok_t dst = *src;
dst.lexeme = scc_str_copy(&src->lexeme);
return dst;
@@ -218,9 +218,9 @@ static inline scc_lexer_tok_t scc_lexer_tok_copy(const scc_lexer_tok_t *src) {
// 移动 token源 token 不再拥有 lexeme
static inline void scc_lexer_tok_move(scc_lexer_tok_t *dst,
scc_lexer_tok_t *src) {
Assert(src != null);
Assert(src != nullptr);
*dst = *src;
src->lexeme.data = null;
src->lexeme.data = nullptr;
src->lexeme.size = 0;
src->lexeme.cap = 0;
}

View File

@@ -4,13 +4,13 @@
#include "scc_lexer.h"
static inline void scc_lexer_gen_number_true(scc_lexer_tok_t *tok) {
Assert(tok != null && tok->type == SCC_TOK_UNKNOWN);
Assert(tok != nullptr && tok->type == SCC_TOK_UNKNOWN);
tok->type = SCC_TOK_INT_LITERAL;
tok->lexeme = scc_str_from_cstr("1");
}
static inline void scc_lexer_gen_number_false(scc_lexer_tok_t *tok) {
Assert(tok != null && tok->type == SCC_TOK_UNKNOWN);
Assert(tok != nullptr && tok->type == SCC_TOK_UNKNOWN);
tok->type = SCC_TOK_INT_LITERAL;
tok->lexeme = scc_str_from_cstr("0");
}

View File

@@ -538,7 +538,7 @@ void scc_lexer_drop_ring(scc_lexer_tok_ring_t *ring_ref) {
}
void scc_lexer_drop(scc_lexer_t *lexer) {
Assert(lexer != null);
Assert(lexer != nullptr);
if (lexer->ring_ref_count) {
LOG_FATAL("drop sstream must be drop ring before ref [%d]",
lexer->ring_ref_count);

View File

@@ -24,12 +24,12 @@ int g_num_arr[3];
int main(int argc, char *argv[]) {
// int num = 0;
if (argc == 3 && strcmp(argv[2], "--debug") == 0) {
log_set_level(NULL, LOG_LEVEL_ALL);
log_set_level(nullptr, LOG_LEVEL_ALL);
} else {
// FIXME it is a hack lexer_logger
log_set_level(&__scc_lexer_log, LOG_LEVEL_NOTSET);
log_set_level(NULL, LOG_LEVEL_INFO | LOG_LEVEL_WARN | LOG_LEVEL_ERROR |
LOG_LEVEL_FATAL);
log_set_level(nullptr, LOG_LEVEL_INFO | LOG_LEVEL_WARN |
LOG_LEVEL_ERROR | LOG_LEVEL_FATAL);
}
const char *file_name = __FILE__;

View File

@@ -412,5 +412,5 @@ TEST_LIST = {
{"edge_cases", test_edge_cases},
{"sequences", test_sequences},
{"error_recovery", test_error_recovery},
{NULL, NULL},
{nullptr, nullptr},
};