feat(pproc): 改进宏处理器中的标识符识别逻辑

修复了宏处理器中对标识符类型的检查方式,使用更准确的子类型判断函数,
确保关键字也能被正确处理为宏名或参数名。同时添加了相关的单元测试用例。

BREAKING CHANGE: 修改了token类型的检查方法
This commit is contained in:
zzy
2026-03-04 17:35:54 +08:00
parent 4015acd866
commit a805814d3f
7 changed files with 42 additions and 15 deletions

View File

@@ -119,7 +119,8 @@ void scc_pproc_parse_function_macro(scc_pproc_t *pp,
if (idx++ % 2 != 1) {
LOG_FATAL("ERROR");
}
} else if (arg->type == SCC_TOK_IDENT) {
} else if (scc_get_tok_subtype(arg->type) ==
SCC_TOK_SUBTYPE_IDENTIFIER) {
if (idx++ % 2 != 0) {
LOG_FATAL("ERROR");
}

View File

@@ -52,7 +52,7 @@ CONTINUE:
scc_ring_next_consume(*stream, *out, ok);
pp->at_line_start = true;
return true;
} else if (tok.type == SCC_TOK_IDENT) {
} else if (scc_get_tok_subtype(tok.type) == SCC_TOK_SUBTYPE_IDENTIFIER) {
// maybe expanded
scc_pproc_macro_t *macro =
scc_pproc_macro_table_get(&pp->macro_table, &tok.lexeme);