fix: review problems
This commit is contained in:
@@ -6,11 +6,6 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
char dec_problem[256];
|
||||
|
||||
// defined in `compiler/analyzer/utility.c`
|
||||
extern fzl_type_t an_toktotype(fzl_token_t *tok);
|
||||
|
||||
// Analyze variable/field/argument declaration
|
||||
fzl_an_res_t analyze_declaration(fzl_analyzer_t *analyzer, fzl_node_t *decl)
|
||||
{
|
||||
@@ -19,7 +14,7 @@ fzl_an_res_t analyze_declaration(fzl_analyzer_t *analyzer, fzl_node_t *decl)
|
||||
|
||||
if (!decl || decl->type != FZL_NODETYPE_DECLARATION)
|
||||
{
|
||||
an_push_error(analyzer, NULL, "node is not typeof DECLARATION");
|
||||
an_push_error(analyzer, NULL, "node is not a declaration");
|
||||
return (fzl_an_res_t){.error = true};
|
||||
}
|
||||
|
||||
@@ -35,12 +30,12 @@ fzl_an_res_t analyze_declaration(fzl_analyzer_t *analyzer, fzl_node_t *decl)
|
||||
if (res != FZL_SYMTABLE_RESULT_OK)
|
||||
{
|
||||
if (res == FZL_SYMTABLE_RESULT_EXISTS)
|
||||
snprintf(dec_problem, sizeof(dec_problem),
|
||||
"'%s' already has been declared", name);
|
||||
snprintf(an_problem, sizeof(an_problem), "'%s' already has been declared",
|
||||
name);
|
||||
else
|
||||
snprintf(dec_problem, sizeof(dec_problem), "cannot store '%s'", name);
|
||||
snprintf(an_problem, sizeof(an_problem), "cannot store '%s'", name);
|
||||
|
||||
an_push_error(analyzer, decl->token, dec_problem);
|
||||
an_push_error(analyzer, decl->token, an_problem);
|
||||
return (fzl_an_res_t){.error = true};
|
||||
}
|
||||
|
||||
@@ -57,9 +52,9 @@ fzl_an_res_t analyze_declaration(fzl_analyzer_t *analyzer, fzl_node_t *decl)
|
||||
|
||||
if (!class_found || class.node->type != FZL_NODETYPE_CLASS)
|
||||
{
|
||||
snprintf(dec_problem, sizeof(dec_problem), "class '%s' does not exists",
|
||||
snprintf(an_problem, sizeof(an_problem), "class '%s' does not exists",
|
||||
(char *)decl->var.type->value);
|
||||
an_push_error(analyzer, decl->var.type, dec_problem);
|
||||
an_push_error(analyzer, decl->var.type, an_problem);
|
||||
return (fzl_an_res_t){.error = true};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user