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:
20
src/main.c
20
src/main.c
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user