添加了 scc_sema_drop 函数用于清理语义分析回调结构, 并在主程序中正确初始化和释放语义分析回调, 确保资源得到适当管理。 同时修复了AST转储中的缩进问题,在函数调用括号前添加正确的缩进, 并修正了测试代码中的结构体字段初始化顺序。
30 lines
756 B
C
30 lines
756 B
C
#ifndef __SCC_SEMA_H__
|
|
#define __SCC_SEMA_H__
|
|
|
|
#include <scc_ast.h>
|
|
|
|
/**
|
|
* @brief 语义分析回调函数类型
|
|
*/
|
|
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 语义分析回调集合
|
|
*/
|
|
typedef struct scc_sema_callbacks {
|
|
scc_sema_callback_t on_decl;
|
|
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;
|
|
|
|
void scc_sema_init(scc_sema_callbacks_t *callbacks);
|
|
void scc_sema_drop(scc_sema_callbacks_t *callbacks);
|
|
|
|
#endif /* __SCC_SEMA_H__ */
|