rework: AST now uses an arena for allocation

For now it works but i dont really like that i use ParseResult, i mean
is necessary but i think i will try to make it cleaner so that i can
just directly use like parse and pass tath into evaluate, that would
require to move the main evaluate funciton into evaluate_tree or
something  and evaluate takes the arena, uses evaluate_tree and frees
the arena, will try that the next commit but for now this version works
perfectly.
This commit is contained in:
2026-04-13 07:57:36 -06:00
parent fb27e1e34c
commit e4ec102cb9
8 changed files with 46 additions and 16 deletions

View File

@@ -1,3 +1,4 @@
#include "arena.h"
#include "evaluator.h"
#include "lexer.h"
#include "parser.h"
@@ -21,8 +22,10 @@ int main(void) {
ASTNodeArray context;
tokenize(buf, &context);
AST tree = parse(&context);
ParseResult par = parse(&context);
AST tree = par.tree;
int64_t result = evaluate(tree.head);
arena_destroy(par.arena);
printf("El resultado es: %" PRIi64 "\n", result);