wip: working on analyzer

- Feat: add assigns analysis
- Fix: change node check condition in binary math analysis
- Feat: add unary and binary conditions analysis
- Fix: add type passtrough in declaration analysis
- Feat: add unary math analysis
This commit is contained in:
samsonium
2026-10-27 12:21:49 +03:00
parent 25991c6f15
commit a263b6206f
9 changed files with 277 additions and 6 deletions
+30
View File
@@ -0,0 +1,30 @@
#include <common/fzl_types.h>
#include <compiler/fzl_analyzer.h>
#include <compiler/fzl_parser.h>
// Analyze unary condition
fzl_an_res_t analyze_unarycond(fzl_analyzer_t *analyzer, fzl_node_t *unary)
{
if (!analyzer)
return (fzl_an_res_t){.error = true};
if (!unary || unary->type != FZL_NODETYPE_NOT)
{
an_push_error(analyzer, NULL, "node is not typeof unary condition");
return (fzl_an_res_t){.error = true};
}
fzl_an_res_t operand_res = analyze_common(analyzer, unary->unary_op.operand);
if (operand_res.error)
return (fzl_an_res_t){.error = true};
if (operand_res.type != FZL_TYPE_BOOL && operand_res.type < FZL_TYPE_INT8)
{
an_push_error(analyzer, unary->unary_op.operand->token,
"unary condition only support bool and integer types");
return (fzl_an_res_t){.error = true};
}
return (fzl_an_res_t){
.error = false, .type = FZL_TYPE_BOOL, .classname = NULL};
}