refactor(argparse): 将null替换为nullptr以提高C++兼容性
- 在argparse库中将所有null指针常量替换为nullptr - 更新头文件和源文件中的指针初始化和比较操作 - 修改测试文件中的相关断言检查 - 更新AST定义文件中的注释说明
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ typedef struct scc_parser {
|
||||
* @brief 初始化解析器
|
||||
* @param parser 解析器实例
|
||||
* @param lexer 词法分析器实例
|
||||
* @param callbacks 语义分析回调(可为 null)
|
||||
* @param callbacks 语义分析回调(可为 nullptr)
|
||||
*/
|
||||
void scc_parser_init(scc_parser_t *parser, scc_lexer_tok_ring_t *tok_ring,
|
||||
scc_sema_callbacks_t *callbacks);
|
||||
|
||||
Reference in New Issue
Block a user