blob: 95eb196c57b3b87dbae49d2fb07fdd1353a0b8e1 [file] [log] [blame]
swissChilif3e7f182021-04-20 13:57:22 -07001#include "compiler.h"
swissChili53472e82021-05-08 16:06:32 -07002#include "lisp.h"
swissChilie9fec8b2021-06-22 13:59:33 -07003#include "gc.h"
swissChili7a6f5eb2021-04-13 16:46:02 -07004
swissChili53472e82021-05-08 16:06:32 -07005int main(int argc, char **argv)
swissChili7a6f5eb2021-04-13 16:46:02 -07006{
swissChili53472e82021-05-08 16:06:32 -07007 if (argc < 2)
swissChilibed80922021-04-13 21:58:05 -07008 {
swissChilie9fec8b2021-06-22 13:59:33 -07009 puts("pass the program you want to run as the first argument please");
swissChilibed80922021-04-13 21:58:05 -070010 return 1;
11 }
12
swissChili923b5362021-05-09 20:31:43 -070013 struct istream *is = new_fistream(argv[1], false);
14
15 if (is == NULL)
16 {
17 fprintf(stderr, "Could not open %s\n", argv[1]);
18 return 1;
19 }
swissChili7a6f5eb2021-04-13 16:46:02 -070020
swissChilie9fec8b2021-06-22 13:59:33 -070021 struct environment env = compile_all(is);
22 value_t (*lisp_main)() = find_function(&env, "main")->def0;
23
24 gc_set_base_here();
25 lisp_main();
swissChilib8fd4712021-06-23 15:32:04 -070026
27 free_all();
swissChili7a6f5eb2021-04-13 16:46:02 -070028}