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

@@ -5,20 +5,20 @@
static inline const scc_lexer_tok_t *scc_parser_peek(scc_parser_t *parser) {
cbool ok = false;
const scc_lexer_tok_t *tok = null;
const scc_lexer_tok_t *tok = nullptr;
scc_ring_unsafe_peek_ref(*parser->ring, tok, ok);
if (ok == false) {
return null;
return nullptr;
}
return tok;
}
static inline const scc_lexer_tok_t *scc_parser_next(scc_parser_t *parser) {
cbool ok = false;
const scc_lexer_tok_t *tok = null;
const scc_lexer_tok_t *tok = nullptr;
scc_ring_unsafe_next_ref(*parser->ring, tok, ok);
if (ok == false) {
return null;
return nullptr;
}
return tok;
}
@@ -26,10 +26,10 @@ static inline const scc_lexer_tok_t *scc_parser_next(scc_parser_t *parser) {
static inline cbool scc_parser_consume_if(scc_parser_t *parser,
scc_tok_type_t type) {
cbool ok = false;
scc_lexer_tok_t *tok = null;
scc_lexer_tok_t *tok = nullptr;
scc_ring_unsafe_peek_ref(*parser->ring, tok, ok);
if (ok == false) {
return null;
return nullptr;
}
if (tok->type == type) {
scc_lexer_tok_drop(tok);
@@ -48,13 +48,13 @@ static inline void scc_parser_restore(scc_parser_t *parser) {
_scc_ring_probe(*parser->ring) = parser->checkpoint;
}
// tok can null it will be safty free
// tok can nullptr it will be safty free
static inline cbool scc_parser_next_consume(scc_parser_t *parser,
scc_lexer_tok_t *tok) {
cbool ok = false;
scc_lexer_tok_t *raw_tok_ref = null;
scc_lexer_tok_t *raw_tok_ref = nullptr;
scc_ring_unsafe_next_ref_consume(*parser->ring, raw_tok_ref, ok);
if (tok == null) {
if (tok == nullptr) {
scc_lexer_tok_drop(raw_tok_ref);
} else {
scc_lexer_tok_move(tok, raw_tok_ref);
@@ -75,7 +75,7 @@ static inline void scc_parser_reset(scc_parser_t *parser) {
static inline scc_pos_t scc_parser_got_current_pos(scc_parser_t *parser) {
const scc_lexer_tok_t *tok = scc_parser_peek(parser);
scc_pos_t pos = scc_pos_create();
if (tok != null)
if (tok != nullptr)
pos = tok->loc;
return pos;
}