refactor: 重构前端代码并添加日志功能
- 重命名和重构了多个文件,包括 lexer、parser 和 AST 相关代码 - 添加了日志功能,使用 LOG_* 宏替代原有的 error 和 warn 函数 - 优化了错误处理和内存分配方式 - 调整了代码结构,提高了模块化和可读性
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
// symtab.c
|
||||
#include "../../frontend.h"
|
||||
#include <lib/core.h>
|
||||
#include "scope.h"
|
||||
#include "symtab.h"
|
||||
|
||||
@ -24,7 +25,7 @@ void symtab_enter_scope(symtab_t* symtab) {
|
||||
void symtab_leave_scope(symtab_t* symtab) {
|
||||
Scope * scope = symtab->cur_scope;
|
||||
if (scope == NULL) {
|
||||
error("cannot leave NULL scope or global scope");
|
||||
LOG_ERROR("cannot leave NULL scope or global scope");
|
||||
}
|
||||
symtab->cur_scope = symtab->cur_scope->parent;
|
||||
scope_destroy(scope);
|
||||
@ -35,7 +36,7 @@ void* symtab_add_symbol(symtab_t* symtab, const char* name, void* ast_node, int
|
||||
void* node = scope_lookup_current(scope, name);
|
||||
if (node != NULL) {
|
||||
if (!can_duplicate) {
|
||||
error("duplicate symbol %s", name);
|
||||
LOG_ERROR("duplicate symbol %s", name);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
Reference in New Issue
Block a user