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
+22 -2
View File
@@ -1,6 +1,9 @@
#include <common/fzl_types.h>
#include <compiler/fzl_analyzer.h>
#include <compiler/fzl_token.h>
#include <compiler/utils/fzl_symtable.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
// Check compatibility between A and B types (and classnames)
@@ -79,13 +82,30 @@ char *an_typetostr(fzl_type_t type, char *classname)
}
// Convert type token to type
fzl_type_t an_toktotype(fzl_token_t *tok)
fzl_type_t an_toktotype(fzl_analyzer_t *analyzer, fzl_token_t *tok,
bool *sym_found)
{
if (!tok)
return FZL_TYPE_NULL;
if (tok->type == FZL_TOKTYPE_NAME)
return FZL_TYPE_OBJECT;
{
fzl_sym_t sym;
bool found = false;
for (ssize_t i = analyzer->symbols_top - 1; i >= 0; i--)
{
if ((found = fzl_symt_get(analyzer->symbols[i], tok->value, &sym)))
break;
}
if (sym_found)
*sym_found = found;
return found ? sym.type : FZL_TYPE_NULL;
}
if (sym_found)
*sym_found = true;
if (strcmp(tok->value, "null") == 0)
return FZL_TYPE_NULL;