blob: 90ee892ec75562ecc8d9fe4c0a82a050c0460266 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#include <stdio.h>
#include <stdlib.h>
#include "interpreter.h"
extern FILE *yyin;
extern int yyparse(void);
extern ASTNode *ast_root;
int main(int argc, char **argv) {
if (argc > 1) {
yyin = fopen(argv[1], "r");
if (!yyin) {
perror(argv[1]);
return EXIT_FAILURE;
}
} else {
yyin = stdin;
}
if (yyparse() != 0) {
fprintf(stderr, "Parsing failed.\n");
return EXIT_FAILURE;
}
Env *env = NULL;
exec_stmt(&env, ast_root);
env_print(env);
free_ast(ast_root);
return EXIT_SUCCESS;
}
|