feat(parser): 启用parser和ast模块并重构解析器结构
- 在cbuild.toml中启用parser和ast依赖项 - 将AST内置类型枚举重命名为SCC_AST_BUILTIN_TYPE_*前缀格式 - 修复ast_def.h中的类型字段命名,将builtin改为type - 添加逗号操作符支持到表达式操作符枚举中 - 更新字面量表达式的lexeme字段为const char*指针和owned标志 - 重构解析器头文件结构,分离为parser.h、parser_utils.h、scc_sema.h等 - 实现新的解析器工具函数,包括预览、消费、回溯等功能 - 更新声明解析逻辑,使用新的解析器接口进行token处理 - 添加符号表语义分析功能框架 - 修复词法分析器中token移动时的空指针检查 - 统一使用scc_tree_dump_printf替代直接的scc_printf调用
This commit is contained in:
@@ -146,8 +146,8 @@ typedef enum scc_cstd {
|
||||
// END
|
||||
/* clang-format on */
|
||||
|
||||
typedef enum scc_tok_type {
|
||||
/* clang-format off */
|
||||
typedef enum scc_tok_type {
|
||||
// must first becase the unknown token must be 0
|
||||
#define X(str, subtype, tok) tok,
|
||||
SCC_CTOK_TABLE
|
||||
@@ -160,8 +160,8 @@ typedef enum scc_tok_type {
|
||||
#define X(name, subtype, tok, std) tok,
|
||||
SCC_CKEYWORD_TABLE
|
||||
#undef X
|
||||
/* clang-format on*/
|
||||
} scc_tok_type_t;
|
||||
/* clang-format on */
|
||||
|
||||
typedef enum scc_tok_subtype {
|
||||
SCC_TOK_SUBTYPE_INVALID, // 错误占位
|
||||
@@ -212,6 +212,7 @@ static inline scc_lexer_tok_t scc_lexer_tok_copy(const scc_lexer_tok_t *src) {
|
||||
// 移动 token(源 token 不再拥有 lexeme)
|
||||
static inline void scc_lexer_tok_move(scc_lexer_tok_t *dst,
|
||||
scc_lexer_tok_t *src) {
|
||||
Assert(src != null);
|
||||
*dst = *src;
|
||||
src->lexeme.data = null;
|
||||
src->lexeme.size = 0;
|
||||
|
||||
Reference in New Issue
Block a user