feat(parser): 添加语义分析回调清理函数并完善资源管理

添加了 scc_sema_drop 函数用于清理语义分析回调结构,
并在主程序中正确初始化和释放语义分析回调,
确保资源得到适当管理。

同时修复了AST转储中的缩进问题,在函数调用括号前添加正确的缩进,
并修正了测试代码中的结构体字段初始化顺序。
This commit is contained in:
zzy
2026-03-11 22:07:52 +08:00
parent e6511c508c
commit 30ac2de73b
5 changed files with 15 additions and 5 deletions

View File

@@ -1123,6 +1123,8 @@ static void test_parser_type(void) {
scc_ast_type_t struct_type;
scc_ast_type_struct_init(&struct_type, null, &struct_def);
SCC_CHECK_AST(&struct_type.base, "struct { int x; }", _scc_parse_type);
scc_vec_init(fields);
scc_vec_push(fields, &field);
scc_ast_decl_struct_init(&struct_def, "A", &fields);
scc_ast_type_struct_init(&struct_type, "A", &struct_def);
SCC_CHECK_AST(&struct_type.base, "struct A { int x; }",