- 新增预处理器库(pproc),替代原有的pprocessor模块 - 实现完整的宏定义解析功能,支持对象宏和函数宏 - 添加条件编译指令处理(#if、#ifdef、#ifndef、#else、#elif、#endif) - 实现宏展开机制,包括嵌套宏和递归宏处理 - 添加宏定义测试用例,覆盖基本功能和复杂场景 - 在cbuild.toml中更新依赖配置,移除parser、ast、ast2ir、ir等未完成模块 - 新增lexer工具函数用于token流处理 - 添加宏定义表管理功能,支持宏的创建、查找、删除操作 - 实现宏参数解析和替换列表处理
40 lines
1.1 KiB
C
40 lines
1.1 KiB
C
#ifndef __SCC_LEXER_UTILS_H__
|
|
#define __SCC_LEXER_UTILS_H__
|
|
|
|
#include "scc_lexer.h"
|
|
|
|
static inline cbool scc_lexer_peek_non_blank(scc_lexer_tok_ring_t *stream,
|
|
scc_lexer_tok_t *out) {
|
|
cbool ok;
|
|
while (1) {
|
|
scc_ring_peek(*stream, *out, ok);
|
|
if (!ok || out->type != SCC_TOK_BLANK)
|
|
break;
|
|
scc_ring_next_consume(*stream, *out, ok);
|
|
scc_lexer_tok_drop(out);
|
|
}
|
|
return ok;
|
|
}
|
|
|
|
static inline cbool scc_lexer_next_non_blank(scc_lexer_tok_ring_t *stream,
|
|
scc_lexer_tok_t *out) {
|
|
cbool ok;
|
|
if (!scc_lexer_peek_non_blank(stream, out))
|
|
return false;
|
|
scc_ring_next_consume(*stream, *out, ok);
|
|
return true;
|
|
}
|
|
|
|
static inline void scc_lexer_skip_until_newline(scc_lexer_tok_ring_t *stream) {
|
|
scc_lexer_tok_t tok;
|
|
cbool ok;
|
|
while (scc_lexer_peek_non_blank(stream, &tok)) {
|
|
if (tok.type == SCC_TOK_ENDLINE)
|
|
break;
|
|
scc_ring_next_consume(*stream, tok, ok);
|
|
scc_lexer_tok_drop(&tok);
|
|
}
|
|
}
|
|
|
|
#endif /* __SCC_LEXER_UTILS_H__ */
|