feat: implement extern block analyzer

This commit is contained in:
samsonium
2026-10-31 01:58:10 +03:00
parent 5c96f96220
commit a4aa220cfa
16 changed files with 197 additions and 27 deletions
+13 -4
View File
@@ -20,14 +20,23 @@ fzl_an_res_t analyze_declaration(fzl_analyzer_t *analyzer, fzl_node_t *decl)
}
char *name = (char *)decl->var.identifier->token->value;
fzl_type_t type = an_toktotype(decl->var.type);
bool type_found = false;
fzl_type_t type = an_toktotype(analyzer, decl->var.type, &type_found);
if (!type_found)
{
snprintf(an_problem, sizeof(an_problem), "symbol '%s' not found",
(char *)decl->var.type->value);
an_push_error(analyzer, decl->var.type, an_problem);
return (fzl_an_res_t){.error = true};
}
char *classname = NULL;
if (type == FZL_TYPE_OBJECT)
classname = decl->var.type->value;
fzl_symtable_res_t res =
fzl_symt_put(analyzer->symbols[analyzer->symbols_top - 1], decl, name,
an_toktotype(decl->var.type), 0);
fzl_symtable_res_t res = fzl_symt_put(
analyzer->symbols[analyzer->symbols_top - 1], decl, name, type, 0);
if (res != FZL_SYMTABLE_RESULT_OK)
{
if (res == FZL_SYMTABLE_RESULT_EXISTS)