refactor(ast): 调整AST结构体和枚举类型的声明表示方式
将结构体、联合和枚举类型的字段表示从向量改为声明指针, 允许name和decl字段为null,更新相关初始化函数的断言检查, 使结构更加灵活并支持不完整类型定义。 BREAKING CHANGE: 修改了scc_ast_type结构体中record和enumeration 子类型的字段表示方法,从fields向量改为decl指针。
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "scc_sema.h"
|
||||
#include <scc_ast.h>
|
||||
#include <scc_core_ring.h>
|
||||
#include <scc_hashtable.h>
|
||||
#include <scc_lexer_token.h>
|
||||
|
||||
/**
|
||||
@@ -13,11 +14,15 @@ typedef struct scc_parser {
|
||||
scc_lexer_tok_ring_t *ring;
|
||||
usize checkpoint;
|
||||
|
||||
scc_hashtable_t type_ht;
|
||||
|
||||
scc_sema_callbacks_t sema_callbacks;
|
||||
scc_ast_translation_unit_t *translation_unit;
|
||||
int errcode;
|
||||
} scc_parser_t;
|
||||
|
||||
// static inline scc_ast_type_t *scc_parser_
|
||||
|
||||
/**
|
||||
* @brief 初始化解析器
|
||||
* @param parser 解析器实例
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
typedef void (*scc_sema_callback_t)(void *context,
|
||||
scc_ast_node_type_t node_type, void *node);
|
||||
|
||||
typedef scc_ast_type_t *(*scc_sema_got_type_t)(void *context, const char *name);
|
||||
|
||||
/**
|
||||
* @brief 语义分析回调集合
|
||||
*/
|
||||
@@ -17,6 +19,7 @@ typedef struct scc_sema_callbacks {
|
||||
scc_sema_callback_t on_stmt;
|
||||
scc_sema_callback_t on_expr;
|
||||
scc_sema_callback_t on_type;
|
||||
scc_sema_got_type_t got_type;
|
||||
void *context;
|
||||
} scc_sema_callbacks_t;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user