feat: implement extern block analyzer
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user