Fixed many minor things, tested it on main and is amazing, i think i need to start adding fractions next so further testing can be done with more powerful operators

This commit is contained in:
2026-03-25 12:25:15 -06:00
parent 92d142b9cf
commit 1ce64d8e9e
7 changed files with 30 additions and 15 deletions

View File

@@ -1,16 +1,30 @@
#include "evaluator.h"
#include "lexer.h"
#include "parser.h"
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
int main(void) {
ASTNodeArray context;
char buf[256];
printf("Insert a valid mathematical expression: ");
int c;
int pos = 0;
while ((c = getc(stdin)) != '\n' && c != EOF) {
buf[pos] = c;
pos++;
}
buf[pos] = '\0';
tokenize("3 + 4 * 5", &context);
ASTNodeArray context;
tokenize(buf, &context);
AST tree = parse(&context);
int64_t result = evaluate(tree.head);
printf("Hola\n");
printf("El resultado es: %" PRIi64 "\n", result);
return EXIT_SUCCESS;
}