移除了libs/format目录下的所有文件,包括: - cbuild.toml构建配置文件 - include/scf.h头文件 - include/scf_impl.h实现头文件 - src/scf.c源文件 - tests/test_scf.c测试文件 - tests/test_scf_x64.c x64架构测试文件 这些文件包含了SCF(scc format)格式的完整实现,但现在不再需要。 feat(lexer): 添加布尔字面量数字生成函数 在lexer工具头文件中添加了两个内联函数用于生成布尔值的数字字面量: - scc_lexer_gen_number_true: 将token类型设为整数字面量,值为"1" - scc_lexer_gen_number_false: 将token类型设为整数字面量,值为"0" refactor(lexer): 改进词法分析器错误处理 - 移除了多余的头文件包含 - 更新错误报告方式,使用SCC_ERROR宏替代LEX_ERROR,提供更准确的错误位置信息 refactor(pproc): 更新预处理器扩展器数据结构 - 将need_rescan字段类型从int改为cbool - 添加need_parse_defined字段用于控制defined操作符解析 - 更新函数签名以支持defined操作符解析参数
55 lines
1.5 KiB
C
55 lines
1.5 KiB
C
#ifndef __SCC_LEXER_UTILS_H__
|
|
#define __SCC_LEXER_UTILS_H__
|
|
|
|
#include "scc_lexer.h"
|
|
|
|
static inline void scc_lexer_gen_number_true(scc_lexer_tok_t *tok) {
|
|
Assert(tok != null && tok->type == SCC_TOK_UNKNOWN);
|
|
tok->type = SCC_TOK_INT_LITERAL;
|
|
tok->lexeme = scc_cstring_from_cstr("1");
|
|
}
|
|
|
|
static inline void scc_lexer_gen_number_false(scc_lexer_tok_t *tok) {
|
|
Assert(tok != null && tok->type == SCC_TOK_UNKNOWN);
|
|
tok->type = SCC_TOK_INT_LITERAL;
|
|
tok->lexeme = scc_cstring_from_cstr("0");
|
|
}
|
|
|
|
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 (1) {
|
|
scc_ring_next_consume(*stream, tok, ok);
|
|
if (!ok)
|
|
break;
|
|
scc_tok_type_t type = tok.type;
|
|
scc_lexer_tok_drop(&tok);
|
|
if (type == SCC_TOK_ENDLINE)
|
|
break;
|
|
}
|
|
}
|
|
|
|
#endif /* __SCC_LEXER_UTILS_H__ */
|