- 重命名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函数用于字符串比较
31 lines
685 B
C
31 lines
685 B
C
#include <scc_lexer_token.h>
|
||
|
||
// 生成字符串映射(根据需求选择#str或#name)
|
||
static const char *token_strings[] = {
|
||
#define X(str, subtype, tok) [tok] = #str,
|
||
SCC_CTOK_TABLE
|
||
#undef X
|
||
|
||
#define X(str, subtype, tok, std) [tok] = #str,
|
||
SCC_CKEYWORD_TABLE
|
||
#undef X
|
||
};
|
||
|
||
static scc_tok_subtype_t token_subtypes[] = {
|
||
#define X(str, subtype, tok) [tok] = subtype,
|
||
SCC_CTOK_TABLE
|
||
#undef X
|
||
|
||
#define X(str, subtype, tok, std) [tok] = subtype,
|
||
SCC_CKEYWORD_TABLE
|
||
#undef X
|
||
};
|
||
|
||
scc_tok_subtype_t scc_get_tok_subtype(scc_tok_type_t type) {
|
||
return token_subtypes[type];
|
||
}
|
||
|
||
const char *scc_get_tok_name(scc_tok_type_t type) {
|
||
return token_strings[type];
|
||
}
|