blob: fc2a3ae921a54b57e1330c6a30e4c2823a4db85d (
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
32
33
34
35
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "interpreter.h"
#include "repl.h"
static void interpret_file(const char *path) {
hashmap_t context = hashmap_create();
exec_file(context, path);
context_print(context);
hashmap_free(context);
}
int main(int argc, char **argv) {
int opt;
const char *script = NULL;
while ((opt = getopt(argc, argv, "i:h")) != -1) {
switch (opt){
case 'i':
interpret_file(optarg);
return EXIT_SUCCESS;
case 'h':
default:
fprintf(stderr,
"Usage: %s [-i program.imp]\n"
" -i <program.imp> interpret program and exit\n"
" (no args) start REPL\n",
argv[0]);
return (opt == 'h') ? EXIT_SUCCESS : EXIT_FAILURE;
}
}
repl();
return EXIT_SUCCESS;
}
|