refactor(lexer): 移除未使用的期望函数并修复内存分配错误
移除了 scc_lexer_tok_expect 函数,因为它不再被使用。 在 lexer_stream_extend 函数中添加了返回语句,以在内存重新分配失败时正确处理错误。 BREAKING CHANGE: 移除了 scc_lexer_tok_expect 函数
This commit is contained in:
@@ -148,13 +148,4 @@ static inline cbool scc_lexer_tok_match(const scc_lexer_tok_t *tok,
|
||||
return tok->type == type;
|
||||
}
|
||||
|
||||
static inline cbool scc_lexer_tok_expect(const scc_lexer_tok_t *tok,
|
||||
scc_tok_type_t type) {
|
||||
if (!scc_lexer_tok_match(tok, type)) {
|
||||
LOG_ERROR("expected token %d, got %d\n", type, tok->type);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif /* __SCC_LEXER_TOKEN_H__ */
|
||||
|
||||
@@ -14,6 +14,7 @@ static void lexer_stream_extend(scc_lexer_stream_t *stream, usize n) {
|
||||
scc_realloc(null, new_cap * sizeof(scc_lexer_tok_t));
|
||||
if (!new_data) {
|
||||
LOG_FATAL("lexer_stream_extend: realloc failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// 将旧缓冲区中的数据拷贝到新缓冲区,保持顺序
|
||||
|
||||
Reference in New Issue
Block a user