2026-04-13 07:57:36 -06:00
|
|
|
#include "arena.h"
|
2026-03-25 12:25:15 -06:00
|
|
|
#include "evaluator.h"
|
2026-03-25 07:43:00 -06:00
|
|
|
#include "lexer.h"
|
|
|
|
|
#include "parser.h"
|
2026-03-25 12:25:15 -06:00
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <inttypes.h>
|
2026-02-28 13:59:02 -06:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
2026-03-25 07:43:00 -06:00
|
|
|
int main(void) {
|
2026-03-25 12:25:15 -06:00
|
|
|
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';
|
2026-03-25 07:43:00 -06:00
|
|
|
|
2026-04-24 09:06:47 -06:00
|
|
|
TokenizeResult tokens = tokenize(buf);
|
2026-03-25 07:43:00 -06:00
|
|
|
|
2026-04-24 09:06:47 -06:00
|
|
|
ParseResult par = parse(tokens);
|
2026-04-13 08:44:30 -06:00
|
|
|
int64_t result = evaluate(par);
|
2026-03-25 07:43:00 -06:00
|
|
|
|
|
|
|
|
|
2026-03-25 12:25:15 -06:00
|
|
|
printf("El resultado es: %" PRIi64 "\n", result);
|
2026-02-28 13:59:02 -06:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
|
}
|