feat(lexer): 添加词法分析器对##操作符的支持

- 重命名lexer_token.h为scc_lexer_token.h以保持命名一致性
- 在词法分析器中实现##操作符的识别和处理
- 修改头文件包含路径和类型定义的位置
- 修复token结构体定义的顺序问题

fix(lexer): 初始化lexer中的cur变量避免未初始化问题

- 在scc_lexer_get_token函数中初始化scc_sstream_char_t cur变量

refactor(core): 增强ring缓冲区功能并添加cstring比较函数

- 在scc_core_ring.h中添加空值检查防止fill函数为空时崩溃
- 添加scc_ring_by_buffer宏用于通过缓冲区创建ring实例
- 在scc_core_str.h中添加scc_cstring_cmp函数用于字符串比较
This commit is contained in:
zzy
2026-02-18 18:17:52 +08:00
parent 2de5ae59f5
commit 9d85dc130d
6 changed files with 38 additions and 12 deletions

View File

@@ -51,7 +51,8 @@
break; \
} \
usize phys_tail = scc_ring_phys(ring, (ring).tail); \
if (!(ring).fill(&(ring).data[phys_tail], (ring).userdata)) { \
if ((ring).fill == null || \
!(ring).fill(&(ring).data[phys_tail], (ring).userdata)) { \
ok = 0; \
break; \
} \
@@ -79,6 +80,17 @@
(ring).userdata = (_userdata); \
} while (0)
#define scc_ring_by_buffer(ring, buffer, size) \
do { \
(ring).data = (buffer); \
(ring).cap = (size); \
(ring).head = 0; \
(ring).probe = 0; \
(ring).tail = (size); \
(ring).fill = null; \
(ring).userdata = null; \
} while (0)
/**
* @brief 释放环形缓冲区内存
* @param ring 环形缓冲区变量

View File

@@ -194,6 +194,11 @@ static inline char *scc_cstring_as_cstr(const scc_cstring_t *str) {
return str->data;
}
static inline int scc_cstring_cmp(const scc_cstring_t *str1,
const scc_cstring_t *str2) {
return scc_strcmp(scc_cstring_as_cstr(str1), scc_cstring_as_cstr(str2));
}
static inline char *scc_cstring_move_cstr(scc_cstring_t *str) {
if (str == null || str->data == null) {
return null;